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:
+ $serial = isset($_GET['serial']) ? htmlspecialchars($_GET['serial']) : ''; //TODO: XSS
echo $this->html->form("$URL/2", 'GET', array(
- array('serial','','text',false,'autofocus','item_serial:'),
+ array('serial',$serial,'text',false,'autofocus','item_serial:'),
array('quantity','1','text',false,false,'quantity:'),
array(false,$button_label,'submit')
));
$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]['item_author'] = $this->db->auth->get_user_id();
$forked_item = $current;
$model_id = $this->db->map_unique('item_serial', $item_serial, 'model_id', 'item');
$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;
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;
+ $current[$item_id]['item_price_in'] -= $quantity_removed * $model_price_in;
+ $current[$item_id]['item_price_out'] -= $quantity_removed * $model_price_out;
$forked_item[$item_id]['item_id'] = '';
$forked_item[$item_id]['item_serial'] .= '@'.time();
$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'));
}