Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Fifo / ProcessBasic.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_ProcessBasic extends Pman_Xtuple_Fifo_ProcessBase
11 {
12      static $cli_desc = "Fill in basic Fifo values.";
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         $id = DB_DataObject::Factory('invdetail');
26         $id->autoJoinLocation();
27         $id->selectAdd();
28         $id->selectAdd('distinct(invdetail_location_id) as location_id, join_location.location_name as location_name');
29         
30         $locs = $id->fetchAll('location_id', 'location_name');
31         $id->free();
32         foreach($locs as $loc=>$name) {
33             
34             $id = DB_DataObject::Factory('invdetail');
35             $id->autoJoin();
36             $id->invdetail_location_id = $loc;
37             $id->selectAdd();
38             $id->selectAdd('distinct(join_invhist.invhist_itemsite_id) as itemsite_id');
39             $is = $id->fetchAll('itemsite_id');
40             $id->free();
41             $tot = count($is);
42             $mu = memory_get_usage();
43             echo "Processing $name ({$tot}) - memory $mu\n";
44             
45             foreach($is as $n=>$itemsite) {
46                 $id = DB_DataObject::Factory('invdetail');
47                 $id->query("SELECT invfifo_fill_all($loc, $itemsite)");
48                 $id->free();
49                 if (!($n % 50)) {
50                     echo "$n/$tot\n";
51                 }
52             }
53         }
54         
55                 die("DONE");
56
57          
58    
59     }
60      
61 }