mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-04 07:12:48 -04:00
Add support for Work Orders
This commit is contained in:
committed by
FrancescoUK
parent
af84a617de
commit
36d549cb9b
@@ -844,7 +844,10 @@ class Config extends Secure_Controller
|
||||
'invoice_email_message' => $this->input->post('invoice_email_message'),
|
||||
'line_sequence' => $this->input->post('line_sequence'),
|
||||
'last_used_invoice_number' =>$this->input->post('last_used_invoice_number'),
|
||||
'last_used_quote_number' =>$this->input->post('last_used_quote_number')
|
||||
'last_used_quote_number' =>$this->input->post('last_used_quote_number'),
|
||||
'work_order_enable' => $this->input->post('work_order_enable') != NULL,
|
||||
'work_order_format' => $this->input->post('work_order_format'),
|
||||
'last_used_work_order_number' =>$this->input->post('last_used_work_order_number')
|
||||
);
|
||||
|
||||
$result = $this->Appconfig->batch_save($batch_save_data);
|
||||
|
||||
@@ -147,13 +147,36 @@ class Sales extends Secure_Controller
|
||||
|
||||
public function change_mode()
|
||||
{
|
||||
$mode = $this->input->post('mode');
|
||||
$this->sale_lib->set_mode($mode);
|
||||
|
||||
if($mode == 'sale')
|
||||
{
|
||||
$this->sale_lib->set_sale_type(SALE_TYPE_POS);
|
||||
}
|
||||
else if($mode == 'sale_quote')
|
||||
{
|
||||
$this->sale_lib->set_sale_type(SALE_TYPE_QUOTE);
|
||||
}
|
||||
else if($mode == 'sale_work_order')
|
||||
{
|
||||
$this->sale_lib->set_sale_type(SALE_TYPE_WORK_ORDER);
|
||||
}
|
||||
else if($mode == 'sale_invoice')
|
||||
{
|
||||
$this->sale_lib->set_sale_type(SALE_TYPE_INVOICE);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sale_lib->set_sale_type(SALE_SALE);
|
||||
}
|
||||
|
||||
$stock_location = $this->input->post('stock_location');
|
||||
if(!$stock_location || $stock_location == $this->sale_lib->get_sale_location())
|
||||
{
|
||||
$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'))
|
||||
{
|
||||
@@ -163,6 +186,30 @@ class Sales extends Secure_Controller
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
public function change_register_mode($sale_type)
|
||||
{
|
||||
if($sale_type == SALE_TYPE_POS)
|
||||
{
|
||||
$this->sale_lib->set_mode('sale');
|
||||
}
|
||||
elseif($sale_type == SALE_TYPE_QUOTE)
|
||||
{
|
||||
$this->sale_lib->set_mode('sale_quote');
|
||||
}
|
||||
elseif($sale_type == SALE_TYPE_WORK_ORDER)
|
||||
{
|
||||
$this->sale_lib->set_mode('sale_work_order');
|
||||
}
|
||||
elseif($sale_type == SALE_TYPE_INVOICE)
|
||||
{
|
||||
$this->sale_lib->set_mode('sale_invoice');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sale_lib->set_mode('sale');
|
||||
}
|
||||
}
|
||||
|
||||
public function set_comment()
|
||||
{
|
||||
$this->sale_lib->set_comment($this->input->post('comment'));
|
||||
@@ -189,6 +236,11 @@ class Sales extends Secure_Controller
|
||||
$this->sale_lib->set_print_after_sale($this->input->post('sales_print_after_sale'));
|
||||
}
|
||||
|
||||
public function set_price_work_orders()
|
||||
{
|
||||
$this->sale_lib->set_price_work_orders($this->input->post('price_work_orders'));
|
||||
}
|
||||
|
||||
public function set_email_receipt()
|
||||
{
|
||||
$this->sale_lib->set_email_receipt($this->input->post('email_receipt'));
|
||||
@@ -443,6 +495,8 @@ class Sales extends Secure_Controller
|
||||
|
||||
public function complete()
|
||||
{
|
||||
$sale_id = $this->sale_lib->get_sale_id();
|
||||
$sale_type = $this->sale_lib->get_sale_type();
|
||||
$data = array();
|
||||
$data['dinner_table'] = $this->sale_lib->get_dinner_table();
|
||||
$data['cart'] = $this->sale_lib->get_cart();
|
||||
@@ -463,10 +517,15 @@ class Sales extends Secure_Controller
|
||||
$data['cur_giftcard_value'] = $this->sale_lib->get_giftcard_remainder();
|
||||
$data['cur_rewards_value'] = $this->sale_lib->get_rewards_remainder();
|
||||
$data['print_after_sale'] = $this->sale_lib->is_print_after_sale();
|
||||
$data['price_work_orders'] = $this->sale_lib->is_price_work_orders();
|
||||
$data['email_receipt'] = $this->sale_lib->get_email_receipt();
|
||||
$customer_id = $this->sale_lib->get_customer();
|
||||
$data["invoice_number"] = $this->sale_lib->get_invoice_number();
|
||||
$data["quote_number"] = $this->sale_lib->get_quote_number();
|
||||
$invoice_number = $this->sale_lib->get_invoice_number();
|
||||
$data["invoice_number"] = $invoice_number;
|
||||
$work_order_number = $this->sale_lib->get_work_order_number();
|
||||
$data["work_order_number"] = $work_order_number;
|
||||
$quote_number = $this->sale_lib->get_quote_number();
|
||||
$data["quote_number"] = $quote_number;
|
||||
$customer_info = $this->_load_customer_data($customer_id, $data);
|
||||
if($customer_info != NULL)
|
||||
{
|
||||
@@ -501,13 +560,26 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
$data['amount_change'] = $data['amount_due'] * -1;
|
||||
|
||||
if($this->sale_lib->is_invoice_mode() || $data['invoice_number_enabled'] == TRUE)
|
||||
$data['print_price_info'] = TRUE;
|
||||
|
||||
if($this->sale_lib->is_sale_by_receipt_mode() && $this->input->post('sales_invoice_enable') == '1' )
|
||||
{
|
||||
$pos_invoice = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pos_invoice = FALSE;
|
||||
}
|
||||
|
||||
if($this->sale_lib->is_invoice_mode() || $pos_invoice)
|
||||
{
|
||||
// generate final invoice number (if using the invoice in sales by receipt mode then the invoice number can be manually entered or altered in some way
|
||||
if($this->sale_lib->is_sale_by_receipt_mode())
|
||||
if($pos_invoice)
|
||||
{
|
||||
// The user can retain the default encoded format or can manually override it. It still passes through the rendering step.
|
||||
$this->sale_lib->set_invoice_number($this->input->post('invoice_number'), $keep_custom = TRUE);
|
||||
$invoice_format = $this->sale_lib->get_invoice_number();
|
||||
// If the user blanks out the invoice number and doesn't put anything in there then revert back to the default format encoding
|
||||
if(empty($invoice_format))
|
||||
{
|
||||
$invoice_format = $this->config->item('sales_invoice_format');
|
||||
@@ -517,10 +589,11 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
$invoice_format = $this->config->item('sales_invoice_format');
|
||||
}
|
||||
$invoice_number = $this->token_lib->render($invoice_format);
|
||||
|
||||
// TODO If duplicate invoice then determine the number of employees and repeat until until success or tried the number of employees (if QSEQ was used).
|
||||
if($this->Sale->check_invoice_number_exists($invoice_number))
|
||||
$invoice_number = $this->token_lib->render($invoice_format);
|
||||
$data['invoice_number'] = $invoice_number;
|
||||
|
||||
if($sale_id == -1 && $this->Sale->check_invoice_number_exists($invoice_number))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_invoice_number_duplicate');
|
||||
$this->_reload($data);
|
||||
@@ -529,9 +602,10 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
$data['invoice_number'] = $invoice_number;
|
||||
$data['sale_status'] = COMPLETED;
|
||||
$sale_type = SALE_TYPE_INVOICE;
|
||||
|
||||
// Save the data to the sales table
|
||||
$data['sale_id_num'] = $this->Sale->save($data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $data["quote_number"], $data['payments'], $data['dinner_table'], $data['taxes']);
|
||||
$data['sale_id_num'] = $this->Sale->save($sale_id, $data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $work_order_number, $quote_number, $sale_type, $data['payments'], $data['dinner_table'], $data['taxes']);
|
||||
$data['sale_id'] = 'POS ' . $data['sale_id_num'];
|
||||
|
||||
// Resort and filter cart lines for printing
|
||||
@@ -551,10 +625,53 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($this->sale_lib->is_work_order_mode())
|
||||
{
|
||||
|
||||
if(!($data['price_work_orders'] == 1))
|
||||
{
|
||||
$data['print_price_info'] = FALSE;
|
||||
}
|
||||
|
||||
$data['sales_work_order'] = $this->lang->line('sales_work_order');
|
||||
$data['work_order_number_label'] = $this->lang->line('sales_work_order_number');
|
||||
|
||||
if($work_order_number == NULL)
|
||||
{
|
||||
// generate work order number
|
||||
$work_order_format = $this->config->item('work_order_format');
|
||||
$work_order_number = $this->token_lib->render($work_order_format);
|
||||
}
|
||||
|
||||
if($sale_id == -1 && $this->Sale->check_work_order_number_exists($work_order_number))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_work_order_number_duplicate');
|
||||
$this->_reload($data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['work_order_number'] = $work_order_number;
|
||||
$data['sale_status'] = SUSPENDED;
|
||||
$sale_type = SALE_TYPE_WORK_ORDER;
|
||||
|
||||
$data['sale_id_num'] = $this->Sale->save($sale_id, $data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $work_order_number, $quote_number, $sale_type, $data['payments'], $data['dinner_table'], $data['taxes']);
|
||||
$this->sale_lib->set_suspended_id($data['sale_id_num']);
|
||||
|
||||
$data['cart'] = $this->sale_lib->sort_and_filter_cart($data['cart']);
|
||||
|
||||
$data = $this->xss_clean($data);
|
||||
|
||||
$data['barcode'] = NULL;
|
||||
|
||||
$this->load->view('sales/work_order', $data);
|
||||
$this->sale_lib->clear_mode();
|
||||
$this->sale_lib->clear_all();
|
||||
}
|
||||
}
|
||||
elseif($this->sale_lib->is_quote_mode())
|
||||
{
|
||||
$invoice_number = NULL;
|
||||
$quote_number = $this->sale_lib->get_quote_number();
|
||||
$data['sales_quote'] = $this->lang->line('sales_quote');
|
||||
$data['quote_number_label'] = $this->lang->line('sales_quote_number');
|
||||
|
||||
if($quote_number == NULL)
|
||||
{
|
||||
@@ -563,19 +680,18 @@ class Sales extends Secure_Controller
|
||||
$quote_number = $this->token_lib->render($quote_format);
|
||||
}
|
||||
|
||||
// TODO If duplicate quote then determine the number of employees and repeat until until success or tried the number of employees (if QSEQ was used).
|
||||
if($this->Sale->check_quote_number_exists($quote_number))
|
||||
if($sale_id == -1 && $this->Sale->check_quote_number_exists($quote_number))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_quote_number_duplicate');
|
||||
$this->_reload($data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['invoice_number'] = $invoice_number;
|
||||
$data['quote_number'] = $quote_number;
|
||||
$data['sale_status'] = SUSPENDED;
|
||||
$sale_type = SALE_TYPE_QUOTE;
|
||||
|
||||
$data['sale_id_num'] = $this->Sale->save($data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $quote_number, $data['payments'], $data['dinner_table'], $data['taxes']);
|
||||
$data['sale_id_num'] = $this->Sale->save($sale_id, $data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $work_order_number, $quote_number, $sale_type, $data['payments'], $data['dinner_table'], $data['taxes']);
|
||||
$this->sale_lib->set_suspended_id($data['sale_id_num']);
|
||||
|
||||
$data['cart'] = $this->sale_lib->sort_and_filter_cart($data['cart']);
|
||||
@@ -592,8 +708,10 @@ class Sales extends Secure_Controller
|
||||
else
|
||||
{
|
||||
// Save the data to the sales table
|
||||
$data['sale_status'] = '0'; // Complete
|
||||
$data['sale_id_num'] = $this->Sale->save($data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], NULL, NULL, $data['payments'], $data['dinner_table'], $data['taxes']);
|
||||
$data['sale_status'] = COMPLETED;
|
||||
$sale_type = SALE_TYPE_POS;
|
||||
|
||||
$data['sale_id_num'] = $this->Sale->save($sale_id, $data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $work_order_number, $quote_number, $sale_type, $data['payments'], $data['dinner_table'], $data['taxes']);
|
||||
|
||||
$data['sale_id'] = 'POS ' . $data['sale_id_num'];
|
||||
|
||||
@@ -801,6 +919,8 @@ class Sales extends Secure_Controller
|
||||
));
|
||||
$data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['sale_id']);
|
||||
$data['print_after_sale'] = FALSE;
|
||||
$data['price_work_orders'] = FALSE;
|
||||
|
||||
if($this->sale_lib->get_mode() == 'sale_invoice')
|
||||
{
|
||||
$data['mode_label'] = $this->lang->line('sales_invoice');
|
||||
@@ -809,29 +929,26 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
$data['mode_label'] = $this->lang->line('sales_quote');
|
||||
}
|
||||
elseif($this->sale_lib->get_mode() == 'sale_work_order')
|
||||
{
|
||||
$data['mode_label'] = $this->lang->line('sales_work_order');
|
||||
}
|
||||
|
||||
return $this->xss_clean($data);
|
||||
}
|
||||
|
||||
private function _reload($data = array())
|
||||
{
|
||||
$sale_id = $this->session->userdata('sale_id');
|
||||
if($sale_id == '')
|
||||
{
|
||||
$sale_id = -1;
|
||||
$this->session->set_userdata('sale_id', -1);
|
||||
}
|
||||
$data['cart'] = $this->sale_lib->get_cart();
|
||||
$customer_info = $this->_load_customer_data($this->sale_lib->get_customer(), $data, TRUE);
|
||||
|
||||
if($this->config->item('invoice_enable') == '0')
|
||||
{
|
||||
$data['modes'] = array(
|
||||
'sale' => $this->lang->line('sales_sale'),
|
||||
'return' => $this->lang->line('sales_return'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['modes'] = array(
|
||||
'sale' => $this->lang->line('sales_sale'),
|
||||
'sale_invoice' => $this->lang->line('sales_sale_by_invoice'),
|
||||
'sale_quote' => $this->lang->line('sales_quote'),
|
||||
'return' => $this->lang->line('sales_return'));
|
||||
}
|
||||
$data['modes'] = $this->sale_lib->get_register_mode_options();
|
||||
$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();
|
||||
@@ -841,6 +958,8 @@ class Sales extends Secure_Controller
|
||||
$data['taxes'] = $this->sale_lib->get_taxes();
|
||||
$data['discount'] = $this->sale_lib->get_discount();
|
||||
$data['payments'] = $this->sale_lib->get_payments();
|
||||
// sale_type (0=pos, 1=invoice, 2=work order, 3=quote, 4=return
|
||||
$sale_type = $this->sale_lib->get_sale_type();
|
||||
|
||||
// Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'payments_cover_total'
|
||||
$totals = $this->sale_lib->get_totals();
|
||||
@@ -878,11 +997,6 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
$data['payment_options'] = $this->Sale->get_payment_options();
|
||||
}
|
||||
$quote_number = $this->sale_lib->get_quote_number();
|
||||
if($quote_number != NULL)
|
||||
{
|
||||
$data['quote_number'] = $quote_number;
|
||||
}
|
||||
|
||||
$data['items_module_allowed'] = $this->Employee->has_grant('items', $this->Employee->get_logged_in_employee_info()->person_id);
|
||||
|
||||
@@ -894,8 +1008,13 @@ class Sales extends Secure_Controller
|
||||
|
||||
$data['invoice_number_enabled'] = $this->sale_lib->is_invoice_mode();
|
||||
$data['print_after_sale'] = $this->sale_lib->is_print_after_sale();
|
||||
$data['quote_or_invoice_mode'] = $data['mode'] == 'sale_invoice' || $data['mode'] == 'sale_quote';
|
||||
$data['sales_or_return_mode'] = $data['mode'] == 'sale' || $data['mode'] == 'return';
|
||||
$data['price_work_orders'] = $this->sale_lib->is_price_work_orders();
|
||||
|
||||
$data['pos_mode'] = $data['mode'] == 'sale' || $data['mode'] == 'return';
|
||||
|
||||
$data['quote_number'] = $this->sale_lib->get_quote_number();
|
||||
$data['work_order_number'] = $this->sale_lib->get_work_order_number();
|
||||
|
||||
if($this->sale_lib->get_mode() == 'sale_invoice')
|
||||
{
|
||||
$data['mode_label'] = $this->lang->line('sales_invoice');
|
||||
@@ -904,6 +1023,10 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
$data['mode_label'] = $this->lang->line('sales_quote');
|
||||
}
|
||||
elseif($this->sale_lib->get_mode() == 'sale_work_order')
|
||||
{
|
||||
$data['mode_label'] = $this->lang->line('sales_work_order');
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['mode_label'] = $this->lang->line('sales_receipt');
|
||||
@@ -978,70 +1101,33 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function save($sale_id = -1)
|
||||
/**
|
||||
* This is used to cancel a suspended pos sale, quote.
|
||||
* Completed sales (POS Sales or Invoiced Sales) can not be removed from the system
|
||||
* Work orders can be canceled but are not physically removed from the sales history
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$newdate = $this->input->post('date');
|
||||
$date_formatter = date_create_from_format($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), $newdate);
|
||||
$sale_data = array(
|
||||
'sale_time' => $date_formatter->format('Y-m-d H:i:s'),
|
||||
'customer_id' => $this->input->post('customer_id') != '' ? $this->input->post('customer_id') : NULL,
|
||||
'employee_id' => $this->input->post('employee_id'),
|
||||
'comment' => $this->input->post('comment'),
|
||||
'invoice_number' => $this->input->post('invoice_number') != '' ? $this->input->post('invoice_number') : NULL
|
||||
);
|
||||
|
||||
// go through all the payment type input from the form, make sure the form matches the name and iterator number
|
||||
$payments = array();
|
||||
$number_of_payments = $this->input->post('number_of_payments');
|
||||
for($i = 0; $i < $number_of_payments; ++$i)
|
||||
$sale_id = $this->sale_lib->get_sale_id();
|
||||
if($sale_id != -1 && $sale_id != '')
|
||||
{
|
||||
$payment_amount = $this->input->post('payment_amount_' . $i);
|
||||
$payment_type = $this->input->post('payment_type_' . $i);
|
||||
// remove any 0 payment if by mistake any was introduced at sale time
|
||||
if($payment_amount != 0)
|
||||
$sale_type = $this->sale_lib->get_sale_type();
|
||||
if($sale_type == SALE_TYPE_WORK_ORDER)
|
||||
{
|
||||
// search for any payment of the same type that was already added, if that's the case add up the new payment amount
|
||||
$key = FALSE;
|
||||
if(!empty($payments))
|
||||
{
|
||||
// search in the multi array the key of the entry containing the current payment_type
|
||||
// NOTE: in PHP5.5 the array_map could be replaced by an array_column
|
||||
$key = array_search($payment_type, array_map(function ($v)
|
||||
{
|
||||
return $v['payment_type'];
|
||||
}, $payments));
|
||||
}
|
||||
|
||||
// if no previous payment is found add a new one
|
||||
if($key === FALSE)
|
||||
{
|
||||
$payments[] = array('payment_type' => $payment_type, 'payment_amount' => $payment_amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add up the new payment amount to an existing payment type
|
||||
$payments[$key]['payment_amount'] += $payment_amount;
|
||||
}
|
||||
$this->Sale->update_sale_status($sale_id, CANCELED);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Sale->delete($sale_id, FALSE);
|
||||
$this->session->set_userdata('sale_id', -1);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->Sale->update($sale_id, $sale_data, $payments))
|
||||
{
|
||||
echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('sales_successfully_updated'), 'id' => $sale_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('sales_unsuccessfully_updated'), 'id' => $sale_id));
|
||||
}
|
||||
}
|
||||
|
||||
public function cancel()
|
||||
{
|
||||
$this->sale_lib->clear_all();
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
public function discard_quote()
|
||||
public function discard_suspended_sale()
|
||||
{
|
||||
$suspended_id = $this->sale_lib->get_suspended_id();
|
||||
$this->sale_lib->clear_all();
|
||||
@@ -1049,8 +1135,15 @@ class Sales extends Secure_Controller
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Suspend the current sale.
|
||||
* If the current sale is already suspended then update the existing suspended sale.
|
||||
* Otherwise create it as a new suspended sale
|
||||
*/
|
||||
public function suspend()
|
||||
{
|
||||
$mode = $this->sale_lib->get_mode();
|
||||
$sale_id = $this->sale_lib->get_sale_id();
|
||||
$dinner_table = $this->sale_lib->get_dinner_table();
|
||||
$cart = $this->sale_lib->get_cart();
|
||||
$payments = $this->sale_lib->get_payments();
|
||||
@@ -1058,13 +1151,20 @@ class Sales extends Secure_Controller
|
||||
$customer_id = $this->sale_lib->get_customer();
|
||||
$customer_info = $this->Customer->get_info($customer_id);
|
||||
$invoice_number = $this->sale_lib->get_invoice_number();
|
||||
$work_order_number = $this->sale_lib->get_work_order_number();
|
||||
$quote_number = $this->sale_lib->get_quote_number();
|
||||
$sale_id = $this->sale_lib->get_sale_id();
|
||||
$sale_type = $this->sale_lib->get_sale_type();
|
||||
if($sale_type == '')
|
||||
{
|
||||
$sale_type = SALE_TYPE_POS;
|
||||
}
|
||||
$comment = $this->sale_lib->get_comment();
|
||||
$sale_status = $this->sale_lib->is_quote_mode() ? QUOTE : SUSPENDED;
|
||||
$sale_status = SUSPENDED;
|
||||
|
||||
$data = array();
|
||||
$sales_taxes = array();
|
||||
if($this->Sale->save($sale_status, $cart, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sales_taxes) == '-1')
|
||||
if($this->Sale->save($sale_id, $sale_status, $cart, $customer_id, $employee_id, $comment, $invoice_number, $work_order_number, $quote_number, $sale_type, $payments, $dinner_table, $sales_taxes) == '-1')
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unsuccessfully_suspended_sale');
|
||||
}
|
||||
@@ -1077,6 +1177,9 @@ class Sales extends Secure_Controller
|
||||
$this->_reload($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* List suspended sales
|
||||
*/
|
||||
public function suspended()
|
||||
{
|
||||
$customer_id = $this->sale_lib->get_customer();
|
||||
@@ -1087,8 +1190,8 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
|
||||
/*
|
||||
* We will eventually drop the current set of "suspended" tables since suspended sales
|
||||
* are now stored in the sales tables with a sale_status value of suspended.
|
||||
* Unsuspended sales are now left in the tables and are only removed
|
||||
* when they are intentionally cancelled.
|
||||
*/
|
||||
public function unsuspend()
|
||||
{
|
||||
@@ -1098,9 +1201,11 @@ class Sales extends Secure_Controller
|
||||
if($sale_id > 0)
|
||||
{
|
||||
$this->sale_lib->copy_entire_sale($sale_id);
|
||||
$this->Sale->delete_suspended_sale($sale_id);
|
||||
}
|
||||
|
||||
// Set current register mode to reflect that of unsuspended order type
|
||||
$this->change_register_mode($this->sale_lib->get_sale_type());
|
||||
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ $lang["config_jsprintsetup_required"] = "Warning: This functionality will only w
|
||||
$lang["config_language"] = "Language";
|
||||
$lang["config_last_used_invoice_number"] = "Last used Invoice Number";
|
||||
$lang["config_last_used_quote_number"] = "Last used Quote Number";
|
||||
$lang["config_last_used_work_order_number"] = "Last Used W/O Number";
|
||||
$lang["config_left"] = "Left";
|
||||
$lang["config_license"] = "License";
|
||||
$lang["config_license_configuration"] = "License Statement";
|
||||
@@ -222,6 +223,7 @@ $lang["config_reward"] = "Reward";
|
||||
$lang["config_reward_configuration"] = "Reward Configuration";
|
||||
$lang["config_right"] = "Right";
|
||||
$lang["config_sales_invoice_format"] = "Sales Invoice Format";
|
||||
$lang["config_work_order_format"] = "Work Order Format";
|
||||
$lang["config_sales_quote_format"] = "Sales Quote Format";
|
||||
$lang["config_saved_successfully"] = "Configuration save successful.";
|
||||
$lang["config_saved_unsuccessfully"] = "Configuration save failed.";
|
||||
@@ -246,3 +248,4 @@ $lang["config_thousands_separator"] = "Thousands Separator";
|
||||
$lang["config_timezone"] = "Timezone";
|
||||
$lang["config_top"] = "Top";
|
||||
$lang["config_website"] = "Website";
|
||||
$lang["config_work_order_enable"] = "Work Order Support";
|
||||
|
||||
@@ -8,6 +8,7 @@ $lang["sales_amount_due"] = "Amount Due";
|
||||
$lang["sales_amount_tendered"] = "Amount Tendered";
|
||||
$lang["sales_cancel_sale"] = "Cancel";
|
||||
$lang["sales_cash"] = "Cash";
|
||||
$lang["sales_cash_deposit"] = "Cash Deposit";
|
||||
$lang["sales_cash_filter"] = "Cash";
|
||||
$lang["sales_change_due"] = "Change Due";
|
||||
$lang["sales_check"] = "Check";
|
||||
@@ -19,6 +20,7 @@ $lang["sales_complete_sale"] = "Complete";
|
||||
$lang["sales_confirm_cancel_sale"] = "Are you sure you want to clear this sale? All items will cleared.";
|
||||
$lang["sales_confirm_delete"] = "Are you sure you want to delete the selected Sale(s)?";
|
||||
$lang["sales_credit"] = "Credit Card";
|
||||
$lang["sales_credit_deposit"] = "Credit Deposit";
|
||||
$lang["sales_customer"] = "Name";
|
||||
$lang["sales_customer_address"] = "Address";
|
||||
$lang["sales_customer_discount"] = "Discount";
|
||||
@@ -36,7 +38,7 @@ $lang["sales_delete_entire_sale"] = "Delete Entire Sale";
|
||||
$lang["sales_delete_successful"] = "Sale delete successful.";
|
||||
$lang["sales_delete_unsuccessful"] = "Sale delete failed.";
|
||||
$lang["sales_description_abbrv"] = "Desc.";
|
||||
$lang["sales_discard_quote"] = "Discard";
|
||||
$lang["sales_discard"] = "Discard";
|
||||
$lang["sales_discount"] = "Disc %";
|
||||
$lang["sales_discount_included"] = "% Discount";
|
||||
$lang["sales_discount_short"] = "%";
|
||||
@@ -57,6 +59,7 @@ $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_include_prices"] = "Include Prices?";
|
||||
$lang["sales_invoice"] = "Invoice";
|
||||
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
|
||||
$lang["sales_invoice_enable"] = "Create Invoice";
|
||||
@@ -94,6 +97,7 @@ $lang["sales_quantity_less_than_reorder_level"] = "Warning: Desired Quantity is
|
||||
$lang["sales_quantity_less_than_zero"] = "Warning: Desired Quantity is insufficient. You can still process the sale, but audit your inventory.";
|
||||
$lang["sales_quote"] = "Quote";
|
||||
$lang["sales_quote_number"] = "Quote Number";
|
||||
$lang["sales_quote_number_duplicate"] = "Quote Number must be unique.";
|
||||
$lang["sales_quote_sent"] = "Quote sent to";
|
||||
$lang["sales_quote_unsent"] = "Quote failed to be sent to";
|
||||
$lang["sales_receipt"] = "Sales Receipt";
|
||||
@@ -114,6 +118,7 @@ $lang["sales_select_customer"] = "Select Customer (Optional)";
|
||||
$lang["sales_send_invoice"] = "Send Invoice";
|
||||
$lang["sales_send_quote"] = "Send Quote";
|
||||
$lang["sales_send_receipt"] = "Send Receipt";
|
||||
$lang["sales_send_work_order"] = "Send Work Order";
|
||||
$lang["sales_serial"] = "Serial";
|
||||
$lang["sales_show_invoice"] = "Show Invoice";
|
||||
$lang["sales_show_receipt"] = "Show Receipt";
|
||||
@@ -125,6 +130,7 @@ $lang["sales_successfully_deleted"] = "You have successfully deleted";
|
||||
$lang["sales_successfully_suspended_sale"] = "Sale suspend successful.";
|
||||
$lang["sales_successfully_updated"] = "Sale update successful.";
|
||||
$lang["sales_suspend_sale"] = "Suspend";
|
||||
$lang["sales_suspended_doc_id"] = "Document";
|
||||
$lang["sales_suspended_sale_id"] = "ID";
|
||||
$lang["sales_suspended_sales"] = "Suspended";
|
||||
$lang["sales_table"] = "Table";
|
||||
@@ -141,3 +147,8 @@ $lang["sales_unsuccessfully_updated"] = "Sale update failed.";
|
||||
$lang["sales_unsuspend"] = "Unsuspend";
|
||||
$lang["sales_unsuspend_and_delete"] = "Action";
|
||||
$lang["sales_update"] = "Update";
|
||||
$lang["sales_work_order"] = "Work Order";
|
||||
$lang["sales_work_order_number"] = "Work Order Number";
|
||||
$lang["sales_work_order_number_duplicate"] = "The Work Order Number is a duplicate";
|
||||
$lang["sales_work_order_sent"] = "Work Order sent to";
|
||||
$lang["sales_work_order_unsent"] = "Work Order failed to be sent to";
|
||||
|
||||
@@ -28,11 +28,23 @@ class Sale_lib
|
||||
|
||||
public function get_register_mode_options()
|
||||
{
|
||||
return array(
|
||||
'sale' => $this->CI->lang->line('sales_receipt'),
|
||||
'sale_invoice' => $this->CI->lang->line('sales_invoice'),
|
||||
'sale_quote' => $this->CI->lang->line('sales_quote')
|
||||
);
|
||||
$register_modes = array();
|
||||
if($this->CI->config->item('invoice_enable') == '0')
|
||||
{
|
||||
$register_modes['sale'] = $this->CI->lang->line('sales_sale');
|
||||
}
|
||||
else
|
||||
{
|
||||
$register_modes['sale'] = $this->CI->lang->line('sales_receipt');
|
||||
$register_modes['sale_quote'] = $this->CI->lang->line('sales_quote');
|
||||
if($this->CI->config->item('work_order_enable') == '1')
|
||||
{
|
||||
$register_modes['sale_work_order'] = $this->CI->lang->line('sales_work_order');
|
||||
}
|
||||
$register_modes['sale_invoice'] = $this->CI->lang->line('sales_invoice');
|
||||
}
|
||||
$register_modes['return'] = $this->CI->lang->line('sales_return');
|
||||
return $register_modes;
|
||||
}
|
||||
|
||||
public function get_cart()
|
||||
@@ -148,6 +160,16 @@ class Sale_lib
|
||||
return $this->CI->session->userdata('sales_quote_number');
|
||||
}
|
||||
|
||||
public function get_work_order_number()
|
||||
{
|
||||
return $this->CI->session->userdata('sales_work_order_number');
|
||||
}
|
||||
|
||||
public function get_sale_type()
|
||||
{
|
||||
return $this->CI->session->userdata('sale_type');
|
||||
}
|
||||
|
||||
public function set_invoice_number($invoice_number, $keep_custom = FALSE)
|
||||
{
|
||||
$current_invoice_number = $this->CI->session->userdata('sales_invoice_number');
|
||||
@@ -166,6 +188,24 @@ class Sale_lib
|
||||
}
|
||||
}
|
||||
|
||||
public function set_work_order_number($work_order_number, $keep_custom = FALSE)
|
||||
{
|
||||
$current_work_order_number = $this->CI->session->userdata('sales_work_order_number');
|
||||
if(!$keep_custom || empty($current_work_order_number))
|
||||
{
|
||||
$this->CI->session->set_userdata('sales_work_order_number', $work_order_number);
|
||||
}
|
||||
}
|
||||
|
||||
public function set_sale_type($sale_type, $keep_custom = FALSE)
|
||||
{
|
||||
$current_sale_type = $this->CI->session->userdata('sale_type');
|
||||
if(!$keep_custom || empty($current_sale_type))
|
||||
{
|
||||
$this->CI->session->set_userdata('sale_type', $sale_type);
|
||||
}
|
||||
}
|
||||
|
||||
public function clear_invoice_number()
|
||||
{
|
||||
$this->CI->session->unset_userdata('sales_invoice_number');
|
||||
@@ -176,6 +216,11 @@ class Sale_lib
|
||||
$this->CI->session->unset_userdata('sales_quote_number');
|
||||
}
|
||||
|
||||
public function clear_sale_type()
|
||||
{
|
||||
$this->CI->session->unset_userdata('sale_type');
|
||||
}
|
||||
|
||||
public function set_suspended_id($suspended_id)
|
||||
{
|
||||
$this->CI->session->set_userdata('suspended_id', $suspended_id);
|
||||
@@ -204,6 +249,11 @@ class Sale_lib
|
||||
return ($this->CI->session->userdata('sales_mode') == 'sale_quote');
|
||||
}
|
||||
|
||||
public function is_work_order_mode()
|
||||
{
|
||||
return ($this->CI->session->userdata('sales_mode') == 'sale_work_order');
|
||||
}
|
||||
|
||||
public function set_invoice_number_enabled($invoice_number_enabled)
|
||||
{
|
||||
return $this->CI->session->set_userdata('sales_invoice_number_enabled', $invoice_number_enabled);
|
||||
@@ -215,11 +265,22 @@ class Sale_lib
|
||||
$this->CI->session->userdata('sales_print_after_sale') == '1');
|
||||
}
|
||||
|
||||
public function is_price_work_orders()
|
||||
{
|
||||
return ($this->CI->session->userdata('sales_price_work_orders') == 'true' ||
|
||||
$this->CI->session->userdata('sales_price_work_orders') == '1');
|
||||
}
|
||||
|
||||
public function set_print_after_sale($print_after_sale)
|
||||
{
|
||||
return $this->CI->session->set_userdata('sales_print_after_sale', $print_after_sale);
|
||||
}
|
||||
|
||||
public function set_price_work_orders($price_work_orders)
|
||||
{
|
||||
return $this->CI->session->set_userdata('sales_price_work_orders', $price_work_orders);
|
||||
}
|
||||
|
||||
public function get_email_receipt()
|
||||
{
|
||||
return $this->CI->session->userdata('sales_email_receipt');
|
||||
@@ -380,7 +441,6 @@ class Sale_lib
|
||||
{
|
||||
$cash_total = $total;
|
||||
$totals['cash_total'] = $cash_total;
|
||||
|
||||
}
|
||||
|
||||
$payment_total = $this->get_payments_total();
|
||||
@@ -862,8 +922,14 @@ 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);
|
||||
$this->set_quote_number($this->CI->Sale->get_quote_number($sale_id));
|
||||
$this->set_sale_type($this->CI->Sale->get_sale_type($sale_id));
|
||||
$this->set_comment($this->CI->Sale->get_comment($sale_id));
|
||||
$this->set_dinner_table($this->CI->Sale->get_dinner_table($sale_id));
|
||||
$this->CI->session->set_userdata('sale_id', $sale_id);
|
||||
}
|
||||
|
||||
public function get_sale_id() {
|
||||
return $this->CI->session->userdata('sale_id');
|
||||
}
|
||||
|
||||
public function get_cart_reordered($sale_id)
|
||||
@@ -880,6 +946,7 @@ class Sale_lib
|
||||
|
||||
public function clear_all()
|
||||
{
|
||||
$this->CI->session->set_userdata('sale_id', -1);
|
||||
$this->set_invoice_number_enabled(FALSE);
|
||||
$this->clear_table();
|
||||
$this->empty_cart();
|
||||
@@ -887,6 +954,7 @@ class Sale_lib
|
||||
$this->clear_email_receipt();
|
||||
$this->clear_invoice_number();
|
||||
$this->clear_quote_number();
|
||||
$this->clear_sale_type();
|
||||
$this->clear_giftcard_remainder();
|
||||
$this->empty_payments();
|
||||
$this->remove_customer();
|
||||
|
||||
@@ -5,6 +5,7 @@ require_once(APPPATH . 'libraries/tokens/Token_customer.php');
|
||||
require_once(APPPATH . 'libraries/tokens/Token_invoice_count.php');
|
||||
require_once(APPPATH . 'libraries/tokens/Token_invoice_sequence.php');
|
||||
require_once(APPPATH . 'libraries/tokens/Token_quote_sequence.php');
|
||||
require_once(APPPATH . 'libraries/tokens/Token_work_order_sequence.php');
|
||||
require_once(APPPATH . 'libraries/tokens/Token_suspended_invoice_count.php');
|
||||
require_once(APPPATH . 'libraries/tokens/Token_year_invoice_count.php');
|
||||
|
||||
@@ -27,7 +28,8 @@ abstract class Token
|
||||
static function get_tokens()
|
||||
{
|
||||
return array(new Token_customer(), new Token_invoice_count(), new Token_invoice_sequence(),
|
||||
new Token_quote_sequence(), new Token_suspended_invoice_count(), new Token_quote_sequence(), new Token_year_invoice_count());
|
||||
new Token_quote_sequence(), new Token_suspended_invoice_count(), new Token_quote_sequence(),
|
||||
new Token_work_order_sequence(), new Token_year_invoice_count());
|
||||
}
|
||||
|
||||
abstract public function token_id();
|
||||
|
||||
19
application/libraries/tokens/Token_work_order_sequence.php
Normal file
19
application/libraries/tokens/Token_work_order_sequence.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Token_work_order_sequence class
|
||||
*/
|
||||
|
||||
class Token_work_order_sequence extends Token
|
||||
{
|
||||
public function token_id()
|
||||
{
|
||||
return 'WSEQ';
|
||||
}
|
||||
|
||||
public function get_value()
|
||||
{
|
||||
return $this->CI->Appconfig->acquire_save_next_work_order_sequence();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -93,5 +93,12 @@ class Appconfig extends CI_Model
|
||||
$this->save('last_used_quote_number', $last_used);
|
||||
return $last_used;
|
||||
}
|
||||
|
||||
public function acquire_save_next_work_order_sequence()
|
||||
{
|
||||
$last_used = $this->get('last_used_work_order_number') + 1;
|
||||
$this->save('last_used_work_order_number', $last_used);
|
||||
return $last_used;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
define('COMPLETED', 0);
|
||||
define('SUSPENDED', 1);
|
||||
define('QUOTE', 2);
|
||||
define('CANCELED', 2);
|
||||
|
||||
define('SALE_TYPE_POS', 0);
|
||||
define('SALE_TYPE_INVOICE', 1);
|
||||
define('SALE_TYPE_WORK_ORDER', 2);
|
||||
define('SALE_TYPE_QUOTE', 3);
|
||||
define('SALE_TYPE_RETURN', 4);
|
||||
|
||||
/**
|
||||
* Sale class
|
||||
@@ -537,8 +543,15 @@ class Sale extends CI_Model
|
||||
* Save the sale information after the sales is complete but before the final document is printed
|
||||
* The sales_taxes variable needs to be initialized to an empty array before calling
|
||||
*/
|
||||
public function save(&$sale_status, &$items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, &$sales_taxes, $sale_id = FALSE)
|
||||
public function save($sale_id, &$sale_status, &$items, $customer_id, $employee_id, $comment, $invoice_number, $work_order_number, $quote_number, $sale_type, $payments, $dinner_table, &$sales_taxes)
|
||||
{
|
||||
|
||||
error_log('>>>save sale_id-' . $sale_id . ', sale_type-' . $sale_type);
|
||||
if($sale_id != -1)
|
||||
{
|
||||
$this->clear_suspended_sale_detail($sale_id);
|
||||
}
|
||||
|
||||
$tax_decimals = tax_decimals();
|
||||
|
||||
if(count($items) == 0)
|
||||
@@ -549,22 +562,34 @@ class Sale extends CI_Model
|
||||
$table_status = $this->determine_sale_status($sale_status, $dinner_table);
|
||||
|
||||
$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,
|
||||
'sale_status' => $sale_status,
|
||||
'invoice_number' => $invoice_number,
|
||||
'quote_number' => $quote_number,
|
||||
'dinner_table_id'=> $dinner_table,
|
||||
'sale_status' => $sale_status
|
||||
'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,
|
||||
'sale_status' => $sale_status,
|
||||
'invoice_number' => $invoice_number,
|
||||
'quote_number' => $quote_number,
|
||||
'work_order_number' => $work_order_number,
|
||||
'dinner_table_id' => $dinner_table,
|
||||
'sale_status' => $sale_status,
|
||||
'sale_type' => $sale_type
|
||||
);
|
||||
|
||||
// Run these queries as a transaction, we want to make sure we do all or nothing
|
||||
$this->db->trans_start();
|
||||
|
||||
$this->db->insert('sales', $sales_data);
|
||||
$sale_id = $this->db->insert_id();
|
||||
error_log('>>> sales_data-' . print_r($sales_data, true));
|
||||
error_log('>>> sales_id-' . $sale_id);
|
||||
if($sale_id == -1)
|
||||
{
|
||||
$this->db->insert('sales', $sales_data);
|
||||
$sale_id = $this->db->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
$this->db->update('sales', $sales_data);
|
||||
}
|
||||
$total_amount = 0;
|
||||
$total_amount_used = 0;
|
||||
foreach($payments as $payment_id=>$payment)
|
||||
@@ -800,19 +825,16 @@ class Sale extends CI_Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete sale
|
||||
* Delete sale. Hard deletes are not supported for sales transactions.
|
||||
* When a sale is "deleted" it is simply changed to a status of canceled.
|
||||
* However, if applicable the inventory still needs to be updated
|
||||
*/
|
||||
public function delete($sale_id, $employee_id, $update_inventory = TRUE)
|
||||
{
|
||||
// start a transaction to assure data integrity
|
||||
$this->db->trans_start();
|
||||
|
||||
// first delete all payments
|
||||
$this->db->delete('sales_payments', array('sale_id' => $sale_id));
|
||||
// then delete all taxes on items
|
||||
$this->db->delete('sales_items_taxes', array('sale_id' => $sale_id));
|
||||
|
||||
if($update_inventory)
|
||||
if($update_inventory && $sale_status = $this->get_sale_status($sale_id) == COMPLETED)
|
||||
{
|
||||
// defect, not all item deletions will be undone??
|
||||
// get array with all the items involved in the sale to update the inventory tracking
|
||||
@@ -840,10 +862,8 @@ class Sale extends CI_Model
|
||||
}
|
||||
}
|
||||
|
||||
// delete all items
|
||||
$this->db->delete('sales_items', array('sale_id' => $sale_id));
|
||||
// delete sale itself
|
||||
$this->db->delete('sales', array('sale_id' => $sale_id));
|
||||
// Set the status of the sale to canceled
|
||||
$this->update_sale_status($sale_id, CANCELED);
|
||||
|
||||
// execute transaction
|
||||
$this->db->trans_complete();
|
||||
@@ -965,6 +985,12 @@ class Sale extends CI_Model
|
||||
$payments[$this->lang->line('sales_rewards')] = $this->lang->line('sales_rewards');
|
||||
}
|
||||
|
||||
if($this->sale_lib->get_mode() == 'sale_work_order')
|
||||
{
|
||||
$payments[$this->lang->line('sales_cash_deposit')] = $this->lang->line('sales_cash_deposit');
|
||||
$payments[$this->lang->line('sales_credit_deposit')] = $this->lang->line('sales_credit_deposit');
|
||||
}
|
||||
|
||||
return $payments;
|
||||
}
|
||||
|
||||
@@ -1021,6 +1047,21 @@ class Sale extends CI_Model
|
||||
return ($this->db->get()->num_rows() == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if work order number exists
|
||||
*/
|
||||
public function check_work_order_number_exists($work_order_number, $sale_id = '')
|
||||
{
|
||||
$this->db->from('sales');
|
||||
$this->db->where('invoice_number', $work_order_number);
|
||||
if(!empty($sale_id))
|
||||
{
|
||||
$this->db->where('sale_id !=', $sale_id);
|
||||
}
|
||||
|
||||
return ($this->db->get()->num_rows() == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Giftcard value
|
||||
*/
|
||||
@@ -1184,12 +1225,12 @@ class Sale extends CI_Model
|
||||
{
|
||||
if($customer_id == -1)
|
||||
{
|
||||
$query = $this->db->query('select sale_id, sale_id as suspended_sale_id, sale_status, sale_time, dinner_table_id, customer_id, comment from '
|
||||
$query = $this->db->query("select sale_id, case when sale_type = '".SALE_TYPE_QUOTE."' then quote_number when sale_type = '".SALE_TYPE_WORK_ORDER."' then work_order_number else sale_id end as doc_id, sale_id as suspended_sale_id, sale_status, sale_time, dinner_table_id, customer_id, comment from "
|
||||
. $this->db->dbprefix('sales') . ' where sale_status = ' . SUSPENDED);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $this->db->query('select sale_id, sale_status, sale_time, dinner_table_id, customer_id, comment from '
|
||||
$query = $this->db->query("select sale_id, case when sale_type = '".SALE_TYPE_QUOTE."' then quote_number when sale_type = '".SALE_TYPE_WORK_ORDER."' then work_order_number else sale_id end as doc_id, sale_status, sale_time, dinner_table_id, customer_id, comment from "
|
||||
. $this->db->dbprefix('sales') . ' where sale_status = '. SUSPENDED .' AND customer_id = ' . $customer_id);
|
||||
}
|
||||
|
||||
@@ -1202,12 +1243,46 @@ class Sale extends CI_Model
|
||||
*/
|
||||
public function get_dinner_table($sale_id)
|
||||
{
|
||||
if($sale_id == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
error_log('>>>get_dinner_table sale_id-'.$sale_id);
|
||||
$this->db->from('sales');
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
|
||||
return $this->db->get()->row()->dinner_table_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sale type for the selected sale
|
||||
*/
|
||||
public function get_sale_type($sale_id)
|
||||
{
|
||||
$this->db->from('sales');
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
|
||||
return $this->db->get()->row()->sale_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sale status for the selected sale
|
||||
*/
|
||||
public function get_sale_status($sale_id)
|
||||
{
|
||||
$this->db->from('sales');
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
|
||||
return $this->db->get()->row()->sale_status;
|
||||
}
|
||||
|
||||
public function update_sale_status($sale_id, $sale_status)
|
||||
{
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
$this->db->update('sales', array('sale_status'=>$sale_status));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the quote_number for the selected sale
|
||||
*/
|
||||
@@ -1277,17 +1352,38 @@ class Sale extends CI_Model
|
||||
$this->db->where('dinner_table_id',$dinner_table);
|
||||
$this->db->update('dinner_tables', $dinner_table_data);
|
||||
|
||||
$this->db->delete('sales_payments', array('sale_id' => $sale_id));
|
||||
$this->db->delete('sales_items_taxes', array('sale_id' => $sale_id));
|
||||
$this->db->delete('sales_items', array('sale_id' => $sale_id));
|
||||
$this->db->delete('sales_taxes', array('sale_id' => $sale_id));
|
||||
$this->db->delete('sales', array('sale_id' => $sale_id, 'sale_status' => SUSPENDED));
|
||||
$this->update_sale_status($sale_id, CANCELED);
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
return $this->db->trans_status();
|
||||
}
|
||||
|
||||
/**
|
||||
* This clears the sales detail for a given sale_id before the detail is resaved.
|
||||
* This allows us to reuse the same sale_id
|
||||
*/
|
||||
public function clear_suspended_sale_detail($sale_id)
|
||||
{
|
||||
$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_payments', array('sale_id' => $sale_id));
|
||||
$this->db->delete('sales_items_taxes', array('sale_id' => $sale_id));
|
||||
$this->db->delete('sales_items', array('sale_id' => $sale_id));
|
||||
$this->db->delete('sales_taxes', array('sale_id' => $sale_id));
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
return $this->db->trans_status();
|
||||
}
|
||||
/**
|
||||
* Gets suspended sale info
|
||||
*/
|
||||
|
||||
@@ -15,36 +15,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_register_mode_default'), 'default_register_mode', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_dropdown('default_register_mode', $register_mode_options, $this->config->item('default_register_mode'), array('class' => 'form-control input-sm')); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_sales_invoice_format'), 'sales_invoice_format', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
'name' => 'sales_invoice_format',
|
||||
'id' => 'sales_invoice_format',
|
||||
'class' => 'form-control input-sm',
|
||||
'value' => $this->config->item('sales_invoice_format'))); ?>
|
||||
<?php echo form_dropdown('default_register_mode', $register_mode_options, $this->config->item('default_register_mode'), array('class' => 'form-control input-sm')); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_sales_quote_format'), 'sales_quote_format', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
'name' => 'sales_quote_format',
|
||||
'id' => 'sales_quote_format',
|
||||
'class' => 'form-control input-sm',
|
||||
'value' => $this->config->item('sales_quote_format'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_recv_invoice_format'), 'recv_invoice_format', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
@@ -84,29 +62,85 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_sales_invoice_format'), 'sales_invoice_format', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
'name' => 'sales_invoice_format',
|
||||
'id' => 'sales_invoice_format',
|
||||
'class' => 'form-control input-sm',
|
||||
'value' => $this->config->item('sales_invoice_format'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_last_used_invoice_number'), 'last_used_invoice_number', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
'type' => 'number',
|
||||
'name' => 'last_used_invoice_number',
|
||||
'id' => 'last_used_invoice_number',
|
||||
'class' => 'form-control input-sm required',
|
||||
'value'=>$this->config->item('last_used_invoice_number'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_sales_quote_format'), 'sales_quote_format', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
'name' => 'sales_quote_format',
|
||||
'id' => 'sales_quote_format',
|
||||
'class' => 'form-control input-sm',
|
||||
'value' => $this->config->item('sales_quote_format'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_last_used_quote_number'), 'last_used_quote_number', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
'type' => 'number',
|
||||
'name' => 'last_used_quote_number',
|
||||
'id' => 'last_used_quote_number',
|
||||
'class' => 'form-control input-sm required',
|
||||
'value'=>$this->config->item('last_used_quote_number'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_work_order_enable'), 'work_order_enable', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-1'>
|
||||
<?php echo form_checkbox(array(
|
||||
'name' => 'work_order_enable',
|
||||
'value' => 'work_order_enable',
|
||||
'id' => 'work_order_enable',
|
||||
'checked' => $this->config->item('work_order_enable')));?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_work_order_format'), 'work_order_format', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
'name' => 'work_order_format',
|
||||
'id' => 'work_order_format',
|
||||
'class' => 'form-control input-sm',
|
||||
'value' => $this->config->item('work_order_format'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_last_used_work_order_number'), 'last_used_work_order_number', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_input(array(
|
||||
'type' => 'number',
|
||||
'name' => 'last_used_work_order_number',
|
||||
'id' => 'last_used_work_order_number',
|
||||
'class' => 'form-control input-sm required',
|
||||
'value'=>$this->config->item('last_used_work_order_number'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo form_submit(array(
|
||||
'name' => 'submit_form',
|
||||
@@ -122,13 +156,30 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
var enable_disable_invoice_enable = (function() {
|
||||
var invoice_enable = $("#invoice_enable").is(":checked");
|
||||
$("#sales_invoice_format, #recv_invoice_format, #invoice_default_comments, #invoice_email_message, select[name='default_register_mode'], #sales_quote_format, select[name='line_sequence'], #last_used_invoice_number, #last_used_quote_number").prop("disabled", !invoice_enable);
|
||||
var invoice_enabled = $("#invoice_enable").is(":checked");
|
||||
var work_order_enabled = $("#work_order_enable").is(":checked");
|
||||
$("#sales_invoice_format, #recv_invoice_format, #invoice_default_comments, #invoice_email_message, select[name='default_register_mode'], #sales_quote_format, select[name='line_sequence'], #last_used_invoice_number, #last_used_quote_number, #work_order_enable, #work_order_format, #last_used_work_order_number").prop("disabled", !invoice_enabled);
|
||||
if(invoice_enabled) {
|
||||
$("#work_order_format, #last_used_work_order_number").prop("disabled", !work_order_enabled);
|
||||
} else {
|
||||
$("#work_order_enable").attr('checked', false);
|
||||
}
|
||||
return arguments.callee;
|
||||
})();
|
||||
|
||||
var enable_disable_work_order_enable = (function() {
|
||||
var work_order_enabled = $("#work_order_enable").is(":checked");
|
||||
var invoice_enabled = $("#invoice_enable").is(":checked");
|
||||
if(invoice_enabled) {
|
||||
$("#work_order_format, #last_used_work_order_number").prop("disabled", !work_order_enabled);
|
||||
}
|
||||
return arguments.callee;
|
||||
})();
|
||||
|
||||
$("#invoice_enable").change(enable_disable_invoice_enable);
|
||||
|
||||
$("#work_order_enable").change(enable_disable_work_order_enable);
|
||||
|
||||
$("#invoice_config_form").validate($.extend(form_support.handler, {
|
||||
|
||||
errorLabelContainer: "#invoice_error_message_box",
|
||||
@@ -136,13 +187,14 @@ $(document).ready(function()
|
||||
submitHandler: function(form) {
|
||||
$(form).ajaxSubmit({
|
||||
beforeSerialize: function(arr, $form, options) {
|
||||
$("#sales_invoice_format, #sales_quote_format, #recv_invoice_format, #invoice_default_comments, #invoice_email_message, #last_used_invoice_number, #last_used_quote_number").prop("disabled", false);
|
||||
$("#sales_invoice_format, #sales_quote_format, #recv_invoice_format, #invoice_default_comments, #invoice_email_message, #last_used_invoice_number, #last_used_quote_number, #work_order_enable, #work_order_format, #last_used_work_order_number").prop("disabled", false);
|
||||
return true;
|
||||
},
|
||||
success: function(response) {
|
||||
$.notify(response.message, { type: response.success ? 'success' : 'danger'} );
|
||||
// set back disabled state
|
||||
enable_disable_invoice_enable();
|
||||
enable_disable_work_order_enable();
|
||||
},
|
||||
dataType:'json'
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ if (isset($error_message))
|
||||
<a href="javascript:void(0);"><div class="btn btn-info btn-sm", id="show_email_button"><?php echo '<span class="glyphicon glyphicon-envelope"> </span>' . $this->lang->line('sales_send_quote'); ?></div></a>
|
||||
<?php endif; ?>
|
||||
<?php echo anchor("sales", '<span class="glyphicon glyphicon-shopping-cart"> </span>' . $this->lang->line('sales_register'), array('class'=>'btn btn-info btn-sm', 'id'=>'show_sales_button')); ?>
|
||||
<?php echo anchor("sales/discard_quote", '<span class="glyphicon glyphicon-remove"> </span>' . $this->lang->line('sales_discard_quote'), array('class'=>'btn btn-danger btn-sm', 'id'=>'discard_quote_button')); ?>
|
||||
<?php echo anchor("sales/discard_suspended_sale", '<span class="glyphicon glyphicon-remove"> </span>' . $this->lang->line('sales_discard'), array('class'=>'btn btn-danger btn-sm', 'id'=>'discard_quote_button')); ?>
|
||||
</div>
|
||||
|
||||
<div id="page-wrap">
|
||||
|
||||
@@ -411,7 +411,7 @@ if(isset($success))
|
||||
<?php echo form_close(); ?>
|
||||
<?php
|
||||
// Only show this part if the payment cover the total and in sale or return mode
|
||||
if($sales_or_return_mode == '1')
|
||||
if($pos_mode == '1')
|
||||
{
|
||||
?>
|
||||
<div class='btn btn-sm btn-success pull-right' id='finish_sale_button' tabindex='<?php echo ++$tabindex; ?>'><span class="glyphicon glyphicon-ok"> </span><?php echo $this->lang->line('sales_complete_sale'); ?></div>
|
||||
@@ -485,7 +485,7 @@ if(isset($success))
|
||||
<div class='btn btn-sm btn-default pull-left' id='suspend_sale_button'><span class="glyphicon glyphicon-align-justify"> </span><?php echo $this->lang->line('sales_suspend_sale'); ?></div>
|
||||
<?php
|
||||
// Only show this part if the payment cover the total
|
||||
if($quote_or_invoice_mode && isset($customer))
|
||||
if(!$pos_mode && isset($customer))
|
||||
{
|
||||
?>
|
||||
<div class='btn btn-sm btn-success' id='finish_invoice_quote_button'><span class="glyphicon glyphicon-ok"> </span><?php echo $mode_label; ?></div>
|
||||
@@ -500,7 +500,7 @@ if(isset($success))
|
||||
|
||||
<?php
|
||||
// Only show this part if the payment cover the total
|
||||
if($payments_cover_total || $quote_or_invoice_mode)
|
||||
if($payments_cover_total || !$pos_mode)
|
||||
{
|
||||
?>
|
||||
<div class="container-fluid">
|
||||
@@ -535,7 +535,20 @@ if(isset($success))
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if($mode == "sale_work_order")
|
||||
{
|
||||
?>
|
||||
<div class="col-xs-6">
|
||||
<label for="price_work_orders" class="control-label checkbox">
|
||||
<?php echo form_checkbox(array('name'=>'price_work_orders', 'id'=>'price_work_orders', 'value'=>1, 'checked'=>$price_work_orders)); ?>
|
||||
<?php echo $this->lang->line('sales_include_prices');?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if(($mode == "sale") && $this->config->item('invoice_enable') == TRUE)
|
||||
@@ -678,7 +691,12 @@ $(document).ready(function()
|
||||
{
|
||||
$.post('<?php echo site_url($controller_name."/set_print_after_sale");?>', {sales_print_after_sale: $(this).is(":checked")});
|
||||
});
|
||||
|
||||
|
||||
$("#price_work_orders").change(function()
|
||||
{
|
||||
$.post('<?php echo site_url($controller_name."/set_price_work_orders");?>', {price_work_orders: $(this).is(":checked")});
|
||||
});
|
||||
|
||||
$('#email_receipt').change(function()
|
||||
{
|
||||
$.post('<?php echo site_url($controller_name."/set_email_receipt");?>', {email_receipt: $('#email_receipt').is(':checked') ? '1' : '0'});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<table id="suspended_sales_table" class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr bgcolor="#CCC">
|
||||
<th><?php echo $this->lang->line('sales_suspended_sale_id'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_suspended_doc_id'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_date'); ?></th>
|
||||
<?php
|
||||
if($this->config->item('dinner_table_enable') == TRUE)
|
||||
@@ -22,7 +22,7 @@
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $suspended_sale['sale_id'];?></td>
|
||||
<td><?php echo $suspended_sale['doc_id'];?></td>
|
||||
<td><?php echo date($this->config->item('dateformat'), strtotime($suspended_sale['sale_time']));?></td>
|
||||
<?php
|
||||
if($this->config->item('dinner_table_enable') == TRUE)
|
||||
@@ -50,7 +50,7 @@
|
||||
<td><?php echo $suspended_sale['comment'];?></td>
|
||||
<td>
|
||||
<?php echo form_open('sales/unsuspend');
|
||||
echo form_hidden('suspended_sale_id', $suspended_sale['suspended_sale_id']);
|
||||
echo form_hidden('suspended_sale_id', $suspended_sale['sale_id']);
|
||||
?>
|
||||
<input type="submit" name="submit" value="<?php echo $this->lang->line('sales_unsuspend'); ?>" id="submit" class="btn btn-primary btn-xs pull-right">
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
213
application/views/sales/work_order.php
Normal file
213
application/views/sales/work_order.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php $this->load->view("partial/header"); ?>
|
||||
|
||||
<?php
|
||||
if (isset($error_message))
|
||||
{
|
||||
echo "<div class='alert alert-dismissible alert-danger'>".$error_message."</div>";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if(!empty($customer_email)): ?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
var send_email = function()
|
||||
{
|
||||
$.get('<?php echo site_url() . "/sales/send_pdf/" . $sale_id_num . "/work_order"; ?>',
|
||||
function(response)
|
||||
{
|
||||
$.notify(response.message, { type: response.success ? 'success' : 'danger'} );
|
||||
}, 'json'
|
||||
);
|
||||
};
|
||||
|
||||
$("#show_email_button").click(send_email);
|
||||
|
||||
<?php if(!empty($email_receipt)): ?>
|
||||
send_email();
|
||||
<?php endif; ?>
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $this->load->view('partial/print_receipt', array('print_after_sale'=>$print_after_sale, 'selected_printer'=>'invoice_printer')); ?>
|
||||
|
||||
<div class="print_hide" id="control_buttons" style="text-align:right">
|
||||
<a href="javascript:printdoc();"><div class="btn btn-info btn-sm", id="show_print_button"><?php echo '<span class="glyphicon glyphicon-print"> </span>' . $this->lang->line('common_print'); ?></div></a>
|
||||
<?php /* this line will allow to print and go back to sales automatically.... echo anchor("sales", '<span class="glyphicon glyphicon-print"> </span>' . $this->lang->line('common_print'), array('class'=>'btn btn-info btn-sm', 'id'=>'show_print_button', 'onclick'=>'window.print();')); */ ?>
|
||||
<?php if(isset($customer_email) && !empty($customer_email)): ?>
|
||||
<a href="javascript:void(0);"><div class="btn btn-info btn-sm", id="show_email_button"><?php echo '<span class="glyphicon glyphicon-envelope"> </span>' . $this->lang->line('sales_send_work_order'); ?></div></a>
|
||||
<?php endif; ?>
|
||||
<?php echo anchor("sales", '<span class="glyphicon glyphicon-shopping-cart"> </span>' . $this->lang->line('sales_register'), array('class'=>'btn btn-info btn-sm', 'id'=>'show_sales_button')); ?>
|
||||
<?php echo anchor("sales/discard_suspended_sale", '<span class="glyphicon glyphicon-remove"> </span>' . $this->lang->line('sales_discard'), array('class'=>'btn btn-danger btn-sm', 'id'=>'discard_work_order_button')); ?>
|
||||
</div>
|
||||
|
||||
<div id="page-wrap">
|
||||
<div id="header"><?php echo $sales_work_order; ?></div>
|
||||
<div id="block1">
|
||||
<div id="customer-title">
|
||||
<?php
|
||||
if(isset($customer))
|
||||
{
|
||||
?>
|
||||
<textarea id="customer" rows="5" cols="6"><?php echo $customer_info ?></textarea>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div id="logo">
|
||||
<?php
|
||||
if($this->Appconfig->get('company_logo') != '')
|
||||
{
|
||||
?>
|
||||
<img id="image" src="<?php echo base_url('uploads/' . $this->Appconfig->get('company_logo')); ?>" alt="company_logo" />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div> </div>
|
||||
<?php
|
||||
if ($this->Appconfig->get('receipt_show_company_name'))
|
||||
{
|
||||
?>
|
||||
<div id="company_name"><?php echo $this->config->item('company'); ?></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="block2">
|
||||
<textarea id="company-title" rows="5" cols="35"><?php echo $company_info ?></textarea>
|
||||
<table id="meta">
|
||||
<tr>
|
||||
<td class="meta-head"><?php echo $work_order_number_label;?> </td>
|
||||
<td><textarea rows="5" cols="6"><?php echo $work_order_number; ?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="meta-head"><?php echo $this->lang->line('common_date'); ?></td>
|
||||
<td><textarea rows="5" cols="6"><?php echo $transaction_date; ?></textarea></td>
|
||||
</tr>
|
||||
<?php
|
||||
if($print_price_info) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="meta-head"><?php echo $this->lang->line('sales_amount_due'); ?></td>
|
||||
<td><textarea rows="5" cols="6"><?php echo to_currency($total); ?></textarea></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<table id="items">
|
||||
<tr>
|
||||
<th><?php echo $this->lang->line('sales_item_number'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_item_name'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_quantity'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_price'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_discount'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_total'); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach($cart as $line=>$item)
|
||||
{
|
||||
?>
|
||||
<tr class="item-row">
|
||||
<td><?php echo $item['item_number']; ?></td>
|
||||
<td class="item-name"><textarea rows="4" cols="6"><?php echo $item['name']; ?></textarea></td>
|
||||
<td style='text-align:center;'><textarea rows="5" cols="6"><?php echo to_quantity_decimals($item['quantity']); ?></textarea></td>
|
||||
<td><textarea rows="4" cols="6"><?php if($print_price_info) echo to_currency($item['price']); ?></textarea></td>
|
||||
<td style='text-align:center;'><textarea rows="4" cols="6"><?php echo $item['discount'] . '%'; ?></textarea></td>
|
||||
<td style='border-right: solid 1px; text-align:right;'><textarea rows="4" cols="6"><?php if($print_price_info) echo to_currency($item['discounted_total']); ?></textarea></td>
|
||||
</tr>
|
||||
|
||||
<?php if($item['is_serialized'] || $item['allow_alt_description'] && !empty($item['description']))
|
||||
{
|
||||
?>
|
||||
<tr class="item-row">
|
||||
<td></td>
|
||||
<td class="item-name" colspan = "4"><div><?php echo $item['description']; ?></div></td>
|
||||
<td style='text-align:center;'><textarea><?php echo $item['serialnumber']; ?></textarea></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td class="blank" colspan="6" align="center"><?php echo ' '; ?></td>
|
||||
</tr>
|
||||
<?php if($print_price_info) { ?>
|
||||
<tr>
|
||||
<td colspan="3" class="blank-bottom"> </td>
|
||||
<td colspan="2" class="total-line"><textarea rows="5" cols="6"><?php echo $this->lang->line('sales_sub_total'); ?></textarea></td>
|
||||
<td class="total-value"><textarea rows="5" cols="6" id="subtotal"><?php echo to_currency($subtotal); ?></textarea></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach($taxes as $tax_group_index=>$sales_tax)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" class="blank"> </td>
|
||||
<td colspan="2" class="total-line"><textarea rows="5" cols="6"><?php echo $sales_tax['tax_group']; ?></textarea></td>
|
||||
<td class="total-value"><textarea rows="5" cols="6" id="taxes"><?php echo to_currency_tax($sales_tax['sale_tax_amount']); ?></textarea></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" class="blank"> </td>
|
||||
<td colspan="2" class="total-line"><textarea rows="5" cols="6"><?php echo $this->lang->line('sales_total'); ?></textarea></td>
|
||||
<td class="total-value"><textarea rows="5" cols="6" id="total"><?php echo to_currency($total); ?></textarea></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php
|
||||
$only_sale_check = FALSE;
|
||||
$show_giftcard_remainder = FALSE;
|
||||
foreach($payments as $payment_id=>$payment)
|
||||
{
|
||||
$only_sale_check |= $payment['payment_type'] == $this->lang->line('sales_check');
|
||||
$splitpayment = explode(':', $payment['payment_type']);
|
||||
$show_giftcard_remainder |= $splitpayment[0] == $this->lang->line('sales_giftcard');
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" class="blank"> </td>
|
||||
<td colspan="2" class="total-line"><textarea rows="5" cols="6"><?php echo $splitpayment[0]; ?></textarea></td>
|
||||
<td class="total-value"><textarea rows="5" cols="6" id="paid"><?php echo to_currency( $payment['payment_amount'] ); ?></textarea></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(window).on("load", function()
|
||||
{
|
||||
// install firefox addon in order to use this plugin
|
||||
if (window.jsPrintSetup)
|
||||
{
|
||||
<?php if (!$this->Appconfig->get('print_header'))
|
||||
{
|
||||
?>
|
||||
// set page header
|
||||
jsPrintSetup.setOption('headerStrLeft', '');
|
||||
jsPrintSetup.setOption('headerStrCenter', '');
|
||||
jsPrintSetup.setOption('headerStrRight', '');
|
||||
<?php
|
||||
}
|
||||
if (!$this->Appconfig->get('print_footer'))
|
||||
{
|
||||
?>
|
||||
// set empty page footer
|
||||
jsPrintSetup.setOption('footerStrLeft', '');
|
||||
jsPrintSetup.setOption('footerStrCenter', '');
|
||||
jsPrintSetup.setOption('footerStrRight', '');
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php $this->load->view("partial/footer"); ?>
|
||||
128
application/views/sales/work_order_email.php
Normal file
128
application/views/sales/work_order_email.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo base_url() . 'css/invoice_email.css';?>"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
if (isset($error_message))
|
||||
{
|
||||
echo "<div class='alert alert-dismissible alert-danger'>".$error_message."</div>";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="page-wrap">
|
||||
<div id="header"><?php echo $this->lang->line('sales_work_order'); ?></div>
|
||||
<table id="info">
|
||||
<tr>
|
||||
<td id="logo">
|
||||
<?php if($this->config->item('company_logo') != '')
|
||||
{
|
||||
?>
|
||||
<img id="image" src="<?php echo 'uploads/' . $this->config->item('company_logo'); ?>" alt="company_logo" />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td id="customer-title">
|
||||
<pre><?php if(isset($customer)) { echo $customer_info; } ?></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="company-title">
|
||||
<pre><?php echo $this->config->item('company'); ?></pre>
|
||||
<pre><?php echo $company_info; ?></pre>
|
||||
</td>
|
||||
<td id="meta">
|
||||
<table align="right">
|
||||
<tr>
|
||||
<td class="meta-head"><?php echo $this->lang->line('sales_work_order_number');?> </td>
|
||||
<td><div><?php echo $work_order_number; ?></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="meta-head"><?php echo $this->lang->line('common_date'); ?></td>
|
||||
<td><div><?php echo $transaction_date; ?></div></td>
|
||||
</tr>
|
||||
<?php if ($amount_due > 0)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td class="meta-head"><?php echo $this->lang->line('sales_amount_due'); ?></td>
|
||||
<td><div class="due"><?php echo to_currency($total); ?></div></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table id="items">
|
||||
<tr>
|
||||
<th><?php echo $this->lang->line('sales_item_number'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_item_name'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_quantity'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_price'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_discount'); ?></th>
|
||||
<th><?php echo $this->lang->line('sales_total'); ?></th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
foreach($cart as $line=>$item)
|
||||
{
|
||||
?>
|
||||
<tr class="item-row">
|
||||
<td><?php echo $item['item_number']; ?></td>
|
||||
<td class="item-name"><?php echo $item['name']; ?></td>
|
||||
<td><?php echo to_quantity_decimals($item['quantity']); ?></td>
|
||||
<td><?php echo to_currency($item['price']); ?></td>
|
||||
<td><?php echo $item['discount'] .'%'; ?></td>
|
||||
<td class="total-line"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="6" align="center"><?php echo ' '; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="3" class="blank"> </td>
|
||||
<td colspan="2" class="total-line"><?php echo $this->lang->line('sales_sub_total'); ?></td>
|
||||
<td id="subtotal" class="total-value"><?php echo to_currency($tax_exclusive_subtotal); ?></td>
|
||||
</tr>
|
||||
<?php foreach($taxes as $name=>$value) { ?>
|
||||
<tr>
|
||||
<td colspan="3" class="blank"> </td>
|
||||
<td colspan="2" class="total-line"><?php echo $name; ?></td>
|
||||
<td id="taxes" class="total-value"><?php echo to_currency_tax($value); ?></td>
|
||||
</tr>
|
||||
<?php }; ?>
|
||||
<tr>
|
||||
<td colspan="3" class="blank"> </td>
|
||||
<td colspan="2" class="total-line"><?php echo $this->lang->line('sales_total'); ?></td>
|
||||
<td id="total" class="total-value"><?php echo to_currency($total); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="terms">
|
||||
<div id="sale_return_policy">
|
||||
<h5>
|
||||
<div><?php echo nl2br($this->config->item('payment_message')); ?></div>
|
||||
<div><?php echo $this->lang->line('sales_comments'). ': ' . (empty($comments) ? $this->config->item('invoice_default_comments') : $comments); ?></div>
|
||||
</h5>
|
||||
<?php echo nl2br($this->config->item('return_policy')); ?>
|
||||
</div>
|
||||
<div id='barcode'>
|
||||
<img src='data:image/png;base64,<?php echo $barcode; ?>' /><br>
|
||||
<?php echo $sale_id; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
22
database/3.1.0_work_orders.sql
Normal file
22
database/3.1.0_work_orders.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- Add support for Work Orders
|
||||
|
||||
INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
('work_order_enable', '0'),
|
||||
('work_order_format', 'W%y{WSEQ:6}'),
|
||||
('last_used_work_order_number', '0');
|
||||
|
||||
ALTER TABLE `ospos_sales`
|
||||
ADD COLUMN `work_order_number` varchar(32) DEFAULT NULL,
|
||||
ADD COLUMN `sale_type` tinyint(2) NOT NULL DEFAULT 0;
|
||||
|
||||
-- sale_type (0=pos, 1=invoice, 2=work order, 3=quote)
|
||||
|
||||
update `ospos_sales`
|
||||
set `sale_type` = '3' where quote_number IS NOT NULL;
|
||||
|
||||
update `ospos_sales`
|
||||
set `sale_type` = '2', `work_order_number` = `quote_number`
|
||||
where quote_number IS NOT NULL;
|
||||
|
||||
update `ospos_sales`
|
||||
set `sale_type` = '1' where invoice_number IS NOT NULL;
|
||||
@@ -111,9 +111,10 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
('gcaptcha_enable', '0'),
|
||||
('gcaptcha_secret_key', ''),
|
||||
('gcaptcha_site_key', ''),
|
||||
('receiving_calculate_average_price', '0');
|
||||
|
||||
|
||||
('receiving_calculate_average_price', '0'),
|
||||
('work_order_enable', '0'),
|
||||
('work_order_format', 'W%y{WSEQ:6}'),
|
||||
('last_used_work_order_number', '0');
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
@@ -563,6 +564,8 @@ CREATE TABLE `ospos_sales` (
|
||||
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`sale_status` tinyint(2) NOT NULL DEFAULT 0,
|
||||
`dinner_table_id` int(11) NULL,
|
||||
`work_order_number` varchar(32) DEFAULT NULL,
|
||||
`sale_type` tinyint(2) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`sale_id`),
|
||||
KEY `customer_id` (`customer_id`),
|
||||
KEY `employee_id` (`employee_id`),
|
||||
|
||||
@@ -111,7 +111,11 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
('gcaptcha_enable', '0'),
|
||||
('gcaptcha_secret_key', ''),
|
||||
('gcaptcha_site_key', ''),
|
||||
('receiving_calculate_average_price', '0');
|
||||
('receiving_calculate_average_price', '0'),
|
||||
('work_order_enable', '0'),
|
||||
('work_order_format', 'W%y{WSEQ:6}'),
|
||||
('last_used_work_order_number', '0');
|
||||
|
||||
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@@ -565,6 +569,8 @@ CREATE TABLE `ospos_sales` (
|
||||
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`sale_status` tinyint(2) NOT NULL DEFAULT 0,
|
||||
`dinner_table_id` int(11) NULL,
|
||||
`work_order_number` varchar(32) DEFAULT NULL,
|
||||
`sale_type` tinyint(2) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`sale_id`),
|
||||
KEY `customer_id` (`customer_id`),
|
||||
KEY `employee_id` (`employee_id`),
|
||||
|
||||
Reference in New Issue
Block a user