Commit | Line | Data |
---|---|---|
16261142 | 1 | <?php |
de77377e | 2 | switch($SUBPATH[0]) { |
16261142 | 3 | default: case 1: |
35916247 TM |
4 | echo $this->html->form("$URL/2", 'GET', array( |
5 | array('barcode','','text',false,'autofocus','model_barcode:'), | |
d0e7939c | 6 | array('quantity','1','text',false,false,'quantity:'), |
35916247 TM |
7 | array(false,'STORE','submit') |
8 | )); | |
16261142 TM |
9 | break; |
10 | case 2: | |
11 | $model_id = $this->db->map_unique('model_barcode', $_GET['barcode'], 'model_id', 'model'); | |
d0e7939c TM |
12 | |
13 | $disable_cols = array('status_id','item_price_out','item_customer', 'model_id','item_quantity'); | |
14 | if($this->db->map_unique('model_barcode', $_GET['barcode'], 'model_countable', 'model')) { | |
15 | //$disable_cols[] = 'item_quantity'; | |
16 | $item_serial = ''; | |
17 | $item_quantity = 1; | |
18 | $action = $_SERVER['SCRIPT_NAME'].'/item/new'; | |
19 | } else { | |
20 | $quantity_added = $_GET['quantity']; | |
21 | if($quantity_added <= 0) $this->post_redirect_get("$URL_INTERNAL/1","Can't store non-possitive amount of items!"); | |
22 | if(!is_numeric($quantity_added)) $quantity_added = 1; | |
23 | $quantity_stored = $this->db->map_unique('item_serial', $_GET['barcode'], 'item_quantity', 'item', false); | |
fbf1a4e6 TM |
24 | $item_price_in = $this->db->map_unique('item_serial', $_GET['barcode'], 'item_price_in', 'item', false); |
25 | $item_price_out = $this->db->map_unique('item_serial', $_GET['barcode'], 'item_price_out', 'item', false); | |
26 | $model_price_in = $this->db->map_unique('model_barcode', $_GET['barcode'], 'model_price_in', 'model'); | |
27 | $model_price_out = $this->db->map_unique('model_barcode', $_GET['barcode'], 'model_price_out', 'model'); | |
d0e7939c TM |
28 | if(!is_numeric($quantity_stored)) $quantity_stored = 0; |
29 | echo("Quantity stored: ".$quantity_stored); | |
30 | ||
31 | $disable_cols[] = 'item_serial'; | |
32 | $item_serial = $_GET['barcode']; | |
33 | $item_quantity = $quantity_stored + $quantity_added; | |
34 | $action = $_SERVER['SCRIPT_NAME'].'/item/0/edit'; | |
35 | } | |
16261142 | 36 | $columns = $this->db->get_columns('item'); |
16261142 | 37 | |
d0e7939c | 38 | $selectbox = $this->db->columns_get_selectbox($columns, 'item'); |
16261142 TM |
39 | //print_r(array('<pre>', $selectbox)); |
40 | //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]); | |
41 | $current = array(array( | |
42 | 'model_id' => $model_id, | |
d0e7939c TM |
43 | 'item_serial' => $item_serial, |
44 | 'item_quantity' => $item_quantity, | |
45 | 'status_id' => 1, | |
fbf1a4e6 TM |
46 | 'item_price_in' => $item_price_in + ($quantity_added * $model_price_in), |
47 | 'item_price_out' => $item_price_out + ($quantity_added * $model_price_out), | |
253705f2 | 48 | 'item_author' => $this->db->auth->get_user_id() |
16261142 TM |
49 | )); |
50 | ||
d0e7939c | 51 | echo $this->html->render_insert_form('item', $columns, $selectbox, $current, $disable_cols, $action); |
16261142 TM |
52 | break; |
53 | } |