Dalsi vylepseni hromadnyho naskladnovani (bohuzel to rozbilo tipovani dodavatele...
authorThomas Mudrunka <tomas@mudrunka.cz>
Fri, 19 Oct 2012 17:39:44 +0000 (19:39 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Fri, 19 Oct 2012 17:39:44 +0000 (19:39 +0200)
assistants/store.inc.php
index.php

index a105f1ac9b27342ee751255ef048dded6606deef..7e02e502d47565ddd3cd52733238283539cec2e9 100644 (file)
@@ -1,11 +1,17 @@
 <?php
+$columns = $this->db->get_columns('item');
+$selectbox = $this->db->columns_get_selectbox($columns, 'item');
+
 switch($SUBPATH[0]) {
        default: case 1:
                $barcode = isset($_GET['barcode']) ? htmlspecialchars($_GET['barcode']) : ''; //TODO: XSS
+
                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('vendor',false,'select',$selectbox['vendor_id'],false,'vendor:'),
+                       array('room',false,'select',$selectbox['room_id'],false,'room:'),
                        array(false,'STORE','submit')
                ));
                break;
@@ -18,8 +24,7 @@ switch($SUBPATH[0]) {
                $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);
-
+               //$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');
 
@@ -29,7 +34,7 @@ switch($SUBPATH[0]) {
                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');
+                       $disable_cols = array('barcode_id','status_id','item_price_out','item_customer', 'model_id','item_quantity','item_date_sold','location_id','vendor_id','room_id');
                        if($countable) {
                                $multi_insert = true;
                                //$disable_cols[] = 'item_quantity';
@@ -51,9 +56,7 @@ switch($SUBPATH[0]) {
 
                                echo('Stock: '.$quantity_stored.'<br />Storing: '.$quantity_added.'<br />Total: '.$item_quantity);
                        }
-                       $columns = $this->db->get_columns('item');
 
-           $selectbox = $this->db->columns_get_selectbox($columns, 'item');
                        //print_r(array('<pre>', $selectbox));
                        //foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]);
                        $current = array(array(
@@ -66,9 +69,11 @@ switch($SUBPATH[0]) {
                                'item_author' => $this->db->auth->get_user_id(),
                                'item_date_bought' => date('Y-m-d'),
                                'location_id' => 0,
-                               'vendor_id' => $vendor_id
+                               'room_id' => $_GET['room'],
+                               'vendor_id' => $_GET['vendor']
                        ));
 
+                       //echo("<pre>"); print_r($selectbox);
                        $insert_form[]=array('item', $columns, $selectbox, $current, $disable_cols, $action, $multi_insert);
                }
 
index f1744a4a17fe63cb429b2efaa180ee23df26bc74..ab5d70a34dd45148e778da211d1da191dc45737b 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -102,6 +102,8 @@ class HTML {
 
        function input($name=false, $value=false, $type='text', $placeholder=false, $options=false, $prefix='') {
                if($type == 'textarea') return $this->textarea($name, $value, $placeholder, $options, $prefix);
+               if($type == 'select') return $this->select($name, $placeholder, $value, $prefix);
+               //select(vendor, $selectbox ,false, prefix:);
                $html = T($prefix)."<input type='$type' ";
                if($name) $html.= "name='$name' ";
                if(!is_bool($value)) {
@@ -124,9 +126,9 @@ class HTML {
                return $html;
        }
 
-       function select($name, $selectbox, $default=false) {
+       function select($name, $selectbox, $default=false, $prefix='') {
                //echo('<pre>'); print_r($selectbox);
-               $html = "<select name='$name'>";
+               $html = T($prefix)."<select name='$name'>";
 
                if(!is_bool($default)) {
                        $value=$default; $title=$selectbox[$value];
@@ -773,6 +775,7 @@ class Sklad_DB extends PDO {
                        foreach($result as $row) $selectbox[$table.$suffix_id][$row[$table.$suffix_id]]=$row[$table.$suffix_name];
                }
                //echo('<pre>'); print_r($selectbox);
+               //return $selectbox;
                //return array_filter($selectbox, 'ksort');
                return array_filter($selectbox, 'natcasesort');
                //array_multisort($selectbox); return $selectbox;
This page took 0.132841 seconds and 4 git commands to generate.