Zjednoduseni naskladnovani + hadani dodavatele (Wolfovo zadost)
[mirrors/SokoMan.git] / assistants / store.inc.php
index 7b9bf27c65ae543eaba58fc8b2aceb4ea8c1f592..a105f1ac9b27342ee751255ef048dded6606deef 100644 (file)
@@ -5,26 +5,31 @@ 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',$barcode,'textarea',false,'autofocus','serial(s):'),
+                       array('serials','','textarea',false,'autofocus','serial(s):'),
                        array(false,'STORE','submit')
                ));
                break;
        case 2:
                $barcode=$_GET['barcode'];
-               $countable = $this->db->map_unique('model_barcode', $barcode, 'model_countable', 'model');
+
+               $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);
-                       $model_id = $this->db->map_unique('model_barcode', $barcode, 'model_id', '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);
-                       $model_price_in = $this->db->map_unique('model_barcode', $barcode, 'model_price_in', 'model');
-                       $model_price_out = $this->db->map_unique('model_barcode', $barcode, 'model_price_out', 'model');
 
-                       $disable_cols = array('status_id','item_price_out','item_customer', 'model_id','item_quantity','item_date_sold');
+                       $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';
@@ -52,7 +57,7 @@ switch($SUBPATH[0]) {
                        //print_r(array('<pre>', $selectbox));
                        //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]);
                        $current = array(array(
-                               'model_id' => $model_id,
+                               'barcode_id' => $barcode_id,
                                'item_serial' => $item_serial,
                                'item_quantity' => $item_quantity,
                                'status_id' => 1,
@@ -60,7 +65,8 @@ switch($SUBPATH[0]) {
                                '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
+                               'location_id' => 0,
+                               'vendor_id' => $vendor_id
                        ));
 
                        $insert_form[]=array('item', $columns, $selectbox, $current, $disable_cols, $action, $multi_insert);
This page took 0.127762 seconds and 4 git commands to generate.