Podopora nepocitatelnych polozek byla dotazena do konce
authorThomas Mudrunka <tomas@mudrunka.cz>
Sat, 27 Aug 2011 02:07:51 +0000 (04:07 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Sat, 27 Aug 2011 02:07:51 +0000 (04:07 +0200)
assistants/dispose.inc.php
assistants/sell.inc.php
index.php
locale/cs/messages.inc.php

index 4ac4362424ae3ea14b6399a2685ae1a21bde9040..18c048b2ce0f829d1eb697acc5220b59c2207ce4 100644 (file)
@@ -1,72 +1,5 @@
 <?php
-//TODO: Merge SELL and DISPOSE to single file with parameter!
-//TODO: Highlight fields that should be filled (and maybe even check them when submited)
-//TODO: Add support for selling/disposing multiple items at once...
-//TODO: Reuse /item/$item_id/edit
-//TODO: Stop using map_unique()!!!
-//TODO: we can use empty selectbox[] if no selectboxes are shown
-switch($SUBPATH[0]) {
-       default: case 1:
-               echo $this->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."<br />Disposing/Selling: ".$quantity_removed."<br />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');
index 6a1a3b8d51a8f83e5f1c03857cc43b6c62ef27b6..cb038d21d3151cd4bd726c0066792f9fb837d11b 100644 (file)
@@ -1,20 +1,78 @@
 <?php
+//TODO: Highlight fields that should be filled (and maybe even check them when submited)
+//TODO: Add support for selling/disposing multiple items at once...
+//TODO: Reuse /item/$item_id/edit
+//TODO: Stop using map_unique()!!!
+//TODO: we can use empty selectbox[] if no selectboxes are shown
+
+if(!isset($status_id)) $status_id = 3;
+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'));
+
 switch($SUBPATH[0]) {
        default: case 1:
                echo $this->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."<br />Disposing/Selling: ".$quantity_removed."<br />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;
 }
index f4fd40c3afb65ca18508675fab17a4890363a0ec..71651ed5584e1d1e4125424cea9ff2ad2ecfba06 100755 (executable)
--- 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
index e6db9c206e2d02022e48326f06b0227d54fc5379..b6e96905e1dad4510d95d65a40c2c66245081c8f 100644 (file)
@@ -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',
This page took 0.160861 seconds and 4 git commands to generate.