diff --git a/application/controllers/config.php b/application/controllers/config.php index d70bafde3..be3b8775d 100644 --- a/application/controllers/config.php +++ b/application/controllers/config.php @@ -39,9 +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_enable'=>$this->input->post('recv_invoice_enable'), 'recv_invoice_format'=>$this->input->post('recv_invoice_format'), - 'sales_invoice_enable'=>$this->input->post('sales_invoice_enable'), 'sales_invoice_format'=>$this->input->post('sales_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**/ diff --git a/application/controllers/giftcards.php b/application/controllers/giftcards.php index e386b08fb..3b052bddd 100644 --- a/application/controllers/giftcards.php +++ b/application/controllers/giftcards.php @@ -41,9 +41,9 @@ class Giftcards extends Secure_area implements iData_controller /* Gives search suggestions for person_id based on what is being searched for */ - function suggest_person() + function person_search() { - $suggestions = $this->Giftcard->get_person_search_suggestions($this->input->post('q'),$this->input->post('limit')); + $suggestions = $this->Customer->get_customer_search_suggestions($this->input->post('q'),$this->input->post('limit')); echo implode("\n",$suggestions); } /** END GARRISON ADDED **/ @@ -56,8 +56,10 @@ class Giftcards extends Secure_area implements iData_controller function view($giftcard_id=-1) { - $data['giftcard_info']=$this->Giftcard->get_info($giftcard_id); - + $giftcard_info=$this->Giftcard->get_info($giftcard_id); + $person_name=$giftcard_info->first_name . ' ' . $giftcard_info->last_name; + $data['selected_person'] = $giftcard_id > 0 ? $giftcard_info->person_id . "|" . $person_name : ""; + $data['giftcard_info']=$giftcard_info; $this->load->view("giftcards/form",$data); } diff --git a/application/libraries/Receiving_lib.php b/application/libraries/Receiving_lib.php index 6fe939728..737cc4241 100644 --- a/application/libraries/Receiving_lib.php +++ b/application/libraries/Receiving_lib.php @@ -101,8 +101,7 @@ class Receiving_lib function clear_invoice_number_enabled() { - $enable = $this->CI->config->config['recv_invoice_enable']; - $this->set_invoice_number_enabled($enable); + $this->set_invoice_number_enabled(FALSE); } function set_stock_source($stock_source) diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php index cd9fa7e6e..ed3775fcb 100644 --- a/application/libraries/Sale_lib.php +++ b/application/libraries/Sale_lib.php @@ -80,8 +80,7 @@ class Sale_lib function clear_invoice_number_enabled() { - $enable = $this->CI->config->config['sales_invoice_enable']; - $this->set_invoice_number_enabled($enable); + $this->set_invoice_number_enabled(FALSE); } function get_email_receipt() @@ -537,15 +536,15 @@ class Sale_lib return to_currency_no_money($subtotal); } - function get_item_total_tax_exclusive($quantity, $price, $discount_percentage) + function get_item_total_tax_exclusive($item_id, $quantity, $price, $discount_percentage) { - $tax_info = $this->CI->Item_taxes->get_info($item['item_id']); + $tax_info = $this->CI->Item_taxes->get_info($item_id); $item_price = $this->get_item_total($quantity, $price, $discount_percentage); // only additive tax here foreach($tax_info as $tax) { $tax_percentage = $tax_info[0]['percent']; - $item_price =- $this->get_item_tax($quantity, $price, $discount_percentage, $tax_percentage); + $item_price -= $this->get_item_tax($quantity, $price, $discount_percentage, $tax_percentage); } return $item_price; @@ -585,13 +584,13 @@ class Sale_lib } else { - if ($CI->config->config['tax_included']) + if ($this->CI->config->config['tax_included']) { $subtotal += $this->get_item_total($item['quantity'], $item['price'], $item['discount']); } else { - $subtotal += $this->get_item_total_tax_exclusive($item['quantity'], $item['price'], $item['discount']); + $subtotal += $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount']); } } } diff --git a/application/models/giftcard.php b/application/models/giftcard.php index 10e894b65..3cd1520ca 100644 --- a/application/models/giftcard.php +++ b/application/models/giftcard.php @@ -41,6 +41,7 @@ class Giftcard extends CI_Model function get_info($giftcard_id) { $this->db->from('giftcards'); + $this->db->join('people', 'people.person_id = giftcards.person_id', 'LEFT'); $this->db->where('giftcard_id',$giftcard_id); $this->db->where('deleted',0); diff --git a/application/views/config.php b/application/views/config.php index ee1b7db58..c0a0f6ba4 100644 --- a/application/views/config.php +++ b/application/views/config.php @@ -268,17 +268,6 @@ echo form_open('config/save/',array('id'=>'config_form')); -
-lang->line('config_sales_invoice_enable').':', 'sales_invoice_enable',array('class'=>'wide')); ?> -
- 'sales_invoice_enable', - 'id'=>'sales_invoice_enable', - 'value'=>'sales_invoice_enable', - 'checked'=>$this->config->item('sales_invoice_enable')));?> -
-
-
lang->line('config_sales_invoice_format').':', 'sales_invoice_format',array('class'=>'wide')); ?>
@@ -289,17 +278,6 @@ echo form_open('config/save/',array('id'=>'config_form'));
-
-lang->line('config_recv_invoice_enable').':', 'recv_invoice_enable',array('class'=>'wide')); ?> -
- 'recv_invoice_enable', - 'id'=>'recv_invoice_enable', - 'value'=>'recv_invoice_enable', - 'checked'=>$this->config->item('recv_invoice_enable')));?> -
-
-
lang->line('config_recv_invoice_format').':', 'recv_invoice_format',array('class'=>'wide')); ?>
diff --git a/application/views/giftcards/form.php b/application/views/giftcards/form.php index 8aac50422..b15900e87 100644 --- a/application/views/giftcards/form.php +++ b/application/views/giftcards/form.php @@ -13,7 +13,7 @@ echo form_open('giftcards/save/'.$giftcard_info->giftcard_id,array('id'=>'giftca 'person_id', 'id'=>'person_id', - 'value'=>$giftcard_info->person_id) + 'value'=>$selected_person) );?>
@@ -58,22 +58,52 @@ echo form_close(); //validation and submit handling $(document).ready(function() { - $("#person_id").autocomplete("",{max:100,minChars:0,delay:10}); - $("#person_id").result(function(event, data, formatted){}); - $("#person_id").search(); - - $('#giftcard_form').validate({ - submitHandler:function(form) + var format_item = function(row) + { + var result = [row[0], "|", row[1]].join(""); + // if more than one occurence + if (row[2] > 1 && row[3] && row[3].toString().trim()) { + // display zip code + result += ' - ' + row[3]; + } + return result; + }; + var autocompleter = $("#person_id").autocomplete('', + { + minChars:0, + delay:15, + max:100, + cacheLength: 1, + formatItem: format_item, + formatResult : format_item + }); + + // declare submitHandler as an object.. will be reused + var submit_form = function(selected_person) + { + $(this).ajaxSubmit( { - $(form).ajaxSubmit({ success:function(response) { tb_remove(); post_giftcard_form_submit(response); }, + error: function(jqXHR, textStatus, errorThrown) + { + selected_customer && autocompleter.val(selected_person); + post_giftcard_form_submit({message: errorThrown}); + }, dataType:'json' }); - + }; + + $('#giftcard_form').validate({ + submitHandler:function(form) + { + var selected_person = autocompleter.val(); + var selected_person_id = selected_person.replace(/(\w)\|.*/, "$1"); + selected_person_id && autocompleter.val(selected_person_id); + submit_form.call(form, selected_person); }, errorLabelContainer: "#error_message_box", wrapper: "li", diff --git a/database/2.3_to_2.3.1.sql b/database/2.3_to_2.3.1.sql index fd01965e5..e7d99ba24 100644 --- a/database/2.3_to_2.3.1.sql +++ b/database/2.3_to_2.3.1.sql @@ -78,9 +78,7 @@ INSERT INTO `ospos_grants` (`permission_id`, `person_id`) VALUES INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('tax_included', '0'), ('recv_invoice_format', '$CO'), -('sales_invoice_format', '$CO'), -('sales_invoice_enable', '0'), -('recv_invoice_enable', '0'); +('sales_invoice_format', '$CO'); -- add invoice_number column to receivings table ALTER TABLE `ospos_receivings` @@ -101,3 +99,7 @@ ALTER TABLE `ospos_sales_suspended` ALTER TABLE `ospos_items` ADD COLUMN `receiving_quantity` int(11) DEFAULT '1', DROP COLUMN `quantity`; + +-- add foreign key to giftcards table +ALTER TABLE `ospos_giftcards` + ADD CONSTRAINT `ospos_giftcards_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); \ No newline at end of file diff --git a/database/database.sql b/database/database.sql index ab2a906ef..0a01f0b0a 100644 --- a/database/database.sql +++ b/database/database.sql @@ -39,9 +39,7 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('website', ''), ('recv_invoice_format', '$CO'), ('sales_invoice_format', '$CO'), -('tax_included', '0'), -('recv_invoice_enable', '0'), -('sales_invoice_enable', '0'); +('tax_included', '0'); -- -------------------------------------------------------- @@ -819,3 +817,9 @@ ALTER TABLE `ospos_item_quantities` -- ALTER TABLE `ospos_suppliers` ADD CONSTRAINT `ospos_suppliers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); + +-- +-- Constraints for table `ospos_giftcards` +-- +ALTER TABLE `ospos_giftcards` + ADD CONSTRAINT `ospos_giftcards_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);