mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-02-18 14:48:42 -05:00
Merge branch 'master' into pic_filename
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
FROM php:5-apache
|
||||
FROM php:7.0.15-apache
|
||||
MAINTAINER jekkos
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
php5-apcu \
|
||||
@@ -7,7 +7,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
libmcrypt-dev
|
||||
|
||||
RUN a2enmod rewrite
|
||||
RUN docker-php-ext-install mysql mysqli bcmath intl gd sockets mbstring mcrypt
|
||||
RUN docker-php-ext-install mysqli bcmath intl gd sockets mbstring mcrypt
|
||||
RUN echo "date.timezone = \"\${PHP_TIMEZONE}\"" > /usr/local/etc/php/conf.d/timezone.ini
|
||||
RUN echo -e “$(hostname -i)\t$(hostname) $(hostname).localhost” >> /etc/hosts
|
||||
|
||||
|
||||
1
LICENSE
1
LICENSE
@@ -12,6 +12,7 @@ Copyright (c) 2015 Toni Haryanto (aka yllumi)
|
||||
Copyright (c) 2016-2017 Ramkrishna Mondal (aka RamkrishnaMondal)
|
||||
Copyright (c) 2016 Rinaldy@dbarber (aka rnld26)
|
||||
Copyright (c) 2016 Jorge Colmenarez (aka jlctmaster), frontuari.com
|
||||
Copyright (c) 2017 Steve Ireland
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
@@ -9,6 +9,7 @@ class Config extends Secure_Controller
|
||||
parent::__construct('config');
|
||||
|
||||
$this->load->library('barcode_lib');
|
||||
$this->load->library('sale_lib');
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -194,7 +195,8 @@ class Config extends Secure_Controller
|
||||
$data['stock_locations'] = $this->Stock_location->get_all()->result_array();
|
||||
$data['support_barcode'] = $this->barcode_lib->get_list_barcodes();
|
||||
$data['logo_exists'] = $this->config->item('company_logo') != '';
|
||||
|
||||
$data['line_sequence_options'] = $this->sale_lib->get_line_sequence_options();
|
||||
|
||||
$data = $this->xss_clean($data);
|
||||
|
||||
// load all the license statements, they are already XSS cleaned in the private function
|
||||
@@ -373,7 +375,6 @@ class Config extends Secure_Controller
|
||||
|
||||
private function _clear_session_state()
|
||||
{
|
||||
$this->load->library('sale_lib');
|
||||
$this->sale_lib->clear_sale_location();
|
||||
$this->sale_lib->clear_all();
|
||||
$this->load->library('receiving_lib');
|
||||
@@ -415,9 +416,9 @@ class Config extends Secure_Controller
|
||||
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
}
|
||||
|
||||
public function save_barcode()
|
||||
{
|
||||
$batch_save_data = array(
|
||||
public function save_barcode()
|
||||
{
|
||||
$batch_save_data = array(
|
||||
'barcode_type' => $this->input->post('barcode_type'),
|
||||
'barcode_quality' => $this->input->post('barcode_quality'),
|
||||
'barcode_width' => $this->input->post('barcode_width'),
|
||||
@@ -432,17 +433,17 @@ class Config extends Secure_Controller
|
||||
'barcode_page_cellspacing' => $this->input->post('barcode_page_cellspacing'),
|
||||
'barcode_generate_if_empty' => $this->input->post('barcode_generate_if_empty') != NULL,
|
||||
'barcode_content' => $this->input->post('barcode_content')
|
||||
);
|
||||
|
||||
$result = $this->Appconfig->batch_save($batch_save_data);
|
||||
$success = $result ? TRUE : FALSE;
|
||||
);
|
||||
|
||||
$result = $this->Appconfig->batch_save($batch_save_data);
|
||||
$success = $result ? TRUE : FALSE;
|
||||
|
||||
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
}
|
||||
|
||||
public function save_receipt()
|
||||
{
|
||||
$batch_save_data = array (
|
||||
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
}
|
||||
|
||||
public function save_receipt()
|
||||
{
|
||||
$batch_save_data = array (
|
||||
'receipt_template' => $this->input->post('receipt_template'),
|
||||
'receipt_show_taxes' => $this->input->post('receipt_show_taxes') != NULL,
|
||||
'receipt_show_total_discount' => $this->input->post('receipt_show_total_discount') != NULL,
|
||||
@@ -457,27 +458,28 @@ class Config extends Secure_Controller
|
||||
'print_right_margin' => $this->input->post('print_right_margin')
|
||||
);
|
||||
|
||||
$result = $this->Appconfig->batch_save($batch_save_data);
|
||||
$success = $result ? TRUE : FALSE;
|
||||
$result = $this->Appconfig->batch_save($batch_save_data);
|
||||
$success = $result ? TRUE : FALSE;
|
||||
|
||||
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
}
|
||||
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
}
|
||||
|
||||
public function save_invoice()
|
||||
{
|
||||
$batch_save_data = array (
|
||||
public function save_invoice()
|
||||
{
|
||||
$batch_save_data = array (
|
||||
'invoice_enable' => $this->input->post('invoice_enable') != NULL,
|
||||
'sales_invoice_format' => $this->input->post('sales_invoice_format'),
|
||||
'recv_invoice_format' => $this->input->post('recv_invoice_format'),
|
||||
'invoice_default_comments' => $this->input->post('invoice_default_comments'),
|
||||
'invoice_email_message' => $this->input->post('invoice_email_message')
|
||||
'invoice_email_message' => $this->input->post('invoice_email_message'),
|
||||
'line_sequence' => $this->input->post('line_sequence')
|
||||
);
|
||||
|
||||
$result = $this->Appconfig->batch_save($batch_save_data);
|
||||
$success = $result ? TRUE : FALSE;
|
||||
$result = $this->Appconfig->batch_save($batch_save_data);
|
||||
$success = $result ? TRUE : FALSE;
|
||||
|
||||
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
}
|
||||
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
}
|
||||
|
||||
public function remove_logo()
|
||||
{
|
||||
@@ -485,22 +487,22 @@ class Config extends Secure_Controller
|
||||
|
||||
echo json_encode(array('success' => $result));
|
||||
}
|
||||
|
||||
private function _handle_logo_upload()
|
||||
{
|
||||
$this->load->helper('directory');
|
||||
|
||||
// load upload library
|
||||
$config = array('upload_path' => './uploads/',
|
||||
'allowed_types' => 'gif|jpg|png',
|
||||
'max_size' => '1024',
|
||||
'max_width' => '800',
|
||||
'max_height' => '680',
|
||||
'file_name' => 'company_logo');
|
||||
$this->load->library('upload', $config);
|
||||
$this->upload->do_upload('company_logo');
|
||||
private function _handle_logo_upload()
|
||||
{
|
||||
$this->load->helper('directory');
|
||||
|
||||
return strlen($this->upload->display_errors()) == 0 || !strcmp($this->upload->display_errors(), '<p>'.$this->lang->line('upload_no_file_selected').'</p>');
|
||||
// load upload library
|
||||
$config = array('upload_path' => './uploads/',
|
||||
'allowed_types' => 'gif|jpg|png',
|
||||
'max_size' => '1024',
|
||||
'max_width' => '800',
|
||||
'max_height' => '680',
|
||||
'file_name' => 'company_logo');
|
||||
$this->load->library('upload', $config);
|
||||
$this->upload->do_upload('company_logo');
|
||||
|
||||
return strlen($this->upload->display_errors()) == 0 || !strcmp($this->upload->display_errors(), '<p>'.$this->lang->line('upload_no_file_selected').'</p>');
|
||||
}
|
||||
|
||||
private function _check_encryption()
|
||||
@@ -557,35 +559,35 @@ class Config extends Secure_Controller
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function backup_db()
|
||||
{
|
||||
$employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
|
||||
if($this->Employee->has_module_grant('config', $employee_id))
|
||||
{
|
||||
$this->load->dbutil();
|
||||
|
||||
$prefs = array(
|
||||
public function backup_db()
|
||||
{
|
||||
$employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
|
||||
if($this->Employee->has_module_grant('config', $employee_id))
|
||||
{
|
||||
$this->load->dbutil();
|
||||
|
||||
$prefs = array(
|
||||
'format' => 'zip',
|
||||
'filename' => 'ospos.sql'
|
||||
);
|
||||
|
||||
$backup = $this->dbutil->backup($prefs);
|
||||
|
||||
$file_name = 'ospos-' . date("Y-m-d-H-i-s") .'.zip';
|
||||
$save = 'uploads/' . $file_name;
|
||||
$this->load->helper('download');
|
||||
while(ob_get_level())
|
||||
{
|
||||
ob_end_clean();
|
||||
}
|
||||
);
|
||||
|
||||
force_download($file_name, $backup);
|
||||
}
|
||||
else
|
||||
{
|
||||
redirect('no_access/config');
|
||||
}
|
||||
}
|
||||
$backup = $this->dbutil->backup($prefs);
|
||||
|
||||
$file_name = 'ospos-' . date("Y-m-d-H-i-s") .'.zip';
|
||||
$save = 'uploads/' . $file_name;
|
||||
$this->load->helper('download');
|
||||
while(ob_get_level())
|
||||
{
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
force_download($file_name, $backup);
|
||||
}
|
||||
else
|
||||
{
|
||||
redirect('no_access/config');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -84,23 +84,35 @@ class Item_kits extends Secure_Controller
|
||||
public function view($item_kit_id = -1)
|
||||
{
|
||||
$info = $this->Item_kit->get_info($item_kit_id);
|
||||
|
||||
if($item_kit_id == -1)
|
||||
{
|
||||
$info->price_option = '0';
|
||||
$info->print_option = '0';
|
||||
}
|
||||
foreach(get_object_vars($info) as $property => $value)
|
||||
{
|
||||
$info->$property = $this->xss_clean($value);
|
||||
}
|
||||
|
||||
$data['item_kit_info'] = $info;
|
||||
|
||||
|
||||
$items = array();
|
||||
foreach($this->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
|
||||
{
|
||||
$item['kit_sequence'] = $this->xss_clean($item_kit_item['kit_sequence']);
|
||||
$item['name'] = $this->xss_clean($this->Item->get_info($item_kit_item['item_id'])->name);
|
||||
$item['item_id'] = $this->xss_clean($item_kit_item['item_id']);
|
||||
$item['quantity'] = $this->xss_clean($item_kit_item['quantity']);
|
||||
|
||||
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
$data['item_kit_items'] = $items;
|
||||
|
||||
$data['selected_kit_item_id'] = $info->kit_item_id;
|
||||
$data['selected_kit_item'] = ($item_kit_id > 0 && isset($info->kit_item_id)) ? $info->item_name : '';
|
||||
|
||||
$this->load->view("item_kits/form", $data);
|
||||
}
|
||||
|
||||
@@ -108,36 +120,54 @@ class Item_kits extends Secure_Controller
|
||||
{
|
||||
$item_kit_data = array(
|
||||
'name' => $this->input->post('name'),
|
||||
'item_id' => $this->input->post('kit_item_id'),
|
||||
'kit_discount_percent' => $this->input->post('kit_discount_percent'),
|
||||
'price_option' => $this->input->post('price_option'),
|
||||
'print_option' => $this->input->post('print_option'),
|
||||
'description' => $this->input->post('description')
|
||||
);
|
||||
|
||||
if($this->Item_kit->save($item_kit_data, $item_kit_id))
|
||||
{
|
||||
$success = TRUE;
|
||||
$new_item = FALSE;
|
||||
//New item kit
|
||||
if ($item_kit_id == -1)
|
||||
{
|
||||
$item_kit_id = $item_kit_data['item_kit_id'];
|
||||
$new_item = TRUE;
|
||||
}
|
||||
|
||||
if($this->input->post('item_kit_item') != NULL)
|
||||
if($this->input->post('item_kit_qty') != NULL)
|
||||
{
|
||||
$item_kit_items = array();
|
||||
foreach($this->input->post('item_kit_item') as $item_id => $quantity)
|
||||
foreach($this->input->post('item_kit_qty') as $item_id => $quantity)
|
||||
{
|
||||
$seq = $this->input->post('item_kit_seq[' . $item_id . ']');
|
||||
$item_kit_items[] = array(
|
||||
'item_id' => $item_id,
|
||||
'quantity' => $quantity
|
||||
'quantity' => $quantity,
|
||||
'kit_sequence' => $seq
|
||||
);
|
||||
}
|
||||
|
||||
$success = $this->Item_kit_items->save($item_kit_items, $item_kit_id);
|
||||
}
|
||||
|
||||
$success = $this->Item_kit_items->save($item_kit_items, $item_kit_id);
|
||||
|
||||
$item_kit_data = $this->xss_clean($item_kit_data);
|
||||
|
||||
echo json_encode(array('success' => $success,
|
||||
'message' => $this->lang->line('item_kits_successful_adding').' '.$item_kit_data['name'], 'id' => $item_kit_id));
|
||||
if($new_item)
|
||||
{
|
||||
echo json_encode(array('success' => $success,
|
||||
'message' => $this->lang->line('item_kits_successful_adding').' '.$item_kit_data['name'], 'id' => $item_kit_id));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('success' => $success,
|
||||
'message' => $this->lang->line('item_kits_successful_updating').' '.$item_kit_data['name'], 'id' => $item_kit_id));
|
||||
}
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
@@ -182,7 +212,7 @@ class Item_kits extends Secure_Controller
|
||||
}
|
||||
|
||||
$data['items'] = $result;
|
||||
$barcode_config = $this->barcode_lib->get_barcode_config();
|
||||
$barcode_config = $this->barcode_lib->get_barcode_config();
|
||||
// in case the selected barcode type is not Code39 or Code128 we set by default Code128
|
||||
// the rationale for this is that EAN codes cannot have strings as seed, so 'KIT ' is not allowed
|
||||
if($barcode_config['barcode_type'] != 'Code39' && $barcode_config['barcode_type'] != 'Code128')
|
||||
@@ -195,4 +225,4 @@ class Item_kits extends Secure_Controller
|
||||
$this->load->view("barcodes/barcode_sheet", $data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -190,9 +190,11 @@ class Items extends Secure_Controller
|
||||
{
|
||||
$data['default_tax_1_rate'] = $this->config->item('default_tax_1_rate');
|
||||
$data['default_tax_2_rate'] = $this->config->item('default_tax_2_rate');
|
||||
|
||||
|
||||
$item_info->receiving_quantity = 0;
|
||||
$item_info->reorder_level = 0;
|
||||
$item_info->item_type = '0'; // standard
|
||||
$item_info->stock_type = '0'; // stock
|
||||
}
|
||||
|
||||
$data['item_info'] = $item_info;
|
||||
@@ -225,19 +227,19 @@ class Items extends Secure_Controller
|
||||
}
|
||||
$data['image_path'] = sizeof($images) > 0 ? base_url($images[0]) : '';
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location)
|
||||
{
|
||||
foreach($stock_locations as $location)
|
||||
{
|
||||
$location = $this->xss_clean($location);
|
||||
|
||||
$quantity = $this->xss_clean($this->Item_quantity->get_item_quantity($item_id, $location['location_id'])->quantity);
|
||||
$quantity = ($item_id == -1) ? 0 : $quantity;
|
||||
$location_array[$location['location_id']] = array('location_name' => $location['location_name'], 'quantity' => $quantity);
|
||||
$data['stock_locations'] = $location_array;
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->view('items/form', $data);
|
||||
}
|
||||
|
||||
|
||||
public function inventory($item_id = -1)
|
||||
{
|
||||
$item_info = $this->Item->get_info($item_id);
|
||||
@@ -247,16 +249,16 @@ class Items extends Secure_Controller
|
||||
}
|
||||
$data['item_info'] = $item_info;
|
||||
|
||||
$data['stock_locations'] = array();
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location)
|
||||
{
|
||||
$data['stock_locations'] = array();
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location)
|
||||
{
|
||||
$location = $this->xss_clean($location);
|
||||
$quantity = $this->xss_clean($this->Item_quantity->get_item_quantity($item_id, $location['location_id'])->quantity);
|
||||
|
||||
$data['stock_locations'][$location['location_id']] = $location['location_name'];
|
||||
$data['item_quantities'][$location['location_id']] = $quantity;
|
||||
}
|
||||
$data['stock_locations'][$location['location_id']] = $location['location_name'];
|
||||
$data['item_quantities'][$location['location_id']] = $quantity;
|
||||
}
|
||||
|
||||
$this->load->view('items/form_inventory', $data);
|
||||
}
|
||||
@@ -270,16 +272,16 @@ class Items extends Secure_Controller
|
||||
}
|
||||
$data['item_info'] = $item_info;
|
||||
|
||||
$data['stock_locations'] = array();
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location)
|
||||
{
|
||||
$data['stock_locations'] = array();
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location)
|
||||
{
|
||||
$location = $this->xss_clean($location);
|
||||
$quantity = $this->xss_clean($this->Item_quantity->get_item_quantity($item_id, $location['location_id'])->quantity);
|
||||
|
||||
$data['stock_locations'][$location['location_id']] = $location['location_name'];
|
||||
$data['item_quantities'][$location['location_id']] = $quantity;
|
||||
}
|
||||
$data['stock_locations'][$location['location_id']] = $location['location_name'];
|
||||
$data['item_quantities'][$location['location_id']] = $quantity;
|
||||
}
|
||||
|
||||
$this->load->view('items/form_count_details', $data);
|
||||
}
|
||||
@@ -351,6 +353,8 @@ class Items extends Secure_Controller
|
||||
'name' => $this->input->post('name'),
|
||||
'description' => $this->input->post('description'),
|
||||
'category' => $this->input->post('category'),
|
||||
'item_type' => $this->input->post('item_type'),
|
||||
'stock_type' => $this->input->post('stock_type'),
|
||||
'supplier_id' => $this->input->post('supplier_id') == '' ? NULL : $this->input->post('supplier_id'),
|
||||
'item_number' => $this->input->post('item_number') == '' ? NULL : $this->input->post('item_number'),
|
||||
'cost_price' => parse_decimals($this->input->post('cost_price')),
|
||||
@@ -408,45 +412,45 @@ class Items extends Secure_Controller
|
||||
}
|
||||
}
|
||||
$success &= $this->Item_taxes->save($items_taxes_data, $item_id);
|
||||
|
||||
//Save item quantity
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location)
|
||||
{
|
||||
$updated_quantity = parse_decimals($this->input->post('quantity_' . $location['location_id']));
|
||||
$location_detail = array('item_id' => $item_id,
|
||||
'location_id' => $location['location_id'],
|
||||
'quantity' => $updated_quantity);
|
||||
$item_quantity = $this->Item_quantity->get_item_quantity($item_id, $location['location_id']);
|
||||
if($item_quantity->quantity != $updated_quantity || $new_item)
|
||||
{
|
||||
$success &= $this->Item_quantity->save($location_detail, $item_id, $location['location_id']);
|
||||
|
||||
$inv_data = array(
|
||||
'trans_date' => date('Y-m-d H:i:s'),
|
||||
'trans_items' => $item_id,
|
||||
'trans_user' => $employee_id,
|
||||
'trans_location' => $location['location_id'],
|
||||
'trans_comment' => $this->lang->line('items_manually_editing_of_quantity'),
|
||||
'trans_inventory' => $updated_quantity - $item_quantity->quantity
|
||||
);
|
||||
|
||||
$success &= $this->Inventory->insert($inv_data);
|
||||
}
|
||||
}
|
||||
//Save item quantity
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location)
|
||||
{
|
||||
$updated_quantity = parse_decimals($this->input->post('quantity_' . $location['location_id']));
|
||||
$location_detail = array('item_id' => $item_id,
|
||||
'location_id' => $location['location_id'],
|
||||
'quantity' => $updated_quantity);
|
||||
$item_quantity = $this->Item_quantity->get_item_quantity($item_id, $location['location_id']);
|
||||
if($item_quantity->quantity != $updated_quantity || $new_item)
|
||||
{
|
||||
$success &= $this->Item_quantity->save($location_detail, $item_id, $location['location_id']);
|
||||
|
||||
$inv_data = array(
|
||||
'trans_date' => date('Y-m-d H:i:s'),
|
||||
'trans_items' => $item_id,
|
||||
'trans_user' => $employee_id,
|
||||
'trans_location' => $location['location_id'],
|
||||
'trans_comment' => $this->lang->line('items_manually_editing_of_quantity'),
|
||||
'trans_inventory' => $updated_quantity - $item_quantity->quantity
|
||||
);
|
||||
|
||||
$success &= $this->Inventory->insert($inv_data);
|
||||
}
|
||||
}
|
||||
|
||||
if($success && $upload_success)
|
||||
{
|
||||
$message = $this->xss_clean($this->lang->line('items_successful_' . ($new_item ? 'adding' : 'updating')) . ' ' . $item_data['name']);
|
||||
{
|
||||
$message = $this->xss_clean($this->lang->line('items_successful_' . ($new_item ? 'adding' : 'updating')) . ' ' . $item_data['name']);
|
||||
|
||||
echo json_encode(array('success' => TRUE, 'message' => $message, 'id' => $item_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $this->xss_clean($upload_success ? $this->lang->line('items_error_adding_updating') . ' ' . $item_data['name'] : strip_tags($this->upload->display_errors()));
|
||||
echo json_encode(array('success' => TRUE, 'message' => $message, 'id' => $item_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $this->xss_clean($upload_success ? $this->lang->line('items_error_adding_updating') . ' ' . $item_data['name'] : strip_tags($this->upload->display_errors()));
|
||||
|
||||
echo json_encode(array('success' => FALSE, 'message' => $message, 'id' => $item_id));
|
||||
}
|
||||
echo json_encode(array('success' => FALSE, 'message' => $message, 'id' => $item_id));
|
||||
}
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
@@ -461,7 +465,23 @@ class Items extends Secure_Controller
|
||||
$exists = $this->Item->item_number_exists($this->input->post('item_number'), $this->input->post('item_id'));
|
||||
echo !$exists ? 'true' : 'false';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
If adding a new item check to see if an item kit with the same name as the item already exists.
|
||||
*/
|
||||
public function check_kit_exists()
|
||||
{
|
||||
if ($this->input->post('item_number') === -1)
|
||||
{
|
||||
$exists = $this->Item_kit->item_kit_exists_for_name($this->input->post('name'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$exists = false;
|
||||
}
|
||||
echo !$exists ? 'true' : 'false';
|
||||
}
|
||||
|
||||
private function _handle_image_upload()
|
||||
{
|
||||
/* Let files be uploaded with their original name */
|
||||
@@ -491,7 +511,7 @@ class Items extends Secure_Controller
|
||||
{
|
||||
$employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
|
||||
$cur_item_info = $this->Item->get_info($item_id);
|
||||
$location_id = $this->input->post('stock_location');
|
||||
$location_id = $this->input->post('stock_location');
|
||||
$inv_data = array(
|
||||
'trans_date' => date('Y-m-d H:i:s'),
|
||||
'trans_items' => $item_id,
|
||||
@@ -604,52 +624,52 @@ class Items extends Secure_Controller
|
||||
$this->load->view('items/form_excel_import', NULL);
|
||||
}
|
||||
|
||||
public function do_excel_import()
|
||||
{
|
||||
if($_FILES['file_path']['error'] != UPLOAD_ERR_OK)
|
||||
{
|
||||
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('items_excel_import_failed')));
|
||||
}
|
||||
else
|
||||
public function do_excel_import()
|
||||
{
|
||||
if($_FILES['file_path']['error'] != UPLOAD_ERR_OK)
|
||||
{
|
||||
if(($handle = fopen($_FILES['file_path']['tmp_name'], 'r')) !== FALSE)
|
||||
{
|
||||
// Skip the first row as it's the table description
|
||||
fgetcsv($handle);
|
||||
$i = 1;
|
||||
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('items_excel_import_failed')));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(($handle = fopen($_FILES['file_path']['tmp_name'], 'r')) !== FALSE)
|
||||
{
|
||||
// Skip the first row as it's the table description
|
||||
fgetcsv($handle);
|
||||
$i = 1;
|
||||
|
||||
$failCodes = array();
|
||||
|
||||
while(($data = fgetcsv($handle)) !== FALSE)
|
||||
{
|
||||
while(($data = fgetcsv($handle)) !== FALSE)
|
||||
{
|
||||
// XSS file data sanity check
|
||||
$data = $this->xss_clean($data);
|
||||
|
||||
/* haven't touched this so old templates will work, or so I guess... */
|
||||
if(sizeof($data) >= 23)
|
||||
{
|
||||
$item_data = array(
|
||||
'name' => $data[1],
|
||||
'description' => $data[11],
|
||||
'category' => $data[2],
|
||||
'cost_price' => $data[4],
|
||||
'unit_price' => $data[5],
|
||||
'reorder_level' => $data[10],
|
||||
'supplier_id' => $this->Supplier->exists($data[3]) ? $data[3] : NULL,
|
||||
'allow_alt_description' => $data[12] != '' ? '1' : '0',
|
||||
'is_serialized' => $data[13] != '' ? '1' : '0',
|
||||
'custom1' => $data[14],
|
||||
'custom2' => $data[15],
|
||||
'custom3' => $data[16],
|
||||
'custom4' => $data[17],
|
||||
'custom5' => $data[18],
|
||||
'custom6' => $data[19],
|
||||
'custom7' => $data[20],
|
||||
'custom8' => $data[21],
|
||||
'custom9' => $data[22],
|
||||
'custom10' => $data[23]
|
||||
);
|
||||
|
||||
$item_data = array(
|
||||
'name' => $data[1],
|
||||
'description' => $data[11],
|
||||
'category' => $data[2],
|
||||
'cost_price' => $data[4],
|
||||
'unit_price' => $data[5],
|
||||
'reorder_level' => $data[10],
|
||||
'supplier_id' => $this->Supplier->exists($data[3]) ? $data[3] : NULL,
|
||||
'allow_alt_description' => $data[12] != '' ? '1' : '0',
|
||||
'is_serialized' => $data[13] != '' ? '1' : '0',
|
||||
'custom1' => $data[14],
|
||||
'custom2' => $data[15],
|
||||
'custom3' => $data[16],
|
||||
'custom4' => $data[17],
|
||||
'custom5' => $data[18],
|
||||
'custom6' => $data[19],
|
||||
'custom7' => $data[20],
|
||||
'custom8' => $data[21],
|
||||
'custom9' => $data[22],
|
||||
'custom10' => $data[23]
|
||||
);
|
||||
|
||||
/* we could do something like this, however, the effectiveness of
|
||||
this is rather limited, since for now, you have to upload files manually
|
||||
into that directory, so you really can do whatever you want, this probably
|
||||
@@ -660,90 +680,90 @@ class Items extends Secure_Controller
|
||||
$pic_file='';
|
||||
}*/
|
||||
$item_data['pic_filename']=$pic_file;
|
||||
|
||||
$item_number = $data[0];
|
||||
$invalidated = FALSE;
|
||||
if($item_number != '')
|
||||
{
|
||||
$item_data['item_number'] = $item_number;
|
||||
$invalidated = $this->Item->item_number_exists($item_number);
|
||||
}
|
||||
|
||||
$item_number = $data[0];
|
||||
$invalidated = FALSE;
|
||||
if($item_number != '')
|
||||
{
|
||||
$item_data['item_number'] = $item_number;
|
||||
$invalidated = $this->Item->item_number_exists($item_number);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$invalidated = TRUE;
|
||||
}
|
||||
|
||||
if(!$invalidated && $this->Item->save($item_data))
|
||||
{
|
||||
$items_taxes_data = NULL;
|
||||
//tax 1
|
||||
if(is_numeric($data[7]) && $data[6] != '')
|
||||
{
|
||||
$items_taxes_data[] = array('name' => $data[6], 'percent' => $data[7] );
|
||||
}
|
||||
if(!$invalidated && $this->Item->save($item_data))
|
||||
{
|
||||
$items_taxes_data = NULL;
|
||||
//tax 1
|
||||
if(is_numeric($data[7]) && $data[6] != '')
|
||||
{
|
||||
$items_taxes_data[] = array('name' => $data[6], 'percent' => $data[7] );
|
||||
}
|
||||
|
||||
//tax 2
|
||||
if(is_numeric($data[9]) && $data[8] != '')
|
||||
{
|
||||
$items_taxes_data[] = array('name' => $data[8], 'percent' => $data[9] );
|
||||
}
|
||||
//tax 2
|
||||
if(is_numeric($data[9]) && $data[8] != '')
|
||||
{
|
||||
$items_taxes_data[] = array('name' => $data[8], 'percent' => $data[9] );
|
||||
}
|
||||
|
||||
// save tax values
|
||||
if(count($items_taxes_data) > 0)
|
||||
{
|
||||
$this->Item_taxes->save($items_taxes_data, $item_data['item_id']);
|
||||
}
|
||||
// save tax values
|
||||
if(count($items_taxes_data) > 0)
|
||||
{
|
||||
$this->Item_taxes->save($items_taxes_data, $item_data['item_id']);
|
||||
}
|
||||
|
||||
// quantities & inventory Info
|
||||
$employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
|
||||
$emp_info = $this->Employee->get_info($employee_id);
|
||||
$comment ='Qty CSV Imported';
|
||||
// quantities & inventory Info
|
||||
$employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
|
||||
$emp_info = $this->Employee->get_info($employee_id);
|
||||
$comment ='Qty CSV Imported';
|
||||
|
||||
$cols = count($data);
|
||||
$cols = count($data);
|
||||
|
||||
// array to store information if location got a quantity
|
||||
$allowed_locations = $this->Stock_location->get_allowed_locations();
|
||||
for ($col = 24; $col < $cols; $col = $col + 2)
|
||||
{
|
||||
$location_id = $data[$col];
|
||||
if(array_key_exists($location_id, $allowed_locations))
|
||||
{
|
||||
$item_quantity_data = array(
|
||||
'item_id' => $item_data['item_id'],
|
||||
'location_id' => $location_id,
|
||||
'quantity' => $data[$col + 1],
|
||||
);
|
||||
$this->Item_quantity->save($item_quantity_data, $item_data['item_id'], $location_id);
|
||||
// array to store information if location got a quantity
|
||||
$allowed_locations = $this->Stock_location->get_allowed_locations();
|
||||
for ($col = 24; $col < $cols; $col = $col + 2)
|
||||
{
|
||||
$location_id = $data[$col];
|
||||
if(array_key_exists($location_id, $allowed_locations))
|
||||
{
|
||||
$item_quantity_data = array(
|
||||
'item_id' => $item_data['item_id'],
|
||||
'location_id' => $location_id,
|
||||
'quantity' => $data[$col + 1],
|
||||
);
|
||||
$this->Item_quantity->save($item_quantity_data, $item_data['item_id'], $location_id);
|
||||
|
||||
$excel_data = array(
|
||||
'trans_items' => $item_data['item_id'],
|
||||
'trans_user' => $employee_id,
|
||||
'trans_comment' => $comment,
|
||||
'trans_location' => $data[$col],
|
||||
'trans_inventory' => $data[$col + 1]
|
||||
);
|
||||
$excel_data = array(
|
||||
'trans_items' => $item_data['item_id'],
|
||||
'trans_user' => $employee_id,
|
||||
'trans_comment' => $comment,
|
||||
'trans_location' => $data[$col],
|
||||
'trans_inventory' => $data[$col + 1]
|
||||
);
|
||||
|
||||
$this->Inventory->insert($excel_data);
|
||||
unset($allowed_locations[$location_id]);
|
||||
}
|
||||
}
|
||||
$this->Inventory->insert($excel_data);
|
||||
unset($allowed_locations[$location_id]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* now iterate through the array and check for which location_id no entry into item_quantities was made yet
|
||||
* those get an entry with quantity as 0.
|
||||
* unfortunately a bit duplicate code from above...
|
||||
*/
|
||||
foreach($allowed_locations as $location_id => $location_name)
|
||||
{
|
||||
$item_quantity_data = array(
|
||||
'item_id' => $item_data['item_id'],
|
||||
'location_id' => $location_id,
|
||||
'quantity' => 0,
|
||||
);
|
||||
$this->Item_quantity->save($item_quantity_data, $item_data['item_id'], $data[$col]);
|
||||
/*
|
||||
* now iterate through the array and check for which location_id no entry into item_quantities was made yet
|
||||
* those get an entry with quantity as 0.
|
||||
* unfortunately a bit duplicate code from above...
|
||||
*/
|
||||
foreach($allowed_locations as $location_id => $location_name)
|
||||
{
|
||||
$item_quantity_data = array(
|
||||
'item_id' => $item_data['item_id'],
|
||||
'location_id' => $location_id,
|
||||
'quantity' => 0,
|
||||
);
|
||||
$this->Item_quantity->save($item_quantity_data, $item_data['item_id'], $data[$col]);
|
||||
|
||||
$excel_data = array(
|
||||
$excel_data = array(
|
||||
'trans_items' => $item_data['item_id'],
|
||||
'trans_user' => $employee_id,
|
||||
'trans_comment' => $comment,
|
||||
@@ -751,16 +771,16 @@ class Items extends Secure_Controller
|
||||
'trans_inventory' => 0
|
||||
);
|
||||
|
||||
$this->Inventory->insert($excel_data);
|
||||
}
|
||||
}
|
||||
else //insert or update item failure
|
||||
{
|
||||
$failCodes[] = $i;
|
||||
}
|
||||
$this->Inventory->insert($excel_data);
|
||||
}
|
||||
}
|
||||
else //insert or update item failure
|
||||
{
|
||||
$failCodes[] = $i;
|
||||
}
|
||||
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($failCodes) > 0)
|
||||
{
|
||||
@@ -775,9 +795,9 @@ class Items extends Secure_Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('items_excel_import_nodata_wrongformat')));
|
||||
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('items_excel_import_nodata_wrongformat')));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -369,21 +369,21 @@ class Reports extends Secure_Controller
|
||||
$stock_locations = $data = $this->xss_clean($this->Stock_location->get_allowed_locations('sales'));
|
||||
$stock_locations['all'] = $this->lang->line('reports_all');
|
||||
$data['stock_locations'] = array_reverse($stock_locations, TRUE);
|
||||
$data['mode'] = 'sale';
|
||||
$data['mode'] = 'sale';
|
||||
|
||||
$this->load->view('reports/date_input', $data);
|
||||
}
|
||||
|
||||
public function date_input_recv()
|
||||
{
|
||||
$data = array();
|
||||
public function date_input_recv()
|
||||
{
|
||||
$data = array();
|
||||
$stock_locations = $data = $this->xss_clean($this->Stock_location->get_allowed_locations('receivings'));
|
||||
$stock_locations['all'] = $this->lang->line('reports_all');
|
||||
$data['stock_locations'] = array_reverse($stock_locations, TRUE);
|
||||
$data['mode'] = 'receiving';
|
||||
$data['mode'] = 'receiving';
|
||||
|
||||
$this->load->view('reports/date_input', $data);
|
||||
}
|
||||
$this->load->view('reports/date_input', $data);
|
||||
}
|
||||
|
||||
//Graphical summary sales report
|
||||
public function graphical_summary_sales($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
@@ -893,7 +893,7 @@ class Reports extends Secure_Controller
|
||||
$this->load->view('reports/tabular_details', $data);
|
||||
}
|
||||
|
||||
public function get_detailed_sales_row($sale_id)
|
||||
public function get_detailed_sales_row($sale_id)
|
||||
{
|
||||
$inputs = array('sale_id' => $sale_id);
|
||||
|
||||
@@ -931,10 +931,11 @@ class Reports extends Secure_Controller
|
||||
|
||||
$this->load->model('reports/Detailed_sales');
|
||||
$model = $this->Detailed_sales;
|
||||
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$headers = $this->xss_clean($model->getDataColumns());
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$summary_data = array();
|
||||
@@ -1041,6 +1042,7 @@ class Reports extends Secure_Controller
|
||||
'employee_name' => $row['employee_name'],
|
||||
'supplier_name' => $row['supplier_name'],
|
||||
'total' => to_currency($row['total']),
|
||||
'profit' => to_currency($row['profit']),
|
||||
'payment_type' => $row['payment_type'],
|
||||
'reference' => $row['reference'],
|
||||
'comment' => $row['comment'],
|
||||
|
||||
@@ -176,7 +176,7 @@ class Sales extends Secure_Controller
|
||||
|
||||
public function set_email_receipt()
|
||||
{
|
||||
$this->sale_lib->set_email_receipt($this->input->post('email_receipt'));
|
||||
$this->sale_lib->set_email_receipt($this->input->post('email_receipt'));
|
||||
}
|
||||
|
||||
// Multiple Payments
|
||||
@@ -248,7 +248,7 @@ class Sales extends Secure_Controller
|
||||
public function add()
|
||||
{
|
||||
$data = array();
|
||||
|
||||
|
||||
$discount = 0;
|
||||
|
||||
// check if any discount is assigned to the selected customer
|
||||
@@ -280,10 +280,42 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
elseif($this->Item_kit->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
|
||||
{
|
||||
if(!$this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount))
|
||||
|
||||
// Add kit item to order if one is assigned
|
||||
$pieces = explode(' ', $item_id_or_number_or_item_kit_or_receipt);
|
||||
$item_kit_id = $pieces[1];
|
||||
$item_kit_info = $this->Item_kit->get_info($item_kit_id);
|
||||
$kit_item_id = $item_kit_info->kit_item_id;
|
||||
$price_option = $item_kit_info->price_option;
|
||||
$stock_type = $item_kit_info->stock_type;
|
||||
$kit_print_option = $item_kit_info->print_option; // 0-all, 1-priced, 2-kit-only
|
||||
|
||||
if ($kit_item_id !== '' && $kit_item_id != 0)
|
||||
{
|
||||
if ($item_kit_info->kit_discount_percent != 0 && $item_kit_info->kit_discount_percent > $discount)
|
||||
{
|
||||
$discount = $item_kit_info->kit_discount_percent;
|
||||
}
|
||||
|
||||
$price = null;
|
||||
$print_option = 0; // Always include in list of items on invoice
|
||||
|
||||
if(!$this->sale_lib->add_item($kit_item_id, $quantity, $item_location, $discount, $price, null, null, null, $print_option))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unable_to_add_item');
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['warning'] = $this->sale_lib->out_of_stock($item_id_or_number_or_item_kit_or_receipt, $item_location);
|
||||
}
|
||||
}
|
||||
|
||||
// Add item kit items to order
|
||||
if(!$this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $price_option, $kit_print_option))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unable_to_add_item');
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -388,7 +420,8 @@ class Sales extends Secure_Controller
|
||||
$data['invoice_number'] = $invoice_number;
|
||||
$data['sale_id_num'] = $this->Sale->save($data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $data['payments']);
|
||||
$data['sale_id'] = 'POS ' . $data['sale_id_num'];
|
||||
|
||||
|
||||
|
||||
$data = $this->xss_clean($data);
|
||||
|
||||
if($data['sale_id_num'] == -1)
|
||||
@@ -403,7 +436,10 @@ class Sales extends Secure_Controller
|
||||
$data['cur_giftcard_value'] = $this->sale_lib->get_giftcard_remainder();
|
||||
$data['print_after_sale'] = $this->sale_lib->is_print_after_sale();
|
||||
$data['email_receipt'] = $this->sale_lib->get_email_receipt();
|
||||
|
||||
|
||||
// Reload (sorted) and filter the cart line items for printing purposes
|
||||
$data['cart'] = $this->get_filtered($this->sale_lib->get_cart_reordered($data['sale_id_num']));
|
||||
|
||||
if($this->sale_lib->is_invoice_number_enabled())
|
||||
{
|
||||
$this->load->view('sales/invoice', $data);
|
||||
@@ -845,5 +881,23 @@ class Sales extends Secure_Controller
|
||||
|
||||
echo !$exists ? 'true' : 'false';
|
||||
}
|
||||
|
||||
public function get_filtered($cart)
|
||||
{
|
||||
$filteredCart = array();
|
||||
foreach($cart as $id => $item)
|
||||
{
|
||||
if ($item['print_option'] == '0') // always include
|
||||
{
|
||||
$filteredCart[$id] = $item;
|
||||
}
|
||||
elseif ($item['print_option'] == '1' && $item['price'] != 0) // include only if the price is not zero
|
||||
{
|
||||
$filteredCart[$id] = $item;
|
||||
}
|
||||
// print_option 2 is never included
|
||||
};
|
||||
return $filteredCart;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -104,6 +104,7 @@ $lang["config_language"] = "Language";
|
||||
$lang["config_left"] = "Left";
|
||||
$lang["config_license"] = "License";
|
||||
$lang["config_license_configuration"] = "License Statement";
|
||||
$lang["config_line_sequence"] = "Line Sequence";
|
||||
$lang["config_lines_per_page"] = "Lines Per Page";
|
||||
$lang["config_lines_per_page_number"] = "";
|
||||
$lang["config_lines_per_page_required"] = "The lines per page is a required field";
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
<?php
|
||||
|
||||
$lang["item_kits_add_item"] = "Add Item";
|
||||
$lang["item_kits_all"] = "All";
|
||||
$lang["item_kits_kit_and_components"] = "Kit and Components";
|
||||
$lang["item_kits_cannot_be_deleted"] = "Could not delete item kit(s)";
|
||||
$lang["item_kits_confirm_delete"] = "Are you sure you want to delete the selected item kits?";
|
||||
$lang["item_kits_description"] = "Item Kit Description";
|
||||
$lang["item_kits_discount_percent"] = "Discount Percent";
|
||||
$lang["item_kits_error_adding_updating"] = "Error adding/updating Item Kit";
|
||||
$lang["item_kits_find_kit_item"] = "Kit Item";
|
||||
$lang["item_kits_info"] = "Item Kit Info";
|
||||
$lang["item_kits_item"] = "Item";
|
||||
$lang["item_kits_items"] = "Items";
|
||||
$lang["item_kits_kit"] = "Kit Id";
|
||||
$lang["item_kits_kit_and_stock"] = "Kit and Stock";
|
||||
$lang["item_kits_kit_only"] = "Kit Only";
|
||||
$lang["item_kits_name"] = "Item Kit Name";
|
||||
$lang["item_kits_new"] = "New Item Kit";
|
||||
$lang["item_kits_no_item_kits_to_display"] = "No item kits to display";
|
||||
$lang["item_kits_none_selected"] = "You have not selected any item kits";
|
||||
$lang["item_kits_one_or_multiple"] = "Item Kit(s)";
|
||||
$lang["item_kits_priced_only"] = "Priced Only";
|
||||
$lang["item_kits_price_option"] = "Price Option";
|
||||
$lang["item_kits_print_option"] = "Print Option";
|
||||
$lang["item_kits_quantity"] = "Quantity";
|
||||
$lang["item_kits_successful_adding"] = "You have successfully added Item Kit";
|
||||
$lang["item_kits_successful_deleted"] = "You have successfully deleted";
|
||||
$lang["item_kits_successful_updating"] = "You have successfully updated Item Kit";
|
||||
$lang["item_kits_update"] = "Update Item Kit";
|
||||
$lang["item_kits_sequence"] = "Sequence";
|
||||
|
||||
@@ -43,6 +43,7 @@ $lang["items_is_serialized"] = "Item has Serial Number";
|
||||
$lang["items_item"] = "Item";
|
||||
$lang["items_item_number"] = "UPC/EAN/ISBN";
|
||||
$lang["items_item_number_duplicate"] = "The item number is already present in the database";
|
||||
$lang["items_kit"] = "Kit";
|
||||
$lang["items_location"] = "Location";
|
||||
$lang["items_empty_upc_items"] = "Empty UPC Items";
|
||||
$lang["items_low_inventory_items"] = "Out Of Stock Items";
|
||||
@@ -54,6 +55,7 @@ $lang["items_no_description_items"] = "No Description Items";
|
||||
$lang["items_no_items_to_display"] = "No Items to display";
|
||||
$lang["items_none"] = "None";
|
||||
$lang["items_none_selected"] = "You have not selected any items to edit";
|
||||
$lang["items_nonstock"] = "Non-stock";
|
||||
$lang["items_number_information"] = "Item Number";
|
||||
$lang["items_number_required"] = "UPC/EAN/ISBN is a required field";
|
||||
$lang["items_one_or_multiple"] = "item(s)";
|
||||
@@ -69,6 +71,9 @@ $lang["items_sales_tax_1"] = "Sales Tax";
|
||||
$lang["items_sales_tax_2"] = "Sales Tax 2";
|
||||
$lang["items_search_custom_items"] = "Search Custom Fields";
|
||||
$lang["items_serialized_items"] = "Serialized Items";
|
||||
$lang["items_standard"] = "Standard";
|
||||
$lang["items_stock"] = "Stock";
|
||||
$lang["items_stock_type"] = "Stock Type";
|
||||
$lang["items_stock_location"] = "Stock location";
|
||||
$lang["items_successful_adding"] = "You have successfully added item";
|
||||
$lang["items_successful_bulk_edit"] = "You have successfully updated the selected items";
|
||||
@@ -80,6 +85,7 @@ $lang["items_tax_2"] = "Tax 2";
|
||||
$lang["items_tax_percent"] = "Tax Percent";
|
||||
$lang["items_tax_percent_required"] = "Tax Percent is a required field";
|
||||
$lang["items_tax_percents"] = "Tax Percent(s)";
|
||||
$lang["items_type"] = "Item Type";
|
||||
$lang["items_unit_price"] = "Retail Price";
|
||||
$lang["items_unit_price_number"] = "Unit price must be a number";
|
||||
$lang["items_unit_price_required"] = "Retail Price is a required field";
|
||||
|
||||
@@ -38,12 +38,15 @@ $lang["sales_edit_item"] = "Edit Item";
|
||||
$lang["sales_edit_sale"] = "Edit Sale";
|
||||
$lang["sales_email_receipt"] = "Email Receipt";
|
||||
$lang["sales_employee"] = "Employee";
|
||||
$lang["sales_entry"] = "Entry";
|
||||
$lang["sales_error_editing_item"] = "Error editing item";
|
||||
$lang["sales_find_or_scan_item"] = "Find/Scan Item";
|
||||
$lang["sales_find_or_scan_item_or_receipt"] = "Find/Scan Item OR Receipt";
|
||||
$lang["sales_giftcard"] = "Gift Card";
|
||||
$lang["sales_giftcard_balance"] = "Giftcard Balance";
|
||||
$lang["sales_giftcard_number"] = "Gift Card Number";
|
||||
$lang["sales_group_by_category"] = "Group by Category";
|
||||
$lang["sales_group_by_type"] = "Group by Type";
|
||||
$lang["sales_id"] = "Sale ID";
|
||||
$lang["sales_invoice"] = "Invoice";
|
||||
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
|
||||
|
||||
@@ -4,11 +4,20 @@ class Sale_lib
|
||||
{
|
||||
private $CI;
|
||||
|
||||
public function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
$this->CI =& get_instance();
|
||||
}
|
||||
|
||||
public function get_line_sequence_options()
|
||||
{
|
||||
return array(
|
||||
'0' => $this->CI->lang->line('sales_entry'),
|
||||
'1' => $this->CI->lang->line('sales_group_by_type'),
|
||||
'2' => $this->CI->lang->line('sales_group_by_category')
|
||||
);
|
||||
}
|
||||
|
||||
public function get_cart()
|
||||
{
|
||||
if(!$this->CI->session->userdata('sales_cart'))
|
||||
@@ -34,7 +43,7 @@ class Sale_lib
|
||||
// avoid returning a NULL that results in a 0 in the comment if nothing is set/available
|
||||
$comment = $this->CI->session->userdata('sales_comment');
|
||||
|
||||
return empty($comment) ? '' : $comment;
|
||||
return empty($comment) ? '' : $comment;
|
||||
}
|
||||
|
||||
public function set_comment($comment)
|
||||
@@ -177,7 +186,7 @@ class Sale_lib
|
||||
$subtotal = 0;
|
||||
foreach($this->get_payments() as $payments)
|
||||
{
|
||||
$subtotal = bcadd($payments['payment_amount'], $subtotal);
|
||||
$subtotal = bcadd($payments['payment_amount'], $subtotal);
|
||||
}
|
||||
|
||||
return $subtotal;
|
||||
@@ -192,7 +201,7 @@ class Sale_lib
|
||||
$precision = $this->CI->config->item('currency_decimals');
|
||||
$rounded_due = bccomp(round($amount_due, $precision, PHP_ROUND_HALF_EVEN), 0, $precision);
|
||||
// take care of rounding error introduced by round tripping payment amount to the browser
|
||||
return $rounded_due == 0 ? 0 : $amount_due;
|
||||
return $rounded_due == 0 ? 0 : $amount_due;
|
||||
}
|
||||
|
||||
public function get_customer()
|
||||
@@ -255,52 +264,52 @@ class Sale_lib
|
||||
$this->CI->session->unset_userdata('sales_mode');
|
||||
}
|
||||
|
||||
public function get_sale_location()
|
||||
{
|
||||
if(!$this->CI->session->userdata('sales_location'))
|
||||
{
|
||||
$this->set_sale_location($this->CI->Stock_location->get_default_location_id());
|
||||
}
|
||||
|
||||
return $this->CI->session->userdata('sales_location');
|
||||
}
|
||||
|
||||
public function set_sale_location($location)
|
||||
{
|
||||
$this->CI->session->set_userdata('sales_location', $location);
|
||||
}
|
||||
|
||||
public function clear_sale_location()
|
||||
{
|
||||
$this->CI->session->unset_userdata('sales_location');
|
||||
}
|
||||
|
||||
public function set_giftcard_remainder($value)
|
||||
{
|
||||
$this->CI->session->set_userdata('sales_giftcard_remainder', $value);
|
||||
}
|
||||
|
||||
public function get_giftcard_remainder()
|
||||
{
|
||||
return $this->CI->session->userdata('sales_giftcard_remainder');
|
||||
}
|
||||
|
||||
public function clear_giftcard_remainder()
|
||||
{
|
||||
$this->CI->session->unset_userdata('sales_giftcard_remainder');
|
||||
}
|
||||
|
||||
public function add_item(&$item_id, $quantity = 1, $item_location, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE)
|
||||
public function get_sale_location()
|
||||
{
|
||||
if(!$this->CI->session->userdata('sales_location'))
|
||||
{
|
||||
$this->set_sale_location($this->CI->Stock_location->get_default_location_id());
|
||||
}
|
||||
|
||||
return $this->CI->session->userdata('sales_location');
|
||||
}
|
||||
|
||||
public function set_sale_location($location)
|
||||
{
|
||||
$this->CI->session->set_userdata('sales_location', $location);
|
||||
}
|
||||
|
||||
public function clear_sale_location()
|
||||
{
|
||||
$this->CI->session->unset_userdata('sales_location');
|
||||
}
|
||||
|
||||
public function set_giftcard_remainder($value)
|
||||
{
|
||||
$this->CI->session->set_userdata('sales_giftcard_remainder', $value);
|
||||
}
|
||||
|
||||
public function get_giftcard_remainder()
|
||||
{
|
||||
return $this->CI->session->userdata('sales_giftcard_remainder');
|
||||
}
|
||||
|
||||
public function clear_giftcard_remainder()
|
||||
{
|
||||
$this->CI->session->unset_userdata('sales_giftcard_remainder');
|
||||
}
|
||||
|
||||
public function add_item(&$item_id, $quantity = 1, $item_location, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE, $print_option = '0')
|
||||
{
|
||||
|
||||
$item_info = $this->CI->Item->get_info_by_id_or_number($item_id);
|
||||
|
||||
//make sure item exists
|
||||
if(empty($item_info))
|
||||
{
|
||||
if (empty($item_info)) {
|
||||
$item_id = -1;
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
$item_id = $item_info->item_id;
|
||||
|
||||
// Serialization and Description
|
||||
@@ -308,74 +317,83 @@ class Sale_lib
|
||||
//Get all items in the cart so far...
|
||||
$items = $this->get_cart();
|
||||
|
||||
//We need to loop through all items in the cart.
|
||||
//If the item is already there, get it's key($updatekey).
|
||||
//We also need to get the next key that we are going to use in case we need to add the
|
||||
//item to the cart. Since items can be deleted, we can't use a count. we use the highest key + 1.
|
||||
//We need to loop through all items in the cart.
|
||||
//If the item is already there, get it's key($updatekey).
|
||||
//We also need to get the next key that we are going to use in case we need to add the
|
||||
//item to the cart. Since items can be deleted, we can't use a count. we use the highest key + 1.
|
||||
|
||||
$maxkey = 0; //Highest key so far
|
||||
$itemalreadyinsale = FALSE; //We did not find the item yet.
|
||||
$maxkey = 0; //Highest key so far
|
||||
$itemalreadyinsale = FALSE; //We did not find the item yet.
|
||||
$insertkey = 0; //Key to use for new entry.
|
||||
$updatekey = 0; //Key to use to update(quantity)
|
||||
|
||||
foreach($items as $item)
|
||||
{
|
||||
//We primed the loop so maxkey is 0 the first time.
|
||||
//Also, we have stored the key in the element itself so we can compare.
|
||||
//We primed the loop so maxkey is 0 the first time.
|
||||
//Also, we have stored the key in the element itself so we can compare.
|
||||
|
||||
if($maxkey <= $item['line'])
|
||||
{
|
||||
if ($maxkey <= $item['line']) {
|
||||
$maxkey = $item['line'];
|
||||
}
|
||||
|
||||
if($item['item_id'] == $item_id && $item['item_location'] == $item_location)
|
||||
{
|
||||
if ($item['item_id'] == $item_id && $item['item_location'] == $item_location) {
|
||||
$itemalreadyinsale = TRUE;
|
||||
$updatekey = $item['line'];
|
||||
if(!$item_info->is_serialized)
|
||||
{
|
||||
$quantity = bcadd($quantity, $items[$updatekey]['quantity']);
|
||||
}
|
||||
if(!$item_info->is_serialized)
|
||||
{
|
||||
$quantity = bcadd($quantity, $items[$updatekey]['quantity']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$insertkey = $maxkey+1;
|
||||
$insertkey = $maxkey + 1;
|
||||
//array/cart records are identified by $insertkey and item_id is just another field.
|
||||
$price = $price != NULL ? $price : $item_info->unit_price;
|
||||
|
||||
if (is_null($price))
|
||||
{
|
||||
$price = $item_info->unit_price;
|
||||
}
|
||||
elseif ($price == 0)
|
||||
{
|
||||
$price = 0.00;
|
||||
$discount = 0.00;
|
||||
}
|
||||
|
||||
$total = $this->get_item_total($quantity, $price, $discount);
|
||||
$discounted_total = $this->get_item_total($quantity, $price, $discount, TRUE);
|
||||
$discounted_total = $this->get_item_total($quantity, $price, $discount, TRUE);
|
||||
//Item already exists and is not serialized, add to quantity
|
||||
if(!$itemalreadyinsale || $item_info->is_serialized)
|
||||
{
|
||||
$item = array($insertkey => array(
|
||||
'item_id' => $item_id,
|
||||
'item_location' => $item_location,
|
||||
'stock_name' => $this->CI->Stock_location->get_location_name($item_location),
|
||||
'line' => $insertkey,
|
||||
'name' => $item_info->name,
|
||||
'item_number' => $item_info->item_number,
|
||||
'description' => $description != NULL ? $description : $item_info->description,
|
||||
'serialnumber' => $serialnumber != NULL ? $serialnumber : '',
|
||||
'allow_alt_description' => $item_info->allow_alt_description,
|
||||
'is_serialized' => $item_info->is_serialized,
|
||||
'quantity' => $quantity,
|
||||
'discount' => $discount,
|
||||
'in_stock' => $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity,
|
||||
'price' => $price,
|
||||
'total' => $total,
|
||||
'discounted_total' => $discounted_total,
|
||||
)
|
||||
);
|
||||
$item = array($insertkey => array(
|
||||
'item_id' => $item_id,
|
||||
'item_location' => $item_location,
|
||||
'stock_name' => $this->CI->Stock_location->get_location_name($item_location),
|
||||
'line' => $insertkey,
|
||||
'name' => $item_info->name,
|
||||
'item_number' => $item_info->item_number,
|
||||
'description' => $description != NULL ? $description : $item_info->description,
|
||||
'serialnumber' => $serialnumber != NULL ? $serialnumber : '',
|
||||
'allow_alt_description' => $item_info->allow_alt_description,
|
||||
'is_serialized' => $item_info->is_serialized,
|
||||
'quantity' => $quantity,
|
||||
'discount' => $discount,
|
||||
'in_stock' => $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity,
|
||||
'price' => $price,
|
||||
'total' => $total,
|
||||
'discounted_total' => $discounted_total,
|
||||
'print_option' => $print_option
|
||||
)
|
||||
);
|
||||
//add to existing array
|
||||
$items += $item;
|
||||
}
|
||||
else
|
||||
{
|
||||
$line = &$items[$updatekey];
|
||||
$line['quantity'] = $quantity;
|
||||
$line['total'] = $total;
|
||||
$line['discounted_total'] = $discounted_total;
|
||||
}
|
||||
else
|
||||
{
|
||||
$line = &$items[$updatekey];
|
||||
$line['quantity'] = $quantity;
|
||||
$line['total'] = $total;
|
||||
$line['discounted_total'] = $discounted_total;
|
||||
}
|
||||
|
||||
$this->set_cart($items);
|
||||
|
||||
@@ -387,16 +405,20 @@ class Sale_lib
|
||||
//make sure item exists
|
||||
if($item_id != -1)
|
||||
{
|
||||
$item_quantity = $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity;
|
||||
$quantity_added = $this->get_quantity_already_added($item_id, $item_location);
|
||||
$item_info = $this->CI->Item->get_info_by_id_or_number($item_id);
|
||||
|
||||
if($item_quantity - $quantity_added < 0)
|
||||
{
|
||||
return $this->CI->lang->line('sales_quantity_less_than_zero');
|
||||
}
|
||||
elseif($item_quantity - $quantity_added < $this->CI->Item->get_info_by_id_or_number($item_id)->reorder_level)
|
||||
{
|
||||
return $this->CI->lang->line('sales_quantity_less_than_reorder_level');
|
||||
if ($item_info->stock_type == '0') {
|
||||
$item_quantity = $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity;
|
||||
$quantity_added = $this->get_quantity_already_added($item_id, $item_location);
|
||||
|
||||
if($item_quantity - $quantity_added < 0)
|
||||
{
|
||||
return $this->CI->lang->line('sales_quantity_less_than_zero');
|
||||
}
|
||||
elseif($item_quantity - $quantity_added < $item_info->reorder_level)
|
||||
{
|
||||
return $this->CI->lang->line('sales_quantity_less_than_reorder_level');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,24 +490,58 @@ class Sale_lib
|
||||
$this->empty_cart();
|
||||
$this->remove_customer();
|
||||
|
||||
foreach($this->CI->Sale->get_sale_items($sale_id)->result() as $row)
|
||||
foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, TRUE);
|
||||
$this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option);
|
||||
}
|
||||
|
||||
$this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
|
||||
}
|
||||
|
||||
public function add_item_kit($external_item_kit_id, $item_location, $discount)
|
||||
public function add_item_kit($external_item_kit_id, $item_location, $discount, $price_option, $kit_print_option)
|
||||
{
|
||||
|
||||
//KIT #
|
||||
$pieces = explode(' ', $external_item_kit_id);
|
||||
$item_kit_id = $pieces[1];
|
||||
$result = TRUE;
|
||||
|
||||
|
||||
foreach($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
|
||||
{
|
||||
$result &= $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity'], $item_location, $discount);
|
||||
if ($price_option == '0') // all
|
||||
{
|
||||
$price = null;
|
||||
}
|
||||
elseif ($price_option == '1') // item kit only
|
||||
{
|
||||
$price = 0;
|
||||
}
|
||||
elseif ($price_option == '2') // item kit plus stock items (assuming materials)
|
||||
{
|
||||
if ($item_kit_item['stock_type'] == 0) // stock item
|
||||
{
|
||||
$price = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$price = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($kit_print_option == '0') // all
|
||||
{
|
||||
$print_option = '0'; // print always
|
||||
}
|
||||
elseif ($kit_print_option == '1') // priced
|
||||
{
|
||||
$print_option = '1'; // print if price not zero
|
||||
}
|
||||
elseif ($kit_print_option == '2') // kit only if price is not zero
|
||||
{
|
||||
$print_option = '2'; // Do not include in list
|
||||
}
|
||||
|
||||
$result &= $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity'], $item_location, $discount, $price, null, null, null, $print_option);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -496,9 +552,9 @@ class Sale_lib
|
||||
$this->empty_cart();
|
||||
$this->remove_customer();
|
||||
|
||||
foreach($this->CI->Sale->get_sale_items($sale_id)->result() as $row)
|
||||
foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, TRUE);
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option);
|
||||
}
|
||||
|
||||
foreach($this->CI->Sale->get_sale_payments($sale_id)->result() as $row)
|
||||
@@ -509,6 +565,18 @@ class Sale_lib
|
||||
$this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
|
||||
$this->set_employee($this->CI->Sale->get_employee($sale_id)->person_id);
|
||||
}
|
||||
|
||||
public function get_cart_reordered($sale_id)
|
||||
{
|
||||
$this->empty_cart();
|
||||
foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price,
|
||||
$row->description, $row->serialnumber, TRUE, $row->print_option);
|
||||
}
|
||||
|
||||
return $this->CI->session->userdata('sales_cart');
|
||||
}
|
||||
|
||||
public function copy_entire_suspended_sale($sale_id)
|
||||
{
|
||||
@@ -517,12 +585,15 @@ class Sale_lib
|
||||
|
||||
foreach($this->CI->Sale_suspended->get_sale_items($sale_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber);
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price,
|
||||
$row->description, $row->serialnumber, TRUE, $row->print_option);
|
||||
}
|
||||
|
||||
foreach($this->CI->Sale_suspended->get_sale_payments($sale_id)->result() as $row)
|
||||
{
|
||||
$this->add_payment($row->payment_type, $row->payment_amount);
|
||||
}
|
||||
|
||||
$suspended_sale_info = $this->CI->Sale_suspended->get_info($sale_id)->row();
|
||||
$this->set_customer($suspended_sale_info->person_id);
|
||||
$this->set_comment($suspended_sale_info->comment);
|
||||
@@ -704,7 +775,6 @@ class Sale_lib
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -60,13 +60,59 @@ class Item extends CI_Model
|
||||
*/
|
||||
public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'items.name', $order = 'asc')
|
||||
{
|
||||
$this->db->from('items');
|
||||
$this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
|
||||
$this->db->join('inventory', 'inventory.trans_items = items.item_id');
|
||||
$this->db->select('MAX(items.name) as name');
|
||||
$this->db->select('MAX(items.category) as category');
|
||||
$this->db->select('MAX(items.supplier_id) as supplier_id');
|
||||
$this->db->select('MAX(items.item_number) as item_number');
|
||||
$this->db->select('MAX(items.description) as description');
|
||||
$this->db->select('MAX(items.cost_price) as cost_price');
|
||||
$this->db->select('MAX(items.unit_price) as unit_price');
|
||||
$this->db->select('MAX(items.reorder_level) as reorder_level');
|
||||
$this->db->select('MAX(items.receiving_quantity) as receiving_quantity');
|
||||
$this->db->select('items.item_id as item_id');
|
||||
$this->db->select('MAX(items.pic_id) as pic_id');
|
||||
$this->db->select('MAX(items.allow_alt_description) as allow_alt_description');
|
||||
$this->db->select('MAX(items.is_serialized) as is_serialized');
|
||||
$this->db->select('MAX(items.deleted) as deleted');
|
||||
$this->db->select('MAX(items.custom1) as custom1');
|
||||
$this->db->select('MAX(items.custom2) as custom2');
|
||||
$this->db->select('MAX(items.custom3) as custom3');
|
||||
$this->db->select('MAX(items.custom4) as custom4');
|
||||
$this->db->select('MAX(items.custom5) as custom5');
|
||||
$this->db->select('MAX(items.custom6) as custom6');
|
||||
$this->db->select('MAX(items.custom7) as custom7');
|
||||
$this->db->select('MAX(items.custom8) as custom8');
|
||||
$this->db->select('MAX(items.custom9) as custom9');
|
||||
$this->db->select('MAX(items.custom10) as custom10');
|
||||
|
||||
$this->db->select('MAX(suppliers.person_id) as person_id');
|
||||
$this->db->select('MAX(suppliers.company_name) as company_name');
|
||||
$this->db->select('MAX(suppliers.agency_name) as agency_name');
|
||||
$this->db->select('MAX(suppliers.account_number) as account_number');
|
||||
$this->db->select('MAX(suppliers.deleted) as deleted');
|
||||
|
||||
$this->db->select('MAX(inventory.trans_id) as trans_id');
|
||||
$this->db->select('MAX(inventory.trans_items) as trans_items');
|
||||
$this->db->select('MAX(inventory.trans_user) as trans_user');
|
||||
$this->db->select('MAX(inventory.trans_date) as trans_date');
|
||||
$this->db->select('MAX(inventory.trans_comment) as trans_comment');
|
||||
$this->db->select('MAX(inventory.trans_location) as trans_location');
|
||||
$this->db->select('MAX(inventory.trans_inventory) as trans_inventory');
|
||||
|
||||
if($filters['stock_location_id'] > -1)
|
||||
{
|
||||
$this->db->join('item_quantities', 'item_quantities.item_id = items.item_id');
|
||||
$this->db->select('MAX(item_quantities.item_id) as qty_item_id');
|
||||
$this->db->select('MAX(item_quantities.location_id) as location_id');
|
||||
$this->db->select('MAX(item_quantities.quantity) as quantity');
|
||||
}
|
||||
|
||||
$this->db->from('items as items');
|
||||
$this->db->join('suppliers as suppliers', 'suppliers.person_id = items.supplier_id', 'left');
|
||||
$this->db->join('inventory as inventory', 'inventory.trans_items = items.item_id');
|
||||
|
||||
if($filters['stock_location_id'] > -1)
|
||||
{
|
||||
$this->db->join('item_quantities as item_quantities', 'item_quantities.item_id = items.item_id');
|
||||
$this->db->where('location_id', $filters['stock_location_id']);
|
||||
}
|
||||
|
||||
@@ -129,18 +175,18 @@ class Item extends CI_Model
|
||||
|
||||
// avoid duplicated entries with same name because of inventory reporting multiple changes on the same item in the same date range
|
||||
$this->db->group_by('items.item_id');
|
||||
|
||||
|
||||
// order by name of item
|
||||
$this->db->order_by($sort, $order);
|
||||
|
||||
if($rows > 0)
|
||||
{
|
||||
if($rows > 0)
|
||||
{
|
||||
$this->db->limit($rows, $limit_from);
|
||||
}
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Returns all the items
|
||||
*/
|
||||
@@ -199,7 +245,7 @@ class Item extends CI_Model
|
||||
return $item_obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Gets information about a particular item by item id or number
|
||||
*/
|
||||
@@ -207,17 +253,17 @@ class Item extends CI_Model
|
||||
{
|
||||
$this->db->from('items');
|
||||
|
||||
if (ctype_digit($item_id))
|
||||
{
|
||||
$this->db->group_start();
|
||||
$this->db->where('item_id', (int) $item_id);
|
||||
$this->db->or_where('items.item_number', $item_id);
|
||||
$this->db->group_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->where('item_number', $item_id);
|
||||
}
|
||||
if (ctype_digit($item_id))
|
||||
{
|
||||
$this->db->group_start();
|
||||
$this->db->where('item_id', (int) $item_id);
|
||||
$this->db->or_where('items.item_number', $item_id);
|
||||
$this->db->group_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->where('item_number', $item_id);
|
||||
}
|
||||
|
||||
$this->db->where('items.deleted', 0);
|
||||
|
||||
@@ -243,7 +289,7 @@ class Item extends CI_Model
|
||||
{
|
||||
$this->db->where('items.deleted', $deleted);
|
||||
}
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
if($query->num_rows() == 1)
|
||||
@@ -284,7 +330,7 @@ class Item extends CI_Model
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
$this->db->where('item_id', $item_id);
|
||||
|
||||
return $this->db->update('items', $item_data);
|
||||
@@ -312,14 +358,14 @@ class Item extends CI_Model
|
||||
$this->Item_quantity->reset_quantity($item_id);
|
||||
$this->db->where('item_id', $item_id);
|
||||
$success = $this->db->update('items', array('deleted'=>1));
|
||||
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
|
||||
$success &= $this->db->trans_status();
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Undeletes one item
|
||||
*/
|
||||
@@ -342,13 +388,13 @@ class Item extends CI_Model
|
||||
$this->Item_quantity->reset_quantity_list($item_ids);
|
||||
$this->db->where_in('item_id', $item_ids);
|
||||
$success = $this->db->update('items', array('deleted'=>1));
|
||||
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
|
||||
$success &= $this->db->trans_status();
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_search_suggestions($search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25)
|
||||
{
|
||||
@@ -357,6 +403,7 @@ class Item extends CI_Model
|
||||
$this->db->select('item_id, name');
|
||||
$this->db->from('items');
|
||||
$this->db->where('deleted', $filters['is_deleted']);
|
||||
$this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
|
||||
$this->db->like('name', $search);
|
||||
$this->db->order_by('name', 'asc');
|
||||
foreach($this->db->get()->result() as $row)
|
||||
@@ -465,7 +512,7 @@ class Item extends CI_Model
|
||||
|
||||
return $suggestions;
|
||||
}
|
||||
|
||||
|
||||
public function get_location_suggestions($search)
|
||||
{
|
||||
$suggestions = array();
|
||||
@@ -479,7 +526,7 @@ class Item extends CI_Model
|
||||
{
|
||||
$suggestions[] = array('label' => $row->location);
|
||||
}
|
||||
|
||||
|
||||
return $suggestions;
|
||||
}
|
||||
|
||||
@@ -497,7 +544,7 @@ class Item extends CI_Model
|
||||
$row_array = (array) $row;
|
||||
$suggestions[] = array('label' => $row_array['custom'.$field_no]);
|
||||
}
|
||||
|
||||
|
||||
return $suggestions;
|
||||
}
|
||||
|
||||
@@ -547,4 +594,4 @@ class Item extends CI_Model
|
||||
return $this->save($data, $item_id);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -46,7 +46,41 @@ class Item_kit extends CI_Model
|
||||
*/
|
||||
public function get_info($item_kit_id)
|
||||
{
|
||||
$this->db->from('item_kits');
|
||||
$this->db->select('
|
||||
item_kit_id,
|
||||
item_kits.name as name,
|
||||
items.name as item_name,
|
||||
item_kits.description,
|
||||
items.description as item_description,
|
||||
item_kits.item_id as kit_item_id,
|
||||
kit_discount_percent,
|
||||
price_option,
|
||||
print_option,
|
||||
category,
|
||||
supplier_id,
|
||||
item_number,
|
||||
cost_price,
|
||||
unit_price,
|
||||
reorder_level,
|
||||
receiving_quantity,
|
||||
pic_id,
|
||||
allow_alt_description,
|
||||
is_serialized,
|
||||
deleted,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
custom4,
|
||||
custom5,
|
||||
custom6,
|
||||
custom7,
|
||||
custom8,
|
||||
custom9,
|
||||
custom10,
|
||||
item_type');
|
||||
|
||||
$this->db->from('item_kits');
|
||||
$this->db->join('items', 'item_kits.item_id = items.item_id', 'left');
|
||||
$this->db->where('item_kit_id', $item_kit_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
@@ -120,7 +154,7 @@ class Item_kit extends CI_Model
|
||||
$this->db->where_in('item_kit_id', $item_kit_ids);
|
||||
|
||||
return $this->db->delete('item_kits');
|
||||
}
|
||||
}
|
||||
|
||||
public function get_search_suggestions($search, $limit = 25)
|
||||
{
|
||||
|
||||
@@ -6,31 +6,49 @@ class Item_kit_items extends CI_Model
|
||||
*/
|
||||
public function get_info($item_kit_id)
|
||||
{
|
||||
$this->db->from('item_kit_items');
|
||||
$this->db->select('item_kit_id, item_kit_items.item_id, quantity, kit_sequence, unit_price, item_type, stock_type');
|
||||
$this->db->from('item_kit_items as item_kit_items');
|
||||
$this->db->join('items as items', 'item_kit_items.item_id = items.item_id');
|
||||
$this->db->where('item_kit_id', $item_kit_id);
|
||||
|
||||
$this->db->order_by('kit_sequence', 'asc');
|
||||
|
||||
//return an array of item kit items for an item
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
/*
|
||||
Gets item kit items for a particular item kit
|
||||
*/
|
||||
public function get_info_for_sale($item_kit_id)
|
||||
{
|
||||
$this->db->from('item_kit_items');
|
||||
$this->db->where('item_kit_id', $item_kit_id);
|
||||
|
||||
$this->db->order_by('kit_sequence', 'desc');
|
||||
|
||||
//return an array of item kit items for an item
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
/*
|
||||
Inserts or updates an item kit's items
|
||||
*/
|
||||
public function save(&$item_kit_items_data, $item_kit_id)
|
||||
{
|
||||
$success = TRUE;
|
||||
|
||||
|
||||
//Run these queries as a transaction, we want to make sure we do all or nothing
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
$this->delete($item_kit_id);
|
||||
|
||||
foreach($item_kit_items_data as $row)
|
||||
{
|
||||
$row['item_kit_id'] = $item_kit_id;
|
||||
$success &= $this->db->insert('item_kit_items', $row);
|
||||
|
||||
if ($item_kit_items_data != NULL) {
|
||||
foreach ($item_kit_items_data as $row) {
|
||||
$row['item_kit_id'] = $item_kit_id;
|
||||
$success &= $this->db->insert('item_kit_items', $row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
$success &= $this->db->trans_status();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
class Receiving extends CI_Model
|
||||
{
|
||||
public function get_info($receiving_id)
|
||||
{
|
||||
{
|
||||
$this->db->from('receivings');
|
||||
$this->db->join('people', 'people.person_id = receivings.supplier_id', 'LEFT');
|
||||
$this->db->join('suppliers', 'suppliers.person_id = receivings.supplier_id', 'LEFT');
|
||||
@@ -30,7 +30,7 @@ class Receiving extends CI_Model
|
||||
{
|
||||
return $this->exists($pieces[1]);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return $this->get_receiving_by_reference($receipt_receiving_id)->num_rows() > 0;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class Receiving extends CI_Model
|
||||
|
||||
return ($this->db->get()->num_rows() == 1);
|
||||
}
|
||||
|
||||
|
||||
public function update($receiving_data, $receiving_id)
|
||||
{
|
||||
$this->db->where('receiving_id', $receiving_id);
|
||||
@@ -106,8 +106,8 @@ class Receiving extends CI_Model
|
||||
|
||||
//Update stock quantity
|
||||
$item_quantity = $this->Item_quantity->get_item_quantity($item['item_id'], $item['item_location']);
|
||||
$this->Item_quantity->save(array('quantity' => $item_quantity->quantity + $items_received, 'item_id' => $item['item_id'],
|
||||
'location_id' => $item['item_location']), $item['item_id'], $item['item_location']);
|
||||
$this->Item_quantity->save(array('quantity' => $item_quantity->quantity + $items_received, 'item_id' => $item['item_id'],
|
||||
'location_id' => $item['item_location']), $item['item_id'], $item['item_location']);
|
||||
|
||||
$recv_remarks = 'RECV ' . $receiving_id;
|
||||
$inv_data = array(
|
||||
@@ -125,7 +125,7 @@ class Receiving extends CI_Model
|
||||
}
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
|
||||
if($this->db->trans_status() === FALSE)
|
||||
{
|
||||
return -1;
|
||||
@@ -133,7 +133,7 @@ class Receiving extends CI_Model
|
||||
|
||||
return $receiving_id;
|
||||
}
|
||||
|
||||
|
||||
public function delete_list($receiving_ids, $employee_id, $update_inventory = TRUE)
|
||||
{
|
||||
$success = TRUE;
|
||||
@@ -153,7 +153,7 @@ class Receiving extends CI_Model
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
||||
public function delete($receiving_id, $employee_id, $update_inventory = TRUE)
|
||||
{
|
||||
// start a transaction to assure data integrity
|
||||
@@ -240,33 +240,33 @@ class Receiving extends CI_Model
|
||||
{
|
||||
$where = 'WHERE receivings_items.receiving_id = ' . $this->db->escape($inputs['receiving_id']);
|
||||
}
|
||||
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') .
|
||||
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') .
|
||||
' (INDEX(receiving_date), INDEX(receiving_time), INDEX(receiving_id))
|
||||
(
|
||||
SELECT
|
||||
DATE(receiving_time) AS receiving_date,
|
||||
receiving_time,
|
||||
MAX(DATE(receiving_time)) AS receiving_date,
|
||||
MAX(receiving_time) AS receiving_time,
|
||||
receivings_items.receiving_id,
|
||||
comment,
|
||||
item_location,
|
||||
reference,
|
||||
payment_type,
|
||||
employee_id,
|
||||
MAX(comment) AS comment,
|
||||
MAX(item_location) AS item_location,
|
||||
MAX(reference) AS reference,
|
||||
MAX(payment_type) AS payment_type,
|
||||
MAX(employee_id) AS employee_id,
|
||||
items.item_id,
|
||||
receivings.supplier_id,
|
||||
quantity_purchased,
|
||||
receivings_items.receiving_quantity,
|
||||
item_cost_price,
|
||||
item_unit_price,
|
||||
discount_percent,
|
||||
MAX(receivings.supplier_id) AS supplier_id,
|
||||
MAX(quantity_purchased) AS quantity_purchased,
|
||||
MAX(receivings_items.receiving_quantity) AS receiving_quantity,
|
||||
MAX(item_cost_price) AS item_cost_price,
|
||||
MAX(item_unit_price) AS item_unit_price,
|
||||
MAX(discount_percent) AS discount_percent,
|
||||
receivings_items.line,
|
||||
serialnumber,
|
||||
receivings_items.description,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased) AS profit,
|
||||
(item_cost_price * quantity_purchased) AS cost
|
||||
MAX(serialnumber) AS serialnumber,
|
||||
MAX(receivings_items.description) AS description,
|
||||
MAX(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal,
|
||||
MAX(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total,
|
||||
MAX((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased)) AS profit,
|
||||
MAX(item_cost_price * quantity_purchased) AS cost
|
||||
FROM ' . $this->db->dbprefix('receivings_items') . ' AS receivings_items
|
||||
INNER JOIN ' . $this->db->dbprefix('receivings') . ' AS receivings
|
||||
ON receivings_items.receiving_id = receivings.receiving_id
|
||||
|
||||
@@ -5,7 +5,7 @@ class Sale extends CI_Model
|
||||
{
|
||||
// NOTE: temporary tables are created to speed up searches due to the fact that are ortogonal to the main query
|
||||
// create a temporary table to contain all the payments per sale item
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
|
||||
'(
|
||||
SELECT payments.sale_id AS sale_id,
|
||||
IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
|
||||
@@ -19,7 +19,7 @@ class Sale extends CI_Model
|
||||
);
|
||||
|
||||
// create a temporary table to contain all the sum of taxes per sale item
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
|
||||
'(
|
||||
SELECT sales_items_taxes.sale_id AS sale_id,
|
||||
sales_items_taxes.item_id AS item_id,
|
||||
@@ -51,23 +51,23 @@ class Sale extends CI_Model
|
||||
|
||||
$this->db->select('
|
||||
sales.sale_id AS sale_id,
|
||||
DATE(sales.sale_time) AS sale_date,
|
||||
sales.sale_time AS sale_time,
|
||||
sales.comment AS comment,
|
||||
sales.invoice_number AS invoice_number,
|
||||
sales.employee_id AS employee_id,
|
||||
sales.customer_id AS customer_id,
|
||||
CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer_name,
|
||||
customer_p.first_name AS first_name,
|
||||
customer_p.last_name AS last_name,
|
||||
customer_p.email AS email,
|
||||
customer_p.comments AS comments,
|
||||
MAX(DATE(sales.sale_time)) AS sale_date,
|
||||
MAX(sales.sale_time) AS sale_time,
|
||||
MAX(sales.comment) AS comment,
|
||||
MAX(sales.invoice_number) AS invoice_number,
|
||||
MAX(sales.employee_id) AS employee_id,
|
||||
MAX(sales.customer_id) AS customer_id,
|
||||
MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
|
||||
MAX(customer_p.first_name) AS first_name,
|
||||
MAX(customer_p.last_name) AS last_name,
|
||||
MAX(customer_p.email) AS email,
|
||||
MAX(customer_p.comments) AS comments,
|
||||
' . "
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due,
|
||||
payments.sale_payment_amount AS amount_tendered,
|
||||
(payments.sale_payment_amount - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
|
||||
MAX(payments.sale_payment_amount) AS amount_tendered,
|
||||
(MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
|
||||
" . '
|
||||
payments.payment_type AS payment_type
|
||||
MAX(payments.payment_type) AS payment_type
|
||||
');
|
||||
|
||||
$this->db->from('sales_items AS sales_items');
|
||||
@@ -109,7 +109,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
// NOTE: temporary tables are created to speed up searches due to the fact that are ortogonal to the main query
|
||||
// create a temporary table to contain all the payments per sale item
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
|
||||
' (PRIMARY KEY(sale_id), INDEX(sale_id))
|
||||
(
|
||||
SELECT payments.sale_id AS sale_id,
|
||||
@@ -124,7 +124,7 @@ class Sale extends CI_Model
|
||||
);
|
||||
|
||||
// create a temporary table to contain all the sum of taxes per sale item
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
|
||||
' (INDEX(sale_id), INDEX(item_id))
|
||||
(
|
||||
SELECT sales_items_taxes.sale_id AS sale_id,
|
||||
@@ -159,12 +159,12 @@ class Sale extends CI_Model
|
||||
|
||||
$this->db->select('
|
||||
sales.sale_id AS sale_id,
|
||||
DATE(sales.sale_time) AS sale_date,
|
||||
sales.sale_time AS sale_time,
|
||||
sales.invoice_number AS invoice_number,
|
||||
MAX(DATE(sales.sale_time)) AS sale_date,
|
||||
MAX(sales.sale_time) AS sale_time,
|
||||
MAX(sales.invoice_number) AS invoice_number,
|
||||
SUM(sales_items.quantity_purchased) AS items_purchased,
|
||||
CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer_name,
|
||||
customer.company_name AS company_name,
|
||||
MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
|
||||
MAX(customer.company_name) AS company_name,
|
||||
' . "
|
||||
ROUND($sale_subtotal, $decimals) AS subtotal,
|
||||
IFNULL(ROUND($sale_tax, $decimals), 0) AS tax,
|
||||
@@ -172,10 +172,10 @@ class Sale extends CI_Model
|
||||
ROUND($sale_cost, $decimals) AS cost,
|
||||
ROUND($sale_total - IFNULL($sale_tax, 0) - $sale_cost, $decimals) AS profit,
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due,
|
||||
payments.sale_payment_amount AS amount_tendered,
|
||||
(payments.sale_payment_amount - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
|
||||
MAX(payments.sale_payment_amount) AS amount_tendered,
|
||||
(MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
|
||||
" . '
|
||||
payments.payment_type AS payment_type
|
||||
MAX(payments.payment_type) AS payment_type
|
||||
');
|
||||
|
||||
$this->db->from('sales_items AS sales_items');
|
||||
@@ -202,7 +202,7 @@ class Sale extends CI_Model
|
||||
$this->db->where('sales.sale_id', $pieces[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$this->db->group_start();
|
||||
// customer last name
|
||||
$this->db->like('customer_p.last_name', $search);
|
||||
@@ -222,13 +222,13 @@ class Sale extends CI_Model
|
||||
}
|
||||
|
||||
if($filters['sale_type'] == 'sales')
|
||||
{
|
||||
$this->db->where('sales_items.quantity_purchased > 0');
|
||||
}
|
||||
elseif($filters['sale_type'] == 'returns')
|
||||
{
|
||||
$this->db->where('sales_items.quantity_purchased < 0');
|
||||
}
|
||||
{
|
||||
$this->db->where('sales_items.quantity_purchased > 0');
|
||||
}
|
||||
elseif($filters['sale_type'] == 'returns')
|
||||
{
|
||||
$this->db->where('sales_items.quantity_purchased < 0');
|
||||
}
|
||||
|
||||
if($filters['only_invoices'] != FALSE)
|
||||
{
|
||||
@@ -310,7 +310,7 @@ class Sale extends CI_Model
|
||||
{
|
||||
$this->db->where('invoice_number IS NOT NULL');
|
||||
}
|
||||
|
||||
|
||||
if($filters['only_cash'] != FALSE)
|
||||
{
|
||||
$this->db->like('payment_type', $this->lang->line('sales_cash'), 'after');
|
||||
@@ -401,7 +401,7 @@ class Sale extends CI_Model
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
public function get_invoice_number_for_year($year = '', $start_from = 0)
|
||||
public function get_invoice_number_for_year($year = '', $start_from = 0)
|
||||
{
|
||||
$year = $year == '' ? date('Y') : $year;
|
||||
$this->db->select('COUNT( 1 ) AS invoice_number_year');
|
||||
@@ -412,7 +412,7 @@ class Sale extends CI_Model
|
||||
|
||||
return ($start_from + $result['invoice_number_year']);
|
||||
}
|
||||
|
||||
|
||||
public function is_valid_receipt(&$receipt_sale_id)
|
||||
{
|
||||
if(!empty($receipt_sale_id))
|
||||
@@ -457,7 +457,7 @@ class Sale extends CI_Model
|
||||
{
|
||||
//Run these queries as a transaction, we want to make sure we do all or nothing
|
||||
$this->db->trans_start();
|
||||
|
||||
|
||||
// first delete all payments
|
||||
$this->db->delete('sales_payments', array('sale_id' => $sale_id));
|
||||
|
||||
@@ -472,12 +472,12 @@ class Sale extends CI_Model
|
||||
|
||||
$success = $this->db->insert('sales_payments', $sales_payments_data);
|
||||
}
|
||||
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
|
||||
$success &= $this->db->trans_status();
|
||||
}
|
||||
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
@@ -534,23 +534,28 @@ class Sale extends CI_Model
|
||||
'discount_percent' => $item['discount'],
|
||||
'item_cost_price' => $cur_item_info->cost_price,
|
||||
'item_unit_price' => $item['price'],
|
||||
'item_location' => $item['item_location']
|
||||
'item_location' => $item['item_location'],
|
||||
'print_option' => $item['print_option']
|
||||
);
|
||||
|
||||
$this->db->insert('sales_items', $sales_items_data);
|
||||
|
||||
// Update stock quantity
|
||||
$item_quantity = $this->Item_quantity->get_item_quantity($item['item_id'], $item['item_location']);
|
||||
$this->Item_quantity->save(array('quantity' => $item_quantity->quantity - $item['quantity'],
|
||||
'item_id' => $item['item_id'],
|
||||
'location_id' => $item['item_location']), $item['item_id'], $item['item_location']);
|
||||
if ($cur_item_info->stock_type === '0')
|
||||
{
|
||||
// Update stock quantity if item type is not non-stock
|
||||
$item_quantity = $this->Item_quantity->get_item_quantity($item['item_id'], $item['item_location']);
|
||||
$this->Item_quantity->save(array('quantity' => $item_quantity->quantity - $item['quantity'],
|
||||
'item_id' => $item['item_id'],
|
||||
'location_id' => $item['item_location']), $item['item_id'], $item['item_location']);
|
||||
}
|
||||
|
||||
// if an items was deleted but later returned it's restored with this rule
|
||||
|
||||
if($item['quantity'] < 0)
|
||||
{
|
||||
$this->Item->undelete($item['item_id']);
|
||||
}
|
||||
|
||||
|
||||
// Inventory Count Details
|
||||
$sale_remarks = 'POS '.$sale_id;
|
||||
$inv_data = array(
|
||||
@@ -564,8 +569,8 @@ class Sale extends CI_Model
|
||||
$this->Inventory->insert($inv_data);
|
||||
|
||||
$customer = $this->Customer->get_info($customer_id);
|
||||
if($customer_id == -1 || $customer->taxable)
|
||||
{
|
||||
if($customer_id == -1 || $customer->taxable)
|
||||
{
|
||||
foreach($this->Item_taxes->get_info($item['item_id']) as $row)
|
||||
{
|
||||
$this->db->insert('sales_items_taxes', array(
|
||||
@@ -580,16 +585,16 @@ class Sale extends CI_Model
|
||||
}
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
|
||||
if($this->db->trans_status() === FALSE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return $sale_id;
|
||||
}
|
||||
|
||||
public function delete_list($sale_ids, $employee_id, $update_inventory = TRUE)
|
||||
public function delete_list($sale_ids, $employee_id, $update_inventory = TRUE)
|
||||
{
|
||||
$result = TRUE;
|
||||
|
||||
@@ -601,7 +606,7 @@ class Sale extends CI_Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function delete($sale_id, $employee_id, $update_inventory = TRUE)
|
||||
public function delete($sale_id, $employee_id, $update_inventory = TRUE)
|
||||
{
|
||||
// start a transaction to assure data integrity
|
||||
$this->db->trans_start();
|
||||
@@ -618,20 +623,24 @@ class Sale extends CI_Model
|
||||
$items = $this->get_sale_items($sale_id)->result_array();
|
||||
foreach($items as $item)
|
||||
{
|
||||
// create query to update inventory tracking
|
||||
$inv_data = array(
|
||||
'trans_date' => date('Y-m-d H:i:s'),
|
||||
'trans_items' => $item['item_id'],
|
||||
'trans_user' => $employee_id,
|
||||
'trans_comment' => 'Deleting sale ' . $sale_id,
|
||||
'trans_location' => $item['item_location'],
|
||||
'trans_inventory' => $item['quantity_purchased']
|
||||
);
|
||||
// update inventory
|
||||
$this->Inventory->insert($inv_data);
|
||||
$cur_item_info = $this->Item->get_info($item['item_id']);
|
||||
|
||||
// update quantities
|
||||
$this->Item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased']);
|
||||
if ($cur_item_info->stock_type === '0') {
|
||||
// create query to update inventory tracking
|
||||
$inv_data = array(
|
||||
'trans_date' => date('Y-m-d H:i:s'),
|
||||
'trans_items' => $item['item_id'],
|
||||
'trans_user' => $employee_id,
|
||||
'trans_comment' => 'Deleting sale ' . $sale_id,
|
||||
'trans_location' => $item['item_location'],
|
||||
'trans_inventory' => $item['quantity_purchased']
|
||||
);
|
||||
// update inventory
|
||||
$this->Inventory->insert($inv_data);
|
||||
|
||||
// update quantities
|
||||
$this->Item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,7 +651,7 @@ class Sale extends CI_Model
|
||||
|
||||
// execute transaction
|
||||
$this->db->trans_complete();
|
||||
|
||||
|
||||
return $this->db->trans_status();
|
||||
}
|
||||
|
||||
@@ -654,6 +663,58 @@ class Sale extends CI_Model
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
/*
|
||||
* Used by the invoice and receipt programs
|
||||
*/
|
||||
public function get_sale_items_ordered($sale_id)
|
||||
{
|
||||
$this->db->select('
|
||||
sale_id,
|
||||
sales_items.item_id,
|
||||
sales_items.description,
|
||||
serialnumber,
|
||||
line,
|
||||
quantity_purchased,
|
||||
item_cost_price,
|
||||
item_unit_price,
|
||||
discount_percent,
|
||||
item_location,
|
||||
print_option,
|
||||
items.name as name,
|
||||
category,
|
||||
item_type');
|
||||
$this->db->from('sales_items as sales_items');
|
||||
$this->db->join('items as items', 'sales_items.item_id = items.item_id');
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
|
||||
// Entry sequence (this will render kits in the expected sequence)
|
||||
if($this->config->item('line_sequence') == '0')
|
||||
{
|
||||
$this->db->order_by('line', 'asc');
|
||||
}
|
||||
// Group by Stock Type (nonstock first - type 1, stock next - type 0)
|
||||
elseif($this->config->item('line_sequence') == '1')
|
||||
{
|
||||
$this->db->order_by('stock_type', 'desc');
|
||||
$this->db->order_by('sales_items.description', 'asc');
|
||||
$this->db->order_by('items.name', 'asc');
|
||||
}
|
||||
// Group by Item Category
|
||||
elseif($this->config->item('line_sequence') == '2')
|
||||
{
|
||||
$this->db->order_by('category', 'asc');
|
||||
$this->db->order_by('sales_items.description', 'asc');
|
||||
$this->db->order_by('items.name', 'asc');
|
||||
}
|
||||
// Group by entry sequence in descending sequence (the Standard)
|
||||
else
|
||||
{
|
||||
$this->db->order_by('line', 'desc');
|
||||
}
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
public function get_sale_payments($sale_id)
|
||||
{
|
||||
$this->db->from('sales_payments');
|
||||
@@ -665,7 +726,7 @@ class Sale extends CI_Model
|
||||
public function get_payment_options($giftcard = TRUE)
|
||||
{
|
||||
$payments = array();
|
||||
|
||||
|
||||
if($this->config->item('payment_options_order') == 'debitcreditcash')
|
||||
{
|
||||
$payments[$this->lang->line('sales_debit')] = $this->lang->line('sales_debit');
|
||||
@@ -719,7 +780,7 @@ class Sale extends CI_Model
|
||||
{
|
||||
$this->db->where('sale_id !=', $sale_id);
|
||||
}
|
||||
|
||||
|
||||
return ($this->db->get()->num_rows() == 1);
|
||||
}
|
||||
|
||||
@@ -729,7 +790,7 @@ class Sale extends CI_Model
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
$this->db->from('giftcards');
|
||||
$this->db->where('giftcard_number', $giftcardNumber);
|
||||
|
||||
@@ -773,7 +834,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
|
||||
// create a temporary table to contain all the payment types and amount
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
|
||||
' (PRIMARY KEY(sale_id), INDEX(sale_id))
|
||||
(
|
||||
SELECT payments.sale_id AS sale_id,
|
||||
@@ -789,38 +850,38 @@ class Sale extends CI_Model
|
||||
)'
|
||||
);
|
||||
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') .
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') .
|
||||
' (INDEX(sale_date), INDEX(sale_time), INDEX(sale_id))
|
||||
(
|
||||
SELECT
|
||||
DATE(sales.sale_time) AS sale_date,
|
||||
sales.sale_time,
|
||||
MAX(DATE(sales.sale_time)) AS sale_date,
|
||||
MAX(sales.sale_time) AS sale_time,
|
||||
sales.sale_id,
|
||||
sales.comment,
|
||||
sales.invoice_number,
|
||||
sales.customer_id,
|
||||
CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer_name,
|
||||
customer_p.first_name AS customer_first_name,
|
||||
customer_p.last_name AS customer_last_name,
|
||||
customer_p.email AS customer_email,
|
||||
customer_p.comments AS customer_comments,
|
||||
customer.company_name AS customer_company_name,
|
||||
sales.employee_id,
|
||||
CONCAT(employee.first_name, " ", employee.last_name) AS employee_name,
|
||||
MAX(sales.comment) AS comment,
|
||||
MAX(sales.invoice_number) AS invoice_number,
|
||||
MAX(sales.customer_id) AS customer_id,
|
||||
MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
|
||||
MAX(customer_p.first_name) AS customer_first_name,
|
||||
MAX(customer_p.last_name) AS customer_last_name,
|
||||
MAX(customer_p.email) AS customer_email,
|
||||
MAX(customer_p.comments) AS customer_comments,
|
||||
MAX(customer.company_name) AS customer_company_name,
|
||||
MAX(sales.employee_id) AS employee_id,
|
||||
MAX(CONCAT(employee.first_name, " ", employee.last_name)) AS employee_name,
|
||||
items.item_id,
|
||||
items.name,
|
||||
items.category,
|
||||
items.supplier_id,
|
||||
sales_items.quantity_purchased,
|
||||
sales_items.item_cost_price,
|
||||
sales_items.item_unit_price,
|
||||
sales_items.discount_percent,
|
||||
MAX(items.name) AS name,
|
||||
MAX(items.category) AS category,
|
||||
MAX(items.supplier_id) AS supplier_id,
|
||||
MAX(sales_items.quantity_purchased) AS quantity_purchased,
|
||||
MAX(sales_items.item_cost_price) AS item_cost_price,
|
||||
MAX(sales_items.item_unit_price) AS item_unit_price,
|
||||
MAX(sales_items.discount_percent) AS discount_percent,
|
||||
sales_items.line,
|
||||
sales_items.serialnumber,
|
||||
sales_items.item_location,
|
||||
sales_items.description,
|
||||
payments.payment_type,
|
||||
payments.sale_payment_amount,
|
||||
MAX(sales_items.serialnumber) AS serialnumber,
|
||||
MAX(sales_items.item_location) AS item_location,
|
||||
MAX(sales_items.description) AS description,
|
||||
MAX(payments.payment_type) AS payment_type,
|
||||
MAX(payments.sale_payment_amount) AS sale_payment_amount,
|
||||
IFNULL(SUM(sales_items_taxes.percent), 0) AS item_tax_percent,
|
||||
' . "
|
||||
ROUND($sale_subtotal, $decimals) AS subtotal,
|
||||
|
||||
@@ -14,7 +14,7 @@ class Detailed_receivings extends Report
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Receiving->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
$columns = array(
|
||||
@@ -26,8 +26,8 @@ class Detailed_receivings extends Report
|
||||
array('supplier_name' => $this->lang->line('reports_supplied_by')),
|
||||
array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
|
||||
array('payment_type' => $this->lang->line('reports_payment_type')),
|
||||
array('reference' => $this->lang->line('receivings_reference')),
|
||||
array('comment' => $this->lang->line('reports_comments'))),
|
||||
array('comment' => $this->lang->line('reports_comments')),
|
||||
array('reference' => $this->lang->line('receivings_reference'))),
|
||||
'details' => array(
|
||||
$this->lang->line('reports_item_number'),
|
||||
$this->lang->line('reports_name'),
|
||||
@@ -39,22 +39,42 @@ class Detailed_receivings extends Report
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
|
||||
public function getDataByReceivingId($receiving_id)
|
||||
{
|
||||
$this->db->select('receiving_id, receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name, " ", employee.last_name) AS employee_name, supplier.company_name AS supplier_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, reference');
|
||||
$this->db->select('receiving_id,
|
||||
MAX(receiving_date) as receiving_date,
|
||||
SUM(quantity_purchased) AS items_purchased,
|
||||
MAX(CONCAT(employee.first_name, " ", employee.last_name)) AS employee_name,
|
||||
MAX(supplier.company_name) AS supplier_name,
|
||||
SUM(subtotal) AS subtotal,
|
||||
SUM(total) AS total,
|
||||
SUM(profit) AS profit,
|
||||
MAX(payment_type) as payment_type,
|
||||
MAX(comment) as comment,
|
||||
MAX(reference) as reference');
|
||||
$this->db->from('receivings_items_temp');
|
||||
$this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
|
||||
$this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
|
||||
$this->db->where('receiving_id', $receiving_id);
|
||||
$this->db->group_by('receiving_id');
|
||||
|
||||
return $this->db->get()->row_array();
|
||||
}
|
||||
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('receiving_id, receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name," ",employee.last_name) AS employee_name, supplier.company_name AS supplier_name, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, reference');
|
||||
$this->db->from('receivings_items_temp');
|
||||
$this->db->select('receiving_id,
|
||||
MAX(receiving_date) as receiving_date,
|
||||
SUM(quantity_purchased) AS items_purchased,
|
||||
MAX(CONCAT(employee.first_name," ",employee.last_name)) AS employee_name,
|
||||
MAX(supplier.company_name) AS supplier_name,
|
||||
SUM(total) AS total,
|
||||
SUM(profit) AS profit,
|
||||
MAX(payment_type) AS payment_type,
|
||||
MAX(comment) AS comment,
|
||||
MAX(reference) AS reference');
|
||||
$this->db->from('receivings_items_temp AS receivings_items_temp');
|
||||
$this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
|
||||
$this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
|
||||
|
||||
@@ -74,13 +94,13 @@ class Detailed_receivings extends Report
|
||||
{
|
||||
$this->db->having('items_purchased = 0');
|
||||
}
|
||||
$this->db->group_by('receiving_id');
|
||||
$this->db->order_by('receiving_date');
|
||||
$this->db->group_by('receiving_id', 'receiving_date');
|
||||
$this->db->order_by('receiving_id');
|
||||
|
||||
$data = array();
|
||||
$data['summary'] = $this->db->get()->result_array();
|
||||
$data['details'] = array();
|
||||
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount_percent, item_location, receivings_items_temp.receiving_quantity');
|
||||
@@ -89,10 +109,10 @@ class Detailed_receivings extends Report
|
||||
$this->db->where('receiving_id = '.$value['receiving_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
$this->db->select('SUM(total) AS total');
|
||||
|
||||
@@ -25,8 +25,8 @@ class Detailed_sales extends Report
|
||||
array('employee_name' => $this->lang->line('reports_sold_by')),
|
||||
array('customer_name' => $this->lang->line('reports_sold_to')),
|
||||
array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
|
||||
array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
|
||||
array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
|
||||
array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
|
||||
array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
|
||||
array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'),
|
||||
array('payment_type' => $this->lang->line('sales_amount_tendered')),
|
||||
@@ -43,7 +43,7 @@ class Detailed_sales extends Report
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
public function getDataBySaleId($sale_id)
|
||||
@@ -57,7 +57,18 @@ class Detailed_sales extends Report
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id,
|
||||
MAX(sale_date) AS sale_date,
|
||||
SUM(quantity_purchased) AS items_purchased,
|
||||
MAX(employee_name) AS employee_name,
|
||||
MAX(customer_name) AS customer_name,
|
||||
SUM(subtotal) AS subtotal,
|
||||
SUM(tax) AS tax,
|
||||
SUM(total) AS total,
|
||||
SUM(cost) AS cost,
|
||||
SUM(profit) AS profit,
|
||||
MAX(payment_type) AS payment_type,
|
||||
MAX(comment) AS comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
|
||||
if($inputs['location_id'] != 'all')
|
||||
@@ -75,7 +86,7 @@ class Detailed_sales extends Report
|
||||
}
|
||||
|
||||
$this->db->group_by('sale_id');
|
||||
$this->db->order_by('sale_date');
|
||||
$this->db->order_by('MAX(sale_date)');
|
||||
|
||||
$data = array();
|
||||
$data['summary'] = $this->db->get()->result_array();
|
||||
@@ -99,7 +110,7 @@ class Detailed_sales extends Report
|
||||
|
||||
if($inputs['location_id'] != 'all')
|
||||
{
|
||||
$this->db->where('item_location', $inputs['location_id']);
|
||||
$this->db->where('item_location', $inputs['location_id']);
|
||||
}
|
||||
|
||||
if($inputs['sale_type'] == 'sales')
|
||||
|
||||
@@ -27,7 +27,7 @@ class Inventory_low extends Report
|
||||
$this->db->join('stock_locations', 'item_quantities.location_id = stock_locations.location_id');
|
||||
$this->db->where('items.deleted', 0);
|
||||
$this->db->where('stock_locations.deleted', 0);
|
||||
$this->db->where('item_quantities.quantity <= items.reorder_level');
|
||||
$this->db->where('items.stock_type', 0);
|
||||
$this->db->order_by('items.name');
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
|
||||
@@ -28,6 +28,7 @@ class Inventory_summary extends Report
|
||||
$this->db->join('item_quantities AS item_quantities', 'items.item_id = item_quantities.item_id');
|
||||
$this->db->join('stock_locations AS stock_locations', 'item_quantities.location_id = stock_locations.location_id');
|
||||
$this->db->where('items.deleted', 0);
|
||||
$this->db->where('items.stock_type', 0);
|
||||
$this->db->where('stock_locations.deleted', 0);
|
||||
|
||||
// should be corresponding to values Inventory_summary::getItemCountDropdownArray() returns...
|
||||
|
||||
@@ -8,13 +8,13 @@ class Specific_customer extends Report
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array(
|
||||
@@ -44,10 +44,10 @@ class Specific_customer extends Report
|
||||
$this->lang->line('reports_discount'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id, MAX(sale_date) AS sale_date, SUM(quantity_purchased) AS items_purchased, MAX(employee_name) AS employee_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, MAX(payment_type) AS payment_type, MAX(comment) AS comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('customer_id', $inputs['customer_id']);
|
||||
|
||||
@@ -61,12 +61,12 @@ class Specific_customer extends Report
|
||||
}
|
||||
|
||||
$this->db->group_by('sale_id');
|
||||
$this->db->order_by('sale_date');
|
||||
$this->db->order_by('MAX(sale_date)');
|
||||
|
||||
$data = array();
|
||||
$data['summary'] = $this->db->get()->result_array();
|
||||
$data['details'] = array();
|
||||
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
@@ -77,7 +77,7 @@ class Specific_customer extends Report
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
|
||||
@@ -8,13 +8,13 @@ class Specific_discount extends Report
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array(
|
||||
@@ -40,12 +40,12 @@ class Specific_discount extends Report
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id, MAX(sale_date) AS sales_date, SUM(quantity_purchased) AS items_purchased, MAX(customer_name) AS customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, MAX(payment_type) AS payment_type, MAX(comment) AS comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
|
||||
@@ -59,12 +59,12 @@ class Specific_discount extends Report
|
||||
}
|
||||
|
||||
$this->db->group_by('sale_id');
|
||||
$this->db->order_by('sale_date');
|
||||
$this->db->order_by('MAX(sale_date)');
|
||||
|
||||
$data = array();
|
||||
$data['summary'] = $this->db->get()->result_array();
|
||||
$data['details'] = array();
|
||||
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, serialnumber, category, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
@@ -75,13 +75,13 @@ class Specific_discount extends Report
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
|
||||
@@ -8,13 +8,13 @@ class Specific_employee extends Report
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array(
|
||||
@@ -42,31 +42,31 @@ class Specific_employee extends Report
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id, MAX(sale_date) AS sale_date, SUM(quantity_purchased) AS items_purchased, MAX(customer_name) AS customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, MAX(payment_type) AS payment_type, MAX(comment) AS comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('employee_id', $inputs['employee_id']);
|
||||
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
}
|
||||
elseif ($inputs['sale_type'] == 'returns')
|
||||
{
|
||||
$this->db->where('quantity_purchased < 0');
|
||||
}
|
||||
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
}
|
||||
elseif ($inputs['sale_type'] == 'returns')
|
||||
{
|
||||
$this->db->where('quantity_purchased < 0');
|
||||
}
|
||||
|
||||
$this->db->group_by('sale_id');
|
||||
$this->db->order_by('sale_date');
|
||||
$this->db->order_by('MAX(sale_date)');
|
||||
|
||||
$data = array();
|
||||
$data['summary'] = $this->db->get()->result_array();
|
||||
$data['details'] = array();
|
||||
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
@@ -74,10 +74,10 @@ class Specific_employee extends Report
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
|
||||
@@ -8,7 +8,7 @@ class Summary_discounts extends Summary_report
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array(
|
||||
@@ -18,18 +18,18 @@ class Summary_discounts extends Summary_report
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('CONCAT(sales_items.discount_percent, "%") AS discount_percent, count(*) AS count');
|
||||
$this->db->select('MAX(CONCAT(sales_items.discount_percent, "%")) AS discount_percent, count(*) AS count');
|
||||
$this->db->from('sales_items AS sales_items');
|
||||
$this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
|
||||
|
||||
$this->db->where('discount_percent > 0');
|
||||
|
||||
$this->_where($inputs);
|
||||
|
||||
|
||||
$this->db->group_by('sales_items.discount_percent');
|
||||
$this->db->order_by('sales_items.discount_percent');
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -8,7 +8,7 @@ class Summary_employees extends Summary_report
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array(
|
||||
@@ -26,7 +26,7 @@ class Summary_employees extends Summary_report
|
||||
parent::_select($inputs);
|
||||
|
||||
$this->db->select('
|
||||
CONCAT(employee_p.first_name, " ", employee_p.last_name) AS employee,
|
||||
MAX(CONCAT(employee_p.first_name, " ", employee_p.last_name)) AS employee,
|
||||
SUM(sales_items.quantity_purchased) AS quantity_purchased
|
||||
');
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Summary_items extends Summary_report
|
||||
parent::_select($inputs);
|
||||
|
||||
$this->db->select('
|
||||
items.name AS name,
|
||||
MAX(items.name) AS name,
|
||||
SUM(sales_items.quantity_purchased) AS quantity_purchased
|
||||
');
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class Summary_items extends Summary_report
|
||||
protected function _group_order()
|
||||
{
|
||||
$this->db->group_by('items.item_id');
|
||||
$this->db->order_by('items.name');
|
||||
$this->db->order_by('name');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -26,11 +26,11 @@ class Summary_sales extends Summary_report
|
||||
parent::_select($inputs);
|
||||
|
||||
$this->db->select('
|
||||
DATE(sales.sale_time) AS sale_date,
|
||||
DATE(sales.sale_time) AS sale_date,
|
||||
SUM(sales_items.quantity_purchased) AS quantity_purchased
|
||||
');
|
||||
}
|
||||
|
||||
|
||||
protected function _group_order()
|
||||
{
|
||||
$this->db->group_by('sale_date');
|
||||
|
||||
@@ -26,7 +26,7 @@ class Summary_suppliers extends Summary_report
|
||||
parent::_select($inputs);
|
||||
|
||||
$this->db->select('
|
||||
CONCAT(supplier_c.company_name, " (", supplier_p.first_name, " ", supplier_p.last_name, ")") AS supplier,
|
||||
MAX(CONCAT(supplier_c.company_name, " (", supplier_p.first_name, " ", supplier_p.last_name, ")")) AS supplier,
|
||||
SUM(sales_items.quantity_purchased) AS quantity_purchased
|
||||
');
|
||||
}
|
||||
@@ -35,15 +35,15 @@ class Summary_suppliers extends Summary_report
|
||||
{
|
||||
parent::_from();
|
||||
|
||||
$this->db->join('items AS items', 'sales_items.item_id = items.item_id', 'inner');
|
||||
$this->db->join('suppliers AS supplier_c', 'supplier_c.person_id = items.supplier_id');
|
||||
$this->db->join('people AS supplier_p', 'supplier_c.person_id = supplier_p.person_id');
|
||||
$this->db->join('items AS items', 'sales_items.item_id = items.item_id');
|
||||
$this->db->join('suppliers AS supplier_c', 'items.supplier_id = supplier_c.person_id ');
|
||||
$this->db->join('people AS supplier_p', 'items.supplier_id = supplier_p.person_id');
|
||||
}
|
||||
|
||||
protected function _group_order()
|
||||
{
|
||||
$this->db->group_by('items.supplier_id');
|
||||
$this->db->order_by('supplier_p.last_name');
|
||||
$this->db->order_by('MAX(CONCAT(supplier_c.company_name, " (", supplier_p.first_name, " ", supplier_p.last_name, ")"))');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -59,6 +59,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_line_sequence'), 'line_sequence', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_dropdown('line_sequence', $line_sequence_options, $this->config->item('line_sequence'), array('class' => 'form-control input-sm')); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo form_submit(array(
|
||||
'name' => 'submit_form',
|
||||
'id' => 'submit_form',
|
||||
|
||||
@@ -16,6 +16,109 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('item_kits_find_kit_item'), 'item_name', array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
<div class="input-group input-group-sm">
|
||||
<?php echo form_input(array(
|
||||
'name'=>'item_name',
|
||||
'id'=>'item_name',
|
||||
'class'=>'form-control input-sm',
|
||||
'size'=>'50',
|
||||
'value'=>$selected_kit_item)
|
||||
); ?>
|
||||
<?php echo form_hidden('kit_item_id', $selected_kit_item_id);?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('item_kits_discount_percent'), 'kit_discount_percent', array('class' => 'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-3'>
|
||||
<div class="input-group input-group-sm">
|
||||
<?php echo form_input(array(
|
||||
'name'=>'kit_discount_percent',
|
||||
'size'=>'5',
|
||||
'maxlength'=>'5',
|
||||
'id'=>'kit_discount_percent',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>$item_kit_info->kit_discount_percent)
|
||||
);?>
|
||||
<span class="input-group-addon input-sm"><b>%</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('item_kits_price_option'), 'price_option', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class="col-xs-8">
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'price_option',
|
||||
'type'=>'radio',
|
||||
'id'=>'price_option',
|
||||
'value'=>0,
|
||||
'checked'=>$item_kit_info->price_option === '0')
|
||||
); ?> <?php echo $this->lang->line('item_kits_kit_and_components'); ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'price_option',
|
||||
'type'=>'radio',
|
||||
'id'=>'price_option',
|
||||
'value'=>1,
|
||||
'checked'=>$item_kit_info->price_option === '1')
|
||||
); ?> <?php echo $this->lang->line('item_kits_kit_only'); ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'price_option',
|
||||
'type'=>'radio',
|
||||
'id'=>'price_option',
|
||||
'value'=>2,
|
||||
'checked'=>$item_kit_info->price_option === '2')
|
||||
); ?> <?php echo $this->lang->line('item_kits_kit_and_stock'); ?>
|
||||
</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('item_kits_print_option'), 'print_option', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class="col-xs-8">
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'print_option',
|
||||
'type'=>'radio',
|
||||
'id'=>'print_option',
|
||||
'value'=>0,
|
||||
'checked'=>$item_kit_info->print_option === '0')
|
||||
); ?> <?php echo $this->lang->line('item_kits_all'); ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'print_option',
|
||||
'type'=>'radio',
|
||||
'id'=>'print_option',
|
||||
'value'=>1,
|
||||
'checked'=>$item_kit_info->print_option === '1')
|
||||
); ?> <?php echo $this->lang->line('item_kits_priced_only'); ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'print_option',
|
||||
'type'=>'radio',
|
||||
'id'=>'print_option',
|
||||
'value'=>2,
|
||||
'checked'=>$item_kit_info->print_option === '2')
|
||||
); ?> <?php echo $this->lang->line('item_kits_kit_only'); ?>
|
||||
</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('item_kits_description'), 'description', array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
@@ -43,7 +146,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%"><?php echo $this->lang->line('common_delete'); ?></th>
|
||||
<th width="70%"><?php echo $this->lang->line('item_kits_item'); ?></th>
|
||||
<th width="10%"><?php echo $this->lang->line('item_kits_sequence'); ?></th>
|
||||
<th width="60%"><?php echo $this->lang->line('item_kits_item'); ?></th>
|
||||
<th width="20%"><?php echo $this->lang->line('item_kits_quantity'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -54,8 +158,9 @@
|
||||
?>
|
||||
<tr>
|
||||
<td><a href='#' onclick='return delete_item_kit_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>
|
||||
<td><input class='quantity form-control input-sm' id='item_seq_<?php echo $item_kit_item['item_id'] ?>' name=item_kit_seq[<?php echo $item_kit_item['item_id'] ?>] value='<?php echo to_quantity_decimals($item_kit_item['kit_sequence']) ?>'/></td>
|
||||
<td><?php echo $item_kit_item['name']; ?></td>
|
||||
<td><input class='quantity form-control input-sm' id='item_kit_item_<?php echo $item_kit_item['item_id'] ?>' name=item_kit_item[<?php echo $item_kit_item['item_id'] ?>] value='<?php echo to_quantity_decimals($item_kit_item['quantity']) ?>'/></td>
|
||||
<td><input class='quantity form-control input-sm' id='item_qty_<?php echo $item_kit_item['item_id'] ?>' name=item_kit_qty[<?php echo $item_kit_item['item_id'] ?>] value='<?php echo to_quantity_decimals($item_kit_item['quantity']) ?>'/></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
@@ -63,6 +168,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -70,50 +176,79 @@
|
||||
//validation and submit handling
|
||||
$(document).ready(function()
|
||||
{
|
||||
$("#item").autocomplete({
|
||||
source: '<?php echo site_url("items/suggest"); ?>',
|
||||
minChars:0,
|
||||
autoFocus: false,
|
||||
delay:10,
|
||||
appendTo: ".modal-content",
|
||||
select: function(e, ui) {
|
||||
if ($("#item_kit_item_" + ui.item.value).length == 1)
|
||||
{
|
||||
$("#item_kit_item_" + ui.item.value).val(parseFloat( $("#item_kit_item_" + ui.item.value).val()) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#item_kit_items").append("<tr><td><a href='#' onclick='return delete_item_kit_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td><td>" + ui.item.label + "</td><td><input class='quantity form-control input-sm' id='item_kit_item_" + ui.item.value + "' type='text' name=item_kit_item[" + ui.item.value + "] value='1'/></td></tr>");
|
||||
}
|
||||
$("#item").val("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#item_kit_form').validate($.extend({
|
||||
submitHandler:function(form)
|
||||
{
|
||||
$(form).ajaxSubmit({
|
||||
success:function(response)
|
||||
{
|
||||
dialog_support.hide();
|
||||
table_support.handle_submit('<?php echo site_url('item_kits'); ?>', response);
|
||||
},
|
||||
dataType:'json'
|
||||
});
|
||||
$("#item").autocomplete({
|
||||
source: '<?php echo site_url("items/suggest"); ?>',
|
||||
minChars:0,
|
||||
autoFocus: false,
|
||||
delay:10,
|
||||
appendTo: ".modal-content",
|
||||
select: function(e, ui) {
|
||||
if ($("#item_kit_item_" + ui.item.value).length == 1)
|
||||
{
|
||||
$("#item_kit_item_" + ui.item.value).val(parseFloat( $("#item_kit_item_" + ui.item.value).val()) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#item_kit_items").append("<tr>" +
|
||||
"<td><a href='#' onclick='return delete_item_kit_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>" +
|
||||
"<td><input class='quantity form-control input-sm' id='item_seq_" + ui.item.value + "' name=item_kit_seq[" + ui.item.value + "] value='0'/></td>" +
|
||||
"<td>" + ui.item.label + "</td>" +
|
||||
"<td><input class='quantity form-control input-sm' id='item_qty_" + ui.item.value + "' name=item_kit_qty[" + ui.item.value + "] value='1'/></td>" +
|
||||
"</tr>");
|
||||
}
|
||||
$("#item").val("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
rules:
|
||||
{
|
||||
name:"required",
|
||||
category:"required"
|
||||
},
|
||||
messages:
|
||||
{
|
||||
name:"<?php echo $this->lang->line('items_name_required'); ?>",
|
||||
category:"<?php echo $this->lang->line('items_category_required'); ?>"
|
||||
}
|
||||
}, form_support.error));
|
||||
$("input[name='item_name']").change(function() {
|
||||
if( ! $("input[name='item_name']").val() ) {
|
||||
$("input[name='kit_item_id']").val('');
|
||||
}
|
||||
});
|
||||
|
||||
var fill_value = function(event, ui) {
|
||||
event.preventDefault();
|
||||
$("input[name='kit_item_id']").val(ui.item.value);
|
||||
$("input[name='item_name']").val(ui.item.label);
|
||||
};
|
||||
|
||||
|
||||
$("#item_name").autocomplete({
|
||||
source: '<?php echo site_url("items/suggest"); ?>',
|
||||
minChars: 0,
|
||||
delay: 15,
|
||||
cacheLength: 1,
|
||||
appendTo: '.modal-content',
|
||||
select: fill_value,
|
||||
focus: fill_value
|
||||
});
|
||||
|
||||
$('#item_kit_form').validate($.extend({
|
||||
submitHandler:function(form)
|
||||
{
|
||||
$(form).ajaxSubmit({
|
||||
success:function(response)
|
||||
{
|
||||
dialog_support.hide();
|
||||
table_support.handle_submit('<?php echo site_url('item_kits'); ?>', response);
|
||||
},
|
||||
dataType:'json'
|
||||
});
|
||||
|
||||
},
|
||||
rules:
|
||||
{
|
||||
name:"required",
|
||||
category:"required"
|
||||
},
|
||||
messages:
|
||||
{
|
||||
name:"<?php echo $this->lang->line('items_name_required'); ?>",
|
||||
category:"<?php echo $this->lang->line('items_category_required'); ?>"
|
||||
}
|
||||
}, form_support.error));
|
||||
});
|
||||
|
||||
function delete_item_kit_row(link)
|
||||
|
||||
@@ -46,6 +46,54 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('items_stock_type'), 'stock_type', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class="col-xs-8">
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'stock_type',
|
||||
'type'=>'radio',
|
||||
'id'=>'stock_type',
|
||||
'value'=>0,
|
||||
'checked'=>$item_info->stock_type === '0')
|
||||
); ?> <?php echo $this->lang->line('items_stock'); ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'stock_type',
|
||||
'type'=>'radio',
|
||||
'id'=>'stock_type',
|
||||
'value'=>1,
|
||||
'checked'=>$item_info->stock_type === '1')
|
||||
); ?> <?php echo $this->lang->line('items_nonstock'); ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('items_type'), 'item_type', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class="col-xs-8">
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'item_type',
|
||||
'type'=>'radio',
|
||||
'id'=>'item_type',
|
||||
'value'=>0,
|
||||
'checked'=>$item_info->item_type === '0')
|
||||
); ?> <?php echo $this->lang->line('items_standard'); ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'item_type',
|
||||
'type'=>'radio',
|
||||
'id'=>'item_type',
|
||||
'value'=>1,
|
||||
'checked'=>$item_info->item_type === '1')
|
||||
); ?> <?php echo $this->lang->line('items_kit'); ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('items_supplier'), 'supplier', array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
|
||||
@@ -10,14 +10,14 @@ if(isset($error))
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><span class="glyphicon glyphicon-stats"> </span><?php echo $this->lang->line('reports_graphical_reports'); ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<?php
|
||||
foreach($grants as $grant)
|
||||
{
|
||||
if (!preg_match('/reports_(inventory|receivings)/', $grant['permission_id']))
|
||||
if (preg_match('/reports_/', $grant['permission_id']) && !preg_match('/(inventory|receivings)/', $grant['permission_id']))
|
||||
{
|
||||
show_report('graphical_summary', $grant['permission_id']);
|
||||
}
|
||||
@@ -29,14 +29,14 @@ if(isset($error))
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><span class="glyphicon glyphicon-list"> </span><?php echo $this->lang->line('reports_summary_reports'); ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<?php
|
||||
foreach($grants as $grant)
|
||||
{
|
||||
if (!preg_match('/reports_(inventory|receivings)/', $grant['permission_id']))
|
||||
if (preg_match('/reports_/', $grant['permission_id']) && !preg_match('/(inventory|receivings)/', $grant['permission_id']))
|
||||
{
|
||||
show_report('summary', $grant['permission_id']);
|
||||
}
|
||||
@@ -48,9 +48,9 @@ if(isset($error))
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><span class="glyphicon glyphicon-list-alt"> </span><?php echo $this->lang->line('reports_detailed_reports'); ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<?php
|
||||
$person_id = $this->session->userdata('person_id');
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<th style="width:20%;" class="total-value"><?php echo $this->lang->line('sales_total'); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach(array_reverse($cart, true) as $line=>$item)
|
||||
foreach($cart as $line=>$item)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
|
||||
21
database/3.0.2_to_3.1.0.sql
Normal file
21
database/3.0.2_to_3.1.0.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- alter quantity fields to be all decimal
|
||||
|
||||
ALTER TABLE `ospos_items`
|
||||
ADD COLUMN `stock_type` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
ADD COLUMN `item_type` TINYINT(2) NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE `ospos_item_kits`
|
||||
ADD COLUMN `item_id` INT(10) NOT NULL DEFAULT 0,
|
||||
ADD COLUMN `kit_discount_percent` DECIMAL(15,2) NOT NULL DEFAULT 0.00,
|
||||
ADD COLUMN `price_option` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
ADD COLUMN `print_option` TINYINT(2) NOT NULL DEFAULT 0;
|
||||
|
||||
|
||||
ALTER TABLE `ospos_item_kit_items`
|
||||
ADD COLUMN `kit_sequence` INT(3) NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE `ospos_sales_items`
|
||||
ADD COLUMN `print_option` TINYINT(2) NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE `ospos_sales_suspended_items`
|
||||
ADD COLUMN `print_option` TINYINT(2) NOT NULL DEFAULT 0;
|
||||
@@ -4,9 +4,9 @@
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_app_config` (
|
||||
`key` varchar(50) NOT NULL,
|
||||
`value` varchar(500) NOT NULL,
|
||||
PRIMARY KEY (`key`)
|
||||
`key` varchar(50) NOT NULL,
|
||||
`value` varchar(500) NOT NULL,
|
||||
PRIMARY KEY (`key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -92,14 +92,14 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_customers` (
|
||||
`person_id` int(10) NOT NULL,
|
||||
`company_name` varchar(255) DEFAULT NULL,
|
||||
`account_number` varchar(255) DEFAULT NULL,
|
||||
`taxable` int(1) NOT NULL DEFAULT '1',
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
UNIQUE KEY `account_number` (`account_number`),
|
||||
KEY `person_id` (`person_id`)
|
||||
`person_id` int(10) NOT NULL,
|
||||
`company_name` varchar(255) DEFAULT NULL,
|
||||
`account_number` varchar(255) DEFAULT NULL,
|
||||
`taxable` int(1) NOT NULL DEFAULT '1',
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
UNIQUE KEY `account_number` (`account_number`),
|
||||
KEY `person_id` (`person_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -114,13 +114,13 @@ CREATE TABLE `ospos_customers` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_employees` (
|
||||
`username` varchar(255) NOT NULL,
|
||||
`password` varchar(255) NOT NULL,
|
||||
`person_id` int(10) NOT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
`hash_version` int(1) NOT NULL DEFAULT '2',
|
||||
UNIQUE KEY `username` (`username`),
|
||||
KEY `person_id` (`person_id`)
|
||||
`username` varchar(255) NOT NULL,
|
||||
`password` varchar(255) NOT NULL,
|
||||
`person_id` int(10) NOT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
`hash_version` int(1) NOT NULL DEFAULT '2',
|
||||
UNIQUE KEY `username` (`username`),
|
||||
KEY `person_id` (`person_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -137,15 +137,15 @@ INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`, `
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_giftcards` (
|
||||
`record_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`giftcard_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`giftcard_number` int(10) NOT NULL,
|
||||
`value` decimal(15,2) NOT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
`person_id` INT(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`giftcard_id`),
|
||||
UNIQUE KEY `giftcard_number` (`giftcard_number`),
|
||||
KEY `person_id` (`person_id`)
|
||||
`record_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`giftcard_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`giftcard_number` int(10) NOT NULL,
|
||||
`value` decimal(15,2) NOT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
`person_id` INT(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`giftcard_id`),
|
||||
UNIQUE KEY `giftcard_number` (`giftcard_number`),
|
||||
KEY `person_id` (`person_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -160,17 +160,17 @@ CREATE TABLE `ospos_giftcards` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_inventory` (
|
||||
`trans_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`trans_items` int(11) NOT NULL DEFAULT '0',
|
||||
`trans_user` int(11) NOT NULL DEFAULT '0',
|
||||
`trans_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`trans_comment` text NOT NULL,
|
||||
`trans_location` int(11) NOT NULL,
|
||||
`trans_inventory` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`trans_id`),
|
||||
KEY `trans_items` (`trans_items`),
|
||||
KEY `trans_user` (`trans_user`),
|
||||
KEY `trans_location` (`trans_location`)
|
||||
`trans_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`trans_items` int(11) NOT NULL DEFAULT '0',
|
||||
`trans_user` int(11) NOT NULL DEFAULT '0',
|
||||
`trans_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`trans_comment` text NOT NULL,
|
||||
`trans_location` int(11) NOT NULL,
|
||||
`trans_inventory` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`trans_id`),
|
||||
KEY `trans_items` (`trans_items`),
|
||||
KEY `trans_user` (`trans_user`),
|
||||
KEY `trans_location` (`trans_location`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
|
||||
--
|
||||
@@ -226,10 +226,10 @@ CREATE TABLE `ospos_items` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_items_taxes` (
|
||||
`item_id` int(10) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`percent` decimal(15,3) NOT NULL,
|
||||
PRIMARY KEY (`item_id`,`name`,`percent`)
|
||||
`item_id` int(10) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`percent` decimal(15,3) NOT NULL,
|
||||
PRIMARY KEY (`item_id`,`name`,`percent`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -244,10 +244,14 @@ CREATE TABLE `ospos_items_taxes` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_item_kits` (
|
||||
`item_kit_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`item_kit_id`)
|
||||
`item_kit_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` varchar(255) NOT NULL,
|
||||
`item_id` INT(10) NOT NULL DEFAULT 0,
|
||||
`kit_discount_percent` DECIMAL(15,2) NOT NULL DEFAULT 0.00,
|
||||
`price_option` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
`print_option` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`item_kit_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
|
||||
--
|
||||
@@ -262,11 +266,12 @@ CREATE TABLE `ospos_item_kits` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_item_kit_items` (
|
||||
`item_kit_id` int(11) NOT NULL,
|
||||
`item_id` int(11) NOT NULL,
|
||||
`quantity` decimal(15,3) NOT NULL,
|
||||
PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`),
|
||||
KEY `ospos_item_kit_items_ibfk_2` (`item_id`)
|
||||
`item_kit_id` int(11) NOT NULL,
|
||||
`item_id` int(11) NOT NULL,
|
||||
`quantity` decimal(15,3) NOT NULL,
|
||||
`kit_sequence` INT(3) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`),
|
||||
KEY `ospos_item_kit_items_ibfk_2` (`item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -280,12 +285,12 @@ CREATE TABLE `ospos_item_kit_items` (
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ospos_item_quantities` (
|
||||
`item_id` int(11) NOT NULL,
|
||||
`location_id` int(11) NOT NULL,
|
||||
`quantity` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`item_id`,`location_id`),
|
||||
KEY `item_id` (`item_id`),
|
||||
KEY `location_id` (`location_id`)
|
||||
`item_id` int(11) NOT NULL,
|
||||
`location_id` int(11) NOT NULL,
|
||||
`quantity` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`item_id`,`location_id`),
|
||||
KEY `item_id` (`item_id`),
|
||||
KEY `location_id` (`location_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@@ -295,13 +300,13 @@ CREATE TABLE IF NOT EXISTS `ospos_item_quantities` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_modules` (
|
||||
`name_lang_key` varchar(255) NOT NULL,
|
||||
`desc_lang_key` varchar(255) NOT NULL,
|
||||
`sort` int(10) NOT NULL,
|
||||
`module_id` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`module_id`),
|
||||
UNIQUE KEY `desc_lang_key` (`desc_lang_key`),
|
||||
UNIQUE KEY `name_lang_key` (`name_lang_key`)
|
||||
`name_lang_key` varchar(255) NOT NULL,
|
||||
`desc_lang_key` varchar(255) NOT NULL,
|
||||
`sort` int(10) NOT NULL,
|
||||
`module_id` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`module_id`),
|
||||
UNIQUE KEY `desc_lang_key` (`desc_lang_key`),
|
||||
UNIQUE KEY `name_lang_key` (`name_lang_key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -328,20 +333,20 @@ INSERT INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_i
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_people` (
|
||||
`first_name` varchar(255) NOT NULL,
|
||||
`last_name` varchar(255) NOT NULL,
|
||||
`gender` int(1) DEFAULT NULL,
|
||||
`phone_number` varchar(255) NOT NULL,
|
||||
`email` varchar(255) NOT NULL,
|
||||
`address_1` varchar(255) NOT NULL,
|
||||
`address_2` varchar(255) NOT NULL,
|
||||
`city` varchar(255) NOT NULL,
|
||||
`state` varchar(255) NOT NULL,
|
||||
`zip` varchar(255) NOT NULL,
|
||||
`country` varchar(255) NOT NULL,
|
||||
`comments` text NOT NULL,
|
||||
`person_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`person_id`)
|
||||
`first_name` varchar(255) NOT NULL,
|
||||
`last_name` varchar(255) NOT NULL,
|
||||
`gender` int(1) DEFAULT NULL,
|
||||
`phone_number` varchar(255) NOT NULL,
|
||||
`email` varchar(255) NOT NULL,
|
||||
`address_1` varchar(255) NOT NULL,
|
||||
`address_2` varchar(255) NOT NULL,
|
||||
`city` varchar(255) NOT NULL,
|
||||
`state` varchar(255) NOT NULL,
|
||||
`zip` varchar(255) NOT NULL,
|
||||
`country` varchar(255) NOT NULL,
|
||||
`comments` text NOT NULL,
|
||||
`person_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`person_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
|
||||
--
|
||||
@@ -358,11 +363,11 @@ INSERT INTO `ospos_people` (`first_name`, `last_name`, `phone_number`, `email`,
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_permissions` (
|
||||
`permission_id` varchar(255) NOT NULL,
|
||||
`module_id` varchar(255) NOT NULL,
|
||||
`location_id` int(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`permission_id`),
|
||||
KEY `module_id` (`module_id`)
|
||||
`permission_id` varchar(255) NOT NULL,
|
||||
`module_id` varchar(255) NOT NULL,
|
||||
`location_id` int(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`permission_id`),
|
||||
KEY `module_id` (`module_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -405,9 +410,9 @@ INSERT INTO `ospos_permissions` (`permission_id`, `module_id`, `location_id`) VA
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_grants` (
|
||||
`permission_id` varchar(255) NOT NULL,
|
||||
`person_id` int(10) NOT NULL,
|
||||
PRIMARY KEY (`permission_id`,`person_id`)
|
||||
`permission_id` varchar(255) NOT NULL,
|
||||
`person_id` int(10) NOT NULL,
|
||||
PRIMARY KEY (`permission_id`,`person_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -447,17 +452,17 @@ INSERT INTO `ospos_grants` (`permission_id`, `person_id`) VALUES
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_receivings` (
|
||||
`receiving_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`supplier_id` int(10) DEFAULT NULL,
|
||||
`employee_id` int(10) NOT NULL DEFAULT '0',
|
||||
`comment` text NOT NULL,
|
||||
`receiving_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`payment_type` varchar(20) DEFAULT NULL,
|
||||
`reference` varchar(32) DEFAULT NULL,
|
||||
PRIMARY KEY (`receiving_id`),
|
||||
KEY `supplier_id` (`supplier_id`),
|
||||
KEY `employee_id` (`employee_id`),
|
||||
KEY `reference` (`reference`)
|
||||
`receiving_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`supplier_id` int(10) DEFAULT NULL,
|
||||
`employee_id` int(10) NOT NULL DEFAULT '0',
|
||||
`comment` text NOT NULL,
|
||||
`receiving_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`payment_type` varchar(20) DEFAULT NULL,
|
||||
`reference` varchar(32) DEFAULT NULL,
|
||||
PRIMARY KEY (`receiving_id`),
|
||||
KEY `supplier_id` (`supplier_id`),
|
||||
KEY `employee_id` (`employee_id`),
|
||||
KEY `reference` (`reference`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
|
||||
--
|
||||
@@ -472,19 +477,19 @@ CREATE TABLE `ospos_receivings` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_receivings_items` (
|
||||
`receiving_id` int(10) NOT NULL DEFAULT '0',
|
||||
`item_id` int(10) NOT NULL DEFAULT '0',
|
||||
`description` varchar(30) DEFAULT NULL,
|
||||
`serialnumber` varchar(30) DEFAULT NULL,
|
||||
`line` int(3) NOT NULL,
|
||||
`quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
`item_cost_price` decimal(15,2) NOT NULL,
|
||||
`item_unit_price` decimal(15,2) NOT NULL,
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`item_location` int(11) NOT NULL,
|
||||
`receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`receiving_id`,`item_id`,`line`),
|
||||
KEY `item_id` (`item_id`)
|
||||
`receiving_id` int(10) NOT NULL DEFAULT '0',
|
||||
`item_id` int(10) NOT NULL DEFAULT '0',
|
||||
`description` varchar(30) DEFAULT NULL,
|
||||
`serialnumber` varchar(30) DEFAULT NULL,
|
||||
`line` int(3) NOT NULL,
|
||||
`quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
`item_cost_price` decimal(15,2) NOT NULL,
|
||||
`item_unit_price` decimal(15,2) NOT NULL,
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`item_location` int(11) NOT NULL,
|
||||
`receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`receiving_id`,`item_id`,`line`),
|
||||
KEY `item_id` (`item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -499,17 +504,17 @@ CREATE TABLE `ospos_receivings_items` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sales` (
|
||||
`sale_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`customer_id` int(10) DEFAULT NULL,
|
||||
`employee_id` int(10) NOT NULL DEFAULT '0',
|
||||
`comment` text NOT NULL,
|
||||
`invoice_number` varchar(32) DEFAULT NULL,
|
||||
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`sale_id`),
|
||||
KEY `customer_id` (`customer_id`),
|
||||
KEY `employee_id` (`employee_id`),
|
||||
KEY `sale_time` (`sale_time`),
|
||||
UNIQUE KEY `invoice_number` (`invoice_number`)
|
||||
`sale_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`customer_id` int(10) DEFAULT NULL,
|
||||
`employee_id` int(10) NOT NULL DEFAULT '0',
|
||||
`comment` text NOT NULL,
|
||||
`invoice_number` varchar(32) DEFAULT NULL,
|
||||
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`sale_id`),
|
||||
KEY `customer_id` (`customer_id`),
|
||||
KEY `employee_id` (`employee_id`),
|
||||
KEY `sale_time` (`sale_time`),
|
||||
UNIQUE KEY `invoice_number` (`invoice_number`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
|
||||
--
|
||||
@@ -524,20 +529,21 @@ CREATE TABLE `ospos_sales` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sales_items` (
|
||||
`sale_id` int(10) NOT NULL DEFAULT '0',
|
||||
`item_id` int(10) NOT NULL DEFAULT '0',
|
||||
`description` varchar(30) DEFAULT NULL,
|
||||
`serialnumber` varchar(30) DEFAULT NULL,
|
||||
`line` int(3) NOT NULL DEFAULT '0',
|
||||
`quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
`item_cost_price` decimal(15,2) NOT NULL,
|
||||
`item_unit_price` decimal(15,2) NOT NULL,
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`item_location` int(11) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`),
|
||||
KEY `sale_id` (`sale_id`),
|
||||
KEY `item_id` (`item_id`),
|
||||
KEY `item_location` (`item_location`)
|
||||
`sale_id` int(10) NOT NULL DEFAULT '0',
|
||||
`item_id` int(10) NOT NULL DEFAULT '0',
|
||||
`description` varchar(30) DEFAULT NULL,
|
||||
`serialnumber` varchar(30) DEFAULT NULL,
|
||||
`line` int(3) NOT NULL DEFAULT '0',
|
||||
`quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
`item_cost_price` decimal(15,2) NOT NULL,
|
||||
`item_unit_price` decimal(15,2) NOT NULL,
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`item_location` int(11) NOT NULL,
|
||||
`print_option` tinyint(2) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`),
|
||||
KEY `sale_id` (`sale_id`),
|
||||
KEY `item_id` (`item_id`),
|
||||
KEY `item_location` (`item_location`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -552,14 +558,14 @@ CREATE TABLE `ospos_sales_items` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sales_items_taxes` (
|
||||
`sale_id` int(10) NOT NULL,
|
||||
`item_id` int(10) NOT NULL,
|
||||
`line` int(3) NOT NULL DEFAULT '0',
|
||||
`name` varchar(255) NOT NULL,
|
||||
`percent` decimal(15,3) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`),
|
||||
KEY `sale_id` (`sale_id`),
|
||||
KEY `item_id` (`item_id`)
|
||||
`sale_id` int(10) NOT NULL,
|
||||
`item_id` int(10) NOT NULL,
|
||||
`line` int(3) NOT NULL DEFAULT '0',
|
||||
`name` varchar(255) NOT NULL,
|
||||
`percent` decimal(15,3) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`),
|
||||
KEY `sale_id` (`sale_id`),
|
||||
KEY `item_id` (`item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -574,11 +580,11 @@ CREATE TABLE `ospos_sales_items_taxes` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sales_payments` (
|
||||
`sale_id` int(10) NOT NULL,
|
||||
`payment_type` varchar(40) NOT NULL,
|
||||
`payment_amount` decimal(15,2) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`payment_type`),
|
||||
KEY `sale_id` (`sale_id`)
|
||||
`sale_id` int(10) NOT NULL,
|
||||
`payment_type` varchar(40) NOT NULL,
|
||||
`payment_amount` decimal(15,2) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`payment_type`),
|
||||
KEY `sale_id` (`sale_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -593,15 +599,15 @@ CREATE TABLE `ospos_sales_payments` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sales_suspended` (
|
||||
`sale_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`customer_id` int(10) DEFAULT NULL,
|
||||
`employee_id` int(10) NOT NULL DEFAULT '0',
|
||||
`comment` text NOT NULL,
|
||||
`invoice_number` varchar(32) DEFAULT NULL,
|
||||
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`sale_id`),
|
||||
KEY `customer_id` (`customer_id`),
|
||||
KEY `employee_id` (`employee_id`)
|
||||
`sale_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`customer_id` int(10) DEFAULT NULL,
|
||||
`employee_id` int(10) NOT NULL DEFAULT '0',
|
||||
`comment` text NOT NULL,
|
||||
`invoice_number` varchar(32) DEFAULT NULL,
|
||||
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`sale_id`),
|
||||
KEY `customer_id` (`customer_id`),
|
||||
KEY `employee_id` (`employee_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
|
||||
--
|
||||
@@ -616,19 +622,20 @@ CREATE TABLE `ospos_sales_suspended` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sales_suspended_items` (
|
||||
`sale_id` int(10) NOT NULL DEFAULT '0',
|
||||
`item_id` int(10) NOT NULL DEFAULT '0',
|
||||
`description` varchar(30) DEFAULT NULL,
|
||||
`serialnumber` varchar(30) DEFAULT NULL,
|
||||
`line` int(3) NOT NULL DEFAULT '0',
|
||||
`quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
`item_cost_price` decimal(15,2) NOT NULL,
|
||||
`item_unit_price` decimal(15,2) NOT NULL,
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`item_location` int(11) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`),
|
||||
KEY `sale_id` (`sale_id`),
|
||||
KEY `item_id` (`item_id`)
|
||||
`sale_id` int(10) NOT NULL DEFAULT '0',
|
||||
`item_id` int(10) NOT NULL DEFAULT '0',
|
||||
`description` varchar(30) DEFAULT NULL,
|
||||
`serialnumber` varchar(30) DEFAULT NULL,
|
||||
`line` int(3) NOT NULL DEFAULT '0',
|
||||
`quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0',
|
||||
`item_cost_price` decimal(15,2) NOT NULL,
|
||||
`item_unit_price` decimal(15,2) NOT NULL,
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`item_location` int(11) NOT NULL,
|
||||
`print_option` tinyint(2) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`),
|
||||
KEY `sale_id` (`sale_id`),
|
||||
KEY `item_id` (`item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -643,13 +650,13 @@ CREATE TABLE `ospos_sales_suspended_items` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sales_suspended_items_taxes` (
|
||||
`sale_id` int(10) NOT NULL,
|
||||
`item_id` int(10) NOT NULL,
|
||||
`line` int(3) NOT NULL DEFAULT '0',
|
||||
`name` varchar(255) NOT NULL,
|
||||
`percent` decimal(15,3) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`),
|
||||
KEY `item_id` (`item_id`)
|
||||
`sale_id` int(10) NOT NULL,
|
||||
`item_id` int(10) NOT NULL,
|
||||
`line` int(3) NOT NULL DEFAULT '0',
|
||||
`name` varchar(255) NOT NULL,
|
||||
`percent` decimal(15,3) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`),
|
||||
KEY `item_id` (`item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -664,10 +671,10 @@ CREATE TABLE `ospos_sales_suspended_items_taxes` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sales_suspended_payments` (
|
||||
`sale_id` int(10) NOT NULL,
|
||||
`payment_type` varchar(40) NOT NULL,
|
||||
`payment_amount` decimal(15,2) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`payment_type`)
|
||||
`sale_id` int(10) NOT NULL,
|
||||
`payment_type` varchar(40) NOT NULL,
|
||||
`payment_amount` decimal(15,2) NOT NULL,
|
||||
PRIMARY KEY (`sale_id`,`payment_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -682,11 +689,11 @@ CREATE TABLE `ospos_sales_suspended_payments` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_sessions` (
|
||||
`id` varchar(40) NOT NULL,
|
||||
`ip_address` varchar(45) NOT NULL,
|
||||
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
|
||||
`data` blob NOT NULL,
|
||||
KEY `ci_sessions_timestamp` (`timestamp`)
|
||||
`id` varchar(40) NOT NULL,
|
||||
`ip_address` varchar(45) NOT NULL,
|
||||
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
|
||||
`data` blob NOT NULL,
|
||||
KEY `ci_sessions_timestamp` (`timestamp`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -700,10 +707,10 @@ CREATE TABLE `ospos_sessions` (
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_stock_locations` (
|
||||
`location_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`location_name` varchar(255) DEFAULT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`location_id`)
|
||||
`location_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`location_name` varchar(255) DEFAULT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`location_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
|
||||
--
|
||||
@@ -719,13 +726,13 @@ INSERT INTO `ospos_stock_locations` ( `deleted`, `location_name` ) VALUES ('0',
|
||||
--
|
||||
|
||||
CREATE TABLE `ospos_suppliers` (
|
||||
`person_id` int(10) NOT NULL,
|
||||
`company_name` varchar(255) NOT NULL,
|
||||
`agency_name` varchar(255) NOT NULL,
|
||||
`account_number` varchar(255) DEFAULT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
UNIQUE KEY `account_number` (`account_number`),
|
||||
KEY `person_id` (`person_id`)
|
||||
`person_id` int(10) NOT NULL,
|
||||
`company_name` varchar(255) NOT NULL,
|
||||
`agency_name` varchar(255) NOT NULL,
|
||||
`account_number` varchar(255) DEFAULT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
UNIQUE KEY `account_number` (`account_number`),
|
||||
KEY `person_id` (`person_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -741,141 +748,141 @@ CREATE TABLE `ospos_suppliers` (
|
||||
-- Constraints for table `ospos_customers`
|
||||
--
|
||||
ALTER TABLE `ospos_customers`
|
||||
ADD CONSTRAINT `ospos_customers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_customers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_employees`
|
||||
--
|
||||
ALTER TABLE `ospos_employees`
|
||||
ADD CONSTRAINT `ospos_employees_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_employees_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_inventory`
|
||||
--
|
||||
ALTER TABLE `ospos_inventory`
|
||||
ADD CONSTRAINT `ospos_inventory_ibfk_1` FOREIGN KEY (`trans_items`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_inventory_ibfk_2` FOREIGN KEY (`trans_user`) REFERENCES `ospos_employees` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_inventory_ibfk_3` FOREIGN KEY (`trans_location`) REFERENCES `ospos_stock_locations` (`location_id`);
|
||||
ADD CONSTRAINT `ospos_inventory_ibfk_1` FOREIGN KEY (`trans_items`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_inventory_ibfk_2` FOREIGN KEY (`trans_user`) REFERENCES `ospos_employees` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_inventory_ibfk_3` FOREIGN KEY (`trans_location`) REFERENCES `ospos_stock_locations` (`location_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_items`
|
||||
--
|
||||
ALTER TABLE `ospos_items`
|
||||
ADD CONSTRAINT `ospos_items_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_items_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_items_taxes`
|
||||
--
|
||||
ALTER TABLE `ospos_items_taxes`
|
||||
ADD CONSTRAINT `ospos_items_taxes_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`) ON DELETE CASCADE;
|
||||
ADD CONSTRAINT `ospos_items_taxes_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_item_kit_items`
|
||||
--
|
||||
ALTER TABLE `ospos_item_kit_items`
|
||||
ADD CONSTRAINT `ospos_item_kit_items_ibfk_1` FOREIGN KEY (`item_kit_id`) REFERENCES `ospos_item_kits` (`item_kit_id`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `ospos_item_kit_items_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`) ON DELETE CASCADE;
|
||||
ADD CONSTRAINT `ospos_item_kit_items_ibfk_1` FOREIGN KEY (`item_kit_id`) REFERENCES `ospos_item_kits` (`item_kit_id`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `ospos_item_kit_items_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_permissions`
|
||||
--
|
||||
ALTER TABLE `ospos_permissions`
|
||||
ADD CONSTRAINT `ospos_permissions_ibfk_1` FOREIGN KEY (`module_id`) REFERENCES `ospos_modules` (`module_id`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `ospos_permissions_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`) ON DELETE CASCADE;
|
||||
ADD CONSTRAINT `ospos_permissions_ibfk_1` FOREIGN KEY (`module_id`) REFERENCES `ospos_modules` (`module_id`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `ospos_permissions_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_grants`
|
||||
--
|
||||
ALTER TABLE `ospos_grants`
|
||||
ADD CONSTRAINT `ospos_grants_ibfk_1` foreign key (`permission_id`) references `ospos_permissions` (`permission_id`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `ospos_grants_ibfk_2` foreign key (`person_id`) references `ospos_employees` (`person_id`) ON DELETE CASCADE;
|
||||
ADD CONSTRAINT `ospos_grants_ibfk_1` foreign key (`permission_id`) references `ospos_permissions` (`permission_id`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `ospos_grants_ibfk_2` foreign key (`person_id`) references `ospos_employees` (`person_id`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_receivings`
|
||||
--
|
||||
ALTER TABLE `ospos_receivings`
|
||||
ADD CONSTRAINT `ospos_receivings_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_receivings_ibfk_2` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_receivings_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_receivings_ibfk_2` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_receivings_items`
|
||||
--
|
||||
ALTER TABLE `ospos_receivings_items`
|
||||
ADD CONSTRAINT `ospos_receivings_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_receivings_items_ibfk_2` FOREIGN KEY (`receiving_id`) REFERENCES `ospos_receivings` (`receiving_id`);
|
||||
ADD CONSTRAINT `ospos_receivings_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_receivings_items_ibfk_2` FOREIGN KEY (`receiving_id`) REFERENCES `ospos_receivings` (`receiving_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales`
|
||||
--
|
||||
ALTER TABLE `ospos_sales`
|
||||
ADD CONSTRAINT `ospos_sales_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_sales_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_sales_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_sales_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales_items`
|
||||
--
|
||||
ALTER TABLE `ospos_sales_items`
|
||||
ADD CONSTRAINT `ospos_sales_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`),
|
||||
ADD CONSTRAINT `ospos_sales_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
|
||||
ADD CONSTRAINT `ospos_sales_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`),
|
||||
ADD CONSTRAINT `ospos_sales_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales_items_taxes`
|
||||
--
|
||||
ALTER TABLE `ospos_sales_items_taxes`
|
||||
ADD CONSTRAINT `ospos_sales_items_taxes_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_items` (`sale_id`),
|
||||
ADD CONSTRAINT `ospos_sales_items_taxes_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`);
|
||||
ADD CONSTRAINT `ospos_sales_items_taxes_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_items` (`sale_id`),
|
||||
ADD CONSTRAINT `ospos_sales_items_taxes_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales_payments`
|
||||
--
|
||||
ALTER TABLE `ospos_sales_payments`
|
||||
ADD CONSTRAINT `ospos_sales_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`);
|
||||
ADD CONSTRAINT `ospos_sales_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales_suspended`
|
||||
--
|
||||
ALTER TABLE `ospos_sales_suspended`
|
||||
ADD CONSTRAINT `ospos_sales_suspended_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_sales_suspended_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_sales_suspended_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_sales_suspended_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales_suspended_items`
|
||||
--
|
||||
ALTER TABLE `ospos_sales_suspended_items`
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`),
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`),
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales_suspended_items_taxes`
|
||||
--
|
||||
ALTER TABLE `ospos_sales_suspended_items_taxes`
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_taxes_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended_items` (`sale_id`),
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_taxes_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`);
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_taxes_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended_items` (`sale_id`),
|
||||
ADD CONSTRAINT `ospos_sales_suspended_items_taxes_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales_suspended_payments`
|
||||
--
|
||||
ALTER TABLE `ospos_sales_suspended_payments`
|
||||
ADD CONSTRAINT `ospos_sales_suspended_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`);
|
||||
ADD CONSTRAINT `ospos_sales_suspended_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_item_quantities`
|
||||
--
|
||||
ALTER TABLE `ospos_item_quantities`
|
||||
ADD CONSTRAINT `ospos_item_quantities_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_item_quantities_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`);
|
||||
ADD CONSTRAINT `ospos_item_quantities_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
|
||||
ADD CONSTRAINT `ospos_item_quantities_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_suppliers`
|
||||
--
|
||||
ALTER TABLE `ospos_suppliers`
|
||||
ADD CONSTRAINT `ospos_suppliers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
|
||||
ADD CONSTRAINT `ospos_suppliers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_giftcards`
|
||||
--
|
||||
ALTER TABLE `ospos_giftcards`
|
||||
ADD CONSTRAINT `ospos_giftcards_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_giftcards_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
|
||||
|
||||
@@ -198,6 +198,8 @@ CREATE TABLE `ospos_items` (
|
||||
`pic_filename` varchar(255) DEFAULT NULL,
|
||||
`allow_alt_description` tinyint(1) NOT NULL,
|
||||
`is_serialized` tinyint(1) NOT NULL,
|
||||
`stock_type` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
`item_type` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
`custom1` VARCHAR(25) NOT NULL,
|
||||
`custom2` VARCHAR(25) NOT NULL,
|
||||
@@ -246,6 +248,10 @@ CREATE TABLE `ospos_items_taxes` (
|
||||
CREATE TABLE `ospos_item_kits` (
|
||||
`item_kit_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`item_id` INT(10) NOT NULL DEFAULT 0,
|
||||
`kit_discount_percent` DECIMAL(15,2) NOT NULL DEFAULT 0.00,
|
||||
`price_option` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
`print_option` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
`description` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`item_kit_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
||||
@@ -265,6 +271,7 @@ CREATE TABLE `ospos_item_kit_items` (
|
||||
`item_kit_id` int(11) NOT NULL,
|
||||
`item_id` int(11) NOT NULL,
|
||||
`quantity` decimal(15,3) NOT NULL,
|
||||
`kit_sequence` INT(3) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`),
|
||||
KEY `ospos_item_kit_items_ibfk_2` (`item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -534,6 +541,7 @@ CREATE TABLE `ospos_sales_items` (
|
||||
`item_unit_price` decimal(15,2) NOT NULL,
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`item_location` int(11) NOT NULL,
|
||||
`print_option` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`),
|
||||
KEY `sale_id` (`sale_id`),
|
||||
KEY `item_id` (`item_id`),
|
||||
@@ -626,6 +634,7 @@ CREATE TABLE `ospos_sales_suspended_items` (
|
||||
`item_unit_price` decimal(15,2) NOT NULL,
|
||||
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
|
||||
`item_location` int(11) NOT NULL,
|
||||
`print_option` TINYINT(2) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`sale_id`,`item_id`,`line`),
|
||||
KEY `sale_id` (`sale_id`),
|
||||
KEY `item_id` (`item_id`)
|
||||
|
||||
@@ -12,6 +12,7 @@ Copyright (c) 2015 Toni Haryanto (aka yllumi)
|
||||
Copyright (c) 2016-2017 Ramkrishna Mondal (aka RamkrishnaMondal)
|
||||
Copyright (c) 2016 Rinaldy@dbarber (aka rnld26)
|
||||
Copyright (c) 2016 Jorge Colmenarez (aka jlctmaster), frontuari.com
|
||||
Copyright (c) 2017 Steve Ireland
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
Reference in New Issue
Block a user