Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Reports / StockAtLocation.php
1 <?php
2 require_once 'Pman/Xtuple/Reports/Base.php';
3
4 class Pman_Xtuple_Reports_StockAtLocation extends Pman_Xtuple_Reports_Base
5 {
6      
7     
8     function get()
9     {
10         $sdate = '-05-01';
11         $edate = '-04-30';
12         //if (preg_match('/sg.php$/', $this->baseURL)) {
13         //    $sdate = '-10-01';
14         //    $edate = '-09-30';
15         //}
16         $sy = strtotime(date('Y') . $sdate) > time() ? date('Y') : (date('Y')+1);
17        
18         $q = DB_DataObject::factory('location');
19         
20         //DB_DataObject::DebugLevel(1);
21        // $q->autoJoin();
22         $q->selectAdd();
23         
24         $q->selectAdd('location_name, location_descrip');
25         $cols = array('location_name', 'location_descrip');
26         
27         for ($y = 2008; $y < $sy + 1; $y++) {
28             $dt = $y . $sdate;
29        
30             $q->selectAdd( "
31                 invdetail_location_atdate('$dt'::date + INTERVAL '1 DAY', location_id, 1)
32                 as  qty_on_hand_eofy_$y,
33                 invdetail_location_atdate('$dt'::date + INTERVAL '1 DAY', location_id , -1)
34                 as  qty_negative_eofy_$y
35                 
36                 ");
37             $cols[] = "qty_negative_eofy_$y";
38             $cols[] = "qty_on_hand_eofy_$y";
39         }
40         
41         $q->orderBy('location_name ASC');
42         //$date_from = date('Y-m-d', strtotime($_REQUEST['date_from']));
43         //$date_to   = date('Y-m-d', strtotime($_REQUEST['date_to']));
44         //DB_DataObject::debugLevel(1);
45         $q->find();
46          
47          
48          
49         $this->toCsv($q,   $cols);
50                 
51                  
52     }
53     
54     
55 }
56