4 $barcode = isset($_GET['barcode']) ?
htmlspecialchars($_GET['barcode']) : ''; //TODO: XSS
5 echo $this->html
->form("$URL/2", 'GET', array(
6 array('barcode',$barcode,'text',false,'autofocus','model_barcode:'),
7 array('quantity','1','text',false,false,'quantity:'),
8 array('serials','','textarea',false,'autofocus','serial(s):'),
9 array(false,'STORE','submit')
13 $barcode=$_GET['barcode'];
15 $barcode_id = $this->db
->map_unique('barcode_name', $barcode, 'barcode_id', 'barcode');
16 $model_id = $this->db
->map_unique('barcode_id', $barcode_id, 'model_id', 'barcode');
17 $model_price_in = $this->db
->map_unique('model_id', $model_id, 'model_price_in', 'model');
18 $model_price_out = $this->db
->map_unique('model_id', $model_id, 'model_price_out', 'model');
19 $item_price_in = $this->db
->map_unique('item_serial', $barcode, 'item_price_in', 'item', false);
20 $item_price_out = $this->db
->map_unique('item_serial', $barcode, 'item_price_out', 'item', false);
22 $countable = $this->db
->map_unique('model_id', $model_id, 'model_countable', 'model');
24 $serials=explode("\n",trim($_GET['serials']));
25 if(!$countable ||
trim($_GET['serials']) == '') $serials = array('');
27 foreach($serials as $serial) {
28 $serial=trim($serial);
30 $disable_cols = array('status_id','item_price_out','item_customer', 'model_id','item_quantity','item_date_sold');
33 //$disable_cols[] = 'item_quantity';
34 $item_serial = $serial;
35 $item_quantity = $quantity_added = 1;
36 $action = $_SERVER['SCRIPT_NAME'].'/item/new';
38 $multi_insert = false;
39 $quantity_added = $_GET['quantity'];
40 if($quantity_added <= 0) $this->post_redirect_get("$URL_INTERNAL/1","Can't store non-possitive amount of items!");
41 if(!is_numeric($quantity_added)) $quantity_added = 1;
42 $quantity_stored = $this->db
->map_unique('item_serial', $barcode, 'item_quantity', 'item', false);
43 if(!is_numeric($quantity_stored)) $quantity_stored = 0;
45 $disable_cols[] = 'item_serial';
46 $item_serial = $barcode;
47 $item_quantity = $quantity_stored +
$quantity_added;
48 $action = $_SERVER['SCRIPT_NAME'].'/item/0/edit';
50 echo('Stock: '.$quantity_stored.'<br />Storing: '.$quantity_added.'<br />Total: '.$item_quantity);
52 $columns = $this->db
->get_columns('item');
54 $selectbox = $this->db
->columns_get_selectbox($columns, 'item');
55 //print_r(array('<pre>', $selectbox));
56 //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]);
57 $current = array(array(
58 'barcode_id' => $barcode_id,
59 'item_serial' => $item_serial,
60 'item_quantity' => $item_quantity,
62 'item_price_in' => $item_price_in +
($quantity_added * $model_price_in),
63 'item_price_out' => $item_price_out +
($quantity_added * $model_price_out),
64 'item_author' => $this->db
->auth
->get_user_id(),
65 'item_date_bought' => date('Y-m-d'),
69 $insert_form[]=array('item', $columns, $selectbox, $current, $disable_cols, $action, $multi_insert);
72 echo $this->html
->render_insert_form_multi($insert_form);
This page took 0.409915 seconds and 4 git commands to generate.