diff --git a/application/controllers/config.php b/application/controllers/config.php index 1a6a42e04..8895bd595 100644 --- a/application/controllers/config.php +++ b/application/controllers/config.php @@ -39,6 +39,7 @@ class Config extends Secure_area 'timezone'=>$this->input->post('timezone'), 'print_after_sale'=>$this->input->post('print_after_sale'), 'tax_included'=>$this->input->post('tax_included'), + 'recv_invoice_format'=>$this->input->post('recv_invoice_format'), 'custom1_name'=>$this->input->post('custom1_name'),/**GARRISON ADDED 4/20/2013**/ 'custom2_name'=>$this->input->post('custom2_name'),/**GARRISON ADDED 4/20/2013**/ 'custom3_name'=>$this->input->post('custom3_name'),/**GARRISON ADDED 4/20/2013**/ diff --git a/application/controllers/items.php b/application/controllers/items.php index 23e747b8c..b1e7211e5 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -21,7 +21,7 @@ class Items extends Secure_area implements iData_controller $stock_locations=$this->Stock_locations->get_allowed_locations(); $data['stock_location']=$stock_location; $data['stock_locations']=$stock_locations; - + var_dump($stock_location); $data['controller_name']=strtolower(get_class()); $data['form_width']=$this->get_form_width(); $data['manage_table']=get_items_manage_table( $this->Item->get_all( $stock_location, $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); @@ -194,15 +194,13 @@ class Items extends Secure_area implements iData_controller function get_row() { $item_id = $this->input->post('row_id'); - $stock_location_id=$this->item_lib->get_item_location(); - $data_row=get_item_data_row($this->Item->get_info($item_id,$stock_location_id),$this); + $data_row=get_item_data_row($this->Item->get_info($item_id),$this); echo $data_row; } function view($item_id=-1) { - $stock_location_id=$this->item_lib->get_item_location(); - $data['item_info']=$this->Item->get_info($item_id,$stock_location_id); + $data['item_info']=$this->Item->get_info($item_id); $data['item_tax_info']=$this->Item_taxes->get_info($item_id); $suppliers = array('' => $this->lang->line('items_none')); foreach($this->Supplier->get_all()->result_array() as $row) @@ -211,14 +209,14 @@ class Items extends Secure_area implements iData_controller } $data['suppliers']=$suppliers; - $data['selected_supplier'] = $this->Item->get_info($item_id,$stock_location_id)->supplier_id; + $data['selected_supplier'] = $this->Item->get_info($item_id)->supplier_id; $data['default_tax_1_rate']=($item_id==-1) ? $this->Appconfig->get('default_tax_1_rate') : ''; $data['default_tax_2_rate']=($item_id==-1) ? $this->Appconfig->get('default_tax_2_rate') : ''; $locations_data = $this->Stock_locations->get_undeleted_all()->result_array(); foreach($locations_data as $location) { - $quantity = $this->Item_quantities->get_item_quantity($item_id, $location['location_id'])->quantity; + $quantity = $this->Item_quantities->get_item_quantity($item_id,$location['location_id'])->quantity; $quantity = ($item_id == -1) ? null: $quantity; $location_array[$location['location_id']] = array('location_name'=>$location['location_name'], 'quantity'=>$quantity); diff --git a/application/controllers/receivings.php b/application/controllers/receivings.php index cd6e7f69f..252726bd0 100644 --- a/application/controllers/receivings.php +++ b/application/controllers/receivings.php @@ -56,7 +56,12 @@ class Receivings extends Secure_area { $this->receiving_lib->set_comment($this->input->post('comment')); } - + + function set_invoice_number() + { + $this->receiving_lib->set_invoice_number($this->input->post('recv_invoice_number')); + } + function add() { $data=array(); @@ -66,7 +71,7 @@ class Receivings extends Secure_area $item_location = $this->receiving_lib->get_stock_source(); if($this->receiving_lib->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt) && $mode=='return') { - $this->receiving_lib->return_entire_receiving($item_id_or_number_or_item_kit_or_receipt,$item_location); + $this->receiving_lib->return_entire_receiving($item_id_or_number_or_item_kit_or_receipt); } elseif($this->receiving_lib->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt)) { @@ -132,11 +137,11 @@ class Receivings extends Secure_area $employee_id=$this->Employee->get_logged_in_employee_info()->person_id; $comment = $this->input->post('comment'); $emp_info=$this->Employee->get_info($employee_id); - $payment_type = $this->input->post('payment_type'); + $payment_type=$this->input->post('payment_type'); + $invoice_number=$this->receiving_lib->get_invoice_number(); $data['payment_type']=$this->input->post('payment_type'); - $data['invoice_number']=$this->input->post('invoice_number'); + $data['invoice_number']=$invoice_number; $data['stock_location']=$this->receiving_lib->get_stock_source(); - if ($this->input->post('amount_tendered')) { $data['amount_tendered'] = $this->input->post('amount_tendered'); @@ -197,6 +202,7 @@ class Receivings extends Secure_area $supplier_id=$this->receiving_lib->get_supplier(); $emp_info=$this->Employee->get_info($receiving_info['employee_id']); $data['payment_type']=$receiving_info['payment_type']; + $data['invoice_number']=$this->receiving_lib->get_invoice_number(); $data['employee']=$emp_info->first_name.' '.$emp_info->last_name; @@ -219,18 +225,17 @@ class Receivings extends Secure_area $data['mode']=$this->receiving_lib->get_mode(); $data['stock_locations']=$this->Stock_locations->get_allowed_locations(); - $show_stock_locations = count($data['stock_locations']); - if ($show_stock_locations > 0) { + $show_stock_locations = count($data['stock_locations']) > 1; + if ($show_stock_locations) + { $data['modes']['requisition'] = $this->lang->line('recvs_requisition'); $data['stock_source']=$this->receiving_lib->get_stock_source(); $data['stock_destination']=$this->receiving_lib->get_stock_destination(); } - $data['show_stock_locations'] = $show_stock_locations; - - $data['invoice_number']=$this->CI->config->config['invoice_number_format']; + $data['show_stock_locations']=$show_stock_locations; $data['total']=$this->receiving_lib->get_total(); - $data['items_module_allowed'] = $this->Employee->has_permission('items', $person_info->person_id); + $data['items_module_allowed']=$this->Employee->has_permission('items',$person_info->person_id); $data['comment']=$this->receiving_lib->get_comment(); $data['payment_options']=array( $this->lang->line('sales_cash') => $this->lang->line('sales_cash'), @@ -238,13 +243,31 @@ class Receivings extends Secure_area $this->lang->line('sales_debit') => $this->lang->line('sales_debit'), $this->lang->line('sales_credit') => $this->lang->line('sales_credit') ); - + + $invoice_number=$this->receiving_lib->get_invoice_number(); + if (empty($invoice_number)) + { + $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) { $info=$this->Supplier->get_info($supplier_id); + $invoice_number=str_replace('$SU',$info->company_name,$invoice_number); $data['supplier']=$info->first_name.' '.$info->last_name; + $words = preg_split("/\s+/", $info->company_name); + $acronym = ""; + foreach ($words as $w) { + $acronym .= $w[0]; + } + $invoice_number=str_replace('$SI',$acronym,$invoice_number); } + $data['invoice_number']=$invoice_number; + $this->load->view("receivings/receiving",$data); $this->_remove_duplicate_cookies(); } diff --git a/application/controllers/reports.php b/application/controllers/reports.php index 8729b2ed1..54f91d465 100644 --- a/application/controllers/reports.php +++ b/application/controllers/reports.php @@ -866,7 +866,7 @@ class Reports extends Secure_area foreach($report_data['summary'] as $key=>$row) { - $summary_data[] = array(anchor('receivings/receipt/'.$row['receiving_id'], 'RECV '.$row['receiving_id'], array('target' => '_blank')), $row['receiving_date'], $row['items_purchased'], $row['employee_name'], $row['supplier_name'], to_currency($row['total']), $row['payment_type'], $row['comment']); + $summary_data[] = array(anchor('receivings/receipt/'.$row['receiving_id'], 'RECV '.$row['receiving_id'], array('target' => '_blank')), $row['receiving_date'], $row['items_purchased'], $row['employee_name'], $row['supplier_name'], to_currency($row['total']), $row['payment_type'], $row['invoice_number'], $row['comment']); foreach($report_data['details'][$key] as $drow) { diff --git a/application/controllers/sales.php b/application/controllers/sales.php index f5432f50c..88fd59733 100644 --- a/application/controllers/sales.php +++ b/application/controllers/sales.php @@ -367,9 +367,9 @@ class Sales extends Secure_area $data['subtotal']=$this->sale_lib->get_subtotal(); $data['taxes']=$this->sale_lib->get_taxes(); $data['total']=$this->sale_lib->get_total(); - $data['items_module_allowed'] = $this->Employee->has_permission('items', $person_info->person_id); - $data['comment'] = $this->sale_lib->get_comment(); - $data['email_receipt'] = $this->sale_lib->get_email_receipt(); + $data['items_module_allowed']=$this->Employee->has_permission('items', $person_info->person_id); + $data['comment']=$this->sale_lib->get_comment(); + $data['email_receipt']=$this->sale_lib->get_email_receipt(); $data['payments_total']=$this->sale_lib->get_payments_total(); $data['amount_due']=$this->sale_lib->get_amount_due(); $data['payments']=$this->sale_lib->get_payments(); diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php index bc82d0288..ac38121a6 100644 --- a/application/language/en/config_lang.php +++ b/application/language/en/config_lang.php @@ -36,4 +36,6 @@ $lang['config_custom10'] = 'Custom Field 10'; //GARRISON ADDED 4/21/2013 $lang['config_stock_location'] = 'Stock location'; $lang['config_stock_location_required'] = 'Stock location number is a required field'; $lang['config_tax_included'] = 'Tax Included'; +$lang['config_recv_invoice_format'] = 'Receivings Invoice'; + ?> \ No newline at end of file diff --git a/application/libraries/Item_lib.php b/application/libraries/Item_lib.php index 9517000f9..08e29f66d 100644 --- a/application/libraries/Item_lib.php +++ b/application/libraries/Item_lib.php @@ -13,8 +13,8 @@ class Item_lib { if(!$this->CI->session->userdata('item_location')) { - $location_name = $this->CI->Stock_locations->get_default_location_id(); - $this->set_item_location($location_name); + $location_id = $this->CI->Stock_locations->get_default_location_id(); + $this->set_item_location($location_id); } return $this->CI->session->userdata('item_location'); } diff --git a/application/libraries/Receiving_lib.php b/application/libraries/Receiving_lib.php index f19f4042b..a1267ccf8 100644 --- a/application/libraries/Receiving_lib.php +++ b/application/libraries/Receiving_lib.php @@ -52,8 +52,8 @@ class Receiving_lib { if(!$this->CI->session->userdata('recv_stock_source')) { - $location_name = $this->CI->Stock_locations->get_default_location_id(); - $this->set_stock_source($location_name); + $location_id = $this->CI->Stock_locations->get_default_location_id(); + $this->set_stock_source($location_id); } return $this->CI->session->userdata('recv_stock_source'); } @@ -72,6 +72,21 @@ class Receiving_lib { $this->CI->session->unset_userdata('comment'); } + + function get_invoice_number() + { + return $this->CI->session->userdata('recv_invoice_number'); + } + + function set_invoice_number($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 set_stock_source($stock_source) { @@ -87,8 +102,8 @@ class Receiving_lib { if(!$this->CI->session->userdata('recv_stock_destination')) { - $location_name = $this->CI->Stock_locations->get_default_location_id(); - $this->set_stock_destination($location_name); + $location_id = $this->CI->Stock_locations->get_default_location_id(); + $this->set_stock_destination($location_id); } return $this->CI->session->userdata('recv_stock_destination'); } @@ -209,6 +224,10 @@ class Receiving_lib { return $this->CI->Receiving->exists($pieces[1]); } + else + { + return $this->CI->Receiving->get_receiving_by_invoice_number($receipt_receiving_id)->num_rows() > 0; + } return false; } @@ -230,10 +249,19 @@ class Receiving_lib { //POS # $pieces = explode(' ',$receipt_receiving_id); - $receiving_id = $pieces[1]; + if ($pieces[0] == "RECV") + { + $receiving_id = $pieces[1]; + } + else + { + $receiving = $this->CI->Receiving->get_receiving_by_invoice_number($receipt_receiving_id)->row(); + $receiving_id = $receiving->receiving_id; + } $this->empty_cart(); $this->delete_supplier(); + $this->clear_comment(); foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row) { @@ -264,7 +292,8 @@ class Receiving_lib $this->add_item($row->item_id,$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber); } $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 copy_entire_requisition($requisition_id,$item_location) @@ -277,7 +306,8 @@ class Receiving_lib $this->add_item_unit($row->item_id,$row->requisition_quantity,$item_location,$row->description); } $this->set_supplier($this->CI->Receiving->get_supplier($requisition_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) @@ -308,6 +338,7 @@ class Receiving_lib $this->empty_cart(); $this->delete_supplier(); $this->clear_comment(); + $this->clear_invoice_number(); } function get_item_total($quantity, $price, $discount_percentage) diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php index 174f6aa4b..5b74f5383 100644 --- a/application/libraries/Sale_lib.php +++ b/application/libraries/Sale_lib.php @@ -172,8 +172,8 @@ class Sale_lib { if(!$this->CI->session->userdata('sale_location')) { - $location_name = $this->CI->Stock_locations->get_default_location_id(); - $this->set_sale_location($location_name); + $location_id = $this->CI->Stock_locations->get_default_location_id(); + $this->set_sale_location($location_id); } return $this->CI->session->userdata('sale_location'); } diff --git a/application/models/item.php b/application/models/item.php index a566bc3e9..a80c7a7ca 100644 --- a/application/models/item.php +++ b/application/models/item.php @@ -16,12 +16,15 @@ class Item extends CI_Model /* Returns all the items */ - function get_all($stock_location_id,$limit=10000,$offset=0) + function get_all($stock_location_id=-1,$limit=10000,$offset=0) { $this->db->from('items'); - $this->db->join('item_quantities','item_quantities.item_id=items.item_id'); + if ($stock_location_id > -1) + { + $this->db->join('item_quantities','item_quantities.item_id=items.item_id'); + $this->db->where('location_id',$stock_location_id); + } $this->db->where('deleted',0); - $this->db->where('location_id',$stock_location_id); $this->db->order_by("name","asc"); $this->db->limit($limit); $this->db->offset($offset); @@ -74,15 +77,10 @@ class Item extends CI_Model /* Gets information about a particular item */ - function get_info($item_id,$stock_location_id=0) + function get_info($item_id) { $this->db->from('items'); - $this->db->join('item_quantities','item_quantities.item_id=items.item_id'); - if ($stock_location_id > 0) - { - $this->db->where('location_id',$stock_location_id); - } - $this->db->where('items.item_id',$item_id); + $this->db->where('item_id',$item_id); $query = $this->db->get(); @@ -554,6 +552,7 @@ class Item extends CI_Model function search($search) { $this->db->from('items'); + $this->db->where("( name LIKE '%".$this->db->escape_like_str($search)."%' or item_number LIKE '%".$this->db->escape_like_str($search)."%' or @@ -585,26 +584,5 @@ class Item extends CI_Model return $this->db->get(); } - function is_sale_store_item_exist($item_number) - { - $this->db->from('items'); - $this->db->where('item_number',$item_number); - $this->db->where('stock_type','sale_stock'); - $this->db->where('deleted',0); - - $query = $this->db->get(); - return ($query->num_rows()==1); - } - - function is_warehouse_item_exist($item_number) - { - $this->db->from('items'); - $this->db->where('item_number',$item_number); - $this->db->where('stock_type','warehouse'); - $this->db->where('deleted',0); - - $query = $this->db->get(); - return ($query->num_rows()==1); - } } ?> \ No newline at end of file diff --git a/application/models/receiving.php b/application/models/receiving.php index 9ec0e0de1..264239796 100644 --- a/application/models/receiving.php +++ b/application/models/receiving.php @@ -8,6 +8,20 @@ class Receiving extends CI_Model return $this->db->get(); } + function get_invoice_count() + { + $this->db->from('receivings'); + $this->db->where('invoice_number is not null'); + return $this->db->count_all_results(); + } + + function get_receiving_by_invoice_number($invoice_number) + { + $this->db->from('receivings'); + $this->db->where('invoice_number', $invoice_number); + return $this->db->get(); + } + function exists($receiving_id) { $this->db->from('receivings'); @@ -27,7 +41,7 @@ class Receiving extends CI_Model 'employee_id'=>$employee_id, 'payment_type'=>$payment_type, 'comment'=>$comment, - 'invoice_number'=>$invoice_number + 'invoice_number'=>empty($invoice_number) ? null : $invoice_number ); //Run these queries as a transaction, we want to make sure we do all or nothing @@ -107,7 +121,7 @@ class Receiving extends CI_Model public function create_receivings_items_temp_table() { $this->db->query("CREATE TEMPORARY TABLE ".$this->db->dbprefix('receivings_items_temp')." - (SELECT date(receiving_time) as receiving_date, ".$this->db->dbprefix('receivings_items').".receiving_id, comment,payment_type, employee_id, + (SELECT date(receiving_time) as receiving_date, ".$this->db->dbprefix('receivings_items').".receiving_id, comment, invoice_number, payment_type, employee_id, ".$this->db->dbprefix('items').".item_id, ".$this->db->dbprefix('receivings').".supplier_id, quantity_purchased, item_cost_price, item_unit_price, discount_percent, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) as subtotal, ".$this->db->dbprefix('receivings_items').".line as line, serialnumber, ".$this->db->dbprefix('receivings_items').".description as description, diff --git a/application/models/reports/detailed_receivings.php b/application/models/reports/detailed_receivings.php index 0ff381ed7..668a8ca5a 100644 --- a/application/models/reports/detailed_receivings.php +++ b/application/models/reports/detailed_receivings.php @@ -9,14 +9,14 @@ class Detailed_receivings extends Report public function getDataColumns() { - return array('summary' => array($this->lang->line('reports_receiving_id'), $this->lang->line('reports_date'), $this->lang->line('reports_items_received'), $this->lang->line('reports_received_by'), $this->lang->line('reports_supplied_by'), $this->lang->line('reports_total'), $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')), + return array('summary' => array($this->lang->line('reports_receiving_id'), $this->lang->line('reports_date'), $this->lang->line('reports_items_received'), $this->lang->line('reports_received_by'), $this->lang->line('reports_supplied_by'), $this->lang->line('reports_total'), $this->lang->line('reports_payment_type'), $this->lang->line('recvs_invoice_number'), $this->lang->line('reports_comments')), 'details' => array($this->lang->line('reports_name'), $this->lang->line('reports_category'), $this->lang->line('reports_quantity_purchased'), $this->lang->line('reports_total'), $this->lang->line('reports_discount')) ); } 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, CONCAT(supplier.first_name," ",supplier.last_name) as supplier_name, sum(total) as total, sum(profit) as profit, payment_type, comment', false); + $this->db->select('receiving_id, receiving_date, sum(quantity_purchased) as items_purchased, CONCAT(employee.first_name," ",employee.last_name) as employee_name, CONCAT(supplier.first_name," ",supplier.last_name) as supplier_name, sum(total) as total, sum(profit) as profit, payment_type, comment, invoice_number', false); $this->db->from('receivings_items_temp'); $this->db->join('people as employee', 'receivings_items_temp.employee_id = employee.person_id'); $this->db->join('people as supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left'); diff --git a/application/models/stock_locations.php b/application/models/stock_locations.php index f50adfa88..15d9ad273 100644 --- a/application/models/stock_locations.php +++ b/application/models/stock_locations.php @@ -97,7 +97,6 @@ class Stock_locations extends CI_Model $this->db->trans_complete(); } - $location_db = $this->get_all()->result_array(); //Update the stock location $this->db->trans_start(); foreach ($stock_locations as $location) @@ -113,7 +112,7 @@ class Stock_locations extends CI_Model $this->db->update('stock_locations',array('location_name'=>$db['location_name'],'deleted'=>0)); // remmove module (and permissions) for stock location - $this->db->delete('modules', array('module_id' => 'items_stock'.$db['location_id'])); + //$this->db->delete('modules', array('module_id' => 'items_stock'.$db['location_id'])); } $to_create = false; break; @@ -125,7 +124,8 @@ class Stock_locations extends CI_Model $location_data = array('location_name'=>$location,'deleted'=>0); $this->db->insert('stock_locations',$location_data); // insert new module for stock location - $module_id = 'items_stock'.$this->db->insert_id(); + $location_id = $this->db->insert_id(); + $module_id = 'items_stock'.$location_id; $module_name = 'module_'.$module_id; $module_data = array('name_lang_key' => $module_name, 'desc_lang_key' => $module_name.'_desc', 'module_id' => $module_id); $this->db->insert('modules', $module_data); @@ -136,6 +136,13 @@ class Stock_locations extends CI_Model $permission_data = array('module_id' => $module_id, 'person_id' => $employee['person_id']); $this->db->insert('permissions', $permission_data); } + // insert quantities for existing items + $items = $this->Item->get_all(); + foreach ($items->result_array() as $item) + { + $quantity_data = array('item_id' => $item['item_id'], 'location_id' => $location_id, 'quantity' => 0); + $this->db->insert('item_quantities', $quantity_data); + } } } $this->db->trans_complete(); diff --git a/application/views/config.php b/application/views/config.php index 0ca907b18..b441f5408 100644 --- a/application/views/config.php +++ b/application/views/config.php @@ -268,6 +268,16 @@ echo form_open('config/save/',array('id'=>'config_form')); +
+lang->line('config_recv_invoice_format').':', 'recv_invoice_format',array('class'=>'wide')); ?> +
+ 'recv_invoice_format', + 'id'=>'recv_invoice_format', + 'value'=>$this->config->item('recv_invoice_format'))); ?> +
+
+
lang->line('config_print_after_sale').':', 'print_after_sale',array('class'=>'wide')); ?>
diff --git a/application/views/receivings/receipt.php b/application/views/receivings/receipt.php index 004f21ef1..ba82ac87f 100644 --- a/application/views/receivings/receipt.php +++ b/application/views/receivings/receipt.php @@ -23,6 +23,13 @@ if (isset($error_message)) } ?>
lang->line('recvs_id').": ".$receiving_id; ?>
+ +
lang->line('recvs_invoice_number').": ".$invoice_number; ?>
+
lang->line('employees_employee').": ".$employee; ?>
diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php index 6133e47c2..8b67cec3d 100644 --- a/application/views/receivings/receiving.php +++ b/application/views/receivings/receiving.php @@ -221,14 +221,20 @@ else 'comment','id'=>'comment','value'=>$comment,'rows'=>'4','cols'=>'23'));?>

+ +
lang->line('recvs_invoice_number').': ';?> - 'invoice_number','value'=>$invoice_number,'size'=>10));?> + 'recv_invoice_number','id'=>'recv_invoice_number','value'=>$invoice_number,'size'=>10));?>
lang->line('sales_payment').': ';?> @@ -331,6 +337,11 @@ $(document).ready(function() $.post('', {comment: $('#comment').val()}); }); + $('#recv_invoice_number').change(function() + { + $.post('', {recv_invoice_number: $('#recv_invoice_number').val()}); + }); + $("#finish_sale_button").click(function() { if (confirm('lang->line("recvs_confirm_finish_receiving"); ?>')) diff --git a/application/views/sales/register.php b/application/views/sales/register.php index 599f308ea..2ba336a83 100644 --- a/application/views/sales/register.php +++ b/application/views/sales/register.php @@ -20,7 +20,7 @@ if (isset($success)) 'mode_form')); ?> lang->line('sales_mode') ?> - 0): ?> + 1): ?> lang->line('sales_stock_location') ?> diff --git a/database/2.3_to_2.3.1.sql b/database/2.3_to_2.3.1.sql index 2d886b434..63e1069de 100644 --- a/database/2.3_to_2.3.1.sql +++ b/database/2.3_to_2.3.1.sql @@ -32,6 +32,7 @@ ALTER TABLE `ospos_permissions` ADD CONSTRAINT `ospos_permissions_ibfk_2` FOREIG -- add invoice_number column to receivings table ALTER TABLE `ospos_receivings` ADD COLUMN `invoice_number` varchar(32) DEFAULT NULL; +ALTER TABLE `ospos_receivings` ADD UNIQUE `invoice_number` (`invoice_number`); diff --git a/database/database.sql b/database/database.sql index 5391df368..28452abb6 100644 --- a/database/database.sql +++ b/database/database.sql @@ -230,7 +230,7 @@ CREATE TABLE `ospos_item_kit_items` ( CREATE TABLE IF NOT EXISTS `ospos_item_quantities` ( `item_id` int(11) NOT NULL, `location_id` int(11) NOT NULL, - `quantity` int(11) NOT NULL, + `quantity` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`item_id`,`location_id`), KEY `item_id` (`item_id`), KEY `location_id` (`location_id`) @@ -357,7 +357,8 @@ CREATE TABLE `ospos_receivings` ( `invoice_number` varchar(32) DEFAULT NULL, PRIMARY KEY (`receiving_id`), KEY `supplier_id` (`supplier_id`), - KEY `employee_id` (`employee_id`) + KEY `employee_id` (`employee_id`), + UNIQUE KEY `invoice_number` (`invoice_number`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; --