From c7c4ac15d6a1b4dcaaea9b74644738dea0b7d62f Mon Sep 17 00:00:00 2001 From: jekkos-t520 Date: Mon, 16 Feb 2015 18:31:06 +0100 Subject: [PATCH] Set update_row response datatype to html Remove MY_Validation override (not needed anymore) Add jquery validation check for account_number --- application/controllers/customers.php | 6 ++++ application/language/en/customers_lang.php | 1 + application/language/es/customers_lang.php | 1 + application/language/fr/customers_lang.php | 1 + application/language/id/customers_lang.php | 1 + application/language/nl-BE/customers_lang.php | 1 + application/language/ru/customers_lang.php | 1 + application/language/th/customers_lang.php | 1 + application/language/tr/customers_lang.php | 1 + application/language/zh/customers_lang.php | 1 + application/libraries/MY_Form_validation.php | 22 ------------- application/models/customer.php | 13 ++++++++ application/views/customers/form.php | 22 ++++++++++++- js/manage_tables.js | 2 +- translations/customers_lang.csv | 31 ++++++++++--------- 15 files changed, 66 insertions(+), 39 deletions(-) delete mode 100755 application/libraries/MY_Form_validation.php diff --git a/application/controllers/customers.php b/application/controllers/customers.php index f1c27102c..3a6c69c25 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 */ 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/id/customers_lang.php b/application/language/id/customers_lang.php index a6eb32d1c..15b15381b 100644 --- a/application/language/id/customers_lang.php +++ b/application/language/id/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "Anda telah berhasil menghapus pelanggan $lang["customers_successful_updating"] = "Anda telah berhasil memperbarui pelanggan"; $lang["customers_taxable"] = "Dapat dikenakan pajak"; $lang["customers_update"] = "Ubah Pelanggan"; +$lang["customers_account_number_duplicate"] = "This account number is already present in the database"; diff --git a/application/language/nl-BE/customers_lang.php b/application/language/nl-BE/customers_lang.php index 28ea02a9a..70f9b59e1 100755 --- a/application/language/nl-BE/customers_lang.php +++ b/application/language/nl-BE/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "Er werd(en)"; $lang["customers_successful_updating"] = "Wijzigingen klantgegevens bewaard voor "; $lang["customers_taxable"] = "Belastbaar"; $lang["customers_update"] = "Bewerk Klant"; +$lang["customers_account_number_duplicate"] = "Deze VAT nummer is reeds aanwezig in de database"; diff --git a/application/language/ru/customers_lang.php b/application/language/ru/customers_lang.php index cb80f894c..5c213a1d4 100644 --- a/application/language/ru/customers_lang.php +++ b/application/language/ru/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "Вы успешно удалили"; $lang["customers_successful_updating"] = "Вы успешно обновили клиент"; $lang["customers_taxable"] = "облагаемый"; $lang["customers_update"] = "Обновлять Клиент"; +$lang["customers_account_number_duplicate"] = "This account number is already present in the database"; diff --git a/application/language/th/customers_lang.php b/application/language/th/customers_lang.php index 15e9b796d..509d1a503 100644 --- a/application/language/th/customers_lang.php +++ b/application/language/th/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "คุณได้ทำการลบ $lang["customers_successful_updating"] = "คุณได้ทำการแก้ไขข้อมูลลูกค้าเรียบร้อยแล้ว"; $lang["customers_taxable"] = "ต้องเสียภาษี"; $lang["customers_update"] = "แก้ไขข้อมูลลูกค้า"; +$lang["customers_account_number_duplicate"] = "This account number is already present in the database"; diff --git a/application/language/tr/customers_lang.php b/application/language/tr/customers_lang.php index 15cc0a344..d114bd11d 100644 --- a/application/language/tr/customers_lang.php +++ b/application/language/tr/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "Silme başarılı"; $lang["customers_successful_updating"] = "Müşteri güncellendi"; $lang["customers_taxable"] = "Vergilendirilebilir"; $lang["customers_update"] = "Müşteri Güncelle"; +$lang["customers_account_number_duplicate"] = "This account number is already present in the database"; diff --git a/application/language/zh/customers_lang.php b/application/language/zh/customers_lang.php index b90f216b9..84320a35b 100755 --- a/application/language/zh/customers_lang.php +++ b/application/language/zh/customers_lang.php @@ -14,3 +14,4 @@ $lang["customers_successful_deleted"] = "成功刪除"; $lang["customers_successful_updating"] = "成功更新顧客"; $lang["customers_taxable"] = "應課稅"; $lang["customers_update"] = "更新客戶"; +$lang["customers_account_number_duplicate"] = "This account number is already present in the database"; diff --git a/application/libraries/MY_Form_validation.php b/application/libraries/MY_Form_validation.php deleted file mode 100755 index 3572f2400..000000000 --- a/application/libraries/MY_Form_validation.php +++ /dev/null @@ -1,22 +0,0 @@ -error_string; - } - - function get_error_messages() - { - return $this->_error_array; - } - -} - -?> \ No newline at end of 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/js/manage_tables.js b/js/manage_tables.js index e4fc35b91..67534ed28 100644 --- a/js/manage_tables.js +++ b/js/manage_tables.js @@ -292,7 +292,7 @@ function update_row(row_id,url,callback) reinit_row(row_id); hightlight_row(row_id); callback && typeof(callback) == "function" && callback(); - }); + }, 'html'); } function reinit_row(checkbox_id) diff --git a/translations/customers_lang.csv b/translations/customers_lang.csv index 6a9d25aa6..eb14d748d 100644 --- a/translations/customers_lang.csv +++ b/translations/customers_lang.csv @@ -1,15 +1,16 @@ -"label","nl-BE","es","en","fr","zh","ru","th","tr","id" -"customers_account_number","Btwnummer","Cuenta #","Account #","# Compte","帳號 #","Номер счота","บัญชี #","Hesap No","No.Pelanggan" -"customers_basic_information","Klantgegevens","Información de Clientes","Customer Information","Informations Client","客戶資訊","Информация о клиенте","ข้อมูลลูกค้า","Müşteri bilgisi","Informasi Pelanggan" -"customers_cannot_be_deleted","De geselecteerde klanten konden niet worden verwijderd. Eén of meerdere klanten hebben verkoopsgegevens in de database zitten.","No se pudo borrar los clientes seleccionados. Uno o más de éstos tiene ventas.","Could not deleted selected customers, one or more of the selected customers has sales.","Impossible de supprimer. Un ou plusiers client(s) sélectionné(s) ont des ventes.","無法刪除選定的客戶,選定的客戶存有銷售紀錄。","Невозможно удалить выбранных клиентов, один или более из них имеет продаж.","ไม่สามารลบลูกค้าที่ถูกเลือก, ลูกค้าที่ถูกเลือกถูขายไปแล้ว.","Seçili müşteriler silinemedi, müşterilerin satışları var.","pelanggan terpilih tidak bisa dihapus; satu atau lebih dari pelanggan yang dipilih memiliki penjualan." -"customers_confirm_delete","Bent u zeker dat u de geselecteerde klanten wil verwijderen?","¿Estás seguro(a) de que quieres borrar a los clientes seleccionados?","Are you sure you want to delete the selected customers?","Etes vous sûr(e) de vouloir supprimer ces clients?","你確定要刪除選定的客戶?","Вы уверены, что хотите удалить выбранных клиентов?","ยืนยันลบข้อมูลลูกค้า?","Seçili müşteriyi silmek istediğinize emin misiniz?","Apakah Anda yakin ingin menghapus pelanggan yang dipilih?" -"customers_customer","Klant","Cliente","Customer","Client","客戶","Клиент","ลูกค้า","Müşteri","Pelanggan" -"customers_error_adding_updating","Fout bij het toevoegen/bewerken van een klant","Error agregando/actualizando cliente","Error adding/updating customer","Érreur lors de l\'ajout/suppression de client","添加/更新客戶錯誤","Ошибка при добавлении/обновлении клиента","แก้ไขข้อมูลลูกค้าผิดพลาด","Müşteri ekleme/güncelleme hatası","Menambah / Memperbarui Pelanggan Salah" -"customers_new","Nieuwe Klant","Nuevo Cliente","New Customer","Nouveau Client","新客戶","Новый Клиент","ลูกค้าใหม่","Yeni Müşteri","Pelanggan Baru" -"customers_none_selected","U hebt geen klanten geselecteerd","No has selccionado clientes para ser borrados","You have not selected any customers to delete","Vous n\\\'avez pas sélectionné de client à supprimer","您還沒有選擇任何客戶進行刪除","Вы не выбрали ни клиентов, чтобы удалить.","คุณยังไม่ได้ทำการเลือกลูกค้า","Silmek için müşteri seçmediniz","Anda belum memilih pelanggan untuk dihapus" -"customers_one_or_multiple","klant(en) verwijderd","cliente(s)","customer(s)","client(s)","客戶","клиент(ов)","ลูกค้า","müşteri","pelanggan" -"customers_successful_adding","Klant succesvol aangemaakt","Has agregado satisfactoriamente el cliente","You have successfully added customer","Vous avez ajouté un nouveau client","成功新增顧客","Вы успешно добавили клиентов","คุณได้ทำการเพิ่มลูกค้าเรียบร้อยแล้ว","Müşteri eklendi","Anda telah berhasil menambah pelanggan" -"customers_successful_deleted","Er werd(en)","Has borrado satisfactoriamente a","You have successfully deleted","Suppréssion réussie","成功刪除","Вы успешно удалили","คุณได้ทำการลบข้อมูลเรียบร้อยแล้ว","Silme başarılı","Anda telah berhasil menghapus pelanggan" -"customers_successful_updating","Wijzigingen klantgegevens bewaard voor ","No se ha podido agregar el cliente","You have successfully updated customer","Édition client réussie","成功更新顧客","Вы успешно обновили клиент","คุณได้ทำการแก้ไขข้อมูลลูกค้าเรียบร้อยแล้ว","Müşteri güncellendi","Anda telah berhasil memperbarui pelanggan" -"customers_taxable","Belastbaar","Gravable","Taxable","Imposable","應課稅","облагаемый","ต้องเสียภาษี","Vergilendirilebilir","Dapat dikenakan pajak" -"customers_update","Bewerk Klant","Actualizar Cliente","Update Customer","Éditer Client","更新客戶","Обновлять Клиент","แก้ไขข้อมูลลูกค้า","Müşteri Güncelle","Ubah Pelanggan" +label,nl-BE,es,en,fr,zh,ru,th,tr,id +customers_account_number,Btwnummer,Cuenta #,Account #,# Compte,帳號 #,Номер счота,บัญชี #,Hesap No,No.Pelanggan +customers_basic_information,Klantgegevens,Información de Clientes,Customer Information,Informations Client,客戶資訊,Информация о клиенте,ข้อมูลลูกค้า,Müşteri bilgisi,Informasi Pelanggan +customers_cannot_be_deleted,De geselecteerde klanten konden niet worden verwijderd. Eén of meerdere klanten hebben verkoopsgegevens in de database zitten.,No se pudo borrar los clientes seleccionados. Uno o más de éstos tiene ventas.,"Could not deleted selected customers, one or more of the selected customers has sales.",Impossible de supprimer. Un ou plusiers client(s) sélectionné(s) ont des ventes.,無法刪除選定的客戶,選定的客戶存有銷售紀錄。,"Невозможно удалить выбранных клиентов, один или более из них имеет продаж.","ไม่สามารลบลูกค้าที่ถูกเลือก, ลูกค้าที่ถูกเลือกถูขายไปแล้ว.","Seçili müşteriler silinemedi, müşterilerin satışları var.",pelanggan terpilih tidak bisa dihapus; satu atau lebih dari pelanggan yang dipilih memiliki penjualan. +customers_confirm_delete,Bent u zeker dat u de geselecteerde klanten wil verwijderen?,¿Estás seguro(a) de que quieres borrar a los clientes seleccionados?,Are you sure you want to delete the selected customers?,Etes vous sûr(e) de vouloir supprimer ces clients?,你確定要刪除選定的客戶?,"Вы уверены, что хотите удалить выбранных клиентов?",ยืนยันลบข้อมูลลูกค้า?,Seçili müşteriyi silmek istediğinize emin misiniz?,Apakah Anda yakin ingin menghapus pelanggan yang dipilih? +customers_customer,Klant,Cliente,Customer,Client,客戶,Клиент,ลูกค้า,Müşteri,Pelanggan +customers_error_adding_updating,Fout bij het toevoegen/bewerken van een klant,Error agregando/actualizando cliente,Error adding/updating customer,Érreur lors de l\'ajout/suppression de client,添加/更新客戶錯誤,Ошибка при добавлении/обновлении клиента,แก้ไขข้อมูลลูกค้าผิดพลาด,Müşteri ekleme/güncelleme hatası,Menambah / Memperbarui Pelanggan Salah +customers_new,Nieuwe Klant,Nuevo Cliente,New Customer,Nouveau Client,新客戶,Новый Клиент,ลูกค้าใหม่,Yeni Müşteri,Pelanggan Baru +customers_none_selected,U hebt geen klanten geselecteerd,No has selccionado clientes para ser borrados,You have not selected any customers to delete,Vous n\\\'avez pas sélectionné de client à supprimer,您還沒有選擇任何客戶進行刪除,"Вы не выбрали ни клиентов, чтобы удалить.",คุณยังไม่ได้ทำการเลือกลูกค้า,Silmek için müşteri seçmediniz,Anda belum memilih pelanggan untuk dihapus +customers_one_or_multiple,klant(en) verwijderd,cliente(s),customer(s),client(s),客戶,клиент(ов),ลูกค้า,müşteri,pelanggan +customers_successful_adding,Klant succesvol aangemaakt,Has agregado satisfactoriamente el cliente,You have successfully added customer,Vous avez ajouté un nouveau client,成功新增顧客,Вы успешно добавили клиентов,คุณได้ทำการเพิ่มลูกค้าเรียบร้อยแล้ว,Müşteri eklendi,Anda telah berhasil menambah pelanggan +customers_successful_deleted,Er werd(en),Has borrado satisfactoriamente a,You have successfully deleted,Suppréssion réussie,成功刪除,Вы успешно удалили,คุณได้ทำการลบข้อมูลเรียบร้อยแล้ว,Silme başarılı,Anda telah berhasil menghapus pelanggan +customers_successful_updating,Wijzigingen klantgegevens bewaard voor ,No se ha podido agregar el cliente,You have successfully updated customer,Édition client réussie,成功更新顧客,Вы успешно обновили клиент,คุณได้ทำการแก้ไขข้อมูลลูกค้าเรียบร้อยแล้ว,Müşteri güncellendi,Anda telah berhasil memperbarui pelanggan +customers_taxable,Belastbaar,Gravable,Taxable,Imposable,應課稅,облагаемый,ต้องเสียภาษี,Vergilendirilebilir,Dapat dikenakan pajak +customers_update,Bewerk Klant,Actualizar Cliente,Update Customer,Éditer Client,更新客戶,Обновлять Клиент,แก้ไขข้อมูลลูกค้า,Müşteri Güncelle,Ubah Pelanggan +customers_account_number_duplicate,Deze VAT nummer is reeds aanwezig in de database,This account number is already present in the database,This account number is already present in the database,This account number is already present in the database,This account number is already present in the database,This account number is already present in the database,This account number is already present in the database,This account number is already present in the database,This account number is already present in the database