From babddd524cff9092ae4a1780dd1e8ee71465fe42 Mon Sep 17 00:00:00 2001 From: jekkos-t520 Date: Thu, 19 Feb 2015 18:10:31 +0100 Subject: [PATCH] Refactor variable substitution for receiving invoice numbers Use localStorage to store selected printer Add printer selection for invoice template Print after sale checkbox is now present in receivings and sales screen Remove print after sale options from receipt_config Add default translations to receivings_lang.csv Fix some bugs preventing to print and email at the same time --- application/controllers/config.php | 2 - application/controllers/receivings.php | 61 +++++++++--- application/controllers/sales.php | 24 ++--- application/language/en/config_lang.php | 4 +- application/language/en/receivings_lang.php | 1 + application/language/en/sales_lang.php | 1 + application/language/es/config_lang.php | 4 +- application/language/es/receivings_lang.php | 23 ++--- application/language/es/sales_lang.php | 1 + application/language/fr/config_lang.php | 4 +- application/language/fr/receivings_lang.php | 21 ++-- application/language/fr/sales_lang.php | 1 + application/language/id/config_lang.php | 4 +- application/language/id/receivings_lang.php | 3 +- application/language/id/sales_lang.php | 1 + application/language/nl-BE/config_lang.php | 4 +- .../language/nl-BE/receivings_lang.php | 49 ++++----- application/language/nl-BE/sales_lang.php | 1 + application/language/ru/config_lang.php | 4 +- application/language/ru/receivings_lang.php | 21 ++-- application/language/ru/sales_lang.php | 1 + application/language/th/config_lang.php | 4 +- application/language/th/receivings_lang.php | 21 ++-- application/language/th/sales_lang.php | 1 + application/language/tr/config_lang.php | 4 +- application/language/tr/receivings_lang.php | 15 +-- application/language/tr/sales_lang.php | 1 + application/language/zh/config_lang.php | 4 +- application/language/zh/receivings_lang.php | 21 ++-- application/language/zh/sales_lang.php | 1 + application/libraries/Receiving_lib.php | 17 +++- application/libraries/Sale_lib.php | 11 +++ application/models/receiving.php | 11 +++ application/models/sale.php | 2 +- application/views/configs/receipt_config.php | 59 +++++------ application/views/partial/print_receipt.php | 75 ++++++++++++++ application/views/receivings/receipt.php | 75 +++++++------- application/views/receivings/receiving.php | 32 ++++-- application/views/sales/invoice.php | 3 + application/views/sales/receipt.php | 77 +-------------- application/views/sales/register.php | 33 +++++-- css/invoice.css | 1 + css/invoice_email.css | 1 + database/2.3.1_to_2.3.2.sql | 1 - database/database.sql | 1 - generate_languages.php | 2 + translations/config_lang.csv | 4 +- translations/receivings_lang.csv | 99 ++++++++++--------- translations/sales_lang.csv | 1 + 49 files changed, 469 insertions(+), 343 deletions(-) create mode 100644 application/views/partial/print_receipt.php diff --git a/application/controllers/config.php b/application/controllers/config.php index d258dde6c..8f3bf7917 100644 --- a/application/controllers/config.php +++ b/application/controllers/config.php @@ -145,8 +145,6 @@ class Config extends Secure_area 'use_invoice_template' => $this->input->post ( 'use_invoice_template' ), 'invoice_default_comments' => $this->input->post ( 'invoice_default_comments' ), 'invoice_email_message' => $this->input->post ( 'invoice_email_message' ), - 'print_after_sale' => $this->input->post ( 'print_after_sale' ), - 'receipt_printer' => $this->input->post ( 'receipt_printer' ), 'receipt_show_taxes' => $this->input->post ( 'receipt_show_taxes' ), 'print_silently' => $this->input->post ( 'print_silently' ), 'print_header' => $this->input->post ( 'print_header' ), diff --git a/application/controllers/receivings.php b/application/controllers/receivings.php index 27431ac65..a108740df 100644 --- a/application/controllers/receivings.php +++ b/application/controllers/receivings.php @@ -63,6 +63,11 @@ class Receivings extends Secure_area $this->receiving_lib->set_invoice_number_enabled($this->input->post('recv_invoice_number_enabled')); } + function set_print_after_sale() + { + $this->receiving_lib->set_print_after_sale($this->input->post('recv_print_after_sale')); + } + function set_invoice_number() { $this->receiving_lib->set_invoice_number($this->input->post('recv_invoice_number')); @@ -218,12 +223,50 @@ class Receivings extends Secure_area } $barcode_config=array('barcode_type'=>1,'barcode_width'=>180, 'barcode_height'=>30, 'barcode_quality'=>100); $data['barcode']=$this->barcode_lib->generate_barcode($data['receiving_id'],$barcode_config); + $data['print_after_sale'] = $this->receiving_lib->is_print_after_sale(); $this->load->view("receivings/receipt",$data); $this->receiving_lib->clear_all(); } $this->_remove_duplicate_cookies(); } + function _substitute_variable($text, $variable, $object, $function) + { + // don't query if this variable isn't used + if (strstr($text, $variable)) + { + $value = call_user_func(array($object, $function)); + $text = str_replace($variable, $value, $text); + } + return $text; + } + + function _substitute_variables($text,$supplier_info) + { + $text=$this->_substitute_variable($text, '$YCO', $this->Receiving, 'get_invoice_number_for_year'); + $text=$this->_substitute_variable($text, '$CO', $this->Receiving , 'get_invoice_count'); + $text=strftime($text); + $text=$this->_substitute_supplier($text, $supplier_info); + return $text; + } + + + function _substitute_supplier($text,$supplier_info) + { + $supplier_id=$this->receiving_lib->get_supplier(); + if($supplier_id!=-1) + { + $text=str_replace('$SU',$supplier_info->company_name,$text); + $words = preg_split("/\s+/", trim($supplier_info->company_name)); + $acronym = ""; + foreach ($words as $w) { + $acronym .= $w[0]; + } + $text=str_replace('$SI',$acronym,$text); + } + return $text; + } + function _substitute_invoice_number($supplier_info='') { $invoice_number=$this->receiving_lib->get_invoice_number(); @@ -231,21 +274,7 @@ class Receivings extends Secure_area { $invoice_number=$this->config->config['recv_invoice_format']; } - $invoice_count=$this->Receiving->get_invoice_count(); - $invoice_number=str_replace('$CO',$invoice_count,$invoice_number); - $invoice_number=strftime($invoice_number); - - $supplier_id=$this->receiving_lib->get_supplier(); - if($supplier_id!=-1) - { - $invoice_number=str_replace('$SU',$supplier_info->company_name,$invoice_number); - $words = preg_split("/\s+/", trim($supplier_info->company_name)); - $acronym = ""; - foreach ($words as $w) { - $acronym .= $w[0]; - } - $invoice_number=str_replace('$SI',$acronym,$invoice_number); - } + $invoice_number = $this->_substitute_variables($invoice_number,$supplier_info); $this->receiving_lib->set_invoice_number($invoice_number); return $invoice_number; } @@ -295,6 +324,7 @@ class Receivings extends Secure_area $supplier_info=$this->Supplier->get_info($supplier_id); $data['supplier']=$supplier_info->first_name.' '.$supplier_info->last_name; } + $data['print_after_sale'] = FALSE; $this->load->view("receivings/receipt",$data); $this->receiving_lib->clear_all(); $this->_remove_duplicate_cookies(); @@ -336,6 +366,7 @@ class Receivings extends Secure_area } $data['invoice_number']=$this->_substitute_invoice_number($suppl_info); $data['invoice_number_enabled']=$this->receiving_lib->is_invoice_number_enabled(); + $data['print_after_sale']=$this->receiving_lib->is_print_after_sale(); $this->load->view("receivings/receiving",$data); $this->_remove_duplicate_cookies(); } diff --git a/application/controllers/sales.php b/application/controllers/sales.php index 2dd4ed37c..cc078cc48 100644 --- a/application/controllers/sales.php +++ b/application/controllers/sales.php @@ -65,6 +65,11 @@ class Sales extends Secure_area $this->sale_lib->set_invoice_number_enabled($this->input->post('sales_invoice_number_enabled')); } + function set_print_after_sale() + { + $this->sale_lib->set_print_after_sale($this->input->post('sales_print_after_sale')); + } + function set_email_receipt() { $this->sale_lib->set_email_receipt($this->input->post('email_receipt')); @@ -227,6 +232,7 @@ class Sales extends Secure_area $emp_info=$this->Employee->get_info($employee_id); $data['payments']=$this->sale_lib->get_payments(); $data['amount_change']=to_currency($this->sale_lib->get_amount_due() * -1); + $data['amount_due']=$this->sale_lib->get_amount_due(); $data['employee']=$emp_info->first_name.' '.$emp_info->last_name; $data['company_info'] = implode("\n", array( $this->config->item('address'), @@ -265,6 +271,8 @@ class Sales extends Secure_area } else { + $barcode_config=array('barcode_type'=>1,'barcode_width'=>180, 'barcode_height'=>30, 'barcode_quality'=>100); + $data['barcode']=$this->barcode_lib->generate_barcode($data['sale_id'],$barcode_config); // if we want to email. .. just attach the pdf in there? if ($this->sale_lib->get_email_receipt() && !empty($cust_info->email)) { @@ -281,7 +289,7 @@ class Sales extends Secure_area $filename = $this->_invoice_email_pdf($data); $this->email->attach($filename); $message = $this->config->item('invoice_email_message'); - $message = $this->_substitute_variables($message); + $message = $this->_substitute_variables($message, $cust_info); $this->email->message($message); } else @@ -291,19 +299,10 @@ class Sales extends Secure_area $this->email->send(); } } - $barcode_config=array('barcode_type'=>1,'barcode_width'=>180, 'barcode_height'=>30, 'barcode_quality'=>100); - $data['barcode']=$this->barcode_lib->generate_barcode($data['sale_id'],$barcode_config); $data['cur_giftcard_value']=$this->sale_lib->get_giftcard_remainder(); - $data['print_receipt'] = $this->Appconfig->get('print_after_sale'); + $data['print_after_sale'] = $this->sale_lib->is_print_after_sale(); if ($this->sale_lib->is_invoice_number_enabled() && $this->config->item('use_invoice_template')) { - $data['customer_info'] = nl2br(implode("\n", array( - $data['customer'], - $data['customer_address'], - $data['customer_location'], - $data['account_number'] - ))); - $this->load->view("sales/invoice",$data); } else @@ -462,13 +461,13 @@ class Sales extends Secure_area // static barcode config for receipts + invoices $barcode_config=array('barcode_type'=>1,'barcode_width'=>180, 'barcode_height'=>30, 'barcode_quality'=>100); $data['barcode']=$this->barcode_lib->generate_barcode($data['sale_id'],$barcode_config); + $data['print_after_sale'] = FALSE; return $data; } function receipt($sale_id) { $data = $this->_load_sale_data($sale_id); - $data['print_receipt'] = FALSE; $this->load->view("sales/receipt",$data); $this->sale_lib->clear_all(); $this->_remove_duplicate_cookies(); @@ -607,6 +606,7 @@ class Sales extends Secure_area } $data['invoice_number']=$this->_substitute_invoice_number($cust_info); $data['invoice_number_enabled']=$this->sale_lib->is_invoice_number_enabled(); + $data['print_after_sale']=$this->sale_lib->is_print_after_sale(); $data['payments_cover_total']=$this->_payments_cover_total(); $this->load->view("sales/register",$data); $this->_remove_duplicate_cookies(); diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php index f967debf3..712673ef6 100644 --- a/application/language/en/config_lang.php +++ b/application/language/en/config_lang.php @@ -61,7 +61,6 @@ $lang["config_info"] = "Store Configuration Information"; $lang["config_language"] = "Language"; $lang["config_phone"] = "Company Phone"; $lang["config_phone_required"] = "Company phone is a required field"; -$lang["config_print_after_sale"] = "Print receipt after sale"; $lang["config_recv_invoice_format"] = "Receivings Invoice Format"; $lang["config_return_policy_required"] = "Return policy is a required field"; $lang["config_sales_invoice_format"] = "Sales Invoice Format"; @@ -91,10 +90,11 @@ $lang["config_decimal_point"] = "Decimal Point"; $lang["config_backup_button"] = "Backup"; $lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'"; $lang["config_company_logo"] = "Company Logo"; +$lang["config_invoice_printer"] = "Invoice Printer"; $lang["config_receipt_printer"] = "Ticket Printer"; $lang["config_receipt_show_taxes"] = "Show Taxes"; $lang["config_receipt_info"] = "Receipt Configuration Information"; -$lang["config_receipt_configuration"] = "Ticket Configuration"; +$lang["config_receipt_configuration"] = "Print Settings"; $lang["config_print_footer"] = "Print Browser Footer"; $lang["config_print_header"] = "Print Browser Header"; $lang["config_print_silently"] = "Show Print Dialog"; diff --git a/application/language/en/receivings_lang.php b/application/language/en/receivings_lang.php index 538b6fcd4..7dcac4164 100644 --- a/application/language/en/receivings_lang.php +++ b/application/language/en/receivings_lang.php @@ -48,3 +48,4 @@ $lang["recvs_total"] = "Total"; $lang["recvs_unable_to_add_item"] = "Unable to add item to receiving"; $lang["recvs_unsuccessfully_updated"] = "Receiving unsuccessfully updated"; $lang["recvs_invoice_enable"] = "Create Invoice"; +$lang["recvs_print_after_sale"] = "Print after sale"; diff --git a/application/language/en/sales_lang.php b/application/language/en/sales_lang.php index 9409e72ff..2888f9ae7 100644 --- a/application/language/en/sales_lang.php +++ b/application/language/en/sales_lang.php @@ -91,6 +91,7 @@ $lang["sales_unsuspend"] = "Unsuspend"; $lang["sales_unsuspend_and_delete"] = ""; $lang["sales_giftcard_balance"] = "Giftcard Balance"; $lang["sales_discount_included"] = "% discount included"; +$lang["sales_print_after_sale"] = "Print after sale"; $lang["sales_invoice"] = "Invoice"; $lang["sales_total_tax_exclusive"] = "Tax excluded"; $lang["sales_send_invoice"] = "Send Invoice"; diff --git a/application/language/es/config_lang.php b/application/language/es/config_lang.php index 7f9663488..950568a3b 100644 --- a/application/language/es/config_lang.php +++ b/application/language/es/config_lang.php @@ -61,7 +61,6 @@ $lang["config_info"] = "Información del Comercio"; $lang["config_language"] = "Idioma"; $lang["config_phone"] = "Teléfono del Comercio"; $lang["config_phone_required"] = "Teléfono del Comercio es requerido"; -$lang["config_print_after_sale"] = "Imprimir recibo después de una venta"; $lang["config_recv_invoice_format"] = ""; $lang["config_return_policy_required"] = "Política de Devolución es requerida"; $lang["config_sales_invoice_format"] = ""; @@ -91,10 +90,11 @@ $lang["config_decimal_point"] = " Decimal Point"; $lang["config_backup_button"] = "Backup"; $lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'"; $lang["config_company_logo"] = "Company Logo"; +$lang["config_invoice_printer"] = "Invoice Printer"; $lang["config_receipt_printer"] = "Ticket Printer"; $lang["config_receipt_show_taxes"] = "Show Taxes"; $lang["config_receipt_info"] = "Receipt Configuration Information"; -$lang["config_receipt_configuration"] = "Ticket Configuration"; +$lang["config_receipt_configuration"] = "Print Settings"; $lang["config_print_footer"] = "Print Browser Footer"; $lang["config_print_header"] = "Print Browser Header"; $lang["config_print_silently"] = "Top Margin"; diff --git a/application/language/es/receivings_lang.php b/application/language/es/receivings_lang.php index 62182bec1..01fcc4dd5 100644 --- a/application/language/es/receivings_lang.php +++ b/application/language/es/receivings_lang.php @@ -13,11 +13,11 @@ $lang["recvs_date"] = ""; $lang["recvs_date_required"] = ""; $lang["recvs_date_type"] = ""; $lang["recvs_delete_confirmation"] = ""; -$lang["recvs_delete_entire_sale"] = ""; +$lang["recvs_delete_entire_sale"] = "Delete entire sale"; $lang["recvs_discount"] = "Descuento %"; $lang["recvs_edit"] = "Editar"; -$lang["recvs_edit_sale"] = ""; -$lang["recvs_employee"] = ""; +$lang["recvs_edit_sale"] = "Edit Receiving"; +$lang["recvs_employee"] = "Employee"; $lang["recvs_error_editing_item"] = "Error al editar artículo"; $lang["recvs_error_requisition"] = ""; $lang["recvs_find_or_scan_item"] = "Encontrar/Escanear Artículo"; @@ -28,7 +28,7 @@ $lang["recvs_invoice_number_duplicate"] = ""; $lang["recvs_item_name"] = "Nombre del Artículo"; $lang["recvs_mode"] = "Modo de Entradas"; $lang["recvs_new_supplier"] = "Nuevo Proveedor"; -$lang["recvs_one_or_multiple"] = ""; +$lang["recvs_one_or_multiple"] = "receiving(s)"; $lang["recvs_quantity"] = "Cant."; $lang["recvs_receipt"] = "Recibo de Entrada"; $lang["recvs_receipt_number"] = ""; @@ -38,13 +38,14 @@ $lang["recvs_requisition"] = ""; $lang["recvs_return"] = "Devolver"; $lang["recvs_select_supplier"] = "Seleccionar Proveedor (Opcional)"; $lang["recvs_start_typing_supplier_name"] = "Empieza a escribir el nombre del proveedor..."; -$lang["recvs_stock_destination"] = ""; -$lang["recvs_stock_locaiton"] = ""; -$lang["recvs_stock_source"] = ""; -$lang["recvs_successfully_deleted"] = ""; -$lang["recvs_successfully_updated"] = ""; +$lang["recvs_stock_destination"] = "Stock destination"; +$lang["recvs_stock_locaiton"] = "Stock destination"; +$lang["recvs_stock_source"] = "Stock destination"; +$lang["recvs_successfully_deleted"] = "You have successfully deleted"; +$lang["recvs_successfully_updated"] = "Receiving successfully updated"; $lang["recvs_supplier"] = "Proveedor"; $lang["recvs_total"] = "Total"; $lang["recvs_unable_to_add_item"] = "No se puede agregar el artículo a la entrada"; -$lang["recvs_unsuccessfully_updated"] = ""; -$lang["recvs_invoice_enable"] = ""; +$lang["recvs_unsuccessfully_updated"] = "Receiving unsuccessfully updated"; +$lang["recvs_invoice_enable"] = "Create Invoice"; +$lang["recvs_print_after_sale"] = "Imprimir recibo después de una venta"; diff --git a/application/language/es/sales_lang.php b/application/language/es/sales_lang.php index 6feb2cef0..f22d86477 100644 --- a/application/language/es/sales_lang.php +++ b/application/language/es/sales_lang.php @@ -91,6 +91,7 @@ $lang["sales_unsuspend"] = "Retomar"; $lang["sales_unsuspend_and_delete"] = "Retomar y Borrar"; $lang["sales_giftcard_balance"] = "Giftcard Balance"; $lang["sales_discount_included"] = "% discount included"; +$lang["sales_print_after_sale"] = "Imprimir recibo después de una venta"; $lang["sales_invoice"] = "Invoice"; $lang["sales_total_tax_exclusive"] = "Tax excluded"; $lang["sales_send_invoice"] = "Send Invoice"; diff --git a/application/language/fr/config_lang.php b/application/language/fr/config_lang.php index aae484c97..2d7188bdc 100644 --- a/application/language/fr/config_lang.php +++ b/application/language/fr/config_lang.php @@ -61,7 +61,6 @@ $lang["config_info"] = "Çonfiguration de l\'Entreprise"; $lang["config_language"] = "Langue"; $lang["config_phone"] = "Téléphone"; $lang["config_phone_required"] = "Le numéro de téléphone est requis"; -$lang["config_print_after_sale"] = "Imprimer un recu après vente"; $lang["config_recv_invoice_format"] = ""; $lang["config_return_policy_required"] = "Le Message est un champ requis"; $lang["config_sales_invoice_format"] = ""; @@ -91,10 +90,11 @@ $lang["config_decimal_point"] = " Decimal Point"; $lang["config_backup_button"] = "Backup"; $lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'"; $lang["config_company_logo"] = "Company Logo"; +$lang["config_invoice_printer"] = "Invoice Printer"; $lang["config_receipt_printer"] = "Ticket Printer"; $lang["config_receipt_show_taxes"] = "Show Taxes"; $lang["config_receipt_info"] = "Receipt Configuration Information"; -$lang["config_receipt_configuration"] = "Ticket Configuration"; +$lang["config_receipt_configuration"] = "Print Settings"; $lang["config_print_footer"] = "Print Browser Footer"; $lang["config_print_header"] = "Print Browser Header"; $lang["config_print_silently"] = "Show Print Dialog"; diff --git a/application/language/fr/receivings_lang.php b/application/language/fr/receivings_lang.php index 5193e638e..a241a29ce 100644 --- a/application/language/fr/receivings_lang.php +++ b/application/language/fr/receivings_lang.php @@ -13,11 +13,11 @@ $lang["recvs_date"] = ""; $lang["recvs_date_required"] = ""; $lang["recvs_date_type"] = ""; $lang["recvs_delete_confirmation"] = ""; -$lang["recvs_delete_entire_sale"] = ""; +$lang["recvs_delete_entire_sale"] = "Delete entire sale"; $lang["recvs_discount"] = "Remise %"; $lang["recvs_edit"] = "Éditer"; -$lang["recvs_edit_sale"] = ""; -$lang["recvs_employee"] = ""; +$lang["recvs_edit_sale"] = "Edit Receiving"; +$lang["recvs_employee"] = "Employee"; $lang["recvs_error_editing_item"] = "Erreur d'édition"; $lang["recvs_error_requisition"] = ""; $lang["recvs_find_or_scan_item"] = "Chercher/Scanner Élément"; @@ -38,13 +38,14 @@ $lang["recvs_requisition"] = ""; $lang["recvs_return"] = "Return"; $lang["recvs_select_supplier"] = "Choisir Fournisseur (Facultatif)"; $lang["recvs_start_typing_supplier_name"] = "Commencez à saisir le nom du fournisseur..."; -$lang["recvs_stock_destination"] = ""; -$lang["recvs_stock_locaiton"] = ""; -$lang["recvs_stock_source"] = ""; -$lang["recvs_successfully_deleted"] = ""; -$lang["recvs_successfully_updated"] = ""; +$lang["recvs_stock_destination"] = "Stock destination"; +$lang["recvs_stock_locaiton"] = "Stock location"; +$lang["recvs_stock_source"] = "Stock source"; +$lang["recvs_successfully_deleted"] = "You have successfully deleted"; +$lang["recvs_successfully_updated"] = "Receiving successfully updated"; $lang["recvs_supplier"] = "Fournisseur"; $lang["recvs_total"] = "Total"; $lang["recvs_unable_to_add_item"] = "Impossible d'ajouter l'item aux arrivages"; -$lang["recvs_unsuccessfully_updated"] = ""; -$lang["recvs_invoice_enable"] = ""; +$lang["recvs_unsuccessfully_updated"] = "Receiving unsuccessfully updated"; +$lang["recvs_invoice_enable"] = "Create Invoice"; +$lang["recvs_print_after_sale"] = "Imprimer un recu après vente"; diff --git a/application/language/fr/sales_lang.php b/application/language/fr/sales_lang.php index 8eae2a82e..2eccd781a 100644 --- a/application/language/fr/sales_lang.php +++ b/application/language/fr/sales_lang.php @@ -91,6 +91,7 @@ $lang["sales_unsuspend"] = "Débloquer"; $lang["sales_unsuspend_and_delete"] = ""; $lang["sales_giftcard_balance"] = "Giftcard Balance"; $lang["sales_discount_included"] = "% discount included"; +$lang["sales_print_after_sale"] = "Imprimer un recu après vente"; $lang["sales_invoice"] = "Invoice"; $lang["sales_total_tax_exclusive"] = "Tax excluded"; $lang["sales_send_invoice"] = "Send Invoice"; diff --git a/application/language/id/config_lang.php b/application/language/id/config_lang.php index 1fa108791..dcf0872af 100644 --- a/application/language/id/config_lang.php +++ b/application/language/id/config_lang.php @@ -61,7 +61,6 @@ $lang["config_info"] = "Informasi Konfigurasi Toko"; $lang["config_language"] = "Bahasa"; $lang["config_phone"] = "Telepon Perusahaan"; $lang["config_phone_required"] = "Telepon Perusahaan wajib diisi"; -$lang["config_print_after_sale"] = "Cetak Faktur setelah penjualan"; $lang["config_recv_invoice_format"] = "Format Nota"; $lang["config_return_policy_required"] = "Kebijakan retur wajib diisi"; $lang["config_sales_invoice_format"] = "Format Nota"; @@ -91,10 +90,11 @@ $lang["config_decimal_point"] = "Titik Desimal"; $lang["config_backup_button"] = "Backup"; $lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'"; $lang["config_company_logo"] = "Company Logo"; +$lang["config_invoice_printer"] = "Invoice Printer"; $lang["config_receipt_printer"] = "Ticket Printer"; $lang["config_receipt_show_taxes"] = "Show Taxes"; $lang["config_receipt_info"] = "Receipt Configuration Information"; -$lang["config_receipt_configuration"] = "Ticket Configuration"; +$lang["config_receipt_configuration"] = "Print Settings"; $lang["config_print_footer"] = "Print Browser Footer"; $lang["config_print_header"] = "Print Browser Header"; $lang["config_print_silently"] = "Show Print Dialog"; diff --git a/application/language/id/receivings_lang.php b/application/language/id/receivings_lang.php index bef1655e6..64a34e097 100644 --- a/application/language/id/receivings_lang.php +++ b/application/language/id/receivings_lang.php @@ -47,4 +47,5 @@ $lang["recvs_supplier"] = "Pemasok"; $lang["recvs_total"] = "Total"; $lang["recvs_unable_to_add_item"] = "Item tidak dapat ditambahkan ke penerimaan barang masuk"; $lang["recvs_unsuccessfully_updated"] = "Tidak Berhasil Diperbaharui"; -$lang["recvs_invoice_enable"] = ""; +$lang["recvs_invoice_enable"] = "Create Invoice"; +$lang["recvs_print_after_sale"] = "Cetak Faktur setelah penjualan"; diff --git a/application/language/id/sales_lang.php b/application/language/id/sales_lang.php index a71528bf6..854c7670c 100644 --- a/application/language/id/sales_lang.php +++ b/application/language/id/sales_lang.php @@ -91,6 +91,7 @@ $lang["sales_unsuspend"] = "Batal Penangguhan"; $lang["sales_unsuspend_and_delete"] = "Batalkan dan hapus penangguhan"; $lang["sales_giftcard_balance"] = "Giftcard Balance"; $lang["sales_discount_included"] = "% discount included"; +$lang["sales_print_after_sale"] = "Cetak Faktur setelah penjualan"; $lang["sales_invoice"] = "Invoice"; $lang["sales_total_tax_exclusive"] = "Tax excluded"; $lang["sales_send_invoice"] = "Send Invoice"; diff --git a/application/language/nl-BE/config_lang.php b/application/language/nl-BE/config_lang.php index 46f8926f4..e595abc59 100755 --- a/application/language/nl-BE/config_lang.php +++ b/application/language/nl-BE/config_lang.php @@ -61,7 +61,6 @@ $lang["config_info"] = "Systeeminstellingen"; $lang["config_language"] = "Taal"; $lang["config_phone"] = "Telefoon"; $lang["config_phone_required"] = "De telefoonnummer van het bedrijf moet ingevuld worden"; -$lang["config_print_after_sale"] = "Druk ticket na verkoop"; $lang["config_recv_invoice_format"] = ""; $lang["config_return_policy_required"] = "De retourvoorwaarden moeten ingevuld worden"; $lang["config_sales_invoice_format"] = ""; @@ -91,10 +90,11 @@ $lang["config_decimal_point"] = "Decimal Point"; $lang["config_backup_button"] = "Backup"; $lang["config_stock_location_invalid_chars"] = "De bedrijfsnaam moet ingevuld worden"; $lang["config_company_logo"] = "Logo"; +$lang["config_invoice_printer"] = "Factuur Printer"; $lang["config_receipt_printer"] = "Ticket Printer"; $lang["config_receipt_show_taxes"] = "Toon VAT"; $lang["config_receipt_info"] = "Ticket Instellingen"; -$lang["config_receipt_configuration"] = "Ticket Configuratie"; +$lang["config_receipt_configuration"] = "Print Instellingen"; $lang["config_print_footer"] = "Print Browser Footer"; $lang["config_print_header"] = "Print Browser Header"; $lang["config_print_silently"] = "Marge Boven"; diff --git a/application/language/nl-BE/receivings_lang.php b/application/language/nl-BE/receivings_lang.php index 5c250bb15..2a5cc1d63 100755 --- a/application/language/nl-BE/receivings_lang.php +++ b/application/language/nl-BE/receivings_lang.php @@ -1,50 +1,51 @@ CI->session->set_userdata('recv_invoice_number_enabled', $invoice_number_enabled); } + function is_print_after_sale() + { + return $this->CI->session->userdata('recv_print_after_sale') == 'true' || + $this->CI->session->userdata('recv_print_after_sale') == '1'; + } + + function set_print_after_sale($print_after_sale) + { + return $this->CI->session->set_userdata('recv_print_after_sale', $print_after_sale); + } + function set_stock_source($stock_source) { $this->CI->session->set_userdata('recv_stock_source',$stock_source); @@ -176,6 +187,7 @@ class Receiving_lib $insertkey=$maxkey+1; $item_info=$this->CI->Item->get_info($item_id,$item_location); //array records are identified by $insertkey and item_id is just another field. + $price=$price!=null ? $price: $item_info->cost_price; $item = array(($insertkey)=> array( 'item_id'=>$item_id, @@ -190,8 +202,9 @@ class Receiving_lib 'quantity'=>$quantity, 'discount'=>$discount, 'in_stock'=>$this->CI->Item_quantities->get_item_quantity($item_id, $item_location)->quantity, - 'price'=>$price!=null ? $price: $item_info->cost_price, - 'receiving_quantity'=>$item_info->receiving_quantity + 'price'=>$price, + 'receiving_quantity'=>$item_info->receiving_quantity, + 'total'=>$this->get_item_total($quantity, $price, $discount) ) ); diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php index 519aea176..db34b36ab 100644 --- a/application/libraries/Sale_lib.php +++ b/application/libraries/Sale_lib.php @@ -78,6 +78,17 @@ class Sale_lib return $this->CI->session->set_userdata('sales_invoice_number_enabled', $invoice_number_enabled); } + function is_print_after_sale() + { + return $this->CI->session->userdata('sales_print_after_sale') == 'true' || + $this->CI->session->userdata('sales_print_after_sale') == '1'; + } + + function set_print_after_sale($print_after_sale) + { + return $this->CI->session->set_userdata('sales_print_after_sale', $print_after_sale); + } + function get_email_receipt() { return $this->CI->session->userdata('email_receipt'); diff --git a/application/models/receiving.php b/application/models/receiving.php index 6d8c1db0d..9e3a0365d 100644 --- a/application/models/receiving.php +++ b/application/models/receiving.php @@ -23,6 +23,17 @@ class Receiving extends CI_Model return $this->db->get(); } + function get_invoice_number_for_year($year='', $start_from = 0) + { + $year = $year == '' ? date('Y') : $year; + $this->db->select("COUNT( 1 ) AS invoice_number_year", FALSE); + $this->db->from('receivings'); + $this->db->where("DATE_FORMAT(receiving_time, '%Y' ) = ", $year, FALSE); + $this->db->where("invoice_number IS NOT ", "NULL", FALSE); + $result = $this->db->get()->row_array(); + return ($start_from + $result[ 'invoice_number_year' ] + 1); + } + function exists($receiving_id) { $this->db->from('receivings'); diff --git a/application/models/sale.php b/application/models/sale.php index d75e89129..da295e323 100644 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -25,7 +25,7 @@ class Sale extends CI_Model function get_invoice_number_for_year($year='', $start_from = 0) { - $year = $year = '' ? date('Y') : $year; + $year = $year == '' ? date('Y') : $year; $this->db->select("COUNT( 1 ) AS invoice_number_year", FALSE); $this->db->from('sales'); $this->db->where("DATE_FORMAT(sale_time, '%Y' ) = ", $year, FALSE); diff --git a/application/views/configs/receipt_config.php b/application/views/configs/receipt_config.php index cafa9977f..852977693 100644 --- a/application/views/configs/receipt_config.php +++ b/application/views/configs/receipt_config.php @@ -54,17 +54,6 @@ echo form_open('config/save_receipt/',array('id'=>'receipt_config_form')); -
-lang->line('config_print_after_sale').':', 'print_after_sale',array('class'=>'wide')); ?> -
- 'print_after_sale', - 'id'=>'print_after_sale', - 'value'=>'print_after_sale', - 'checked'=>$this->config->item('print_after_sale')));?> -
-
-
lang->line('config_print_silently').':', 'print_silently',array('class'=>'wide')); ?>
@@ -104,7 +93,14 @@ echo form_open('config/save_receipt/',array('id'=>'receipt_config_form')); config->item('receipt_printer'),'id="receipt_printer"');?> + '','id="receipt_printer"');?> +
+
+ +
+lang->line('config_invoice_printer').':', 'config_invoice_printer',array('class'=>'wide')); ?> +
+
@@ -184,19 +180,7 @@ echo form_close(); //validation and submit handling $(document).ready(function() { - var printers = (window.jsPrintSetup && jsPrintSetup.getPrintersList() && jsPrintSetup.getPrintersList().split(',')) || []; - $.each(printers, function(key, value) - { - $('#receipt_printer').append($('