From b819442e986ec1e03fba231d9e14f442ac7cb98c Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Sat, 22 Apr 2017 13:33:27 +0100 Subject: [PATCH] Fix indentation and regen db scripts --- application/controllers/Giftcards.php | 33 +++++----- application/controllers/Sales.php | 11 ++-- application/models/Giftcard.php | 8 ++- application/views/configs/general_config.php | 66 ++++++++++---------- application/views/giftcards/form.php | 17 ++--- database/database.sql | 5 +- database/migrate_phppos_dist.sql | 5 +- 7 files changed, 77 insertions(+), 68 deletions(-) diff --git a/application/controllers/Giftcards.php b/application/controllers/Giftcards.php index 28f3ab23e..53d633a5d 100644 --- a/application/controllers/Giftcards.php +++ b/application/controllers/Giftcards.php @@ -63,15 +63,17 @@ class Giftcards extends Secure_Controller $giftcard_info = $this->Giftcard->get_info($giftcard_id); $data['selected_person_name'] = ($giftcard_id > 0 && isset($giftcard_info->person_id)) ? $giftcard_info->first_name . ' ' . $giftcard_info->last_name : ''; - $data['selected_person_id'] = $giftcard_info->person_id; - if($this->config->item('giftcard_number') == "random"){ - $data['giftcard_number'] = $giftcard_id > 0 ? $giftcard_info->giftcard_number : ''; + $data['selected_person_id'] = $giftcard_info->person_id; + if($this->config->item('giftcard_number') == "random") + { + $data['giftcard_number'] = $giftcard_id > 0 ? $giftcard_info->giftcard_number : ''; } - else{ - $data['giftcard_number'] = $giftcard_id > 0 ? $giftcard_info->giftcard_number : $this->Giftcard->get_max_number()->giftcard_number + 1; + else + { + $data['giftcard_number'] = $giftcard_id > 0 ? $giftcard_info->giftcard_number : $this->Giftcard->get_max_number()->giftcard_number + 1; } - $data['giftcard_id'] = $giftcard_id; - $data['giftcard_value'] = $giftcard_info->value; + $data['giftcard_id'] = $giftcard_id; + $data['giftcard_value'] = $giftcard_info->value; $data = $this->xss_clean($data); @@ -80,12 +82,13 @@ class Giftcards extends Secure_Controller public function save($giftcard_id = -1) { - if($giftcard_id == -1 && trim($this->input->post('giftcard_number')) == ''){ + $giftcard_number = $this->input->post('giftcard_number'); + + if($giftcard_id == -1 && trim($giftcard_number) == '') + { $giftcard_number = $this->Giftcard->generate_unique_giftcard_name($this->input->post('value')); } - else{ - $giftcard_number = $this->input->post('giftcard_number'); - } + $giftcard_data = array( 'record_time' => date('Y-m-d H:i:s'), 'giftcard_number' => $giftcard_number, @@ -100,12 +103,12 @@ class Giftcards extends Secure_Controller //New giftcard if($giftcard_id == -1) { - echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('giftcards_successful_adding').' '. + echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('giftcards_successful_adding') . ' ' . $giftcard_data['giftcard_number'], 'id' => $giftcard_data['giftcard_id'])); } else //Existing giftcard { - echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('giftcards_successful_updating').' '. + echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('giftcards_successful_updating') . ' ' . $giftcard_data['giftcard_number'], 'id' => $giftcard_id)); } } @@ -113,7 +116,7 @@ class Giftcards extends Secure_Controller { $giftcard_data = $this->xss_clean($giftcard_data); - echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('giftcards_error_adding_updating').' '. + echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('giftcards_error_adding_updating') . ' ' . $giftcard_data['giftcard_number'], 'id' => -1)); } } @@ -124,7 +127,7 @@ class Giftcards extends Secure_Controller if($this->Giftcard->delete_list($giftcards_to_delete)) { - echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('giftcards_successful_deleted').' '. + echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('giftcards_successful_deleted') . ' ' . count($giftcards_to_delete).' '.$this->lang->line('giftcards_one_or_multiple'))); } else diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index 00c3c8024..c062b7998 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -197,10 +197,12 @@ class Sales extends Secure_Controller $data = array(); $payment_type = $this->input->post('payment_type'); - if($payment_type != $this->lang->line('sales_giftcard')){ + if($payment_type != $this->lang->line('sales_giftcard')) + { $this->form_validation->set_rules('amount_tendered', 'lang:sales_amount_tendered', 'trim|required|callback_numeric'); } - else{ + else + { $this->form_validation->set_rules('amount_tendered', 'lang:sales_amount_tendered', 'trim|required'); } if($this->form_validation->run() == FALSE) @@ -246,7 +248,7 @@ class Sales extends Secure_Controller { $customer_id = $this->sale_lib->get_customer(); $package_id = $this->Customer->get_info($customer_id)->package_id; - if(isset($package_id) && $package_id!=NULL) + if(!empty($package_id)) { $package_name = $this->Customer_rewards->get_name($package_id); $points = $this->Customer->get_info($customer_id)->points; @@ -259,7 +261,7 @@ class Sales extends Secure_Controller if(($cur_rewards_value - $current_payments_with_rewards) <= 0) { - $data['error'] = $this->lang->line('rewards_remaining_balance'). to_currency($cur_rewards_value); + $data['error'] = $this->lang->line('rewards_remaining_balance') . to_currency($cur_rewards_value); } else { @@ -273,7 +275,6 @@ class Sales extends Secure_Controller $this->sale_lib->add_payment($payment_type, $amount_tendered); } } - } else { diff --git a/application/models/Giftcard.php b/application/models/Giftcard.php index ff4603dcb..033cbe72f 100644 --- a/application/models/Giftcard.php +++ b/application/models/Giftcard.php @@ -279,11 +279,13 @@ class Giftcard extends CI_Model { $value = str_replace('.', 'DE', $value); $random = bin2hex(openssl_random_pseudo_bytes(3)); - $giftcard_name = (string)$random.'-'.$value; - if($this->exists_gitcard_name($giftcard_name)){ + $giftcard_name = (string)$random . '-' . $value; + if($this->exists_gitcard_name($giftcard_name)) + { $this->generate_unique_giftcard_name($value); } - return strtoupper($giftcard_name); + + return strtoupper($giftcard_name); } } ?> diff --git a/application/views/configs/general_config.php b/application/views/configs/general_config.php index b8a3405c3..1d7f44ff3 100644 --- a/application/views/configs/general_config.php +++ b/application/views/configs/general_config.php @@ -60,29 +60,29 @@ -
+
lang->line('config_customer_sales_tax_support'), 'customer_sales_tax_support', array('class' => 'control-label col-xs-2')); ?> -
+
'customer_sales_tax_support', 'id' => 'customer_sales_tax_support', 'value' => 'customer_sales_tax_support', 'checked'=>$this->config->item('customer_sales_tax_support'))); ?> -
-
+
+
-
+
lang->line('config_default_origin_tax_code'), 'default_origin_tax_code', array('class' => 'control-label col-xs-2')); ?> -
+
'default_origin_tax_code', 'id' => 'default_origin_tax_code', 'class' => 'form-control input-sm text-uppercase', 'value'=>$this->config->item('default_origin_tax_code'))); ?> -
-
+
+
-
+
lang->line('config_default_sales_discount'), 'default_sales_discount', array('class' => 'control-label col-xs-2 required')); ?>
@@ -150,20 +150,20 @@
lang->line('config_giftcard_number'), 'giftcard_number', array('class' => 'control-label col-xs-2')); ?>
- + 'giftcard_number', + 'value' => 'series', + 'checked'=>$this->config->item('giftcard_number') === "series")); ?> + lang->line('config_giftcard_series'); ?> + +
@@ -323,24 +323,24 @@ $(document).ready(function() rules: { - default_tax_1_rate: - { + default_tax_1_rate: + { remote: "" - }, + }, default_tax2_rate: { remote: "" }, - lines_per_page: - { - required: true, + lines_per_page: + { + required: true, remote: "" - }, - default_sales_discount: - { - required: true, + }, + default_sales_discount: + { + required: true, remote: "" - } + } }, messages: diff --git a/application/views/giftcards/form.php b/application/views/giftcards/form.php index 210927c79..24f76681c 100644 --- a/application/views/giftcards/form.php +++ b/application/views/giftcards/form.php @@ -18,9 +18,10 @@
config->item('giftcard_number') == "series"){ - $class = " required"; + $class = ''; + if($this->config->item('giftcard_number') == 'series') + { + $class = ' required'; } ?>
@@ -75,13 +76,13 @@ $(document).ready(function() var autocompleter = $("#person_name").autocomplete({ source: '', - minChars: 0, - delay: 15, - cacheLength: 1, + minChars: 0, + delay: 15, + cacheLength: 1, appendTo: '.modal-content', select: fill_value, focus: fill_value - }); + }); // declare submitHandler as an object.. will be reused var submit_form = function() { @@ -136,4 +137,4 @@ $(document).ready(function() } }, form_support.error)); }); - \ No newline at end of file + diff --git a/database/database.sql b/database/database.sql index 71c0699b7..f0564e9e5 100644 --- a/database/database.sql +++ b/database/database.sql @@ -94,7 +94,8 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('customer_reward_enable',''), ('default_origin_tax_code', ''), ('cash_decimals', '2'), -('financial_year','1'); +('financial_year','1'), +('giftcard_number', 'series'); -- -------------------------------------------------------- @@ -154,7 +155,7 @@ INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`, ` CREATE TABLE `ospos_giftcards` ( `record_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `giftcard_id` int(11) NOT NULL AUTO_INCREMENT, - `giftcard_number` int(10) NOT NULL, + `giftcard_number` VARCHAR(255) NULL, `value` decimal(15,2) NOT NULL, `deleted` int(1) NOT NULL DEFAULT '0', `person_id` INT(10) DEFAULT NULL, diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index 0622dda35..8ace78db8 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -94,7 +94,8 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('customer_reward_enable',''), ('default_origin_tax_code', ''), ('cash_decimals', '2'), -('financial_year','1'); +('financial_year','1'), +('giftcard_number', 'series'); -- -------------------------------------------------------- @@ -154,7 +155,7 @@ INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`, ` CREATE TABLE `ospos_giftcards` ( `record_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `giftcard_id` int(11) NOT NULL AUTO_INCREMENT, - `giftcard_number` int(10) NOT NULL, + `giftcard_number` VARCHAR(255) NULL, `value` decimal(15,2) NOT NULL, `deleted` int(1) NOT NULL DEFAULT '0', `person_id` INT(10) DEFAULT NULL,