X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;ds=inline;f=assistants%2Fstore.inc.php;h=a105f1ac9b27342ee751255ef048dded6606deef;hb=1e0a73dc3e7bf25709b497eb8c98a572264bcdd1;hp=a4dcbe8b1b3eb6cf143386b825b4defebdf4a996;hpb=274c2053a765e8b3cfecd046f60cc4b057971d35;p=mirrors%2FSokoMan.git
diff --git a/assistants/store.inc.php b/assistants/store.inc.php
index a4dcbe8..a105f1a 100644
--- a/assistants/store.inc.php
+++ b/assistants/store.inc.php
@@ -5,51 +5,74 @@ switch($SUBPATH[0]) {
echo $this->html->form("$URL/2", 'GET', array(
array('barcode',$barcode,'text',false,'autofocus','model_barcode:'),
array('quantity','1','text',false,false,'quantity:'),
+ array('serials','','textarea',false,'autofocus','serial(s):'),
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');
- if($this->db->map_unique('model_barcode', $_GET['barcode'], 'model_countable', 'model')) {
- //$disable_cols[] = 'item_quantity';
- $item_serial = '';
- $item_quantity = $quantity_added = 1;
- $action = $_SERVER['SCRIPT_NAME'].'/item/new';
- } else {
- $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;
-
- $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);
+ $barcode=$_GET['barcode'];
+
+ $barcode_id = $this->db->map_unique('barcode_name', $barcode, 'barcode_id', 'barcode');
+ $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');
+ $item_price_in = $this->db->map_unique('item_serial', $barcode, 'item_price_in', 'item', false);
+ $item_price_out = $this->db->map_unique('item_serial', $barcode, 'item_price_out', 'item', false);
+ $vendor_id = $this->db->map_unique('barcode_id', $barcode_id, 'vendor_id', 'item', false);
+
+
+ $countable = $this->db->map_unique('model_id', $model_id, 'model_countable', 'model');
+
+ $serials=explode("\n",trim($_GET['serials']));
+ if(!$countable || trim($_GET['serials']) == '') $serials = array('');
+
+ foreach($serials as $serial) {
+ $serial=trim($serial);
+
+ $disable_cols = array('barcode_id','status_id','item_price_out','item_customer', 'model_id','item_quantity','item_date_sold','location_id');
+ if($countable) {
+ $multi_insert = true;
+ //$disable_cols[] = 'item_quantity';
+ $item_serial = $serial;
+ $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', $barcode, 'item_quantity', 'item', false);
+ if(!is_numeric($quantity_stored)) $quantity_stored = 0;
+
+ $disable_cols[] = 'item_serial';
+ $item_serial = $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');
+
+ $selectbox = $this->db->columns_get_selectbox($columns, 'item');
+ //print_r(array('
', $selectbox)); + //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]); + $current = array(array( + 'barcode_id' => $barcode_id, + 'item_serial' => $item_serial, + 'item_quantity' => $item_quantity, + 'status_id' => 1, + '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, + 'vendor_id' => $vendor_id + )); + + $insert_form[]=array('item', $columns, $selectbox, $current, $disable_cols, $action, $multi_insert); } - $columns = $this->db->get_columns('item'); - - $selectbox = $this->db->columns_get_selectbox($columns, 'item'); - //print_r(array('', $selectbox)); - //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]); - $current = array(array( - 'model_id' => $model_id, - 'item_serial' => $item_serial, - 'item_quantity' => $item_quantity, - 'status_id' => 1, - '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() - )); - echo $this->html->render_insert_form('item', $columns, $selectbox, $current, $disable_cols, $action); + echo $this->html->render_insert_form_multi($insert_form); + break; }