Merge pull request #1169 from jlctmaster/dinner-tables

Support for Configurable Dinner Tables Feature
This commit is contained in:
FrancescoUK
2017-03-01 22:17:16 +00:00
committed by GitHub
25 changed files with 594 additions and 26 deletions

View File

@@ -11,9 +11,10 @@ Copyright (c) 2015 Aamir Shahzad (aka asakpke), RoshanTech.com
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) 2016-2017 Jorge Colmenarez (aka jlctmaster), frontuari.com
Copyright (c) 2017 Steve Ireland
Copyright (c) 2017 i92guboj
Copyright (c) 2017 Deep Shah (aka deepshah)
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

View File

@@ -132,4 +132,4 @@ $autoload['language'] = array();
|
| $autoload['model'] = array('first_model' => 'first');
*/
$autoload['model'] = array('Appconfig', 'Person', 'Customer', 'Employee', 'Module', 'Item', 'Item_taxes', 'Sale', 'Sale_suspended', 'Supplier', 'Inventory', 'Receiving', 'Giftcard', 'Item_kit', 'Item_kit_items', 'Stock_location', 'Item_quantity');
$autoload['model'] = array('Appconfig', 'Person', 'Customer', 'Employee', 'Module', 'Item', 'Item_taxes', 'Sale', 'Sale_suspended', 'Supplier', 'Inventory', 'Receiving', 'Giftcard', 'Item_kit', 'Item_kit_items', 'Stock_location', 'Item_quantity','Dinner_table');

View File

@@ -193,6 +193,7 @@ class Config extends Secure_Controller
public function index()
{
$data['stock_locations'] = $this->Stock_location->get_all()->result_array();
$data['dinner_tables'] = $this->Dinner_table->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();
@@ -376,9 +377,19 @@ class Config extends Secure_Controller
$this->load->view('partial/stock_locations', array('stock_locations' => $stock_locations));
}
public function dinner_tables()
{
$dinner_tables = $this->Dinner_table->get_all()->result_array();
$dinner_tables = $this->xss_clean($dinner_tables);
$this->load->view('partial/dinner_tables', array('dinner_tables' => $dinner_tables));
}
private function _clear_session_state()
{
$this->sale_lib->clear_sale_location();
$this->sale_lib->clear_table();
$this->sale_lib->clear_all();
$this->load->library('receiving_lib');
$this->receiving_lib->clear_stock_source();
@@ -419,6 +430,47 @@ class Config extends Secure_Controller
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
}
public function save_tables()
{
$this->db->trans_start();
$this->Appconfig->save('dinner_table_enable',$this->input->post('dinner_table_enable'));
$deleted_tables = $this->Dinner_table->get_all()->result_array();
$not_to_delete = array();
foreach($this->input->post() as $key => $value)
{
if (strstr($key, 'dinner_table') && $key != 'dinner_table_enable')
{
$dinner_table_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
$not_to_delete[] = $dinner_table_id;
// save or update
$table_data = array('name' => $value);
if ($this->Dinner_table->save($table_data, $dinner_table_id))
{
$this->_clear_session_state();
}
}
}
// all locations not available in post will be deleted now
foreach ($deleted_tables as $dinner_table)
{
if(!in_array($dinner_table['dinner_table_id'],$not_to_delete))
{
$this->Dinner_table->delete($dinner_table['dinner_table_id']);
}
}
$this->db->trans_complete();
$success = $this->db->trans_status();
echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
}
public function save_barcode()
{
$batch_save_data = array(

View File

@@ -146,6 +146,8 @@ class Sales extends Secure_Controller
{
$mode = $this->input->post('mode');
$this->sale_lib->set_mode($mode);
$dinner_table = $this->input->post('dinner_table');
$this->sale_lib->set_dinner_table($dinner_table);
}
elseif($this->Stock_location->is_allowed_location($stock_location, 'sales'))
{
@@ -387,6 +389,7 @@ class Sales extends Secure_Controller
public function complete()
{
$data = array();
$data['dinner_table'] = $this->sale_lib->get_dinner_table();
$data['cart'] = $this->sale_lib->get_cart();
$data['subtotal'] = $this->sale_lib->get_subtotal();
$data['discounted_subtotal'] = $this->sale_lib->get_subtotal(TRUE);
@@ -449,7 +452,7 @@ class Sales extends Secure_Controller
$data['quote_number'] = $quote_number;
// Save the data to the sales table
$data['sale_id_num'] = $this->Sale->save($data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $data['payments']);
$data['sale_id_num'] = $this->Sale->save($data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $data['payments'], $data['dinner_table']);
$data['sale_id'] = 'POS ' . $data['sale_id_num'];
// Resort and filter cart lines for printing
@@ -506,7 +509,7 @@ class Sales extends Secure_Controller
else
{
// Save the data to the sales table
$data['sale_id_num'] = $this->Sale->save($data['cart'], $customer_id, $employee_id, $data['comments'], null, $data['payments']);
$data['sale_id_num'] = $this->Sale->save($data['cart'], $customer_id, $employee_id, $data['comments'], null, $data['payments'], $data['dinner_table']);
$data['sale_id'] = 'POS ' . $data['sale_id_num'];
$data['cart'] = $this->sale_lib->sort_and_filter_cart($data['cart']);
@@ -818,6 +821,8 @@ class Sales extends Secure_Controller
'return' => $this->lang->line('sales_return'));
}
$data['mode'] = $this->sale_lib->get_mode();
$data['empty_tables'] = $this->sale_lib->get_empty_tables();
$data['selected_table'] = $this->sale_lib->get_dinner_table();
$data['stock_locations'] = $this->Stock_location->get_allowed_locations('sales');
$data['stock_location'] = $this->sale_lib->get_sale_location();
$data['subtotal'] = $this->sale_lib->get_subtotal(TRUE);
@@ -1005,6 +1010,7 @@ class Sales extends Secure_Controller
public function suspend()
{
$dinner_table = $this->sale_lib->get_dinner_table();
$cart = $this->sale_lib->get_cart();
$payments = $this->sale_lib->get_payments();
$employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
@@ -1016,7 +1022,7 @@ class Sales extends Secure_Controller
//SAVE sale to database
$data = array();
if ($this->Sale_suspended->save($cart, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments) == '-1')
if ($this->Sale_suspended->save($cart, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table) == '-1')
{
$data['error'] = $this->lang->line('sales_unsuccessfully_suspended_sale');
}

View File

@@ -77,6 +77,11 @@ $lang["config_default_tax_rate_2"] = "Tax 2 Rate";
$lang["config_default_tax_rate_number"] = "The default tax rate must be a number";
$lang["config_default_tax_rate_required"] = "The default tax rate is a required field";
$lang["config_default_tax_name_required"] = "The default tax name is a required field";
$lang["config_dinner_table"] = "Table";
$lang["config_dinner_table_enable"] = "Enable Dinner Tables";
$lang["config_dinner_table_duplicate"] = "Please use an unique table name";
$lang["config_dinner_table_invalid_chars"] = "The table name can not contain '_'";
$lang["config_dinner_table_required"] = "Table is a required field";
$lang["config_dot"] = "dot";
$lang["config_email"] = "Email";
$lang["config_email_configuration"] = "Email Configuration";
@@ -175,6 +180,8 @@ $lang["config_stock_location"] = "Stock location";
$lang["config_stock_location_duplicate"] = "Please use an unique location name";
$lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'";
$lang["config_stock_location_required"] = "Stock location is a required field";
$lang["config_table"] = "Table";
$lang["config_table_configuration"] = "Table Configuration";
$lang["config_takings_printer"] = "Takings Printer";
$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Tax Included";

View File

@@ -117,6 +117,7 @@ $lang["sales_successfully_updated"] = "Sale successfully updated";
$lang["sales_suspend_sale"] = "Suspend";
$lang["sales_suspended_sale_id"] = "ID";
$lang["sales_suspended_sales"] = "Suspended";
$lang["sales_table"] = "Table";
$lang["sales_tax"] = "Tax";
$lang["sales_tax_percent"] = "Tax %";
$lang["sales_total"] = "Total";

View File

@@ -77,6 +77,11 @@ $lang["config_default_tax_rate_2"] = "Impuesto 2";
$lang["config_default_tax_rate_number"] = "El Impuesto Predeterminado debe ser un número";
$lang["config_default_tax_rate_required"] = "El Impuesto Predeterminado es requerido";
$lang["config_default_tax_name_required"] = "El nombre del impuesto predeterminado es requerido";
$lang["config_dinner_table"] = "Mesa";
$lang["config_dinner_table_enable"] = "Activar Mesa de Restaurante";
$lang["config_dinner_table_duplicate"] = "Utilice un nombre de mesa único";
$lang["config_dinner_table_invalid_chars"] = "El nombre de la mesa no puede contener '_'";
$lang["config_dinner_table_required"] = "La mesa es un campo obligatorio";
$lang["config_dot"] = "punto";
$lang["config_email"] = "Email";
$lang["config_email_configuration"] = "Configuracion de correo";
@@ -170,6 +175,8 @@ $lang["config_stock_location"] = "Ubicación de Inventario";
$lang["config_stock_location_duplicate"] = "Por favor use un nombre de inventario único";
$lang["config_stock_location_invalid_chars"] = "Nombre de la Ubicación de Inventario no debe contener '_'";
$lang["config_stock_location_required"] = "Número de Ubicación de Inventario es requerido";
$lang["config_table"] = "Mesa";
$lang["config_table_configuration"] = "Configuración de Mesa";
$lang["config_takings_printer"] = "Impresion de retenciones";
$lang["config_tax_decimals"] = "Decimales de impuestos";
$lang["config_tax_included"] = "Impuestos incluidos";

View File

@@ -107,6 +107,7 @@ $lang["sales_successfully_updated"] = "La venta ha sido actualizada satisfactori
$lang["sales_suspend_sale"] = "Suspender Venta";
$lang["sales_suspended_sale_id"] = "ID de Venta Suspendida";
$lang["sales_suspended_sales"] = "Ventas Suspendidas";
$lang["sales_table"] = "Mesa";
$lang["sales_tax"] = "Impuesto";
$lang["sales_tax_percent"] = "% de Impuesto";
$lang["sales_total"] = "Total";

View File

@@ -388,6 +388,29 @@ class Sale_lib
$this->CI->session->unset_userdata('sales_mode');
}
public function get_dinner_table()
{
if(!$this->CI->session->userdata('dinner_table'))
{
if($this->CI->config->item('dinner_table_enable') == TRUE)
{
$this->set_dinner_table(1);
}
}
return $this->CI->session->userdata('dinner_table');
}
public function set_dinner_table($dinner_table)
{
$this->CI->session->set_userdata('dinner_table', $dinner_table);
}
public function clear_table()
{
$this->CI->session->unset_userdata('dinner_table');
}
public function get_sale_location()
{
if(!$this->CI->session->userdata('sales_location'))
@@ -746,11 +769,13 @@ class Sale_lib
$this->set_invoice_number($suspended_sale_info->invoice_number);
$this->set_quote_number($suspended_sale_info->quote_number);
$this->set_dinner_table($suspended_sale_info->dinner_table_id);
}
public function clear_all()
{
$this->set_invoice_number_enabled(FALSE);
$this->clear_table();
$this->empty_cart();
$this->clear_comment();
$this->clear_email_receipt();
@@ -924,6 +949,11 @@ class Sale_lib
return $total;
}
public function get_empty_tables()
{
return $this->CI->Dinner_table->get_empty_tables();
}
}
?>

View File

@@ -0,0 +1,96 @@
<?php
class Dinner_table extends CI_Model
{
public function exists($dinner_table_id)
{
$this->db->from('dinner_tables');
$this->db->where('dinner_table_id', $dinner_table_id);
return ($this->db->get()->num_rows() >= 1);
}
public function save(&$table_data, $dinner_table_id)
{
$name = $$table_data['name'];
if(!$this->exists($dinner_table_id))
{
$this->db->trans_start();
$location_data = array('name'=>$name, 'deleted'=>0);
$this->db->insert('dinner_tables', $table_data);
$dinner_table_id = $this->db->insert_id();
$this->db->trans_complete();
return $this->db->trans_status();
}
else
{
$this->db->where('dinner_table_id', $dinner_table_id);
return $this->db->update('dinner_tables', $table_data);
}
}
/*
Get empty tables
*/
public function get_empty_tables()
{
$this->db->from('dinner_tables');
$this->db->where('status', 0);
$this->db->where('deleted', 0);
$empty_tables = $this->db->get()->result_array();
$empty_tables_array = array();
foreach($empty_tables as $empty_table)
{
$empty_tables_array[$empty_table['dinner_table_id']] = $empty_table['name'];
}
return $empty_tables_array;
}
public function get_name($dinner_table_id)
{
$this->db->from('dinner_tables');
$this->db->where('dinner_table_id',$dinner_table_id);
return $this->db->get()->row()->name;
}
public function get_all()
{
$this->db->from('dinner_tables');
return $this->db->get();
}
public function get_undeleted_all()
{
$this->db->from('dinner_tables');
$this->db->where('deleted', 0);
return $this->db->get();
}
/*
Deletes one table
*/
public function delete($dinner_table_id)
{
$this->db->trans_start();
$this->db->where('dinner_table_id', $dinner_table_id);
$this->db->update('dinner_tables', array('deleted' => 1));
$this->db->trans_complete();
return $this->db->trans_status();
}
}
?>

View File

@@ -486,7 +486,7 @@ class Sale extends CI_Model
return $success;
}
public function save($items, $customer_id, $employee_id, $comment, $invoice_number, $payments, $sale_id = FALSE)
public function save($items, $customer_id, $employee_id, $comment, $invoice_number, $payments, $dinner_table, $sale_id = FALSE)
{
if(count($items) == 0)
{
@@ -498,7 +498,8 @@ class Sale extends CI_Model
'customer_id' => $this->Customer->exists($customer_id) ? $customer_id : null,
'employee_id' => $employee_id,
'comment' => $comment,
'invoice_number' => $invoice_number
'invoice_number' => $invoice_number,
'dinner_table_id'=> $dinner_table
);
// Run these queries as a transaction, we want to make sure we do all or nothing

View File

@@ -52,20 +52,30 @@ class Sale_suspended extends CI_Model
return $this->db->update('sales_suspended', $sale_data);
}
public function save($items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $sale_id = FALSE)
public function save($items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sale_id = FALSE)
{
if(count($items) == 0)
{
return -1;
}
if($dinner_table > 2) //not delivery or take away
{
$table_status = 1;
}
else
{
$table_status = 0;
}
$sales_data = array(
'sale_time' => date('Y-m-d H:i:s'),
'customer_id' => $this->Customer->exists($customer_id) ? $customer_id : null,
'employee_id' => $employee_id,
'comment' => $comment,
'invoice_number' => $invoice_number,
'quote_number' => $quote_number,
'quote_number' => $quote_number,
'dinner_table_id' => $dinner_table
);
//Run these queries as a transaction, we want to make sure we do all or nothing
@@ -122,6 +132,13 @@ class Sale_suspended extends CI_Model
}
}
$dinner_table_data = array(
'status' => $table_status
);
$this->db->where('dinner_table_id',$dinner_table);
$this->db->update('dinner_tables', $dinner_table_data);
$this->db->trans_complete();
if($this->db->trans_status() === FALSE)
@@ -137,6 +154,14 @@ class Sale_suspended extends CI_Model
//Run these queries as a transaction, we want to make sure we do all or nothing
$this->db->trans_start();
$dinner_table = $this->get_dinner_table($sale_id);
$dinner_table_data = array(
'status' => 0
);
$this->db->where('dinner_table_id',$dinner_table);
$this->db->update('dinner_tables', $dinner_table_data);
$this->db->delete('sales_suspended_payments', array('sale_id' => $sale_id));
$this->db->delete('sales_suspended_items_taxes', array('sale_id' => $sale_id));
$this->db->delete('sales_suspended_items', array('sale_id' => $sale_id));
@@ -184,5 +209,13 @@ class Sale_suspended extends CI_Model
return $this->db->get()->row()->comment;
}
public function get_dinner_table($sale_id)
{
$this->db->from('sales_suspended');
$this->db->where('sale_id', $sale_id);
return $this->db->get()->row()->dinner_table_id;
}
}
?>

View File

@@ -16,6 +16,9 @@
<li role="presentation">
<a data-toggle="tab" href="#stock_tab" title="<?php echo $this->lang->line('config_location_configuration'); ?>"><?php echo $this->lang->line('config_location'); ?></a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#table_tab" title="<?php echo $this->lang->line('config_table_configuration'); ?>"><?php echo $this->lang->line('config_table'); ?></a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#receipt_tab" title="<?php echo $this->lang->line('config_receipt_configuration'); ?>"><?php echo $this->lang->line('config_receipt'); ?></a>
</li>
@@ -49,6 +52,9 @@
<div class="tab-pane" id="stock_tab">
<?php $this->load->view("configs/stock_config"); ?>
</div>
<div class="tab-pane" id="table_tab">
<?php $this->load->view("configs/table_config"); ?>
</div>
<div class="tab-pane" id="receipt_tab">
<?php $this->load->view("configs/receipt_config"); ?>
</div>

View File

@@ -0,0 +1,155 @@
<?php echo form_open('config/save_tables/', array('id' => 'table_config_form', 'class' => 'form-horizontal')); ?>
<div id="config_wrapper">
<fieldset id="config_info">
<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
<ul id="table_error_message_box" class="error_message_box"></ul>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_dinner_table_enable'), 'dinner_table_enable', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-1'>
<?php echo form_checkbox(array(
'name' => 'dinner_table_enable',
'value' => 'dinner_table_enable',
'id' => 'dinner_table_enable',
'checked' => $this->config->item('dinner_table_enable')));?>
</div>
</div>
<div id="dinner_tables">
<?php $this->load->view('partial/dinner_tables', array('dinner_tables' => $dinner_tables)); ?>
</div>
<?php echo form_submit(array(
'name' => 'submit',
'id' => 'submit',
'value'=>$this->lang->line('common_submit'),
'class' => 'btn btn-primary btn-sm pull-right')); ?>
</fieldset>
</div>
<?php echo form_close(); ?>
<script type="text/javascript">
//validation and submit handling
$(document).ready(function()
{
var enable_disable_dinner_table_enable = (function() {
var dinner_table_enable = $("#dinner_table_enable").is(":checked");
$("input[name*='dinner_table']:not(input[name=dinner_table_enable])").prop("disabled", !dinner_table_enable);
if(dinner_table_enable)
{
$(".add_dinner_table, .remove_dinner_table").show();
}
else
{
$(".add_dinner_table, .remove_dinner_table").hide();
}
return arguments.callee;
})();
$("#dinner_table_enable").change(enable_disable_dinner_table_enable);
var table_count = <?php echo sizeof($dinner_tables); ?>;
var hide_show_remove = function() {
if ($("input[name*='dinner_tables']:enabled").length > 1)
{
$(".remove_dinner_tables").show();
}
else
{
$(".remove_dinner_tables").hide();
}
};
var add_dinner_table = function() {
var id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
var new_block_id = 'dinner_table_' + ++id;
$(new_block).find('label').html("<?php echo $this->lang->line('config_dinner_table'); ?> " + ++table_count).attr('for', new_block_id).attr('class', 'control-label col-xs-2');
$(new_block).find('input').attr('id', new_block_id).removeAttr('disabled').attr('name', new_block_id).attr('class', 'form-control input-sm').val('');
hide_show_remove();
};
var remove_dinner_table = function() {
$(this).parent().remove();
hide_show_remove();
};
var init_add_remove_tables = function() {
$('.add_dinner_table').click(add_dinner_table);
$('.remove_dinner_table').click(remove_dinner_table);
hide_show_remove();
// set back disabled state
enable_disable_dinner_table_enable();
};
init_add_remove_tables();
var duplicate_found = false;
// run validator once for all fields
$.validator.addMethod('dinner_table' , function(value, element) {
var value_count = 0;
$("input[name*='dinner_table']:not(input[name=dinner_table_enable])").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});
return value_count < 2;
}, "<?php echo $this->lang->line('config_dinner_table_duplicate'); ?>");
$.validator.addMethod('valid_chars', function(value, element) {
return value.indexOf('_') === -1;
}, "<?php echo $this->lang->line('config_dinner_table_invalid_chars'); ?>");
$('#table_config_form').validate($.extend(form_support.handler, {
submitHandler: function(form) {
$(form).ajaxSubmit({
beforeSerialize: function(arr, $form, options) {
$("input[name*='dinner_table']:not(input[name=dinner_table_enable])").prop("disabled", false);
return true;
},
success: function(response) {
$.notify({ message: response.message }, { type: response.success ? 'success' : 'danger'});
$("#dinner_tables").load('<?php echo site_url("config/dinner_tables"); ?>', init_add_remove_tables);
},
dataType: 'json'
});
},
errorLabelContainer: "#table_error_message_box",
rules:
{
<?php
$i = 0;
foreach($dinner_tables as $dinner_table=>$table)
{
?>
<?php echo 'dinner_table_' . ++$i ?>:
{
required: true,
dinner_table: true,
valid_chars: true
},
<?php
}
?>
},
messages:
{
<?php
$i = 0;
foreach($dinner_tables as $dinner_table=>$table)
{
?>
<?php echo 'dinner_table_' . ++$i ?>: "<?php echo $this->lang->line('config_dinner_table_required'); ?>",
<?php
}
?>
}
}));
});
</script>

View File

@@ -0,0 +1,29 @@
<?php
$i = 0;
foreach($dinner_tables as $dinner_tables=>$table)
{
$dinner_table_id = $table['dinner_table_id'];
$dinner_table_name = $table['name'];
++$i;
?>
<div class="form-group form-group-sm" style="<?php echo $table['deleted'] ? 'display:none;' : 'display:block;' ?>">
<?php echo form_label($this->lang->line('config_dinner_table') . ' ' . $i, 'dinner_table_' . $i, array('class'=>'required control-label col-xs-2')); ?>
<div class='col-xs-2'>
<?php $form_data = array(
'name'=>'dinner_table_' . $dinner_table_id,
'id'=>'dinner_table_' . $dinner_table_id,
'class'=>'dinner_table valid_chars form-control input-sm required',
'value'=>$dinner_table_name
);
$table['deleted'] && $form_data['disabled'] = 'disabled';
echo form_input($form_data);
?>
</div>
<span class="add_dinner_table glyphicon glyphicon-plus" style="padding-top: 0.5em;"></span>
<span>&nbsp;&nbsp;</span>
<span class="remove_dinner_table glyphicon glyphicon-minus" style="padding-top: 0.5em;"></span>
</div>
<?php
}
?>

View File

@@ -30,8 +30,18 @@ if (isset($success))
<li class="pull-left">
<?php echo form_dropdown('mode', $modes, $mode, array('onchange'=>"$('#mode_form').submit();", 'class'=>'selectpicker show-menu-arrow', 'data-style'=>'btn-default btn-sm', 'data-width'=>'fit')); ?>
</li>
<?php
if($this->config->item('dinner_table_enable') == TRUE)
{
?>
<li class="pull-left first_li">
<label class="control-label"><?php echo $this->lang->line('sales_table'); ?></label>
</li>
<li class="pull-left">
<?php echo form_dropdown('dinner_table', $empty_tables, $selected_table,array('onchange'=>"$('#mode_form').submit();", 'class'=>'selectpicker show-menu-arrow', 'data-style'=>'btn-default btn-sm', 'data-width'=>'fit')); ?>
</li>
<?php
}
if (count($stock_locations) > 1)
{
?>

View File

@@ -3,6 +3,7 @@
<tr bgcolor="#CCC">
<th><?php echo $this->lang->line('sales_suspended_sale_id'); ?></th>
<th><?php echo $this->lang->line('sales_date'); ?></th>
<th><?php echo $this->lang->line('sales_table'); ?></th>
<th><?php echo $this->lang->line('sales_customer'); ?></th>
<th><?php echo $this->lang->line('sales_comments'); ?></th>
<th><?php echo $this->lang->line('sales_unsuspend_and_delete'); ?></th>
@@ -16,6 +17,7 @@
<tr>
<td><?php echo $suspended_sale['sale_id'];?></td>
<td><?php echo date($this->config->item('dateformat'), strtotime($suspended_sale['sale_time']));?></td>
<td><?php echo $this->Dinner_table->get_name($suspended_sale['dinner_table_id']);?></td>
<td>
<?php
if (isset($suspended_sale['customer_id']))

View File

@@ -23,15 +23,48 @@ ALTER TABLE `ospos_sales_suspended`
ALTER TABLE `ospos_sales_suspended_items`
ADD COLUMN `print_option` TINYINT(2) NOT NULL DEFAULT 0;
-- alter pic_id field, to rather contain a file name
ALTER TABLE `ospos_items` CHANGE `pic_id` `pic_filename` VARCHAR(255);
--
-- Table structure for table `ospos_dinner_tables`
--
CREATE TABLE IF NOT EXISTS `ospos_dinner_tables` (
`dinner_table_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0',
`deleted` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`dinner_table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted`) VALUES
(1, 'Delivery', 0, 0),
(2, 'Take Away', 0, 0);
-- alter ospos_sales table
ALTER TABLE `ospos_sales`
ADD COLUMN `dinner_table_id` int(11) NULL AFTER `invoice_number`;
ALTER TABLE `ospos_sales`
ADD KEY `dinner_table_id` (`dinner_table_id`),
ADD CONSTRAINT `ospos_sales_ibfk_3` FOREIGN KEY (`dinner_table_id`) REFERENCES `ospos_dinner_tables` (`dinner_table_id`);
-- alter ospos_sales_suspended table
ALTER TABLE `ospos_sales_suspended`
ADD COLUMN `dinner_table_id` int(11) NULL AFTER `quote_number`;
ALTER TABLE `ospos_sales_suspended`
ADD KEY `dinner_table_id` (`dinner_table_id`),
ADD CONSTRAINT `ospos_sales_suspended_ibfk_3` FOREIGN KEY (`dinner_table_id`) REFERENCES `ospos_dinner_tables` (`dinner_table_id`);
-- add enabled dinner tables key into config
INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
('date_or_time_format', ''),
('sales_quote_format', 'Q%y{QSEQ:6}'),
('default_register_mode', 'sale'),
('last_used_invoice_number', '0'),
('last_used_quote_number', '0'),
('line_sequence', '0');
-- alter pic_id field, to rather contain a file name
ALTER TABLE `ospos_items` CHANGE `pic_id` `pic_filename` VARCHAR(255);
('line_sequence', '0'),
('dinner_table_enable','');

View File

@@ -74,7 +74,8 @@ ALTER TABLE `ospos_receivings_items`
--
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_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`),
ADD CONSTRAINT `ospos_sales_ibfk_3` FOREIGN KEY (`dinner_table_id`) REFERENCES `ospos_dinner_tables` (`dinner_table_id`);
--
-- Constraints for table `ospos_sales_items`
@@ -102,7 +103,8 @@ ALTER TABLE `ospos_sales_payments`
--
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_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`),
ADD CONSTRAINT `ospos_sales_suspended_ibfk_3` FOREIGN KEY (`dinner_table_id`) REFERENCES `ospos_dinner_tables` (`dinner_table_id`);
--
-- Constraints for table `ospos_sales_suspended_items`

View File

@@ -518,10 +518,12 @@ CREATE TABLE `ospos_sales` (
`comment` text NOT NULL,
`invoice_number` varchar(32) DEFAULT NULL,
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
`dinner_table_id` int(11) NULL,
PRIMARY KEY (`sale_id`),
KEY `customer_id` (`customer_id`),
KEY `employee_id` (`employee_id`),
KEY `sale_time` (`sale_time`),
KEY `dinner_table_id` (`dinner_table_id`),
UNIQUE KEY `invoice_number` (`invoice_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
@@ -614,9 +616,11 @@ CREATE TABLE `ospos_sales_suspended` (
`invoice_number` varchar(32) DEFAULT NULL,
`quote_number` varchar(32) DEFAULT NULL,
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
`dinner_table_id` int(11) NULL,
PRIMARY KEY (`sale_id`),
KEY `customer_id` (`customer_id`),
KEY `employee_id` (`employee_id`)
KEY `employee_id` (`employee_id`),
KEY `dinner_table_id` (`dinner_table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
--
@@ -748,6 +752,28 @@ CREATE TABLE `ospos_suppliers` (
-- Dumping data for table `ospos_suppliers`
--
-- --------------------------------------------------------
--
-- Table structure for table `ospos_dinner_tables`
--
CREATE TABLE `ospos_dinner_tables` (
`dinner_table_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0',
`deleted` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`dinner_table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `ospos_dinner_tables`
--
INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted`) VALUES
(1, 'Delivery', 0, 0),
(2, 'Take Away', 0, 0);
--
-- Constraints for dumped tables
@@ -825,7 +851,8 @@ ALTER TABLE `ospos_receivings_items`
--
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_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`),
ADD CONSTRAINT `ospos_sales_ibfk_3` FOREIGN KEY (`dinner_table_id`) REFERENCES `ospos_dinner_tables` (`dinner_table_id`);
--
-- Constraints for table `ospos_sales_items`
@@ -853,7 +880,8 @@ ALTER TABLE `ospos_sales_payments`
--
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_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`),
ADD CONSTRAINT `ospos_sales_suspended_ibfk_3` FOREIGN KEY (`dinner_table_id`) REFERENCES `ospos_dinner_tables` (`dinner_table_id`);
--
-- Constraints for table `ospos_sales_suspended_items`

View File

@@ -514,10 +514,12 @@ CREATE TABLE `ospos_sales` (
`comment` text NOT NULL,
`invoice_number` varchar(32) DEFAULT NULL,
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
`dinner_table_id` int(11) NULL,
PRIMARY KEY (`sale_id`),
KEY `customer_id` (`customer_id`),
KEY `employee_id` (`employee_id`),
KEY `sale_time` (`sale_time`),
KEY `dinner_table_id` (`dinner_table_id`),
UNIQUE KEY `invoice_number` (`invoice_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
@@ -609,9 +611,11 @@ CREATE TABLE `ospos_sales_suspended` (
`comment` text NOT NULL,
`invoice_number` varchar(32) DEFAULT NULL,
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
`dinner_table_id` int(11) NULL,
PRIMARY KEY (`sale_id`),
KEY `customer_id` (`customer_id`),
KEY `employee_id` (`employee_id`)
KEY `employee_id` (`employee_id`),
KEY `dinner_table_id` (`dinner_table_id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
--
@@ -743,6 +747,28 @@ CREATE TABLE `ospos_suppliers` (
-- Dumping data for table `ospos_suppliers`
--
-- --------------------------------------------------------
--
-- Table structure for table `ospos_dinner_tables`
--
CREATE TABLE `ospos_dinner_tables` (
`dinner_table_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0',
`deleted` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`dinner_table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `ospos_dinner_tables`
--
INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted`) VALUES
(1, 'Delivery', 0, 0),
(2, 'Take Away', 0, 0);
--
-- This migration script should be run after creating tables with the regular database script and before applying the constraints.
@@ -909,6 +935,13 @@ SELECT `item_id`, 1, `quantity` FROM `phppos`.`phppos_items`;
INSERT INTO `ospos_suppliers` (`person_id`, `company_name`, `account_number`, `deleted`)
SELECT `person_id`, `company_name`, `account_number`, `deleted` FROM `phppos`.phppos_suppliers;
--
-- Copy data to table `ospos_dinner_tables`
--
INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted`)
SELECT `dinner_table_id`, `name`, `status`, `deleted` FROM `phppos`.phppos_dinner_tables;
--
-- Constraints for dumped tables
@@ -986,7 +1019,8 @@ ALTER TABLE `ospos_receivings_items`
--
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_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`),
ADD CONSTRAINT `ospos_sales_ibfk_3` FOREIGN KEY (`dinner_table_id`) REFERENCES `ospos_dinner_tables` (`dinner_table_id`);
--
-- Constraints for table `ospos_sales_items`
@@ -1014,7 +1048,8 @@ ALTER TABLE `ospos_sales_payments`
--
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_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`),
ADD CONSTRAINT `ospos_sales_suspended_ibfk_3` FOREIGN KEY (`dinner_table_id`) REFERENCES `ospos_dinner_tables` (`dinner_table_id`);
--
-- Constraints for table `ospos_sales_suspended_items`

View File

@@ -163,3 +163,9 @@ SELECT `item_id`, 1, `quantity` FROM `phppos`.`phppos_items`;
INSERT INTO `ospos_suppliers` (`person_id`, `company_name`, `account_number`, `deleted`)
SELECT `person_id`, `company_name`, `account_number`, `deleted` FROM `phppos`.phppos_suppliers;
--
-- Copy data to table `ospos_dinner_tables`
--
INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted`)
SELECT `dinner_table_id`, `name`, `status`, `deleted` FROM `phppos`.phppos_dinner_tables;

View File

@@ -26,3 +26,4 @@ RENAME TABLE `ospos_sales_suspended_items_taxes` TO `phppos_sales_suspended_item
RENAME TABLE `ospos_sales_suspended_payments` TO `phppos_sales_suspended_payments`;
RENAME TABLE `ospos_sessions` TO `phppos_sessions`;
RENAME TABLE `ospos_suppliers` TO `phppos_suppliers`;
RENAME TABLE `ospos_dinner_tables` TO `phppos_dinner_tables`;

View File

@@ -518,10 +518,12 @@ CREATE TABLE `ospos_sales` (
`comment` text NOT NULL,
`invoice_number` varchar(32) DEFAULT NULL,
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
`dinner_table_id` int(11) NULL,
PRIMARY KEY (`sale_id`),
KEY `customer_id` (`customer_id`),
KEY `employee_id` (`employee_id`),
KEY `sale_time` (`sale_time`),
KEY `dinner_table_id` (`dinner_table_id`),
UNIQUE KEY `invoice_number` (`invoice_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
@@ -614,9 +616,11 @@ CREATE TABLE `ospos_sales_suspended` (
`invoice_number` varchar(32) DEFAULT NULL,
`quote_number` varchar(32) DEFAULT NULL,
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
`dinner_table_id` int(11) NULL,
PRIMARY KEY (`sale_id`),
KEY `customer_id` (`customer_id`),
KEY `employee_id` (`employee_id`)
KEY `employee_id` (`employee_id`),
KEY `dinner_table_id` (`dinner_table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
--
@@ -748,3 +752,24 @@ CREATE TABLE `ospos_suppliers` (
-- Dumping data for table `ospos_suppliers`
--
-- --------------------------------------------------------
--
-- Table structure for table `ospos_dinner_tables`
--
CREATE TABLE `ospos_dinner_tables` (
`dinner_table_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0',
`deleted` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`dinner_table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `ospos_dinner_tables`
--
INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted`) VALUES
(1, 'Delivery', 0, 0),
(2, 'Take Away', 0, 0);

View File

@@ -11,9 +11,10 @@ Copyright (c) 2015 Aamir Shahzad (aka asakpke), RoshanTech.com
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) 2016-2017 Jorge Colmenarez (aka jlctmaster), frontuari.com
Copyright (c) 2017 Steve Ireland
Copyright (c) 2017 i92guboj
Copyright (c) 2017 Deep Shah (aka deepshah)
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