X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=assistants%2Fsell.inc.php;h=d1527141ce7a321db4b686d30805f6a806f2a3fa;hb=refs%2Fheads%2Fmaster;hp=cb038d21d3151cd4bd726c0066792f9fb837d11b;hpb=5ef6c52f74756cfd5fc08f5af74b970d560b0293;p=mirrors%2FSokoMan.git diff --git a/assistants/sell.inc.php b/assistants/sell.inc.php index cb038d2..d152714 100644 --- a/assistants/sell.inc.php +++ b/assistants/sell.inc.php @@ -10,12 +10,13 @@ if(!isset($item_customer)) $item_customer = ''; if(!isset($hide_cols_additional)) $hide_cols_additional = array(); $button_label = strtoupper($ASSISTANT); -$hide_cols_common = array_merge($hide_cols_additional,array('status_id','item_price_in','item_serial','item_quantity','model_id','vendor_id','room_id')); +$hide_cols_common = array_merge($hide_cols_additional,array('status_id','item_price_in','item_serial','item_quantity','model_id','vendor_id','room_id','item_date_bought')); switch($SUBPATH[0]) { default: case 1: + $serial = isset($_GET['serial']) ? htmlspecialchars($_GET['serial']) : ''; //TODO: XSS echo $this->html->form("$URL/2", 'GET', array( - array('serial','','text',false,'autofocus','item_serial:'), + array('serial',$serial,'text',false,'autofocus','item_serial:'), array('quantity','1','text',false,false,'quantity:'), array(false,$button_label,'submit') )); @@ -25,45 +26,20 @@ switch($SUBPATH[0]) { $item_id = $this->db->map_unique('item_serial', $item_serial, 'item_id', 'item'); $current = $this->db->get_listing('item', $item_id, 1); + $current[$item_id]['item_author'] = $this->db->auth->get_user_id(); $forked_item = $current; - $model_id = $this->db->map_unique('item_serial', $item_serial, 'model_id', 'item'); + $barcode_id = $this->db->map_unique('item_id', $item_id, 'barcode_id', 'item'); + $model_id = $this->db->map_unique('barcode_id', $barcode_id, 'model_id', 'barcode'); $model_price_in = $this->db->map_unique('model_id', $model_id, 'model_price_in', 'model'); $model_price_out = $this->db->map_unique('model_id', $model_id, 'model_price_out', 'model'); - $model_countable = $this->db->map_unique('model_id', $model_id, 'model_countable', 'model'); - if($model_countable) { - $current[$item_id]['status_id'] = $status_id; - $current[$item_id]['item_customer'] = $item_customer; - $item_quantity = 1; - $current[$item_id]['item_price_out'] = $model_price_out; - $hide_cols = $hide_cols_common; - } else { - $hide_cols = array_merge($hide_cols_common,array('item_price_out','item_note','item_customer')); - $quantity_removed = $_GET['quantity']; - if($quantity_removed <= 0) $this->post_redirect_get("$URL_INTERNAL/1","Can't dispose non-possitive amount of items!"); - if(!is_numeric($quantity_removed)) $quantity_removed = 1; - $quantity_stored = $this->db->map_unique('item_serial', $item_serial, 'item_quantity', 'item', false); - if(!is_numeric($quantity_stored)) $quantity_stored = 0; - $item_quantity = $quantity_stored - $quantity_removed; - - - echo("Stock: ".$quantity_stored."
Disposing/Selling: ".$quantity_removed."
Keeping: ".$item_quantity); - - $current[$item_id]['item_quantity'] = $item_quantity; - $current[$item_id]['item_price_in'] = $item_quantity * $model_price_in; - $current[$item_id]['item_price_out'] = $item_quantity * $model_price_out; - - $forked_item[$item_id]['item_id'] = ''; - $forked_item[$item_id]['item_serial'] .= '@'.time(); - $forked_item[$item_id]['status_id'] = $status_id; - $forked_item[$item_id]['item_quantity'] = $quantity_removed; - $forked_item[$item_id]['item_price_in'] = $quantity_removed * $model_price_in; - $forked_item[$item_id]['item_price_out'] = $quantity_removed * $model_price_out; - $forked_item[$item_id]['item_customer'] = $item_customer; - - $forked_hide_cols = array_merge($hide_cols_common,array('item_price_out')); - } + $current[$item_id]['status_id'] = $status_id; + $current[$item_id]['item_customer'] = $item_customer; + $item_quantity = 1; + $current[$item_id]['item_price_out'] = $model_price_out; + $current[$item_id]['item_date_sold'] = date('Y-m-d'); + $hide_cols = $hide_cols_common; $columns = $this->db->get_columns('item'); $selectbox = $this->db->columns_get_selectbox($columns, 'item'); @@ -72,7 +48,6 @@ switch($SUBPATH[0]) { //echo $this->html->render_insert_form('item', $columns, $selectbox, $current, $hide_cols, $action); $insert_form[]=array('item', $columns, $selectbox, $current, $hide_cols, $action, false); - if(!$model_countable) $insert_form[]=array('item', $columns, $selectbox, $forked_item, $forked_hide_cols, $action, false); echo $this->html->render_insert_form_multi($insert_form); break; }