*** empty log message ***
[fa-stable.git] / purchasing / includes / po_class.inc
1 <?php
2
3 /* Definition of the purch_order class to hold all the information for a purchase order and delivery
4 */
5
6 class purch_order 
7 {
8
9         var $supplier_id;
10         
11         var $line_items; /*array of objects of class line_details using the product id as the pointer */
12         var $curr_code;
13         var $requisition_no;
14         var $delivery_address;
15         var $Comments;
16         var $Location;
17         var $supplier_name;
18         var $orig_order_date;
19         var $order_no; /*Only used for modification of existing orders otherwise only established when order committed */
20         var $lines_on_order;
21         
22         var $reference;
23         
24         function purch_order()
25         {
26                 /*Constructor function initialises a new purchase order object */
27                 $this->line_items = array();
28                 $this->lines_on_order = $this->order_no = $this->supplier_id = 0;
29         }
30
31         function add_to_order($line_no, $stock_id, $qty, $item_descr, $price, $uom, $req_del_date, $qty_inv, $qty_recd)
32         {
33                 if ($qty != 0 && isset($qty))
34                 {
35                         $this->line_items[$line_no] = new line_details($line_no, $stock_id, $item_descr, $qty, $price, $uom, $req_del_date, $qty_inv, $qty_recd);
36                         $this->lines_on_order++;
37                         Return 1;
38                 }
39                 Return 0;
40         }
41
42         function update_order_item($line_no, $qty, $price, $req_del_date)
43         {
44                 $this->line_items[$line_no]->quantity = $qty;
45                 $this->line_items[$line_no]->price = $price;
46                 $this->line_items[$line_no]->req_del_date = $req_del_date;
47                 $this->line_items[$line_no]->price = $price;
48         }
49
50         function remove_from_order($line_no)
51         {
52                  $this->line_items[$line_no]->Deleted = true;
53         }
54         
55         function order_has_items() 
56         {
57                 if (count($this->line_items) > 0)
58                 {
59                         foreach ($this->line_items as $ordered_items) 
60                         {
61                                 if ($ordered_items->Deleted == false)
62                                 {
63                                         return true;
64                                 }
65                         }
66                 }
67                 return false;           
68         }
69         
70         function clear_items() 
71         {
72         unset($this->line_items);
73                 $this->line_items = array();
74                 
75                 $this->lines_on_order = 0;  
76                 $this->order_no = 0;
77         }
78
79         
80         function any_already_received()
81         {
82                 /* Checks if there have been deliveries or invoiced entered against any of the line items */
83                 if (count($this->line_items) > 0)
84                 {
85                         foreach ($this->line_items as $ordered_items) 
86                         {
87                                 if ($ordered_items->qty_received != 0 || $ordered_items->qty_inv != 0)
88                                 {
89                                         return 1;
90                                 }
91                         }
92                 }
93                 return 0;
94         }
95
96         function some_already_received($line_no)
97         {
98                 /* Checks if there have been deliveries or amounts invoiced against a specific line item */
99                 if (count($this->line_items) > 0)
100                 {
101                         if ($this->line_items[$line_no]->qty_received != 0 || 
102                                 $this->line_items[$line_no]->qty_inv != 0)
103                         {
104                                 return 1;
105                         }
106                 }
107                 return 0;
108         }
109 } /* end of class defintion */
110
111 class line_details 
112 {
113
114         Var $line_no;
115         Var $po_detail_rec;
116         Var $stock_id;
117         Var $item_description;
118         Var $quantity;
119         Var $price;
120         Var $units;
121         Var $req_del_date;
122         Var $qty_inv;
123         Var $qty_received;
124         Var $standard_cost;
125         Var $receive_qty;
126         Var $Deleted;   
127         
128         function line_details($line_no, $stock_item, $item_descr, $qty, $prc, $uom, $req_del_date, $qty_inv, $qty_recd)
129         {
130
131                 /* Constructor function to add a new LineDetail object with passed params */
132                 $this->line_no = $line_no;
133                 $this->stock_id = $stock_item;
134                 $this->item_description = $item_descr;
135                 $this->quantity = $qty;
136                 $this->req_del_date = $req_del_date;
137                 $this->price = $prc;
138                 $this->units = $uom;
139                 $this->qty_received = $qty_recd;
140                 $this->qty_inv = $qty_inv;
141                 $this->receive_qty = 0; /*initialise these last two only */
142                 $this->standard_cost =0;
143                 $this->Deleted = false;
144         }
145 }
146
147 ?>