X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=assistants%2Fstore.inc.php;h=418ce9407177537b47a4bd616197115ebb0da6ab;hb=acb09ed65891a25d8163b92fe17db5bc78e601b1;hp=cf482920b1001540b2a6bb24d0f4f72fc412d57f;hpb=253705f2193c14e1f4162a37e8d1550d79efe5ec;p=mirrors%2FSokoMan.git diff --git a/assistants/store.inc.php b/assistants/store.inc.php index cf48292..418ce94 100644 --- a/assistants/store.inc.php +++ b/assistants/store.inc.php @@ -1,33 +1,41 @@ html->form("$URL/2", 'GET', array( - array('barcode','','text',false,'autofocus','model_barcode:'), + array('barcode',$barcode,'text',false,'autofocus','model_barcode:'), array('quantity','1','text',false,false,'quantity:'), array(false,'STORE','submit') )); break; case 2: $model_id = $this->db->map_unique('model_barcode', $_GET['barcode'], 'model_id', 'model'); + $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'); - $disable_cols = array('status_id','item_price_out','item_customer', 'model_id','item_quantity'); + $disable_cols = array('status_id','item_price_out','item_customer', 'model_id','item_quantity','item_date_sold'); if($this->db->map_unique('model_barcode', $_GET['barcode'], 'model_countable', 'model')) { + $multi_insert = true; //$disable_cols[] = 'item_quantity'; $item_serial = ''; - $item_quantity = 1; + $item_quantity = $quantity_added = 1; $action = $_SERVER['SCRIPT_NAME'].'/item/new'; } else { + $multi_insert = false; $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); 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'; + + echo('Stock: '.$quantity_stored.'
Storing: '.$quantity_added.'
Total: '.$item_quantity); } $columns = $this->db->get_columns('item'); @@ -39,11 +47,13 @@ switch($SUBPATH[0]) { 'item_serial' => $item_serial, 'item_quantity' => $item_quantity, 'status_id' => 1, - 'item_price_in' => $this->db->map_unique('model_barcode', $_GET['barcode'], 'model_price_in', 'model'), - 'item_price_out' => $this->db->map_unique('model_barcode', $_GET['barcode'], 'model_price_out', 'model'), - 'item_author' => $this->db->auth->get_user_id() + '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 )); - echo $this->html->render_insert_form('item', $columns, $selectbox, $current, $disable_cols, $action); + echo $this->html->render_insert_form('item', $columns, $selectbox, $current, $disable_cols, $action, $multi_insert); break; }