2 $columns = $this->db
->get_columns('item');
3 $selectbox = $this->db
->columns_get_selectbox($columns, 'item');
7 $barcode = isset($_GET['barcode']) ?
htmlspecialchars($_GET['barcode']) : ''; //TODO: XSS
9 echo $this->html
->form("$URL/2", 'GET', array(
10 array('barcode',$barcode,'text',false,'autofocus','model_barcode:'),
11 array('quantity','1','text',false,false,'quantity:'),
12 array('serials','','textarea',false,'autofocus','serial(s):'),
13 array('vendor',false,'select',$selectbox['vendor_id'],false,'vendor:'),
14 array('room',false,'select',$selectbox['room_id'],false,'room:'),
15 array(false,'STORE','submit')
19 $barcode=$_GET['barcode'];
21 $barcode_id = $this->db
->map_unique('barcode_name', $barcode, 'barcode_id', 'barcode');
22 $model_id = $this->db
->map_unique('barcode_id', $barcode_id, 'model_id', 'barcode');
23 $model_price_in = $this->db
->map_unique('model_id', $model_id, 'model_price_in', 'model');
24 $model_price_out = $this->db
->map_unique('model_id', $model_id, 'model_price_out', 'model');
25 $item_price_in = $this->db
->map_unique('item_serial', $barcode, 'item_price_in', 'item', false);
26 $item_price_out = $this->db
->map_unique('item_serial', $barcode, 'item_price_out', 'item', false);
27 //$vendor_id = $this->db->map_unique('barcode_id', $barcode_id, 'vendor_id', 'item', false);
29 $countable = $this->db
->map_unique('model_id', $model_id, 'model_countable', 'model');
31 $serials=explode("\n",trim($_GET['serials']));
32 if(!$countable ||
trim($_GET['serials']) == '') $serials = array('');
34 foreach($serials as $serial) {
35 $serial=trim($serial);
37 $disable_cols = array('barcode_id','status_id','item_price_out','item_customer', 'model_id','item_quantity','item_date_sold','location_id','vendor_id','room_id');
40 //$disable_cols[] = 'item_quantity';
41 $item_serial = $serial;
42 $item_quantity = $quantity_added = 1;
43 $action = $_SERVER['SCRIPT_NAME'].'/item/new';
45 $multi_insert = false;
46 $quantity_added = $_GET['quantity'];
47 if($quantity_added <= 0) $this->post_redirect_get("$URL_INTERNAL/1","Can't store non-possitive amount of items!");
48 if(!is_numeric($quantity_added)) $quantity_added = 1;
49 $quantity_stored = $this->db
->map_unique('item_serial', $barcode, 'item_quantity', 'item', false);
50 if(!is_numeric($quantity_stored)) $quantity_stored = 0;
52 $disable_cols[] = 'item_serial';
53 $item_serial = $barcode;
54 $item_quantity = $quantity_stored +
$quantity_added;
55 $action = $_SERVER['SCRIPT_NAME'].'/item/0/edit';
57 echo('Stock: '.$quantity_stored.'<br />Storing: '.$quantity_added.'<br />Total: '.$item_quantity);
60 //print_r(array('<pre>', $selectbox));
61 //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]);
62 $current = array(array(
63 'barcode_id' => $barcode_id,
64 'item_serial' => $item_serial,
65 'item_quantity' => $item_quantity,
67 'item_price_in' => $item_price_in +
($quantity_added * $model_price_in),
68 'item_price_out' => $item_price_out +
($quantity_added * $model_price_out),
69 'item_author' => $this->db
->auth
->get_user_id(),
70 'item_date_bought' => date('Y-m-d'),
72 'room_id' => $_GET['room'],
73 'vendor_id' => $_GET['vendor']
76 //echo("<pre>"); print_r($selectbox);
77 $insert_form[]=array('item', $columns, $selectbox, $current, $disable_cols, $action, $multi_insert);
80 echo $this->html
->render_insert_form_multi($insert_form);
This page took 0.3439 seconds and 4 git commands to generate.