From 5ef6c52f74756cfd5fc08f5af74b970d560b0293 Mon Sep 17 00:00:00 2001 From: Thomas Mudrunka Date: Sat, 27 Aug 2011 04:07:51 +0200 Subject: [PATCH] Podopora nepocitatelnych polozek byla dotazena do konce --- assistants/dispose.inc.php | 75 ++------------------------------------ assistants/sell.inc.php | 70 ++++++++++++++++++++++++++++++++--- index.php | 1 + locale/cs/messages.inc.php | 1 + 4 files changed, 70 insertions(+), 77 deletions(-) diff --git a/assistants/dispose.inc.php b/assistants/dispose.inc.php index 4ac4362..18c048b 100644 --- a/assistants/dispose.inc.php +++ b/assistants/dispose.inc.php @@ -1,72 +1,5 @@ html->form("$URL/2", 'GET', array( - array('serial','','text',false,'autofocus','item_serial:'), - array('quantity','1','text',false,false,'quantity:'), - array(false,'DISPOSE','submit') - )); - break; - case 2: - $item_serial = $_GET['serial']; - $item_id = $this->db->map_unique('item_serial', $item_serial, 'item_id', 'item'); - - $current = $this->db->get_listing('item', $item_id, 1); - $forked_item = $current; - - $disable_cols = array('status_id','item_price_in','item_serial','item_quantity','model_id','vendor_id','room_id','item_customer'); - - $model_id = $this->db->map_unique('item_serial', $item_serial, 'model_id', 'item'); - $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'] = 2; - $current[$item_id]['item_customer'] = 0; - $item_quantity = 1; - $current[$item_id]['item_price_out'] = $model_price_out; - } else { - $disable_cols = array_merge($disable_cols,array('item_price_out','item_note')); - $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'] = '2'; - $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'] = 0; - - $forked_disable_cols = array('model_id','vendor_id','item_serial','item_quantity','room_id','status_id','item_price_in','item_price_out','item_customer'); - } - - $columns = $this->db->get_columns('item'); - $selectbox = $this->db->columns_get_selectbox($columns, 'item'); - - $action = $_SERVER['SCRIPT_NAME']."/item/$item_id/edit"; - //echo $this->html->render_insert_form('item', $columns, $selectbox, $current, $disable_cols, $action); - - $insert_form[]=array('item', $columns, $selectbox, $current, $disable_cols, $action, false); - if(!$model_countable) $insert_form[]=array('item', $columns, $selectbox, $forked_item, $forked_disable_cols, $action, false); - echo $this->html->render_insert_form_multi($insert_form); - break; -} +$status_id = 2; +$item_customer = 0; +$hide_cols_additional = array('item_customer'); +require('sell.inc.php'); diff --git a/assistants/sell.inc.php b/assistants/sell.inc.php index 6a1a3b8..cb038d2 100644 --- a/assistants/sell.inc.php +++ b/assistants/sell.inc.php @@ -1,20 +1,78 @@ html->form("$URL/2", 'GET', array( array('serial','','text',false,'autofocus','item_serial:'), - array(false,'SELL','submit') + array('quantity','1','text',false,false,'quantity:'), + array(false,$button_label,'submit') )); break; case 2: - $item_id = $this->db->map_unique('item_serial', $_GET['serial'], 'item_id', 'item'); - $columns = $this->db->get_columns('item'); - $selectbox = $this->db->columns_get_selectbox($columns, 'item'); + $item_serial = $_GET['serial']; + $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]['status_id'] = 3; + $forked_item = $current; + + $model_id = $this->db->map_unique('item_serial', $item_serial, 'model_id', 'item'); + $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')); + } + + $columns = $this->db->get_columns('item'); + $selectbox = $this->db->columns_get_selectbox($columns, 'item'); $action = $_SERVER['SCRIPT_NAME']."/item/$item_id/edit"; - echo $this->html->render_insert_form('item', $columns, $selectbox, $current, false, $action); + //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; } diff --git a/index.php b/index.php index f4fd40c..71651ed 100755 --- a/index.php +++ b/index.php @@ -844,6 +844,7 @@ class Sklad_UI { $assistant_vars['SUBPATH'] = array_slice($PATH_CHUNKS, 3); $assistant_vars['URL_INTERNAL'] = 'assistant/'.$PATH_CHUNKS[2]; $assistant_vars['URL'] = $_SERVER['SCRIPT_NAME'].'/'.$assistant_vars['URL_INTERNAL']; + $assistant_vars['ASSISTANT'] = $PATH_CHUNKS[2]; echo $this->safe_include(DIR_ASSISTANTS,$PATH_CHUNKS[2],$assistant_vars); break; case 'barcode': //barcode diff --git a/locale/cs/messages.inc.php b/locale/cs/messages.inc.php index e6db9c2..b6e9690 100644 --- a/locale/cs/messages.inc.php +++ b/locale/cs/messages.inc.php @@ -28,6 +28,7 @@ $LOCALE_MESSAGES = array( 'model_barcode:' => 'Čárový kód modelu:', 'model_price_in' => 'Předpokládaná cena', 'model_price_out' => 'Doporučená cena', + 'model_countable' => 'Model počitatelný', 'room_name' => 'Sklad', 'room_descript' => 'Popis skladu', -- 2.30.2