2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 /* Definition of the purch_order class to hold all the information for a purchase order and delivery
18 var $trans_type; // order/grn/invoice (direct)
19 var $line_items; /*array of objects of class line_details using the product id as the pointer */
22 var $delivery_address;
28 var $order_no; /*Only used for modification of existing orders otherwise only established when order committed */
33 function purch_order()
35 /*Constructor function initialises a new purchase order object */
36 $this->line_items = array();
37 $this->lines_on_order = $this->order_no = $this->supplier_id = 0;
40 function add_to_order($line_no, $stock_id, $qty, $item_descr, $price, $uom, $req_del_date, $qty_inv, $qty_recd)
42 if ($qty != 0 && isset($qty))
44 $this->line_items[$line_no] = new line_details($line_no, $stock_id, $item_descr, $qty, $price, $uom,
45 $req_del_date, $qty_inv, $qty_recd);
46 $this->lines_on_order++;
52 function update_order_item($line_no, $qty, $price, $req_del_date, $description="")
54 if ($description != "")
55 $this->line_items[$line_no]->item_description = $description;
56 $this->line_items[$line_no]->quantity = $qty;
57 $this->line_items[$line_no]->price = $price;
58 $this->line_items[$line_no]->req_del_date = $req_del_date;
59 $this->line_items[$line_no]->price = $price;
62 function remove_from_order($line_no)
64 array_splice($this->line_items, $line_no, 1);
67 function order_has_items()
69 return count($this->line_items) != 0;
72 function clear_items()
74 unset($this->line_items);
75 $this->line_items = array();
77 $this->lines_on_order = 0;
82 function any_already_received()
84 /* Checks if there have been deliveries or invoiced entered against any of the line items */
85 if (count($this->line_items) > 0)
87 foreach ($this->line_items as $ordered_items)
89 if ($ordered_items->qty_received != 0 || $ordered_items->qty_inv != 0)
98 function some_already_received($line_no)
100 /* Checks if there have been deliveries or amounts invoiced against a specific line item */
101 if (count($this->line_items) > 0)
103 if ($this->line_items[$line_no]->qty_received != 0 ||
104 $this->line_items[$line_no]->qty_inv != 0)
111 } /* end of class defintion */
120 var $item_description;
131 function line_details($line_no, $stock_item, $item_descr, $qty, $prc, $uom, $req_del_date,
132 $qty_inv, $qty_recd, $grn_item_id=0)
135 /* Constructor function to add a new LineDetail object with passed params */
136 $this->line_no = $line_no;
137 $this->stock_id = $stock_item;
138 $item_row = get_item($stock_item);
142 $this->descr_editable = $item_row["editable"];
143 if ($item_descr == null || !$this->descr_editable)
144 $this->item_description = $item_row["description"];
146 $this->item_description = $item_descr;
147 $this->quantity = $qty;
148 $this->req_del_date = $req_del_date;
150 // $this->units = $uom;
151 $this->units = $item_row["units"];
152 $this->qty_received = $qty_recd;
153 $this->qty_inv = $qty_inv;
154 $this->receive_qty = 0; /*initialise these last two only */
155 $this->standard_cost =0;
156 $this->grn_item_id = $grn_item_id;