Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Fifo / ProcessCoheadVoids.php
1 <?php
2
3 /**
4  * fill in any fifo basic entries that have not been processed..
5  * -- does not fill in values.. - just qty's
6  *
7  */
8 require_once 'ProcessBase.php';
9  
10 class Pman_Xtuple_Fifo_ProcessCoheadVoids extends Pman_Xtuple_Fifo_ProcessBase
11 {
12      static $cli_desc = "Flag voids for coheads.";
13    
14     static $permitError = false;
15     
16    
17     function get()
18     {
19         // set up the failure code..
20         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
21         
22         // we have to have a pointer to work out where we left off..
23         // this process can go by invdetail_id ASC..
24         
25         $co = DB_DataObject::Factory('invfifo');
26         
27         $co->selecTAdd();
28         $co->selecTAdd('distinct(invfifo_cohead_id) as cohead_id');
29         $co->whereAdd('
30                         invfifo_void = -1
31                     AND
32                         invfifo_cohead_id > 0
33                        ');
34         $locs = $co->fetchAll('cohead_id');
35         print_R($locs);
36         if (!$locs) {
37             die("no changed needed\n");
38             return;
39         }
40             $co = DB_DataObject::Factory('invfifo');
41             
42             $co->query('
43                 update
44                     invfifo
45                 set
46                     invfifo_void = 0
47                 WHERE
48                     invfifo_cohead_id IN (
49                         ' . implode(',', $locs) .'
50                     )
51                 '); 
52             
53             
54             //$id = DB_DataObject::Factory('cohead');
55             //$id->query('SELECT invfifo_cohead_void_flag_order(cohead_id) FROM cohead where cohead_id IN ( 
56             //             ' . implode(',', $locs) .'
57             //        )
58             //    ');
59             //   
60             
61         
62         
63         
64        
65         
66          
67         
68         $tot = count($locs);
69
70         foreach($locs as $n=>$cohead_id) {
71         
72             $id = DB_DataObject::Factory('invdetail');
73             $id->query("SELECT invfifo_cohead_void_flag_order($cohead_id)");
74             $id->free();
75             usleep(10);
76             if (!($n % 50)) {
77                 sleep(5);
78                 echo "$n/$tot\n";
79             }
80             
81         }
82         
83         die("DONE\n");
84
85          
86    
87     }
88      
89 }