- } else {
- $quantity_added = $_GET['quantity'];
- if($quantity_added <= 0) $this->post_redirect_get("$URL_INTERNAL/1","Can't store non-possitive amount of items!");
- if(!is_numeric($quantity_added)) $quantity_added = 1;
- $quantity_stored = $this->db->map_unique('item_serial', $_GET['barcode'], 'item_quantity', 'item', false);
- $item_price_in = $this->db->map_unique('item_serial', $_GET['barcode'], 'item_price_in', 'item', false);
- $item_price_out = $this->db->map_unique('item_serial', $_GET['barcode'], 'item_price_out', 'item', false);
- $model_price_in = $this->db->map_unique('model_barcode', $_GET['barcode'], 'model_price_in', 'model');
- $model_price_out = $this->db->map_unique('model_barcode', $_GET['barcode'], 'model_price_out', 'model');
- if(!is_numeric($quantity_stored)) $quantity_stored = 0;
- echo("Quantity stored: ".$quantity_stored);
-
- $disable_cols[] = 'item_serial';
- $item_serial = $_GET['barcode'];
- $item_quantity = $quantity_stored + $quantity_added;
- $action = $_SERVER['SCRIPT_NAME'].'/item/0/edit';
+
+ //print_r(array('<pre>', $selectbox));
+ //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]);
+ $current = array(array(
+ 'barcode_id' => $barcode_id,
+ 'item_serial' => $item_serial,
+ 'item_quantity' => $item_quantity,
+ 'status_id' => 1,
+ 'item_price_in' => $item_price_in + ($quantity_added * $model_price_in),
+ 'item_price_out' => $item_price_out + ($quantity_added * $model_price_out),
+ 'item_author' => $this->db->auth->get_user_id(),
+ 'item_date_bought' => date('Y-m-d'),
+ 'location_id' => 0,
+ 'room_id' => $_GET['room'],
+ 'vendor_id' => $_GET['vendor']
+ ));
+
+ //echo("<pre>"); print_r($selectbox);
+ $insert_form[]=array('item', $columns, $selectbox, $current, $disable_cols, $action, $multi_insert);