diff --git a/application/controllers/Receivings.php b/application/controllers/Receivings.php index 8f9188efb..3be9eba63 100644 --- a/application/controllers/Receivings.php +++ b/application/controllers/Receivings.php @@ -46,7 +46,7 @@ class Receivings extends Secure_Controller if((!$stock_source || $stock_source == $this->receiving_lib->get_stock_source()) && (!$stock_destination || $stock_destination == $this->receiving_lib->get_stock_destination())) { - $this->receiving_lib->clear_invoice_number(); + $this->receiving_lib->clear_reference(); $mode = $this->input->post('mode'); $this->receiving_lib->set_mode($mode); } @@ -63,20 +63,15 @@ class Receivings extends Secure_Controller { $this->receiving_lib->set_comment($this->input->post('comment')); } - - public function set_invoice_number_enabled() - { - $this->receiving_lib->set_invoice_number_enabled($this->input->post('recv_invoice_number_enabled')); - } - + public function set_print_after_sale() { $this->receiving_lib->set_print_after_sale($this->input->post('recv_print_after_sale')); } - public function set_invoice_number() + public function set_reference() { - $this->receiving_lib->set_invoice_number($this->input->post('recv_invoice_number')); + $this->receiving_lib->set_reference($this->input->post('recv_reference')); } public function add() @@ -180,7 +175,7 @@ class Receivings extends Secure_Controller public function remove_supplier() { - $this->receiving_lib->clear_invoice_number(); + $this->receiving_lib->clear_reference(); $this->receiving_lib->remove_supplier(); $this->_reload(); @@ -195,7 +190,8 @@ class Receivings extends Secure_Controller $data['receipt_title'] = $this->lang->line('recvs_receipt'); $data['transaction_time'] = date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat')); $data['mode'] = $this->receiving_lib->get_mode(); - $data['comment'] = $this->input->post('comment'); + $data['comment'] = $this->receiving_lib->get_comment(); + $data['reference'] = $this->receiving_lib->get_reference(); $data['payment_type'] = $this->input->post('payment_type'); $data['show_stock_locations'] = $this->Stock_location->show_locations('receivings'); $data['stock_location'] = $this->receiving_lib->get_stock_source(); @@ -228,86 +224,26 @@ class Receivings extends Secure_Controller $data['supplier_location'] = ''; } } - $invoice_number = $this->_substitute_invoice_number($supplier_info); - if($this->receiving_lib->is_invoice_number_enabled() && $this->Receiving->invoice_number_exists($invoice_number)) - { - $data['error'] = $this->lang->line('recvs_invoice_number_duplicate'); - $this->_reload($data); + //SAVE receiving to database + $data['receiving_id'] = 'RECV ' . $this->Receiving->save($data['cart'], $supplier_id, $employee_id, $data['comment'], $data['reference'], $data['payment_type'], $data['stock_location']); + + $data = $this->xss_clean($data); + + if($data['receiving_id'] == 'RECV -1') + { + $data['error_message'] = $this->lang->line('recvs_transaction_failed'); } else { - $invoice_number = $this->receiving_lib->is_invoice_number_enabled() ? $invoice_number : NULL; - $data['invoice_number'] = $invoice_number; - //SAVE receiving to database - $data['receiving_id'] = 'RECV ' . $this->Receiving->save($data['cart'], $supplier_id, $employee_id, $data['comment'], $invoice_number, $data['payment_type'], $data['stock_location']); - - $data = $this->xss_clean($data); - - if($data['receiving_id'] == 'RECV -1') - { - $data['error_message'] = $this->lang->line('recvs_transaction_failed'); - } - else - { - $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['receiving_id']); - } - - $data['print_after_sale'] = $this->receiving_lib->is_print_after_sale(); - - $this->load->view("receivings/receipt",$data); - - $this->receiving_lib->clear_all(); - } - } - - private 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); + $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['receiving_id']); } - return $text; - } - - private 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); + $data['print_after_sale'] = $this->receiving_lib->is_print_after_sale(); - return $text; - } + $this->load->view("receivings/receipt",$data); - private 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; - } - - private function _substitute_invoice_number($supplier_info = '') - { - $invoice_number = $this->config->config['recv_invoice_format']; - $invoice_number = $this->_substitute_variables($invoice_number, $supplier_info); - $this->receiving_lib->set_invoice_number($invoice_number, TRUE); - - return $this->receiving_lib->get_invoice_number(); + $this->receiving_lib->clear_all(); } public function requisition_complete() @@ -342,7 +278,7 @@ class Receivings extends Secure_Controller $data['transaction_time'] = date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($receiving_info['receiving_time'])); $data['show_stock_locations'] = $this->Stock_location->show_locations('receivings'); $data['payment_type'] = $receiving_info['payment_type']; - $data['invoice_number'] = $this->receiving_lib->get_invoice_number(); + $data['reference'] = $this->receiving_lib->get_reference(); $data['receiving_id'] = 'RECV ' . $receiving_id; $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['receiving_id']); $employee_info = $this->Employee->get_info($receiving_info['employee_id']); @@ -366,6 +302,7 @@ class Receivings extends Secure_Controller $data['supplier_location'] = ''; } } + $data['print_after_sale'] = FALSE; $data = $this->xss_clean($data); @@ -392,6 +329,7 @@ class Receivings extends Secure_Controller $data['total'] = $this->receiving_lib->get_total(); $data['items_module_allowed'] = $this->Employee->has_grant('items', $this->Employee->get_logged_in_employee_info()->person_id); $data['comment'] = $this->receiving_lib->get_comment(); + $data['reference'] = $this->receiving_lib->get_reference(); $data['payment_options'] = $this->Receiving->get_payment_options(); $supplier_id = $this->receiving_lib->get_supplier(); @@ -413,8 +351,7 @@ class Receivings extends Secure_Controller $data['supplier_location'] = ''; } } - $data['invoice_number'] = $this->_substitute_invoice_number($supplier_info); - $data['invoice_number_enabled'] = $this->receiving_lib->is_invoice_number_enabled(); + $data['print_after_sale'] = $this->receiving_lib->is_print_after_sale(); $data = $this->xss_clean($data); @@ -433,7 +370,7 @@ class Receivings extends Secure_Controller 'supplier_id' => $this->input->post('supplier_id') ? $this->input->post('supplier_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 + 'reference' => $this->input->post('reference') != '' ? $this->input->post('reference') : NULL ); if($this->Receiving->update($receiving_data, $receiving_id)) @@ -452,14 +389,5 @@ class Receivings extends Secure_Controller $this->_reload(); } - - public function check_invoice_number() - { - $receiving_id = $this->input->post('receiving_id'); - $invoice_number = $this->input->post('invoice_number'); - $exists =! empty($invoice_number) && $this->Receiving->invoice_number_exists($invoice_number, $receiving_id); - - echo !$exists ? 'true' : 'false'; - } } ?> diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php index f715a613d..9775abfc4 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -34,66 +34,6 @@ class Reports extends Secure_Controller $this->load->view("reports/listing", $data); } - public function get_detailed_sales_row($sale_id) - { - $this->load->model('reports/Detailed_sales'); - $model = $this->Detailed_sales; - - $report_data = $model->getDataBySaleId($sale_id); - - $summary_data = $this->xss_clean(array( - 'sale_id' => $report_data['sale_id'], - 'sale_date' => $report_data['sale_date'], - 'quantity' => to_quantity_decimals($report_data['items_purchased']), - 'employee' => $report_data['employee_name'], - 'customer' => $report_data['customer_name'], - 'subtotal' => to_currency($report_data['subtotal']), - 'total' => to_currency($report_data['total']), - 'tax' => to_currency($report_data['tax']), - 'cost' => to_currency($report_data['cost']), - 'profit' => to_currency($report_data['profit']), - 'payment_type' => $report_data['payment_type'], - 'comment' => $report_data['comment'], - 'edit' => anchor("sales/edit/". $report_data['sale_id'], '', - array('class'=>"modal-dlg modal-btn-delete modal-btn-submit print_hide", 'title' => $this->lang->line('sales_update')) - ) - )); - - echo json_encode(array($sale_id => $summary_data)); - } - - public function get_detailed_receivings_row($receiving_id) - { - $this->load->model('reports/Detailed_receivings'); - $model = $this->Detailed_receivings; - - $report_data = $model->getDataByReceivingId($receiving_id); - - $summary_data = $this->xss_clean(array( - 'receiving_id' => $report_data['receiving_id'], - 'receiving_date' => $report_data['receiving_date'], - 'quantity' => to_quantity_decimals($report_data['items_purchased']), - 'invoice_number' => $report_data['invoice_number'], - 'employee' => $report_data['employee_name'], - 'supplier' => $report_data['supplier_name'], - 'total' => to_currency($report_data['total']), - 'comment' => $report_data['comment'], - 'payment_type' => $report_data['payment_type'], - 'edit' => anchor("receivings/edit/". $report_data['receiving_id'], '', - array('class'=>"modal-dlg modal-btn-delete modal-btn-submit print_hide", 'title' => $this->lang->line('recvs_update')) - ) - )); - - if($this->config->item('invoice_enable') == TRUE) - { - $summary_data[]['invoice_number'] = $this->xss_clean($report_data['invoice_number']); - } - - $summary_data[] = $this->xss_clean($report_data['comment']); - - echo json_encode(array($receiving_id => $summary_data)); - } - //Summary sales report public function summary_sales($start_date, $end_date, $sale_type) { @@ -844,6 +784,34 @@ class Reports extends Secure_Controller $this->load->view("reports/tabular_details", $data); } + public function get_detailed_sales_row($sale_id) + { + $this->load->model('reports/Detailed_sales'); + $model = $this->Detailed_sales; + + $report_data = $model->getDataBySaleId($sale_id); + + $summary_data = $this->xss_clean(array( + 'sale_id' => $report_data['sale_id'], + 'sale_date' => $report_data['sale_date'], + 'quantity' => to_quantity_decimals($report_data['items_purchased']), + 'employee' => $report_data['employee_name'], + 'customer' => $report_data['customer_name'], + 'subtotal' => to_currency($report_data['subtotal']), + 'total' => to_currency($report_data['total']), + 'tax' => to_currency($report_data['tax']), + 'cost' => to_currency($report_data['cost']), + 'profit' => to_currency($report_data['profit']), + 'payment_type' => $report_data['payment_type'], + 'comment' => $report_data['comment'], + 'edit' => anchor("sales/edit/". $report_data['sale_id'], '', + array('class'=>"modal-dlg modal-btn-delete modal-btn-submit print_hide", 'title' => $this->lang->line('sales_update')) + ) + )); + + echo json_encode(array($sale_id => $summary_data)); + } + public function detailed_sales($start_date, $end_date, $sale_type, $location_id = 'all') { $this->load->model('reports/Detailed_sales'); @@ -901,6 +869,31 @@ class Reports extends Secure_Controller $this->load->view("reports/tabular_details", $data); } + public function get_detailed_receivings_row($receiving_id) + { + $this->load->model('reports/Detailed_receivings'); + $model = $this->Detailed_receivings; + + $report_data = $model->getDataByReceivingId($receiving_id); + + $summary_data = $this->xss_clean(array( + 'receiving_id' => $report_data['receiving_id'], + 'receiving_date' => $report_data['receiving_date'], + 'quantity' => to_quantity_decimals($report_data['items_purchased']), + 'employee' => $report_data['employee_name'], + 'supplier' => $report_data['supplier_name'], + 'total' => to_currency($report_data['total']), + 'payment_type' => $report_data['payment_type'], + 'reference' => $report_data['reference'], + 'comment' => $report_data['comment'], + 'edit' => anchor("receivings/edit/". $report_data['receiving_id'], '', + array('class'=>"modal-dlg modal-btn-delete modal-btn-submit print_hide", 'title' => $this->lang->line('recvs_update')) + ) + )); + + echo json_encode(array($receiving_id => $summary_data)); + } + public function detailed_receivings($start_date, $end_date, $receiving_type, $location_id = 'all') { $this->load->model('reports/Detailed_receivings'); @@ -924,18 +917,13 @@ class Reports extends Secure_Controller 'supplier' => $row['supplier_name'], 'total' => to_currency($row['total']), 'payment_type' => $row['payment_type'], - 'invoice_number' => $row['invoice_number'], + 'reference' => $row['reference'], 'comment' => $row['comment'], 'edit' => anchor("receivings/edit/" . $row['receiving_id'], '', array('class' => "modal-dlg modal-btn-delete modal-btn-submit print_hide", 'title' => $this->lang->line('recvs_update')) ) )); - if(!$this->config->item('invoice_enable')) - { - unset($summary_data['invoice_number']); - } - foreach($report_data['details'][$key] as $drow) { $quantity_purchased = $drow['receiving_quantity'] > 1 ? to_quantity_decimals($drow['quantity_purchased']) . ' x ' . to_quantity_decimals($drow['receiving_quantity']) : to_quantity_decimals($drow['quantity_purchased']); diff --git a/application/language/de-CH/receivings_lang.php b/application/language/de-CH/receivings_lang.php index cbc7231d1..69cdd3d64 100644 --- a/application/language/de-CH/receivings_lang.php +++ b/application/language/de-CH/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "Kann Bestand nicht von oder zum gleichen Lag $lang["recvs_find_or_scan_item"] = "Finde/Scanne Artikel"; $lang["recvs_find_or_scan_item_or_receipt"] = "Finde/Scanne Artikel oder Quittung"; $lang["recvs_id"] = "Eingangs-Nr."; -$lang["recvs_invoice_enable"] = "Erzeuge Rechnung"; -$lang["recvs_invoice_number"] = "Rechnungs-Nr."; -$lang["recvs_invoice_number_duplicate"] = "Bitte geben Sie eine eindeutige Rechnungs-Nr. ein"; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Artikelname"; $lang["recvs_mode"] = "Eingangsmodus"; $lang["recvs_new_supplier"] = "Neuer Lieferant"; diff --git a/application/language/en/receivings_lang.php b/application/language/en/receivings_lang.php index 083664ba5..4ff72fb50 100644 --- a/application/language/en/receivings_lang.php +++ b/application/language/en/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "Unable to move inventory from and to the sam $lang["recvs_find_or_scan_item"] = "Find/Scan Item"; $lang["recvs_find_or_scan_item_or_receipt"] = "Find/Scan Item OR Receipt"; $lang["recvs_id"] = "Receiving ID"; -$lang["recvs_invoice_enable"] = "Create Invoice"; -$lang["recvs_invoice_number"] = "Invoice #"; -$lang["recvs_invoice_number_duplicate"] = "Please enter an unique invoice number"; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Item Name"; $lang["recvs_mode"] = "Receiving Mode"; $lang["recvs_new_supplier"] = "New Supplier"; diff --git a/application/language/es/receivings_lang.php b/application/language/es/receivings_lang.php index 4571bb6ea..2d723e744 100644 --- a/application/language/es/receivings_lang.php +++ b/application/language/es/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "No se puede mover el inventorio desde y haci $lang["recvs_find_or_scan_item"] = "Encontrar/Escanear Artículo"; $lang["recvs_find_or_scan_item_or_receipt"] = "Encontrar/Escanear Artículo o Entrada"; $lang["recvs_id"] = "ID de Entrada"; -$lang["recvs_invoice_enable"] = "Crear Factura"; -$lang["recvs_invoice_number"] = "Factura #"; -$lang["recvs_invoice_number_duplicate"] = "Por favor ingrese un número de factura único"; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Nombre del Artículo"; $lang["recvs_mode"] = "Modo de Entradas"; $lang["recvs_new_supplier"] = "Nuevo Proveedor"; diff --git a/application/language/fr/receivings_lang.php b/application/language/fr/receivings_lang.php index 267a548d7..010b8b250 100644 --- a/application/language/fr/receivings_lang.php +++ b/application/language/fr/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = ""; $lang["recvs_find_or_scan_item"] = "Chercher/Scanner Élément"; $lang["recvs_find_or_scan_item_or_receipt"] = "Chercher Elément OU Recu"; $lang["recvs_id"] = "ID Arrivage"; -$lang["recvs_invoice_enable"] = "Create Invoice"; -$lang["recvs_invoice_number"] = ""; -$lang["recvs_invoice_number_duplicate"] = ""; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Nom d'Élément"; $lang["recvs_mode"] = "Receiving Mode"; $lang["recvs_new_supplier"] = "Nouveau Fournisseur"; diff --git a/application/language/hr-HR/receivings_lang.php b/application/language/hr-HR/receivings_lang.php index 0d2359335..efe450756 100644 --- a/application/language/hr-HR/receivings_lang.php +++ b/application/language/hr-HR/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "Nije moguće micati inventuru iz i na skaldi $lang["recvs_find_or_scan_item"] = "Traži/skeniraj artikal"; $lang["recvs_find_or_scan_item_or_receipt"] = "Traži/skeniraj artikal ili račun"; $lang["recvs_id"] = "Primka br."; -$lang["recvs_invoice_enable"] = "Napravi fakturu"; -$lang["recvs_invoice_number"] = "Faktura br."; -$lang["recvs_invoice_number_duplicate"] = "Molim unesite jedinstven broj fakture"; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Naziv artikla"; $lang["recvs_mode"] = "Ulazni mod"; $lang["recvs_new_supplier"] = "Novi dobavljač"; diff --git a/application/language/hu-HU/receivings_lang.php b/application/language/hu-HU/receivings_lang.php index d2b9540b8..ebce7d478 100644 --- a/application/language/hu-HU/receivings_lang.php +++ b/application/language/hu-HU/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "Nem sikerült a készlet mozgatása ugyan ar $lang["recvs_find_or_scan_item"] = "Termék keresése/scan"; $lang["recvs_find_or_scan_item_or_receipt"] = "Termék keresése/scan"; $lang["recvs_id"] = "Átvételi ID"; -$lang["recvs_invoice_enable"] = "Számla készitése"; -$lang["recvs_invoice_number"] = "Számla #"; -$lang["recvs_invoice_number_duplicate"] = "Kérem adjon meg egyedi számot"; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Termék neve"; $lang["recvs_mode"] = "Átvétel módja"; $lang["recvs_new_supplier"] = "Új beszállitó"; diff --git a/application/language/id/receivings_lang.php b/application/language/id/receivings_lang.php index c329dca03..97607e368 100644 --- a/application/language/id/receivings_lang.php +++ b/application/language/id/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "Kesalahan Daftar Permintaan"; $lang["recvs_find_or_scan_item"] = "Cari/Scan Item"; $lang["recvs_find_or_scan_item_or_receipt"] = "Cari/Scan Item ATAU Faktur"; $lang["recvs_id"] = "ID Penerimaan"; -$lang["recvs_invoice_enable"] = "Create Invoice"; -$lang["recvs_invoice_number"] = "Nomer Nota"; -$lang["recvs_invoice_number_duplicate"] = "Nomer Nota Double"; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Nama Item"; $lang["recvs_mode"] = "Jenis Penerimaan"; $lang["recvs_new_supplier"] = "Pemasok Baru"; diff --git a/application/language/nl-BE/receivings_lang.php b/application/language/nl-BE/receivings_lang.php index 7167ed68b..1d57eef14 100755 --- a/application/language/nl-BE/receivings_lang.php +++ b/application/language/nl-BE/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "Kon de stock transfer niet vervolledigen"; $lang["recvs_find_or_scan_item"] = "Zoek/Scan Product"; $lang["recvs_find_or_scan_item_or_receipt"] = "Zoek/Scan Product OF Tickets"; $lang["recvs_id"] = "Ordernummer"; -$lang["recvs_invoice_enable"] = "Maak Factuur"; -$lang["recvs_invoice_number"] = "Factuur #"; -$lang["recvs_invoice_number_duplicate"] = "Gelieve een uniek factuurnummer in te voeren"; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Productnaam"; $lang["recvs_mode"] = "Order type"; $lang["recvs_new_supplier"] = "N. Leverancier"; diff --git a/application/language/pt-BR/receivings_lang.php b/application/language/pt-BR/receivings_lang.php index 7f4c0dc3c..d327649ea 100644 --- a/application/language/pt-BR/receivings_lang.php +++ b/application/language/pt-BR/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "Não é possível mover o inventário de e p $lang["recvs_find_or_scan_item"] = "Localizar Item"; $lang["recvs_find_or_scan_item_or_receipt"] = "Produto no Estoque"; $lang["recvs_id"] = "Recebimento ID"; -$lang["recvs_invoice_enable"] = "Criar Fatura"; -$lang["recvs_invoice_number"] = "Fatura nº"; -$lang["recvs_invoice_number_duplicate"] = "Por favor insira um número de fatura única"; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Nome do item"; $lang["recvs_mode"] = "Tipo Recebimento"; $lang["recvs_new_supplier"] = "Novo Fornecedor"; diff --git a/application/language/ru/receivings_lang.php b/application/language/ru/receivings_lang.php index 2ec2577f1..525c9f467 100644 --- a/application/language/ru/receivings_lang.php +++ b/application/language/ru/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = ""; $lang["recvs_find_or_scan_item"] = "Найти/Сканировать товар"; $lang["recvs_find_or_scan_item_or_receipt"] = "Найти/Сканировать товар ИЛИ квитанция"; $lang["recvs_id"] = "получение ID"; -$lang["recvs_invoice_enable"] = "Create Invoice"; -$lang["recvs_invoice_number"] = ""; -$lang["recvs_invoice_number_duplicate"] = ""; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Название товара"; $lang["recvs_mode"] = "получая режим"; $lang["recvs_new_supplier"] = "Новый поставщик"; diff --git a/application/language/th/receivings_lang.php b/application/language/th/receivings_lang.php index 8da6e7bb4..c7e24d43e 100644 --- a/application/language/th/receivings_lang.php +++ b/application/language/th/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = ""; $lang["recvs_find_or_scan_item"] = "ค้นหาสินค้า"; $lang["recvs_find_or_scan_item_or_receipt"] = "ค้นหาสินค้าหรือบิล"; $lang["recvs_id"] = "รายการสินค้าเข้า ID"; -$lang["recvs_invoice_enable"] = "Create Invoice"; -$lang["recvs_invoice_number"] = ""; -$lang["recvs_invoice_number_duplicate"] = ""; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "ชื่อสินคัา"; $lang["recvs_mode"] = "ประเภทธุรกรรม"; $lang["recvs_new_supplier"] = "ผู้ผลิตรายใหม่"; diff --git a/application/language/tr/receivings_lang.php b/application/language/tr/receivings_lang.php index 27155a157..148321a1f 100644 --- a/application/language/tr/receivings_lang.php +++ b/application/language/tr/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = "Ürün aynı yere taşınamaz"; $lang["recvs_find_or_scan_item"] = "Ürün Bul/Oku"; $lang["recvs_find_or_scan_item_or_receipt"] = "Ürün yada Fatura Bul/Oku"; $lang["recvs_id"] = "Alım No"; -$lang["recvs_invoice_enable"] = "Create Invoice"; -$lang["recvs_invoice_number"] = ""; -$lang["recvs_invoice_number_duplicate"] = ""; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "Ürün Adı"; $lang["recvs_mode"] = "Alım Türü"; $lang["recvs_new_supplier"] = "Yeni Sağlayıcı"; diff --git a/application/language/zh/receivings_lang.php b/application/language/zh/receivings_lang.php index e4daae3e7..11944434b 100755 --- a/application/language/zh/receivings_lang.php +++ b/application/language/zh/receivings_lang.php @@ -22,9 +22,7 @@ $lang["recvs_error_requisition"] = ""; $lang["recvs_find_or_scan_item"] = "查找 / 掃描產品"; $lang["recvs_find_or_scan_item_or_receipt"] = "查找 / 掃描產品或收據"; $lang["recvs_id"] = "進貨編號"; -$lang["recvs_invoice_enable"] = "Create Invoice"; -$lang["recvs_invoice_number"] = ""; -$lang["recvs_invoice_number_duplicate"] = ""; +$lang["recvs_reference"] = "Reference"; $lang["recvs_item_name"] = "產品名稱"; $lang["recvs_mode"] = "進貨模式"; $lang["recvs_new_supplier"] = "新供應商"; diff --git a/application/libraries/Receiving_lib.php b/application/libraries/Receiving_lib.php index fb6817fb0..629ac0862 100644 --- a/application/libraries/Receiving_lib.php +++ b/application/libraries/Receiving_lib.php @@ -1,383 +1,366 @@ CI =& get_instance(); - } + function __construct() + { + $this->CI =& get_instance(); + } - function get_cart() - { - if(!$this->CI->session->userdata('cartRecv')) - $this->set_cart(array()); + function get_cart() + { + if(!$this->CI->session->userdata('cartRecv')) + $this->set_cart(array()); - return $this->CI->session->userdata('cartRecv'); - } + return $this->CI->session->userdata('cartRecv'); + } - function set_cart($cart_data) - { - $this->CI->session->set_userdata('cartRecv',$cart_data); - } + function set_cart($cart_data) + { + $this->CI->session->set_userdata('cartRecv',$cart_data); + } - function get_supplier() - { - if(!$this->CI->session->userdata('supplier')) - $this->set_supplier(-1); + function get_supplier() + { + if(!$this->CI->session->userdata('supplier')) + $this->set_supplier(-1); - return $this->CI->session->userdata('supplier'); - } + return $this->CI->session->userdata('supplier'); + } - function set_supplier($supplier_id) - { - $this->CI->session->set_userdata('supplier',$supplier_id); - } + function set_supplier($supplier_id) + { + $this->CI->session->set_userdata('supplier',$supplier_id); + } - function get_mode() - { - if(!$this->CI->session->userdata('recv_mode')) - $this->set_mode('receive'); + function get_mode() + { + if(!$this->CI->session->userdata('recv_mode')) + $this->set_mode('receive'); - return $this->CI->session->userdata('recv_mode'); - } + return $this->CI->session->userdata('recv_mode'); + } - function set_mode($mode) - { - $this->CI->session->set_userdata('recv_mode',$mode); - } - - function get_stock_source() - { - if(!$this->CI->session->userdata('recv_stock_source')) - { - $location_id = $this->CI->Stock_location->get_default_location_id(); - $this->set_stock_source($location_id); - } - return $this->CI->session->userdata('recv_stock_source'); - } - - function get_comment() - { - // avoid returning a null that results in a 0 in the comment if nothing is set/available - $comment = $this->CI->session->userdata('comment'); - return empty($comment) ? '' : $comment; - } - - function set_comment($comment) - { - $this->CI->session->set_userdata('comment', $comment); - } - - function clear_comment() - { - $this->CI->session->unset_userdata('comment'); - } + function set_mode($mode) + { + $this->CI->session->set_userdata('recv_mode',$mode); + } + + function get_stock_source() + { + if(!$this->CI->session->userdata('recv_stock_source')) + { + $location_id = $this->CI->Stock_location->get_default_location_id(); + $this->set_stock_source($location_id); + } + return $this->CI->session->userdata('recv_stock_source'); + } + + function get_comment() + { + // avoid returning a null that results in a 0 in the comment if nothing is set/available + $comment = $this->CI->session->userdata('comment'); + return empty($comment) ? '' : $comment; + } + + function set_comment($comment) + { + $this->CI->session->set_userdata('comment', $comment); + } + + function clear_comment() + { + $this->CI->session->unset_userdata('comment'); + } - function get_invoice_number() - { - return $this->CI->session->userdata('recv_invoice_number'); - } - - function set_invoice_number($invoice_number, $keep_custom = FALSE) - { - $current_invoice_number = $this->CI->session->userdata('recv_invoice_number'); - if (!$keep_custom || empty($current_invoice_number)) - { - $this->CI->session->set_userdata('recv_invoice_number', $invoice_number); - } - } - - function clear_invoice_number() - { - $this->CI->session->unset_userdata('recv_invoice_number'); - } - - function is_invoice_number_enabled() - { - return $this->CI->session->userdata('recv_invoice_number_enabled') == 'true' || - $this->CI->session->userdata('recv_invoice_number_enabled') == '1'; - } - - function set_invoice_number_enabled($invoice_number_enabled) - { - return $this->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); - } - - function clear_stock_source() - { - $this->CI->session->unset_userdata('recv_stock_source'); - } - - function get_stock_destination() - { - if(!$this->CI->session->userdata('recv_stock_destination')) - { - $location_id = $this->CI->Stock_location->get_default_location_id(); - $this->set_stock_destination($location_id); - } - return $this->CI->session->userdata('recv_stock_destination'); - } + function get_reference() + { + return $this->CI->session->userdata('recv_reference'); + } + + function set_reference($reference) + { + $this->CI->session->set_userdata('recv_reference', $reference); + } + + function clear_reference() + { + $this->CI->session->unset_userdata('recv_reference'); + } + + 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); + } + + function clear_stock_source() + { + $this->CI->session->unset_userdata('recv_stock_source'); + } + + function get_stock_destination() + { + if(!$this->CI->session->userdata('recv_stock_destination')) + { + $location_id = $this->CI->Stock_location->get_default_location_id(); + $this->set_stock_destination($location_id); + } + return $this->CI->session->userdata('recv_stock_destination'); + } - function set_stock_destination($stock_destination) - { - $this->CI->session->set_userdata('recv_stock_destination',$stock_destination); - } - - function clear_stock_destination() - { - $this->CI->session->unset_userdata('recv_stock_destination'); - } + function set_stock_destination($stock_destination) + { + $this->CI->session->set_userdata('recv_stock_destination',$stock_destination); + } + + function clear_stock_destination() + { + $this->CI->session->unset_userdata('recv_stock_destination'); + } - function add_item($item_id,$quantity=1,$item_location=null,$discount=0,$price=null,$description=null,$serialnumber=null,$receiving_quantity=null) - { - //make sure item exists in database. - if(!$this->CI->Item->exists($item_id)) - { - //try to get item id given an item_number - $item_id = $this->CI->Item->get_item_id($item_id); + function add_item($item_id,$quantity=1,$item_location=null,$discount=0,$price=null,$description=null,$serialnumber=null,$receiving_quantity=null) + { + //make sure item exists in database. + if(!$this->CI->Item->exists($item_id)) + { + //try to get item id given an item_number + $item_id = $this->CI->Item->get_item_id($item_id); - if(!$item_id) - return false; - } + if(!$item_id) + return false; + } - //Get items in the receiving so far. - $items = $this->get_cart(); + //Get items in the receiving so far. + $items = $this->get_cart(); - //We need to loop through all items in the cart. - //If the item is already there, get it's key($updatekey). - //We also need to get the next key that we are going to use in case we need to add the - //item to the list. Since items can be deleted, we can't use a count. we use the highest key + 1. + //We need to loop through all items in the cart. + //If the item is already there, get it's key($updatekey). + //We also need to get the next key that we are going to use in case we need to add the + //item to the list. Since items can be deleted, we can't use a count. we use the highest key + 1. - $maxkey=0; //Highest key so far - $itemalreadyinsale=FALSE; //We did not find the item yet. - $insertkey=0; //Key to use for new entry. - $updatekey=0; //Key to use to update(quantity) + $maxkey=0; //Highest key so far + $itemalreadyinsale=FALSE; //We did not find the item yet. + $insertkey=0; //Key to use for new entry. + $updatekey=0; //Key to use to update(quantity) - foreach ($items as $item) - { - //We primed the loop so maxkey is 0 the first time. - //Also, we have stored the key in the element itself so we can compare. - //There is an array function to get the associated key for an element, but I like it better - //like that! + foreach ($items as $item) + { + //We primed the loop so maxkey is 0 the first time. + //Also, we have stored the key in the element itself so we can compare. + //There is an array function to get the associated key for an element, but I like it better + //like that! - if($maxkey <= $item['line']) - { - $maxkey = $item['line']; - } + if($maxkey <= $item['line']) + { + $maxkey = $item['line']; + } - if($item['item_id']==$item_id && $item['item_location']==$item_location) - { - $itemalreadyinsale=TRUE; - $updatekey=$item['line']; - } - } + if($item['item_id']==$item_id && $item['item_location']==$item_location) + { + $itemalreadyinsale=TRUE; + $updatekey=$item['line']; + } + } - $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, - 'item_location'=>$item_location, - 'stock_name'=>$this->CI->Stock_location->get_location_name($item_location), - 'line'=>$insertkey, - 'name'=>$item_info->name, - 'description'=>$description!=null ? $description: $item_info->description, - 'serialnumber'=>$serialnumber!=null ? $serialnumber: '', - 'allow_alt_description'=>$item_info->allow_alt_description, - 'is_serialized'=>$item_info->is_serialized, - 'quantity'=>$quantity, - 'discount'=>$discount, - 'in_stock'=>$this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity, - 'price'=>$price, - 'receiving_quantity'=>$receiving_quantity!=null ? $receiving_quantity : $item_info->receiving_quantity, - 'total'=>$this->get_item_total($quantity, $price, $discount) - ) - ); + $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, + 'item_location'=>$item_location, + 'stock_name'=>$this->CI->Stock_location->get_location_name($item_location), + 'line'=>$insertkey, + 'name'=>$item_info->name, + 'description'=>$description!=null ? $description: $item_info->description, + 'serialnumber'=>$serialnumber!=null ? $serialnumber: '', + 'allow_alt_description'=>$item_info->allow_alt_description, + 'is_serialized'=>$item_info->is_serialized, + 'quantity'=>$quantity, + 'discount'=>$discount, + 'in_stock'=>$this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity, + 'price'=>$price, + 'receiving_quantity'=>$receiving_quantity!=null ? $receiving_quantity : $item_info->receiving_quantity, + 'total'=>$this->get_item_total($quantity, $price, $discount) + ) + ); - //Item already exists - if($itemalreadyinsale) - { - $items[$updatekey]['quantity']+=$quantity; - } - else - { - //add to existing array - $items+=$item; - } + //Item already exists + if($itemalreadyinsale) + { + $items[$updatekey]['quantity']+=$quantity; + } + else + { + //add to existing array + $items+=$item; + } - $this->set_cart($items); + $this->set_cart($items); - return true; - } + return true; + } - function edit_item($line,$description,$serialnumber,$quantity,$discount,$price) - { - $items = $this->get_cart(); - if(isset($items[$line])) - { - $line = &$items[$line]; - $line['description'] = $description; - $line['serialnumber'] = $serialnumber; - $line['quantity'] = $quantity; - $line['discount'] = $discount; - $line['price'] = $price; - $line['total'] = $this->get_item_total($quantity, $price, $discount); - $this->set_cart($items); - } + function edit_item($line,$description,$serialnumber,$quantity,$discount,$price) + { + $items = $this->get_cart(); + if(isset($items[$line])) + { + $line = &$items[$line]; + $line['description'] = $description; + $line['serialnumber'] = $serialnumber; + $line['quantity'] = $quantity; + $line['discount'] = $discount; + $line['price'] = $price; + $line['total'] = $this->get_item_total($quantity, $price, $discount); + $this->set_cart($items); + } - return false; - } - - function is_valid_receipt($receipt_receiving_id) - { - //RECV # - $pieces = explode(' ', $receipt_receiving_id); + return false; + } + + function is_valid_receipt($receipt_receiving_id) + { + //RECV # + $pieces = explode(' ', $receipt_receiving_id); - if(count($pieces) == 2 && preg_match('/(RECV|KIT)/', $pieces[1])) - { - return $this->CI->Receiving->exists($pieces[1]); - } - else - { - return $this->CI->Receiving->get_receiving_by_invoice_number($receipt_receiving_id)->num_rows() > 0; - } + if(count($pieces) == 2 && preg_match('/(RECV|KIT)/', $pieces[1])) + { + return $this->CI->Receiving->exists($pieces[1]); + } + else + { + return $this->CI->Receiving->get_receiving_by_reference($receipt_receiving_id)->num_rows() > 0; + } - return FALSE; - } - - function is_valid_item_kit($item_kit_id) - { - //KIT # - $pieces = explode(' ',$item_kit_id); + return FALSE; + } + + function is_valid_item_kit($item_kit_id) + { + //KIT # + $pieces = explode(' ',$item_kit_id); - if(count($pieces)==2) - { - return $this->CI->Item_kit->exists($pieces[1]); - } + if(count($pieces)==2) + { + return $this->CI->Item_kit->exists($pieces[1]); + } - return false; - } + return false; + } - function return_entire_receiving($receipt_receiving_id) - { - //POS # - $pieces = explode(' ',$receipt_receiving_id); - if (preg_match("/(RECV|KIT)/", $pieces[0])) - { - $receiving_id = $pieces[1]; - } - else - { - $receiving = $this->CI->Receiving->get_receiving_by_invoice_number($receipt_receiving_id)->row(); - $receiving_id = $receiving->receiving_id; - } + function return_entire_receiving($receipt_receiving_id) + { + //RECV # + $pieces = explode(' ',$receipt_receiving_id); + if (preg_match("/(RECV|KIT)/", $pieces[0])) + { + $receiving_id = $pieces[1]; + } + else + { + $receiving = $this->CI->Receiving->get_receiving_by_reference($receipt_receiving_id)->row(); + $receiving_id = $receiving->receiving_id; + } - $this->empty_cart(); - $this->remove_supplier(); - $this->clear_comment(); + $this->empty_cart(); + $this->remove_supplier(); + $this->clear_comment(); - foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row) - { - $this->add_item($row->item_id,-$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber,$row->receiving_quantity); - } - $this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id); - } - - function add_item_kit($external_item_kit_id,$item_location) - { - //KIT # - $pieces = explode(' ',$external_item_kit_id); - $item_kit_id = $pieces[1]; - - foreach ($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item) - { - $this->add_item($item_kit_item['item_id'],$item_kit_item['quantity'],$item_location); - } - } + foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row) + { + $this->add_item($row->item_id,-$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber,$row->receiving_quantity); + } + $this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id); + } + + function add_item_kit($external_item_kit_id,$item_location) + { + //KIT # + $pieces = explode(' ',$external_item_kit_id); + $item_kit_id = $pieces[1]; + + foreach ($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item) + { + $this->add_item($item_kit_item['item_id'],$item_kit_item['quantity'], $item_location); + } + } - function copy_entire_receiving($receiving_id) - { - $this->empty_cart(); - $this->remove_supplier(); + function copy_entire_receiving($receiving_id) + { + $this->empty_cart(); + $this->remove_supplier(); - foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row) - { - $this->add_item($row->item_id,$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber,$row->receiving_quantity); - } - $this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id); - $receiving_info=$this->CI->Receiving->get_info($receiving_id); - //$this->set_invoice_number($receiving_info->row()->invoice_number); - } - - function delete_item($line) - { - $items=$this->get_cart(); - unset($items[$line]); - $this->set_cart($items); - } + foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row) + { + $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity); + } + $this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id); + $receiving_info = $this->CI->Receiving->get_info($receiving_id); + //$this->set_reference($receiving_info->row()->reference); + } + + function delete_item($line) + { + $items=$this->get_cart(); + unset($items[$line]); + $this->set_cart($items); + } - function empty_cart() - { - $this->CI->session->unset_userdata('cartRecv'); - } + function empty_cart() + { + $this->CI->session->unset_userdata('cartRecv'); + } - function remove_supplier() - { - $this->CI->session->unset_userdata('supplier'); - } - - function clear_mode() - { - $this->CI->session->unset_userdata('receiving_mode'); - } + function remove_supplier() + { + $this->CI->session->unset_userdata('supplier'); + } + + function clear_mode() + { + $this->CI->session->unset_userdata('receiving_mode'); + } - function clear_all() - { - $this->set_invoice_number_enabled(FALSE); - $this->clear_mode(); - $this->empty_cart(); - $this->remove_supplier(); - $this->clear_comment(); - $this->clear_invoice_number(); - } - - function get_item_total($quantity, $price, $discount_percentage) - { - $total = bcmul($quantity, $price, PRECISION); - $discount_fraction = bcdiv($discount_percentage, 100, PRECISION); - $discount_amount = bcmul($total, $discount_fraction, PRECISION); - return bcsub($total, $discount_amount, PRECISION); - } + function clear_all() + { + $this->clear_mode(); + $this->empty_cart(); + $this->remove_supplier(); + $this->clear_comment(); + $this->clear_reference(); + } + + function get_item_total($quantity, $price, $discount_percentage) + { + $total = bcmul($quantity, $price, PRECISION); + $discount_fraction = bcdiv($discount_percentage, 100, PRECISION); + $discount_amount = bcmul($total, $discount_fraction, PRECISION); + return bcsub($total, $discount_amount, PRECISION); + } - function get_total() - { - $total = 0; - foreach($this->get_cart() as $item) - { - $total = bcadd($total, $this->get_item_total($item['quantity'], $item['price'], $item['discount']), PRECISION); - } - - return $total; - } + function get_total() + { + $total = 0; + foreach($this->get_cart() as $item) + { + $total = bcadd($total, $this->get_item_total($item['quantity'], $item['price'], $item['discount']), PRECISION); + } + + return $total; + } } ?> diff --git a/application/models/Receiving.php b/application/models/Receiving.php index b586dfbca..a5c008879 100644 --- a/application/models/Receiving.php +++ b/application/models/Receiving.php @@ -11,37 +11,14 @@ class Receiving extends CI_Model return $this->db->get(); } - /* - Gets total of invoice rows - */ - public function get_invoice_count() + public function get_receiving_by_reference($reference) { $this->db->from('receivings'); - $this->db->where('invoice_number IS NOT NULL'); - - return $this->db->count_all_results(); - } - - public function get_receiving_by_invoice_number($invoice_number) - { - $this->db->from('receivings'); - $this->db->where('invoice_number', $invoice_number); + $this->db->where('reference', $reference); return $this->db->get(); } - - public function get_invoice_number_for_year($year = '', $start_from = 0) - { - $year = $year == '' ? date('Y') : $year; - $this->db->select('COUNT( 1 ) AS invoice_number_year'); - $this->db->from('receivings'); - $this->db->where('DATE_FORMAT(receiving_time, "%Y" ) = ', $year); - $this->db->where('invoice_number IS NOT NULL'); - $result = $this->db->get()->row_array(); - return ($start_from + $result['invoice_number_year'] + 1); - } - public function exists($receiving_id) { $this->db->from('receivings'); @@ -57,7 +34,7 @@ class Receiving extends CI_Model return $this->db->update('receivings', $receiving_data); } - public function save($items, $supplier_id, $employee_id, $comment, $invoice_number, $payment_type, $receiving_id = FALSE) + public function save($items, $supplier_id, $employee_id, $comment, $reference, $payment_type, $receiving_id = FALSE) { if(count($items) == 0) { @@ -69,7 +46,7 @@ class Receiving extends CI_Model 'employee_id' => $employee_id, 'payment_type' => $payment_type, 'comment' => $comment, - 'invoice_number' => $invoice_number + 'reference' => $reference ); //Run these queries as a transaction, we want to make sure we do all or nothing @@ -211,19 +188,6 @@ class Receiving extends CI_Model return $this->Supplier->get_info($this->db->get()->row()->supplier_id); } - - public function invoice_number_exists($invoice_number, $receiving_id = '') - { - $this->db->from('receivings'); - $this->db->where('invoice_number', $invoice_number); - if(!empty($receiving_id)) - { - $this->db->where('receiving_id !=', $receiving_id); - } - $query = $this->db->get(); - - return ($query->num_rows() == 1); - } public function get_payment_options() { @@ -246,7 +210,7 @@ class Receiving extends CI_Model " . $this->db->dbprefix('receivings_items') . " . receiving_id, comment, item_location, - invoice_number, + reference, payment_type, employee_id, " . $this->db->dbprefix('items') . " . item_id, diff --git a/application/models/reports/Detailed_receivings.php b/application/models/reports/Detailed_receivings.php index be5aa9d9f..66004d0d3 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -18,7 +18,7 @@ class Detailed_receivings extends Report 'supplier' => $this->lang->line('reports_supplied_by'), 'total' => $this->lang->line('reports_total'), 'payment_type' => $this->lang->line('reports_payment_type'), - 'invoice_number' => $this->lang->line('recvs_invoice_number'), + 'reference' => $this->lang->line('recvs_reference'), 'comment' => $this->lang->line('reports_comments'), 'edit' => ''), 'details' => array( @@ -30,16 +30,12 @@ class Detailed_receivings extends Report $this->lang->line('reports_discount')) ); - if (!get_instance()->config->item('invoice_enable')) - { - unset($columns['summary']['invoice_number']); - } return $columns; } public function getDataByReceivingId($receiving_id) { - $this->db->select('receiving_id, DATE_FORMAT(receiving_date, "%d-%m-%Y") AS receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name, " ", employee.last_name) AS employee_name, suppliers.company_name AS supplier_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, invoice_number'); + $this->db->select('receiving_id, DATE_FORMAT(receiving_date, "%d-%m-%Y") AS receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name, " ", employee.last_name) AS employee_name, suppliers.company_name AS supplier_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, reference'); $this->db->from('receivings_items_temp'); $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id'); $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left'); @@ -50,7 +46,7 @@ class Detailed_receivings extends Report public function getData(array $inputs) { - $this->db->select('receiving_id, receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name," ",employee.last_name) AS employee_name, supplier.company_name AS supplier_name, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, invoice_number'); + $this->db->select('receiving_id, receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name," ",employee.last_name) AS employee_name, supplier.company_name AS supplier_name, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, reference'); $this->db->from('receivings_items_temp'); $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id'); $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left'); diff --git a/application/views/receivings/form.php b/application/views/receivings/form.php index 31146a287..c95b28136 100755 --- a/application/views/receivings/form.php +++ b/application/views/receivings/form.php @@ -24,19 +24,12 @@ - config->item('invoice_enable') == TRUE) - { - ?> -
- lang->line('recvs_invoice_number'), 'invoice_number', array('class'=>'control-label col-xs-3')); ?> -
- 'invoice_number', 'value' => $receiving_info['invoice_number'], 'id' => 'invoice_number', 'class'=>'form-control input-sm'));?> -
+
+ lang->line('recvs_reference'), 'reference', array('class'=>'control-label col-xs-3')); ?> +
+ 'reference', 'value' => $receiving_info['reference'], 'id' => 'reference', 'class'=>'form-control input-sm'));?>
- +
lang->line('recvs_employee'), 'employee', array('class'=>'control-label col-xs-3')); ?> @@ -59,7 +52,8 @@ $(document).ready(function() { load->view('partial/datepicker_locale'); ?> - $('#datetime').datetimepicker({ + $('#datetime').datetimepicker( + { format: "config->item("dateformat")) . ' ' . dateformat_bootstrap($this->config->item("timeformat"));?>", startDate: "config->item('dateformat') . ' ' . $this->config->item('timeformat'), mktime(0, 0, 0, 1, 1, 2010));?>", config->item('language'); ?>" }); - var fill_value = function(event, ui) + var fill_value = function(event, ui) { event.preventDefault(); $("input[name='supplier_id']").val(ui.item.value); @@ -132,40 +126,11 @@ $(document).ready(function() }, rules: { - config->item('invoice_enable') == TRUE) - { - ?> - invoice_number: { - remote: - { - url: "", - type: "POST", - data: - { - "receiving_id" : , - "invoice_number" : function() - { - return $("#invoice_number").val(); - } - } - } - } - }, messages: { - config->item('invoice_enable') == TRUE) - { - ?> - invoice_number: 'lang->line("recvs_invoice_number_duplicate"); ?>' - + } }, form_support.error)); diff --git a/application/views/receivings/receipt.php b/application/views/receivings/receipt.php index e0b4ad04c..677a7d462 100644 --- a/application/views/receivings/receipt.php +++ b/application/views/receivings/receipt.php @@ -48,10 +48,10 @@ if (isset($error_message)) ?>
lang->line('recvs_id').": ".$receiving_id; ?>
-
lang->line('recvs_invoice_number').": ".$invoice_number; ?>
+
lang->line('recvs_reference').": ".$reference; ?>
diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php index ffb4eff41..3a5ee3a82 100644 --- a/application/views/receivings/receiving.php +++ b/application/views/receivings/receiving.php @@ -358,19 +358,13 @@ if (isset($success)) config->item('invoice_enable') == TRUE) + if ($mode == "receive") { ?> - lang->line('recvs_invoice_enable'); ?> + lang->line('recvs_reference');?> - 'recv_invoice_enable', 'id'=>'recv_invoice_enable', 'class'=>'checkbox', 'value'=>1, 'checked'=>$invoice_number_enabled)); ?> - - - - lang->line('recvs_invoice_number');?> - - 'recv_invoice_number', 'id'=>'recv_invoice_number', 'class'=>'form-control input-sm', 'value'=>$invoice_number, 'size'=>5));?> + 'recv_reference', 'id'=>'recv_reference', 'class'=>'form-control input-sm', 'value'=>$reference, 'size'=>5));?> ', {comment: $('#comment').val()}); }); - config->item('invoice_enable') == TRUE) + $('#recv_reference').keyup(function() { - ?> - $('#recv_invoice_number').keyup(function() - { - $.post('', {recv_invoice_number: $('#recv_invoice_number').val()}); - }); + $.post('', {recv_reference: $('#recv_reference').val()}); + }); - $("#recv_print_after_sale").change(function() - { - $.post('', {recv_print_after_sale: $(this).is(":checked")}); - }); - - var enable_invoice_number = function() - { - var enabled = $("#recv_invoice_enable").is(":checked"); - $("#recv_invoice_number").prop("disabled", !enabled).parents('tr').show(); - return enabled; - } - - enable_invoice_number(); - - $("#recv_invoice_enable").change(function() - { - var enabled = enable_invoice_number(); - $.post('', {recv_invoice_number_enabled: enabled}); - - }); - + $("#recv_print_after_sale").change(function() + { + $.post('', {recv_print_after_sale: $(this).is(":checked")}); + }); $('#item,#supplier').click(function() { diff --git a/database/2.4_to_3.0.sql b/database/2.4_to_3.0.sql index 2237cc0d3..93aaae8c7 100644 --- a/database/2.4_to_3.0.sql +++ b/database/2.4_to_3.0.sql @@ -9,6 +9,11 @@ ALTER TABLE `ospos_item_kit_items` ALTER TABLE `ospos_item_quantities` MODIFY COLUMN `quantity` decimal(15,3) NOT NULL DEFAULT '0'; + +ALTER TABLE `ospos_receivings` + DROP KEY `invoice_number`, + CHANGE COLUMN `invoice_number` `reference` varchar(32) DEFAULT NULL, + ADD KEY `reference` (`reference`); ALTER TABLE `ospos_receivings_items` MODIFY COLUMN `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', diff --git a/database/database.sql b/database/database.sql index a0b85a7b4..46c62be5a 100644 --- a/database/database.sql +++ b/database/database.sql @@ -441,11 +441,11 @@ CREATE TABLE `ospos_receivings` ( `comment` text NOT NULL, `receiving_id` int(10) NOT NULL AUTO_INCREMENT, `payment_type` varchar(20) DEFAULT NULL, - `invoice_number` varchar(32) DEFAULT NULL, + `reference` varchar(32) DEFAULT NULL, PRIMARY KEY (`receiving_id`), KEY `supplier_id` (`supplier_id`), KEY `employee_id` (`employee_id`), - UNIQUE KEY `invoice_number` (`invoice_number`) + KEY `reference` (`reference`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index 46951d2a6..be72f5a9e 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -441,11 +441,11 @@ CREATE TABLE `ospos_receivings` ( `comment` text NOT NULL, `receiving_id` int(10) NOT NULL AUTO_INCREMENT, `payment_type` varchar(20) DEFAULT NULL, - `invoice_number` varchar(32) DEFAULT NULL, + `reference` varchar(32) DEFAULT NULL, PRIMARY KEY (`receiving_id`), KEY `supplier_id` (`supplier_id`), KEY `employee_id` (`employee_id`), - UNIQUE KEY `invoice_number` (`invoice_number`) + KEY `reference` (`reference`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -831,7 +831,7 @@ SELECT `first_name`, `last_name`, `phone_number`, `email`, `address_1`, `address -- Copy data to table `ospos_receivings` -- -INSERT INTO `ospos_receivings` (`receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, `invoice_number`) +INSERT INTO `ospos_receivings` (`receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, `reference`) SELECT `receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, NULL FROM `phppos`.phppos_receivings; -- diff --git a/database/phppos_migrate.sql b/database/phppos_migrate.sql index ccc285158..93c313996 100644 --- a/database/phppos_migrate.sql +++ b/database/phppos_migrate.sql @@ -108,7 +108,7 @@ SELECT `first_name`, `last_name`, `phone_number`, `email`, `address_1`, `address -- Copy data to table `ospos_receivings` -- -INSERT INTO `ospos_receivings` (`receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, `invoice_number`) +INSERT INTO `ospos_receivings` (`receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, `reference`) SELECT `receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, NULL FROM `phppos`.phppos_receivings; -- diff --git a/database/tables.sql b/database/tables.sql index 78a129b39..ac7c9ed31 100644 --- a/database/tables.sql +++ b/database/tables.sql @@ -441,11 +441,11 @@ CREATE TABLE `ospos_receivings` ( `comment` text NOT NULL, `receiving_id` int(10) NOT NULL AUTO_INCREMENT, `payment_type` varchar(20) DEFAULT NULL, - `invoice_number` varchar(32) DEFAULT NULL, + `reference` varchar(32) DEFAULT NULL, PRIMARY KEY (`receiving_id`), KEY `supplier_id` (`supplier_id`), KEY `employee_id` (`employee_id`), - UNIQUE KEY `invoice_number` (`invoice_number`) + KEY `reference` (`reference`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- diff --git a/translations/receivings_lang.csv b/translations/receivings_lang.csv index 4d07d1ba4..f9644c968 100644 --- a/translations/receivings_lang.csv +++ b/translations/receivings_lang.csv @@ -21,9 +21,7 @@ recvs_error_requisition,Nem sikerült a készlet mozgatása ugyan arra a raktár recvs_find_or_scan_item,Termék keresése/scan,Finde/Scanne Artikel,Zoek/Scan Product,Encontrar/Escanear Artículo,Find/Scan Item,Chercher/Scanner Élément,查找 / 掃描產品,Найти/Сканировать товар,ค้นหาสินค้า,Ürün Bul/Oku,Cari/Scan Item,Localizar Item,Traži/skeniraj artikal recvs_find_or_scan_item_or_receipt,Termék keresése/scan,Finde/Scanne Artikel oder Quittung,Zoek/Scan Product OF Tickets,Encontrar/Escanear Artículo o Entrada,Find/Scan Item OR Receipt,Chercher Elément OU Recu,查找 / 掃描產品或收據,Найти/Сканировать товар ИЛИ квитанция,ค้นหาสินค้าหรือบิล,Ürün yada Fatura Bul/Oku,Cari/Scan Item ATAU Faktur,Produto no Estoque,Traži/skeniraj artikal ili račun recvs_id,Átvételi ID,Eingangs-Nr.,Ordernummer,ID de Entrada,Receiving ID,ID Arrivage,進貨編號,получение ID,รายการสินค้าเข้า ID,Alım No,ID Penerimaan,Recebimento ID,Primka br. -recvs_invoice_enable,Számla készitése,Erzeuge Rechnung,Maak Factuur,Crear Factura,Create Invoice,Create Invoice,Create Invoice,Create Invoice,Create Invoice,Create Invoice,Create Invoice,Criar Fatura,Napravi fakturu -recvs_invoice_number,Számla #,Rechnungs-Nr.,Factuur #,Factura #,Invoice #,,,,,,Nomer Nota,Fatura nº,Faktura br. -recvs_invoice_number_duplicate,Kérem adjon meg egyedi számot,Bitte geben Sie eine eindeutige Rechnungs-Nr. ein,Gelieve een uniek factuurnummer in te voeren,Por favor ingrese un número de factura único,Please enter an unique invoice number,,,,,,Nomer Nota Double,Por favor insira um número de fatura única,Molim unesite jedinstven broj fakture +recvs_reference,Reference,Reference,Reference,Reference,Reference,Reference,Reference,Reference,Reference,Reference,Reference,Reference,Reference recvs_item_name,Termék neve,Artikelname,Productnaam,Nombre del Artículo,Item Name,Nom d'Élément,產品名稱,Название товара,ชื่อสินคัา,Ürün Adı,Nama Item,Nome do item,Naziv artikla recvs_mode,Átvétel módja,Eingangsmodus,Order type,Modo de Entradas,Receiving Mode,Receiving Mode,進貨模式,получая режим,ประเภทธุรกรรม,Alım Türü,Jenis Penerimaan,Tipo Recebimento,Ulazni mod recvs_new_supplier,Új beszállitó,Neuer Lieferant,N. Leverancier,Nuevo Proveedor,New Supplier,Nouveau Fournisseur,新供應商,Новый поставщик,ผู้ผลิตรายใหม่,Yeni Sağlayıcı,Pemasok Baru,Novo Fornecedor,Novi dobavljač