f9725765a16739dd2e05fc020aa8f72d862bd321
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(false,'STORE','submit')
12 $model_id = $this->db
->map_unique('model_barcode', $_GET['barcode'], 'model_id', 'model');
14 $disable_cols = array('status_id','item_price_out','item_customer', 'model_id','item_quantity');
15 if($this->db
->map_unique('model_barcode', $_GET['barcode'], 'model_countable', 'model')) {
16 //$disable_cols[] = 'item_quantity';
19 $action = $_SERVER['SCRIPT_NAME'].'/item/new';
21 $quantity_added = $_GET['quantity'];
22 if($quantity_added <= 0) $this->post_redirect_get("$URL_INTERNAL/1","Can't store non-possitive amount of items!");
23 if(!is_numeric($quantity_added)) $quantity_added = 1;
24 $quantity_stored = $this->db
->map_unique('item_serial', $_GET['barcode'], 'item_quantity', 'item', false);
25 $item_price_in = $this->db
->map_unique('item_serial', $_GET['barcode'], 'item_price_in', 'item', false);
26 $item_price_out = $this->db
->map_unique('item_serial', $_GET['barcode'], 'item_price_out', 'item', false);
27 $model_price_in = $this->db
->map_unique('model_barcode', $_GET['barcode'], 'model_price_in', 'model');
28 $model_price_out = $this->db
->map_unique('model_barcode', $_GET['barcode'], 'model_price_out', 'model');
29 if(!is_numeric($quantity_stored)) $quantity_stored = 0;
30 echo("Quantity stored: ".$quantity_stored);
32 $disable_cols[] = 'item_serial';
33 $item_serial = $_GET['barcode'];
34 $item_quantity = $quantity_stored +
$quantity_added;
35 $action = $_SERVER['SCRIPT_NAME'].'/item/0/edit';
37 $columns = $this->db
->get_columns('item');
39 $selectbox = $this->db
->columns_get_selectbox($columns, 'item');
40 //print_r(array('<pre>', $selectbox));
41 //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]);
42 $current = array(array(
43 'model_id' => $model_id,
44 'item_serial' => $item_serial,
45 'item_quantity' => $item_quantity,
47 'item_price_in' => $item_price_in +
($quantity_added * $model_price_in),
48 'item_price_out' => $item_price_out +
($quantity_added * $model_price_out),
49 'item_author' => $this->db
->auth
->get_user_id()
52 echo $this->html
->render_insert_form('item', $columns, $selectbox, $current, $disable_cols, $action);
This page took 0.278459 seconds and 3 git commands to generate.