Fix #7123 - getting abra ready to test
[Pman.Xtuple] / DataObjects / Invhist.php
1 <?php
2 /**
3  * Table Definition for invhist
4  */
5 require_once 'DB/DataObject.php';
6
7 class Pman_Xtuple_DataObjects_Invhist extends DB_DataObject 
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'invhist';             // table name
13     public $invhist_id;                      // int4(4)  not_null default_nextval%28%28invhist_invhist_id_seq%29%3A%3Aregclass%29 primary_key
14     public $invhist_itemsite_id;             // int4(4)  
15     public $invhist_transdate;               // timestamptz(8)  default_%28now%29%3A%3Atimestamp%286%29%20with%20time%20zone
16     public $invhist_transtype;               // bpchar(-1)  
17     public $invhist_invqty;                  // numeric(-1)  
18     public $invhist_invuom;                  // text(-1)  
19     public $invhist_ordnumber;               // text(-1)  
20     public $invhist_docnumber;               // text(-1)  
21     public $invhist_qoh_before;              // numeric(-1)  
22     public $invhist_qoh_after;               // numeric(-1)  
23     public $invhist_unitcost;                // numeric(-1)  
24     public $invhist_acct_id;                 // int4(4)  
25     public $invhist_xfer_warehous_id;        // int4(4)  
26     public $invhist_comments;                // text(-1)  
27     public $invhist_posted;                  // bool(1)  default_true
28     public $invhist_imported;                // bool(1)  
29     public $invhist_hasdetail;               // bool(1)  default_false
30     public $invhist_ordtype;                 // text(-1)  
31     public $invhist_analyze;                 // bool(1)  default_true
32     public $invhist_user;                    // text(-1)  default_%22current_user%22%28%29
33     public $invhist_created;                 // timestamptz(8)  not_null default_now%28%29
34     public $invhist_costmethod;              // bpchar(-1)  not_null
35     public $invhist_value_before;            // numeric(-1)  not_null
36     public $invhist_value_after;             // numeric(-1)  not_null
37     public $invhist_series;                  // int4(4)  
38
39     
40     /* the code above is auto generated do not remove the tag below */
41     ###END_AUTOCODE
42     
43     function applyFilters($q, $au, $roo)
44     {
45         
46         $id = DB_DataObject::Factory('invdetail');
47         $this->_join .= "
48             RIGHT JOIN invdetail AS join_invdetail ON
49             invhist.invhist_id = join_invdetail.invdetail_invhist_id";
50         $this->selectAs($id, '%s', 'join_invdetail');
51     
52         $id = DB_DataObject::Factory('location');
53         $this->_join .= "
54             LEFT JOIN location AS join_location ON
55             join_invdetail.invdetail_location_id = join_location.location_id";
56         $this->selectAs($id, '%s', 'join_location');
57     
58         if (!empty($_REQUEST['invdetail_location_id'])) {
59             $l = (int) $_REQUEST['invdetail_location_id'];
60             $this->whereAdd(
61                 "invdetail_location_id = $l"
62             );
63         }
64         
65         
66         
67         
68         /*
69          does not work (not needed yet..)
70          if (!empty($q['_with_item'])) {
71             $itemsite = DB_DataObject::Factory('item');
72             
73             $this->_join .= "
74                 INNER JOIN itemsite AS join_invhist_itemsite_id ON
75                 invhist_itemsite_id = join_invhist_itemsite_id.itemsite_id";
76             $this->selectAs($itemsite, '%s', 'join_invhist_itemsite_id');
77             
78             $item = DB_DataObject::Factory('item');
79             
80             $this->_join .= "
81                 INNER JOIN item AS join_invhist_item ON
82                 join_invhist_itemsite_id.itemsite_item_id = join_invhist_item.item_id";
83             $this->selectAs($item, '%s', 'join_invhist_item');
84         }
85         */
86     }
87     function details()
88     {
89         if (!$this->invhist_hasdetail) {
90             return false;
91         }
92         $d = DB_DAtaObject::factory('invdetail');
93         $d->invdetail_invhist_id = $this->pid();
94         return $d->fetchAll();
95          
96     }
97     
98 }