diff --git a/application/controllers/config.php b/application/controllers/config.php index aa708f59f..35c84d697 100644 --- a/application/controllers/config.php +++ b/application/controllers/config.php @@ -58,7 +58,7 @@ class Config extends Secure_area if (!empty($upload_data['orig_name'])) { - $batch_save_data['company_logo'] = $upload_data['raw_name']; + $batch_save_data['company_logo'] = $upload_data['raw_name'] . $upload_data['file_ext']; } $result = $this->Appconfig->batch_save( $batch_save_data ); diff --git a/application/controllers/customers.php b/application/controllers/customers.php index f1c27102c..d8cb101bb 100644 --- a/application/controllers/customers.php +++ b/application/controllers/customers.php @@ -93,6 +93,12 @@ class Customers extends Person_controller } } + function check_account_number() + { + $exists = $this->Customer->account_number_exists($this->input->post('account_number'),$this->input->post('person_id')); + echo json_encode(array('success'=>!$exists,'message'=>$this->lang->line('customers_account_number_duplicate'))); + } + /* This deletes customers from the customers table */ @@ -159,11 +165,18 @@ class Customers extends Person_controller ); $customer_data=array( - 'account_number'=>$data[12]=='' ? null:$data[12], - 'taxable'=>$data[13]=='' ? 0:1, + 'taxable'=>$data[13]=='' ? 0:1 ); - if(!$this->Customer->save($person_data,$customer_data)) + $account_number = $data[12]; + $invalidated = false; + if ($account_number != "") + { + $customer_data['account_number'] = $account_number; + $invalidated = $this->Customer->account_number_exists($account_number); + } + + if($invalidated || !$this->Customer->save($person_data,$customer_data)) { $failCodes[] = $i; } @@ -179,7 +192,7 @@ class Customers extends Person_controller } $success = true; - if(count($failCodes) > 1) + if(count($failCodes) > 0) { $msg = "Most customers imported. But some were not, here is list of their CODE (" .count($failCodes) ."): ".implode(", ", $failCodes); $success = false; diff --git a/application/controllers/items.php b/application/controllers/items.php index e85a9831a..404f49ffe 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -613,11 +613,12 @@ class Items extends Secure_area implements iData_controller 'custom10' => $data[23] /** GARRISON ADDED 5/6/2013 **/ ); $item_number = $data[0]; + $invalidated = false; if ($item_number != "") { $item_data['item_number'] = $item_number; + $invalidated = $this->Item->item_number_exists($item_number); } - $invalidated = $this->Item->item_number_exists($item_number); } else { @@ -663,7 +664,7 @@ class Items extends Secure_area implements iData_controller 'location_id' => $location_id, 'quantity' => $data[$col + 1], ); - $this->Item_quantities->save($item_quantity_data, $item_data['item_id'], $data[$col]); + $this->Item_quantities->save($item_quantity_data, $item_data['item_id'], $location_id); $excel_data = array ( 'trans_items'=>$item_data['item_id'], diff --git a/application/core/MY_Lang.php b/application/core/MY_Lang.php new file mode 100644 index 000000000..75e8c596e --- /dev/null +++ b/application/core/MY_Lang.php @@ -0,0 +1,90 @@ +config->set_item( 'language', $idiom ); + $loaded = $this->is_loaded; + $this->is_loaded = array(); + + foreach($loaded as $file) + { + $this->load( str_replace( '_lang.php', '', $file ) ); + } + } + } + + /** + * Fetch a single line of text from the language array. Takes variable number + * of arguments and supports wildcards in the form of '%1', '%2', etc. + * Overloaded function. + * + * @access public + * @return mixed false if not found or the language string + */ + function line($line = '') + { + //get the arguments passed to the function + $args = func_get_args(); + + //count the number of arguments + $c = count($args); + + //if one or more arguments, perform the necessary processing + if ($c) + { + //first argument should be the actual language line key + //so remove it from the array (pop from front) + $line = array_shift($args); + + //check to make sure the key is valid and load the line + if ($line == '') + { + $line = FALSE; + } + else + { + if (isset($this->language[$line])) + { + $line = $this->language[$line]; + //if the line exists and more function arguments remain + //perform wildcard replacements + if ($args) + { + $i = 1; + foreach ($args as $arg) + { + $line = preg_replace('/\%'.$i.'/', $arg, $line); + $i++; + } + } + } + else + { + // just return label name (with TBD) + $line = $line . ' (TBD)'; + log_message('error', 'Could not find the language line "'.$line.'"'); + } + } + } + else + { + //if no arguments given, no language line available + $line = false; + } + + return $line; + } +} + +?> diff --git a/application/hooks/load_config.php b/application/hooks/load_config.php index d1f969771..57b487684 100644 --- a/application/hooks/load_config.php +++ b/application/hooks/load_config.php @@ -14,16 +14,22 @@ function load_config() if ( $CI->config->item( 'language' ) ) { $CI->config->set_item( 'language', $CI->config->item( 'language' ) ); - - $map = directory_map('./application/language/' . $CI->config->item( 'language' )); + // fallback to english if language folder does not exist + $language = $CI->config->item( 'language' ); + if (!file_exists('./application/language/' . $language)) + { + $language = 'en'; + } + $map = directory_map('./application/language/' . $language); foreach($map as $file) { if ( substr(strrchr($file,'.'),1) == "php") { - $CI->lang->load( str_replace( '_lang.php', '', $file ) ); + $CI->lang->load( str_replace( '_lang.php', '', $file ), $language); } } + } //Set timezone from config database diff --git a/application/language/en/customers_lang.php b/application/language/en/customers_lang.php index 2be5b8e8f..e6c55d4e3 100644 --- a/application/language/en/customers_lang.php +++ b/application/language/en/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "You have successfully deleted"; $lang["customers_successful_updating"] = "You have successfully updated customer"; $lang["customers_taxable"] = "Taxable"; $lang["customers_update"] = "Update Customer"; +$lang["customers_account_number_duplicate"] = "This account number is already present in the database"; diff --git a/application/language/es/customers_lang.php b/application/language/es/customers_lang.php index 3c5502a54..726286fe2 100644 --- a/application/language/es/customers_lang.php +++ b/application/language/es/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "Has borrado satisfactoriamente a"; $lang["customers_successful_updating"] = "No se ha podido agregar el cliente"; $lang["customers_taxable"] = "Gravable"; $lang["customers_update"] = "Actualizar Cliente"; +$lang["customers_account_number_duplicate"] = "This account number is already present in the database"; diff --git a/application/language/fr/customers_lang.php b/application/language/fr/customers_lang.php index c7f87820d..890e1312f 100644 --- a/application/language/fr/customers_lang.php +++ b/application/language/fr/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "Suppréssion réussie"; $lang["customers_successful_updating"] = "Édition client réussie"; $lang["customers_taxable"] = "Imposable"; $lang["customers_update"] = "Éditer Client"; +$lang["customers_account_number_duplicate"] = "This account number is already present in the database"; diff --git a/application/language/fr/form_validation_lang.php b/application/language/fr/form_validation_lang.php deleted file mode 100644 index 7b8fec6b3..000000000 --- a/application/language/fr/form_validation_lang.php +++ /dev/null @@ -1,18 +0,0 @@ -error_string; - } - - function get_error_messages() - { - return $this->_error_array; - } - -} - -?> \ No newline at end of file diff --git a/application/libraries/MY_Language.php b/application/libraries/MY_Language.php deleted file mode 100644 index a9b69505b..000000000 --- a/application/libraries/MY_Language.php +++ /dev/null @@ -1,26 +0,0 @@ -config->set_item( 'language', $idiom ); - $loaded = $this->is_loaded; - $this->is_loaded = array(); - - foreach($loaded as $file) - { - $this->load( str_replace( '_lang.php', '', $file ) ); - } - } - } -} - -?> diff --git a/application/models/customer.php b/application/models/customer.php index 8b0e54913..1b686c25a 100644 --- a/application/models/customer.php +++ b/application/models/customer.php @@ -14,6 +14,19 @@ class Customer extends Person return ($query->num_rows()==1); } + function account_number_exists($account_number,$person_id='') + { + $this->db->from('customers'); + $this->db->where('account_number', $account_number); + if (!empty($person_id)) + { + $this->db->where('person_id !=', $person_id); + } + $query=$this->db->get(); + return ($query->num_rows()==1); + } + + /* Returns all the customers */ diff --git a/application/views/customers/form.php b/application/views/customers/form.php index 507368450..e7ebcc95a 100644 --- a/application/views/customers/form.php +++ b/application/views/customers/form.php @@ -12,6 +12,7 @@ echo form_open('customers/save/'.$person_info->person_id,array('id'=>'customer_f 'account_number', 'id'=>'account_number', + 'class'=>'account_number', 'value'=>$person_info->account_number) );?> @@ -41,6 +42,24 @@ echo form_close(); //validation and submit handling $(document).ready(function() { + + $.validator.addMethod("account_number", function(value, element) + { + return JSON.parse($.ajax( + { + type: 'POST', + url: '', + data: {'person_id' : 'person_id; ?>', 'account_number' : $(element).val() }, + success: function(response) + { + success=response.success; + }, + async:false, + dataType: 'json' + }).responseText).success; + + }, 'lang->line("customers_account_number_duplicate"); ?>'); + $('#customer_form').validate({ submitHandler:function(form) { @@ -60,7 +79,8 @@ $(document).ready(function() { first_name: "required", last_name: "required", - email: "email" + email: "email", + account_number: { account_number: true } }, messages: { diff --git a/application/views/sales/receipt.php b/application/views/sales/receipt.php index 36cc37885..4ac274ec5 100644 --- a/application/views/sales/receipt.php +++ b/application/views/sales/receipt.php @@ -47,9 +47,9 @@ if (isset($error_message))
| lang->line('sales_item_name_short'); ?> | -lang->line('sales_taxed_price_short'); ?> | -lang->line('sales_quantity_short'); ?> | +lang->line('sales_description_abbrv'); ?> | +lang->line('sales_price'); ?> | +lang->line('sales_quantity'); ?> | lang->line('sales_total'); ?> | + |
|---|---|---|---|---|---|---|
| @@ -101,10 +101,11 @@ if (isset($error_message)) $payment) { - $only_sale_check &= $payment[ SALE_PAYMENT_PAYMENT_TYPE ] == $this->lang->line('sales_check'); + $only_sale_check &= $payment[ 'payment_type' ] == $this->lang->line('sales_check'); + $show_gifcard_remainder &= $payment[ 'payment_type' ] == $this->lang->line('sales_giftcard'); ?> | ||||||
| @@ -117,7 +118,7 @@ if (isset($error_message)) | ||||||