X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=assistants%2Fsell.inc.php;h=268f88f54db304bfd312fa688b60755d9524301e;hb=bd3726b4451118c135088d97059d711d874b1274;hp=33b08e57cb62e12cca50f7c6962896469ad1866f;hpb=4ece8e8078c74faac1037693e70656a8a50cb778;p=mirrors%2FSokoMan.git
diff --git a/assistants/sell.inc.php b/assistants/sell.inc.php
index 33b08e5..268f88f 100644
--- a/assistants/sell.inc.php
+++ b/assistants/sell.inc.php
@@ -10,7 +10,7 @@ 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'));
+$hide_cols_common = array_merge($hide_cols_additional,array('status_id','item_price_in','item_serial','item_quantity','model_id','vendor_id','room_id','item_date_bought'));
switch($SUBPATH[0]) {
default: case 1:
@@ -29,7 +29,8 @@ switch($SUBPATH[0]) {
$current[$item_id]['item_author'] = $this->db->auth->get_user_id();
$forked_item = $current;
- $model_id = $this->db->map_unique('item_serial', $item_serial, 'model_id', 'item');
+ $barcode_id = $this->db->map_unique('item_id', $item_id, 'barcode_id', 'item');
+ $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');
@@ -38,16 +39,18 @@ switch($SUBPATH[0]) {
$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;
+ $current[$item_id]['item_price_out'] = $model_price_out;
+ $current[$item_id]['item_date_sold'] = date('Y-m-d');
$hide_cols = $hide_cols_common;
} else {
- $hide_cols = array_merge($hide_cols_common,array('item_price_out','item_note','item_customer'));
+ $hide_cols = array_merge($hide_cols_common,array('item_price_out','item_note','item_customer','item_date_sold','location_id'));
$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;
+ if($item_quantity < 0) $this->post_redirect_get("$URL_INTERNAL/1","You don't have enough stored items!");
echo("Stock: ".$quantity_stored."
Disposing/Selling: ".$quantity_removed."
Keeping: ".$item_quantity);
@@ -63,6 +66,7 @@ switch($SUBPATH[0]) {
$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_item[$item_id]['item_date_sold'] = date('Y-m-d');
$forked_hide_cols = array_merge($hide_cols_common,array('item_price_out'));
}