Browse Source

Merge remote-tracking branch 'fork/v1.5.0' into v1.5.0

Denys Vitali 2 years ago
parent
commit
3f3748e980
100 changed files with 1400 additions and 7766 deletions
  1. 0 1
      .gitignore
  2. 1 0
      application/core/Base_Controller.php
  3. 47 0
      application/helpers/settings_helper.php
  4. 1 1
      application/modules/clients/controllers/Ajax.php
  5. 1 1
      application/modules/clients/controllers/Clients.php
  6. 27 26
      application/modules/clients/models/Mdl_clients.php
  7. 20 18
      application/modules/clients/views/form.php
  8. 5 5
      application/modules/clients/views/view.php
  9. 2 2
      application/modules/custom_values/views/field.php
  10. 2 2
      application/modules/dashboard/controllers/Dashboard.php
  11. 1 1
      application/modules/dashboard/views/index.php
  12. 32 30
      application/modules/email_templates/views/form.php
  13. 14 14
      application/modules/guest/controllers/Payment_handler.php
  14. 10 11
      application/modules/guest/controllers/View.php
  15. 2 2
      application/modules/guest/views/index.php
  16. 1 1
      application/modules/guest/views/invoices_index.php
  17. 15 15
      application/modules/invoices/controllers/Ajax.php
  18. 1 1
      application/modules/invoices/controllers/Cron.php
  19. 32 31
      application/modules/invoices/controllers/Invoices.php
  20. 1 1
      application/modules/invoices/models/Mdl_invoice_amounts.php
  21. 8 8
      application/modules/invoices/models/Mdl_invoices.php
  22. 10 10
      application/modules/invoices/models/Mdl_invoices_recurring.php
  23. 2 1
      application/modules/invoices/views/archive.php
  24. 5 7
      application/modules/invoices/views/modal_change_client.php
  25. 5 7
      application/modules/invoices/views/modal_copy_invoice.php
  26. 3 7
      application/modules/invoices/views/modal_create_credit.php
  27. 6 5
      application/modules/invoices/views/modal_create_invoice.php
  28. 4 4
      application/modules/invoices/views/partial_item_table.php
  29. 2 1
      application/modules/invoices/views/view.php
  30. 2 1
      application/modules/invoices/views/view_sumex.php
  31. 8 6
      application/modules/layout/views/includes/head.php
  32. 14 14
      application/modules/layout/views/includes/navbar.php
  33. 8 6
      application/modules/layout/views/layout_guest.php
  34. 2 2
      application/modules/mailer/controllers/Mailer.php
  35. 9 9
      application/modules/mailer/helpers/phpmailer_helper.php
  36. 6 4
      application/modules/mailer/views/invoice.php
  37. 5 3
      application/modules/mailer/views/quote.php
  38. 13 13
      application/modules/payments/models/Mdl_payments.php
  39. 3 2
      application/modules/payments/views/form.php
  40. 1 1
      application/modules/payments/views/modal_add_payment.php
  41. 4 4
      application/modules/quotes/controllers/Quotes.php
  42. 6 6
      application/modules/quotes/models/Mdl_quotes.php
  43. 3 2
      application/modules/quotes/views/modal_copy_quote.php
  44. 5 7
      application/modules/quotes/views/modal_create_quote.php
  45. 3 7
      application/modules/quotes/views/modal_quote_to_invoice.php
  46. 3 3
      application/modules/quotes/views/partial_item_table.php
  47. 5 5
      application/modules/reports/controllers/Reports.php
  48. 63 61
      application/modules/reports/views/sales_by_year_index.php
  49. 8 8
      application/modules/sessions/controllers/Sessions.php
  50. 4 3
      application/modules/sessions/views/session_login.php
  51. 4 3
      application/modules/sessions/views/session_new_password.php
  52. 4 3
      application/modules/sessions/views/session_passwordreset.php
  53. 2 1
      application/modules/settings/controllers/Ajax.php
  54. 2 2
      application/modules/settings/controllers/Settings.php
  55. 18 24
      application/modules/settings/views/partial_settings_email.php
  56. 88 70
      application/modules/settings/views/partial_settings_general.php
  57. 64 77
      application/modules/settings/views/partial_settings_invoices.php
  58. 20 12
      application/modules/settings/views/partial_settings_merchant.php
  59. 3 7
      application/modules/settings/views/partial_settings_projects_tasks.php
  60. 21 35
      application/modules/settings/views/partial_settings_quotes.php
  61. 12 6
      application/modules/settings/views/partial_settings_taxes.php
  62. 1 3
      application/modules/settings/views/partial_settings_updates.php
  63. 15 14
      application/modules/setup/controllers/Setup.php
  64. 43 34
      application/modules/setup/sql/023_1.5.0.sql
  65. 2 2
      application/modules/setup/views/configure_database.php
  66. 5 4
      application/modules/setup/views/create_user.php
  67. 1 1
      application/modules/setup/views/prerequisites.php
  68. 47 47
      application/modules/tasks/models/Mdl_tasks.php
  69. 3 1
      application/modules/tasks/views/form.php
  70. 4 4
      application/modules/tasks/views/modal_task_lookups.php
  71. 18 18
      application/modules/upload/controllers/Upload.php
  72. 1 1
      application/modules/users/controllers/Users.php
  73. 9 5
      application/modules/users/views/form.php
  74. 0 6
      application/views/quote_templates/public/InvoicePlane_Web.php
  75. 5 0
      assets/.gitignore
  76. 45 0
      assets/core/scss/_bootstrap-welcome.scss
  77. 100 0
      assets/core/scss/_welcome.scss
  78. 3 0
      assets/invoiceplane/invoiceplane.theme
  79. 2 91
      assets/invoiceplane/sass/welcome.scss
  80. 3 0
      assets/invoiceplane_blue/invoiceplane_blue.theme
  81. 2 91
      assets/invoiceplane_blue/sass/welcome.scss
  82. 3 2
      composer.json
  83. 414 0
      composer.lock
  84. 1 1
      index.php
  85. 0 6
      system/.htaccess
  86. 0 133
      system/core/Benchmark.php
  87. 0 559
      system/core/CodeIgniter.php
  88. 0 857
      system/core/Common.php
  89. 0 379
      system/core/Config.php
  90. 0 96
      system/core/Controller.php
  91. 0 274
      system/core/Exceptions.php
  92. 0 266
      system/core/Hooks.php
  93. 0 897
      system/core/Input.php
  94. 0 203
      system/core/Lang.php
  95. 0 1411
      system/core/Loader.php
  96. 0 296
      system/core/Log.php
  97. 0 80
      system/core/Model.php
  98. 0 849
      system/core/Output.php
  99. 0 515
      system/core/Router.php
  100. 0 0
      system/core/Security.php

+ 0 - 1
.gitignore

@@ -6,7 +6,6 @@
 # Dependencies
 /node_modules
 /vendor
-composer.lock
 
 # Other files
 /.htaccess

+ 1 - 0
application/core/Base_Controller.php

@@ -48,6 +48,7 @@ class Base_Controller extends MX_Controller
             $this->load->helper('invoice');
             $this->load->helper('date');
             $this->load->helper('redirect');
+            $this->load->helper('form');
 
             // Load setting model and load settings
             $this->load->model('settings/mdl_settings');

+ 47 - 0
application/helpers/settings_helper.php

@@ -22,3 +22,50 @@ function get_setting($setting_key, $default = '')
     $CI = &get_instance();
     return $CI->mdl_settings->setting($setting_key, $default);
 }
+
+/**
+ * Compares the two given values and outputs selected="selected"
+ * if the values match or the operation is true for the single value
+ *
+ * Examples
+ * check_select($option_key, 'key_1')           Checks if $option_key equals (==) 'key_1'.
+ * check_select($option_key, 'key_1', '!=')     Checks if $option_key not equals (!=) 'key_1'.
+ * check_select($option_key)                    The same like if ($option_key) { ...
+ * check_select($option_key, null, 'e')         Checks if the $option_key value is empty.
+ * check_select($option_key != 'key_1')         If the first param is bool, it is used to validate the select
+ *
+ * @param string|integer $value1
+ * @param string|integer|null $value2
+ * @param string $operator
+ * @return void
+ */
+function check_select($value1, $value2 = null, $operator = '==')
+{
+    $select = 'selected="selected"';
+
+    // Instant-validate if $value1 is a bool value
+    if (is_bool($value1) && $value2 === null) {
+        echo $value1 ? $select : '';
+        return;
+    }
+
+    switch ($operator) {
+        case '==':
+            $echo_selected = $value1 == $value2 ? true : false;
+            break;
+        case '!=':
+            $echo_selected = $value1 != $value2 ? true : false;
+            break;
+        case 'e':
+            $echo_selected = empty($value1) ? true : false;
+            break;
+        case '!e':
+            $echo_selected = empty($value1) ? true : false;
+            break;
+        default:
+            $echo_selected = $value1 ? true : false;
+            break;
+    }
+
+    echo $echo_selected ? $select : '';
+}

+ 1 - 1
application/modules/clients/controllers/Ajax.php

@@ -29,7 +29,7 @@ class Ajax extends Admin_Controller
 
         $clients = $this->mdl_clients->select('client_name,client_surname')
             ->where(
-            "client_name LIKE $escapedQuery%
+                "client_name LIKE $escapedQuery%
             OR client_surname LIKE $escapedQuery%
             OR CONCATENATE(client_name,' ', client_surname) LIKE  $escapedQuery%")
             ->order_by('CONCATENATE(client_name,client_surname)')

+ 1 - 1
application/modules/clients/controllers/Clients.php

@@ -157,7 +157,7 @@ class Clients extends Admin_Controller
                 'custom_values' => $custom_values,
                 'countries' => get_country_list(trans('cldr')),
                 'selected_country' => $this->mdl_clients->form_value('client_country') ?:
-                    $this->mdl_settings->setting('default_country'),
+                    get_setting('default_country'),
                 'languages' => get_available_languages(),
             )
         );

+ 27 - 26
application/modules/clients/models/Mdl_clients.php

@@ -90,46 +90,47 @@ class Mdl_Clients extends Response_Model
             ),
             // SUMEX
             'client_birthdate' => array(
-              'field' => 'client_birthdate',
-              'rules' => 'callback_convert_date'
+                'field' => 'client_birthdate',
+                'rules' => 'callback_convert_date'
             ),
             'client_gender' => array(
-              'field' => 'client_gender'
+                'field' => 'client_gender'
             ),
             'client_avs' => array(
-              'field' => 'client_avs',
-              'label' => trans('sumex_ssn'),
-              'rules' => 'callback_fix_avs'
+                'field' => 'client_avs',
+                'label' => trans('sumex_ssn'),
+                'rules' => 'callback_fix_avs'
             ),
             'client_insurednumber' => array(
-              'field' => 'client_insurednumber',
-              'label' => trans('sumex_insurednumber')
+                'field' => 'client_insurednumber',
+                'label' => trans('sumex_insurednumber')
             ),
             'client_veka' => array(
-              'field' => 'client_veka',
-              'label' => trans('sumex_veka')
+                'field' => 'client_veka',
+                'label' => trans('sumex_veka')
             ),
         );
     }
 
-    function fix_avs($input){
-      if($input != ""){
-          if(preg_match('/(\d{3})\.(\d{4})\.(\d{4})\.(\d{2})/', $input, $matches)){
-            return $matches[1].$matches[2].$matches[3].$matches[4];
-          }
-          else if(preg_match('/^\d{13}$/',$input)){
-            return $input;
-          }
-      }
-      return "";
+    function fix_avs($input)
+    {
+        if ($input != "") {
+            if (preg_match('/(\d{3})\.(\d{4})\.(\d{4})\.(\d{2})/', $input, $matches)) {
+                return $matches[1] . $matches[2] . $matches[3] . $matches[4];
+            } else if (preg_match('/^\d{13}$/', $input)) {
+                return $input;
+            }
+        }
+        return "";
     }
 
-    function convert_date($input){
-      $this->load->helper('date_helper');
-      if($input == ""){
-        return "";
-      }
-      return date_to_mysql($input);
+    function convert_date($input)
+    {
+        $this->load->helper('date_helper');
+        if ($input == "") {
+            return "";
+        }
+        return date_to_mysql($input);
     }
 
     public function db_array()

+ 20 - 18
application/modules/clients/views/form.php

@@ -52,9 +52,9 @@ $cv = $this->controller->view_data["custom_values"];
                     <input id="client_name" name="client_name" type="text" class="form-control"
                            placeholder="<?php echo trans('client_name'); ?>" required autofocus
                            value="<?php echo htmlspecialchars($this->mdl_clients->form_value('client_name')); ?>">
-                           <input id="client_surname" name="client_surname" type="text" class="form-control"
-                                  placeholder="<?php echo trans('client_surname_optional'); ?>"
-                                  value="<?php echo htmlspecialchars($this->mdl_clients->form_value('client_surname')); ?>">
+                    <input id="client_surname" name="client_surname" type="text" class="form-control"
+                           placeholder="<?php echo trans('client_surname_optional'); ?>"
+                           value="<?php echo htmlspecialchars($this->mdl_clients->form_value('client_surname')); ?>">
                 </div>
 
             </div>
@@ -138,7 +138,7 @@ $cv = $this->controller->view_data["custom_values"];
 
                         <div class="controls">
                             <select name="client_country" id="client_country" class="form-control">
-                                <option></option>
+                                <option value=""><?php echo trans('none'); ?></option>
                                 <?php foreach ($countries as $cldr => $country) { ?>
                                     <option value="<?php echo $cldr; ?>"
                                         <?php if ($selected_country == $cldr) {
@@ -167,16 +167,16 @@ $cv = $this->controller->view_data["custom_values"];
 
                         <div class="controls">
                             <select name="client_gender" id="client_gender" class="form-control simple-select">
-                              <?php
-                              $genders = array(
-                                trans('gender_male'),
-                                trans('gender_female'),
-                                trans('gender_other'),
-                               );
-                              foreach($genders as $key=>$val){
-                                echo '<option value="'.$key.'"'.($key == $this->mdl_clients->form_value('client_gender')?' selected':'').'>'.$val.'</option>';
-                              }
-                              ?>
+                                <?php
+                                $genders = array(
+                                    trans('gender_male'),
+                                    trans('gender_female'),
+                                    trans('gender_other'),
+                                );
+                                foreach ($genders as $key => $val) {
+                                    echo '<option value="' . $key . '"' . ($key == $this->mdl_clients->form_value('client_gender') ? ' selected' : '') . '>' . $val . '</option>';
+                                }
+                                ?>
                             </select>
                         </div>
                     </div>
@@ -185,13 +185,14 @@ $cv = $this->controller->view_data["custom_values"];
                         <label><?php echo trans('birthdate'); ?>: </label>
                         <?php
                         $bdate = $this->mdl_clients->form_value('client_birthdate');
-                        if($bdate != ""){
-                          $bdate = date_from_mysql($bdate);
+                        if ($bdate != "") {
+                            $bdate = date_from_mysql($bdate);
                         }
 
                         ?>
                         <div class="controls">
-                            <input type="text" name="client_birthdate" id="client_birthdate" class="form-control datepicker"
+                            <input type="text" name="client_birthdate" id="client_birthdate"
+                                   class="form-control datepicker"
                                    value="<?php echo htmlspecialchars($bdate); ?>">
                         </div>
                     </div>
@@ -211,7 +212,8 @@ $cv = $this->controller->view_data["custom_values"];
                         <label><?php echo trans('sumex_insurednumber'); ?>: </label>
                         <?php $insuredNumber = $this->mdl_clients->form_value('client_insurednumber'); ?>
                         <div class="controls">
-                            <input type="text" name="client_insurednumber" id="client_insurednumber" class="form-control"
+                            <input type="text" name="client_insurednumber" id="client_insurednumber"
+                                   class="form-control"
                                    value="<?php echo htmlentities($insuredNumber); ?>">
                         </div>
                     </div>

+ 5 - 5
application/modules/clients/views/view.php

@@ -212,11 +212,11 @@
                         <?php endforeach; ?>
                     </table>
                 </div>
-                <?php if($client->client_surname != ""): //Client is not a company ?>
-                <div class="col-xs-12 col-md-6">
-                    <h4><?php echo trans('personal_information'); ?></h4>
-                    <br/>
-                    <table class="table table-condensed table-striped">
+                <?php if ($client->client_surname != ""): //Client is not a company ?>
+                    <div class="col-xs-12 col-md-6">
+                        <h4><?php echo trans('personal_information'); ?></h4>
+                        <br/>
+                        <table class="table table-condensed table-striped">
                             <tr>
                                 <th><?php echo trans('birthdate'); ?></th>
                                 <td><?php echo format_date($client->client_birthdate); ?></td>

+ 2 - 2
application/modules/custom_values/views/field.php

@@ -32,8 +32,8 @@
         <div class="form-group">
             <label class="col-xs-12 col-sm-1 control-label"><?php echo trans('type'); ?>: </label>
             <div class="col-xs-12 col-sm-8 col-md-6">
-                <select name="custom_field_types" id="custom_field_types" class="form-control simple-select" disabled="disabled">
-                    <option value=""></option>
+                <select name="custom_field_types" id="custom_field_types" class="form-control simple-select"
+                        disabled="disabled">
                     <?php foreach ($custom_values_types as $type): ?>
                         <?php $alpha = str_replace("-", "_", strtolower($type)); ?>
                         <option value="<?php echo $type; ?>"

+ 2 - 2
application/modules/dashboard/controllers/Dashboard.php

@@ -25,8 +25,8 @@ class Dashboard extends Admin_Controller
         $this->load->model('tasks/mdl_tasks');
         $this->load->helper('client');
 
-        $quote_overview_period = $this->mdl_settings->setting('quote_overview_period');
-        $invoice_overview_period = $this->mdl_settings->setting('invoice_overview_period');
+        $quote_overview_period = get_setting('quote_overview_period');
+        $invoice_overview_period = get_setting('invoice_overview_period');
 
         $this->layout->set(
             array(

+ 1 - 1
application/modules/dashboard/views/index.php

@@ -1,7 +1,7 @@
 <div id="content">
     <?php echo $this->layout->load_view('layout/alerts'); ?>
 
-    <div class="row <?php if ($this->mdl_settings->setting('disable_quickactions') == 1) {
+    <div class="row <?php if (get_setting('disable_quickactions') == 1) {
         echo 'hidden';
     } ?>">
         <div class="col-xs-12">

+ 32 - 30
application/modules/email_templates/views/form.php

@@ -109,8 +109,9 @@
                 </label>
             </div>
             <div class="col-xs-12 col-sm-6">
-                <select name="email_template_pdf_template" id="email_template_pdf_template" class="form-control simple-select">
-                    <option value="" class="empty-option"><?php echo trans('none'); ?></option>
+                <select name="email_template_pdf_template" id="email_template_pdf_template"
+                        class="form-control simple-select">
+                    <option value=""><?php echo trans('none'); ?></option>
                     <?php foreach ($invoice_templates as $template): ?>
                         <option class="hidden-invoice" value="<?php echo $template; ?>"
                                 <?php if ($selected_pdf_template == $template) { ?>selected="selected"<?php } ?>><?php echo $template; ?></option>
@@ -187,7 +188,8 @@
             <div class="col-xs-6 col-sm-4 col-md-3 col-lg-2">
                 <strong><?php echo trans('client'); ?></strong><br>
                 <a href="#" class="text-tag" data-tag="{{{client_name}}}"><?php echo trans('client_name'); ?></a><br>
-                <a href="#" class="text-tag" data-tag="{{{client_surname}}}"><?php echo trans('client_surname'); ?></a><br>
+                <a href="#" class="text-tag"
+                   data-tag="{{{client_surname}}}"><?php echo trans('client_surname'); ?></a><br>
                 <a href="#" class="text-tag"
                    data-tag="{{{client_address_1}}}"><?php echo trans('client'); ?> <?php echo lang('address'); ?>
                     1</a><br>
@@ -195,13 +197,13 @@
                    data-tag="{{{client_address_2}}}"><?php echo trans('client'); ?> <?php echo lang('address'); ?>
                     2</a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{client_city}}}"><?php echo trans('client'); ?> <?php echo lang('city'); ?></a><br>
+                   data-tag="{{{client_city}}}"><?php echo trans('client'); ?><?php echo lang('city'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{client_state}}}"><?php echo trans('client'); ?> <?php echo lang('state'); ?></a><br>
+                   data-tag="{{{client_state}}}"><?php echo trans('client'); ?><?php echo lang('state'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{client_zip}}}"><?php echo trans('client'); ?> <?php echo lang('zip_code'); ?></a><br>
+                   data-tag="{{{client_zip}}}"><?php echo trans('client'); ?><?php echo lang('zip_code'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{client_country}}}"><?php echo trans('client'); ?> <?php echo lang('country'); ?></a><br>
+                   data-tag="{{{client_country}}}"><?php echo trans('client'); ?><?php echo lang('country'); ?></a><br>
                 <?php foreach ($custom_fields['ip_client_custom'] as $custom) { ?>
                     <a href="#" class="text-tag"
                        data-tag="{{{<?php echo $custom->custom_field_column; ?>}}}"><?php echo $custom->custom_field_label; ?></a>
@@ -220,31 +222,31 @@
                 <a href="#" class="text-tag"
                    data-tag="{{{user_address_2}}}"><?php echo trans('user'); ?> <?php echo lang('address'); ?> 2</a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_city}}}"><?php echo trans('user'); ?> <?php echo lang('city'); ?></a><br>
+                   data-tag="{{{user_city}}}"><?php echo trans('user'); ?><?php echo lang('city'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_state}}}"><?php echo trans('user'); ?> <?php echo lang('state'); ?></a><br>
+                   data-tag="{{{user_state}}}"><?php echo trans('user'); ?><?php echo lang('state'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_zip}}}"><?php echo trans('user'); ?> <?php echo lang('zip_code'); ?></a><br>
+                   data-tag="{{{user_zip}}}"><?php echo trans('user'); ?><?php echo lang('zip_code'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_country}}}"><?php echo trans('user'); ?> <?php echo lang('country'); ?></a><br>
+                   data-tag="{{{user_country}}}"><?php echo trans('user'); ?><?php echo lang('country'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_phone}}}"><?php echo trans('user'); ?> <?php echo lang('phone'); ?></a><br>
+                   data-tag="{{{user_phone}}}"><?php echo trans('user'); ?><?php echo lang('phone'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_fax}}}"><?php echo trans('user'); ?> <?php echo lang('fax'); ?></a><br>
+                   data-tag="{{{user_fax}}}"><?php echo trans('user'); ?><?php echo lang('fax'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_mobile}}}"><?php echo trans('user'); ?> <?php echo lang('mobile'); ?></a><br>
+                   data-tag="{{{user_mobile}}}"><?php echo trans('user'); ?><?php echo lang('mobile'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_email}}}"><?php echo trans('user'); ?> <?php echo lang('email'); ?></a><br>
+                   data-tag="{{{user_email}}}"><?php echo trans('user'); ?><?php echo lang('email'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_web}}}"><?php echo trans('user'); ?> <?php echo lang('web_address'); ?></a><br>
+                   data-tag="{{{user_web}}}"><?php echo trans('user'); ?><?php echo lang('web_address'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_subscribernumber}}}"><?php echo trans('user'); ?> <?php echo lang('user_subscriber_number'); ?></a><br>
+                   data-tag="{{{user_subscribernumber}}}"><?php echo trans('user'); ?><?php echo lang('user_subscriber_number'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_iban}}}"><?php echo trans('user'); ?> <?php echo lang('user_iban'); ?></a><br>
+                   data-tag="{{{user_iban}}}"><?php echo trans('user'); ?><?php echo lang('user_iban'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_gln}}}"><?php echo trans('user'); ?> <?php echo lang('gln'); ?></a><br>
+                   data-tag="{{{user_gln}}}"><?php echo trans('user'); ?><?php echo lang('gln'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{user_rcc}}}"><?php echo trans('user'); ?> <?php echo lang('sumex_rcc'); ?></a><br>
+                   data-tag="{{{user_rcc}}}"><?php echo trans('user'); ?><?php echo lang('sumex_rcc'); ?></a><br>
                 <?php foreach ($custom_fields['ip_user_custom'] as $custom) { ?>
                     <a href="#" class="text-tag"
                        data-tag="{{{<?php echo $custom->custom_field_column; ?>}}}"><?php echo $custom->custom_field_label; ?></a>
@@ -255,23 +257,23 @@
             <div class="col-xs-6 col-sm-4 col-md-3 col-lg-2 hidden-invoice">
                 <strong><?php echo trans('invoices'); ?></strong><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{invoice_guest_url}}}"><?php echo trans('invoice'); ?> <?php echo lang('guest_url'); ?></a><br>
+                   data-tag="{{{invoice_guest_url}}}"><?php echo trans('invoice'); ?><?php echo lang('guest_url'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{invoice_number}}}"><?php echo trans('invoice'); ?> <?php echo lang('id'); ?></a><br>
+                   data-tag="{{{invoice_number}}}"><?php echo trans('invoice'); ?><?php echo lang('id'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{invoice_date_due}}}"><?php echo trans('invoice'); ?> <?php echo lang('due_date'); ?></a><br>
+                   data-tag="{{{invoice_date_due}}}"><?php echo trans('invoice'); ?><?php echo lang('due_date'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{invoice_date_created}}}"><?php echo trans('invoice'); ?> <?php echo lang('created'); ?></a><br>
+                   data-tag="{{{invoice_date_created}}}"><?php echo trans('invoice'); ?><?php echo lang('created'); ?></a><br>
                 <a href="#" class="text-tag"
                    data-tag="{{{invoice_terms}}}"><?php echo trans('invoice_terms'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{invoice_total}}}"><?php echo trans('invoice'); ?> <?php echo lang('total'); ?></a><br>
+                   data-tag="{{{invoice_total}}}"><?php echo trans('invoice'); ?><?php echo lang('total'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{invoice_paid}}}"><?php echo trans('invoice'); ?> <?php echo lang('total_paid'); ?></a><br>
+                   data-tag="{{{invoice_paid}}}"><?php echo trans('invoice'); ?><?php echo lang('total_paid'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{invoice_balance}}}"><?php echo trans('invoice'); ?> <?php echo lang('balance'); ?></a><br>
+                   data-tag="{{{invoice_balance}}}"><?php echo trans('invoice'); ?><?php echo lang('balance'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{invoice_status}}}"><?php echo trans('invoice'); ?> <?php echo lang('status'); ?></a><br>
+                   data-tag="{{{invoice_status}}}"><?php echo trans('invoice'); ?><?php echo lang('status'); ?></a><br>
                 <?php foreach ($custom_fields['ip_invoice_custom'] as $custom) { ?>
                     <a href="#" class="text-tag"
                        data-tag="{{{<?php echo $custom->custom_field_column; ?>}}}"><?php echo $custom->custom_field_label; ?></a>
@@ -288,9 +290,9 @@
                 <a href="#" class="text-tag"
                    data-tag="{{{sumex_observations}}}"><?php echo trans('sumex_observations'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{sumex_treatmentstart}}}"><?php echo trans('treatment').' '.trans('start'); ?></a><br>
+                   data-tag="{{{sumex_treatmentstart}}}"><?php echo trans('treatment') . ' ' . trans('start'); ?></a><br>
                 <a href="#" class="text-tag"
-                   data-tag="{{{sumex_treatmentend}}}"><?php echo trans('treatment').' '.trans('end'); ?></a><br>
+                   data-tag="{{{sumex_treatmentend}}}"><?php echo trans('treatment') . ' ' . trans('end'); ?></a><br>
                 <a href="#" class="text-tag"
                    data-tag="{{{sumex_casedate}}}"><?php echo trans('case_date'); ?></a><br>
                 <a href="#" class="text-tag"

+ 14 - 14
application/modules/guest/controllers/Payment_handler.php

@@ -40,14 +40,14 @@ class Payment_Handler extends Base_Controller
             $invoice = $invoice->row();
 
             // Load the merchant driver
-            $this->merchant->load($this->mdl_settings->setting('merchant_driver'));
+            $this->merchant->load(get_setting('merchant_driver'));
 
             // Pass the required settings
             $settings = array(
-                'username' => $this->mdl_settings->setting('merchant_username'),
-                'password' => $this->encrypt->decode($this->mdl_settings->setting('merchant_password')),
-                'signature' => $this->mdl_settings->setting('merchant_signature'),
-                'test_mode' => ($this->mdl_settings->setting('merchant_test_mode')) ? true : false
+                'username' => get_setting('merchant_username'),
+                'password' => $this->encrypt->decode(get_setting('merchant_password')),
+                'signature' => get_setting('merchant_signature'),
+                'test_mode' => (get_setting('merchant_test_mode')) ? true : false
             );
 
             // Init the driver
@@ -57,7 +57,7 @@ class Payment_Handler extends Base_Controller
             $params = array(
                 'description' => trans('invoice') . ' ' . $invoice->invoice_number,
                 'amount' => $invoice->invoice_balance,
-                'currency' => $this->mdl_settings->setting('merchant_currency_code'),
+                'currency' => get_setting('merchant_currency_code'),
                 'return_url' => site_url('guest/payment_handler/payment_return/' . $invoice_url_key . '/r'),
                 'cancel_url' => site_url('guest/payment_handler/payment_cancel/' . $invoice_url_key . '/c'),
             );
@@ -98,7 +98,7 @@ class Payment_Handler extends Base_Controller
                     'invoice_id' => $invoice->invoice_id,
                     'payment_date' => date('Y-m-d'),
                     'payment_amount' => $invoice->invoice_balance,
-                    'payment_method_id' => ($this->mdl_settings->setting('online_payment_method')) ? $this->mdl_settings->setting('online_payment_method') : 0
+                    'payment_method_id' => (get_setting('online_payment_method')) ? get_setting('online_payment_method') : 0
                 );
 
                 $this->mdl_payments->save(null, $db_array);
@@ -125,14 +125,14 @@ class Payment_Handler extends Base_Controller
             $invoice = $invoice->row();
 
             // Load the merchant driver
-            $this->merchant->load($this->mdl_settings->setting('merchant_driver'));
+            $this->merchant->load(get_setting('merchant_driver'));
 
             // Pass the required settings
             $settings = array(
-                'username' => $this->mdl_settings->setting('merchant_username'),
-                'password' => $this->encrypt->decode($this->mdl_settings->setting('merchant_password')),
-                'signature' => $this->mdl_settings->setting('merchant_signature'),
-                'test_mode' => ($this->mdl_settings->setting('merchant_test_mode')) ? true : false
+                'username' => get_setting('merchant_username'),
+                'password' => $this->encrypt->decode(get_setting('merchant_password')),
+                'signature' => get_setting('merchant_signature'),
+                'test_mode' => (get_setting('merchant_test_mode')) ? true : false
             );
 
             // Init the driver
@@ -142,7 +142,7 @@ class Payment_Handler extends Base_Controller
             $params = array(
                 'description' => trans('invoice') . ' ' . $invoice->invoice_number,
                 'amount' => $invoice->invoice_balance,
-                'currency' => $this->mdl_settings->setting('merchant_currency_code')
+                'currency' => get_setting('merchant_currency_code')
             );
 
             // Get the response
@@ -155,7 +155,7 @@ class Payment_Handler extends Base_Controller
             $db_array = array(
                 'invoice_id' => $invoice->invoice_id,
                 'merchant_response_date' => date('Y-m-d'),
-                'merchant_response_driver' => $this->mdl_settings->setting('merchant_driver'),
+                'merchant_response_driver' => get_setting('merchant_driver'),
                 'merchant_response' => $merchant_response,
                 'merchant_response_reference' => ($response->reference()) ? $response->reference() : ''
             );

+ 10 - 11
application/modules/guest/controllers/View.php

@@ -55,10 +55,9 @@ class View extends Base_Controller
                 'attachments' => $attachments,
             );
 
-            $this->load->view('invoice_templates/public/' . $this->mdl_settings->setting('public_invoice_template') . '.php', $data);
-        }
-        else{
-          echo '<h2>'.trans('invoice_not_found').'</h2>';
+            $this->load->view('invoice_templates/public/' . get_setting('public_invoice_template') . '.php', $data);
+        } else {
+            echo '<h2>' . trans('invoice_not_found') . '</h2>';
         }
     }
 
@@ -77,7 +76,7 @@ class View extends Base_Controller
             $invoice = $invoice->row();
 
             if (!$invoice_template) {
-                $invoice_template = $this->mdl_settings->setting('pdf_invoice_template');
+                $invoice_template = get_setting('pdf_invoice_template');
             }
 
             $this->load->helper('pdf');
@@ -100,13 +99,13 @@ class View extends Base_Controller
         if ($invoice->num_rows() == 1) {
             $invoice = $invoice->row();
 
-            if($invoice->sumex_id == NULL){
-              show_404();
-              return;
+            if ($invoice->sumex_id == NULL) {
+                show_404();
+                return;
             }
 
             if (!$invoice_template) {
-                $invoice_template = $this->mdl_settings->setting('pdf_invoice_template');
+                $invoice_template = get_setting('pdf_invoice_template');
             }
 
             $this->load->helper('pdf');
@@ -165,7 +164,7 @@ class View extends Base_Controller
                 'attachments' => $attachments,
             );
 
-            $this->load->view('quote_templates/public/' . $this->mdl_settings->setting('public_quote_template') . '.php', $data);
+            $this->load->view('quote_templates/public/' . get_setting('public_quote_template') . '.php', $data);
         }
     }
 
@@ -204,7 +203,7 @@ class View extends Base_Controller
             $quote = $quote->row();
 
             if (!$quote_template) {
-                $quote_template = $this->mdl_settings->setting('pdf_quote_template');
+                $quote_template = get_setting('pdf_quote_template');
             }
 
             $this->load->helper('pdf');

+ 2 - 2
application/modules/guest/views/index.php

@@ -63,7 +63,7 @@
                                         <?php echo trans('pdf'); ?>
                                     </a>
 
-                                    <?php if ($this->mdl_settings->setting('merchant_enabled') == 1 and $invoice->invoice_balance > 0) { ?>
+                                    <?php if (get_setting('merchant_enabled') == 1 and $invoice->invoice_balance > 0) { ?>
                                         <a href="<?php echo site_url('guest/payment_handler/make_payment/' . $invoice->invoice_url_key); ?>"
                                            class="btn btn-sm btn-success">
                                             <i class="glyphicon glyphicon-ok"></i>
@@ -225,7 +225,7 @@
                                     <?php echo trans('pdf'); ?>
                                 </a>
 
-                                <?php if ($this->mdl_settings->setting('merchant_enabled') == 1 and $invoice->invoice_balance > 0) { ?>
+                                <?php if (get_setting('merchant_enabled') == 1 and $invoice->invoice_balance > 0) { ?>
                                     <a href="<?php echo site_url('guest/payment_handler/make_payment/' . $invoice->invoice_url_key); ?>"
                                        class="btn btn-success btn-sm">
                                         <i class="glyphicon glyphicon-ok"></i>

+ 1 - 1
application/modules/guest/views/invoices_index.php

@@ -75,7 +75,7 @@
                                 <?php echo trans('pdf'); ?>
                             </a>
 
-                            <?php if ($this->mdl_settings->setting('merchant_enabled') == 1 and $invoice->invoice_balance > 0) { ?>
+                            <?php if (get_setting('merchant_enabled') == 1 and $invoice->invoice_balance > 0) { ?>
                             <a href="<?php echo site_url('guest/payment_handler/make_payment/' . $invoice->invoice_url_key); ?>"
                                class="btn btn-success btn-sm">
                                 <i class="glyphicon glyphicon-ok"></i>

+ 15 - 15
application/modules/invoices/controllers/Ajax.php

@@ -38,8 +38,8 @@ class Ajax extends Admin_Controller
                     $item->item_price = ($item->item_quantity ? standardize_amount($item->item_price) : floatval(0));
                     $item->item_discount_amount = ($item->item_discount_amount) ? standardize_amount($item->item_discount_amount) : null;
                     $item->item_product_id = ($item->item_product_id ? $item->item_product_id : null);
-                    if(property_exists($item, 'item_date')){
-                      $item->item_date = ($item->item_date ? date_to_mysql($item->item_date) : null);
+                    if (property_exists($item, 'item_date')) {
+                        $item->item_date = ($item->item_date ? date_to_mysql($item->item_date) : null);
                     }
                     $item->item_product_unit_id = ($item->item_product_unit_id ? $item->item_product_unit_id : null);
                     $item->item_product_unit = $this->mdl_units->get_name($item->item_product_unit_id, $item->item_quantity);
@@ -108,25 +108,25 @@ class Ajax extends Admin_Controller
 
             // check if status changed to sent, the feature is enabled and settings is set to sent
             if ($this->config->item('disable_read_only') === false) {
-                if ($invoice_status == $this->mdl_settings->setting('read_only_toggle')) {
+                if ($invoice_status == get_setting('read_only_toggle')) {
                     $db_array['is_read_only'] = 1;
                 }
             }
 
             $this->mdl_invoices->save($invoice_id, $db_array);
             $sumexInvoice = $this->mdl_invoices->where('sumex_invoice', $invoice_id)->get()->num_rows();
-            if($sumexInvoice >= 1){
-              $sumex_array = array(
-                  'sumex_invoice' => $invoice_id,
-                  'sumex_reason' => $this->input->post('invoice_sumex_reason'),
-                  'sumex_diagnosis' => $this->input->post('invoice_sumex_diagnosis'),
-                  'sumex_treatmentstart' => date_to_mysql($this->input->post('invoice_sumex_treatmentstart')),
-                  'sumex_treatmentend' => date_to_mysql($this->input->post('invoice_sumex_treatmentend')),
-                  'sumex_casedate' => date_to_mysql($this->input->post('invoice_sumex_casedate')),
-                  'sumex_casenumber' => $this->input->post('invoice_sumex_casenumber'),
-                  'sumex_observations' => $this->input->post('invoice_sumex_observations')
-              );
-              $this->mdl_invoice_sumex->save($invoice_id, $sumex_array);
+            if ($sumexInvoice >= 1) {
+                $sumex_array = array(
+                    'sumex_invoice' => $invoice_id,
+                    'sumex_reason' => $this->input->post('invoice_sumex_reason'),
+                    'sumex_diagnosis' => $this->input->post('invoice_sumex_diagnosis'),
+                    'sumex_treatmentstart' => date_to_mysql($this->input->post('invoice_sumex_treatmentstart')),
+                    'sumex_treatmentend' => date_to_mysql($this->input->post('invoice_sumex_treatmentend')),
+                    'sumex_casedate' => date_to_mysql($this->input->post('invoice_sumex_casedate')),
+                    'sumex_casenumber' => $this->input->post('invoice_sumex_casenumber'),
+                    'sumex_observations' => $this->input->post('invoice_sumex_observations')
+                );
+                $this->mdl_invoice_sumex->save($invoice_id, $sumex_array);
             }
 
             // Recalculate for discounts

+ 1 - 1
application/modules/invoices/controllers/Cron.php

@@ -21,7 +21,7 @@ class Cron extends Base_Controller
     public function recur($cron_key = null)
     {
         // Check the provided cron key
-        if ($cron_key != $this->mdl_settings->setting('cron_key')) {
+        if ($cron_key != get_setting('cron_key')) {
             if (IP_DEBUG) log_message('error', 'Wrong cron key provided!');
             exit('Wrong cron key!');
         }

+ 32 - 31
application/modules/invoices/controllers/Invoices.php

@@ -193,34 +193,33 @@ class Invoices extends Admin_Controller
                 'custom_fields' => $custom_fields,
                 'custom_values' => $custom_values,
                 'custom_js_vars' => array(
-                    'currency_symbol' => $this->mdl_settings->setting('currency_symbol'),
-                    'currency_symbol_placement' => $this->mdl_settings->setting('currency_symbol_placement'),
-                    'decimal_point' => $this->mdl_settings->setting('decimal_point')
+                    'currency_symbol' => get_setting('currency_symbol'),
+                    'currency_symbol_placement' => get_setting('currency_symbol_placement'),
+                    'decimal_point' => get_setting('decimal_point')
                 ),
                 'invoice_statuses' => $this->mdl_invoices->statuses()
             )
         );
 
-        if($invoice->sumex_id != null){
-          $this->layout->buffer(
-              array(
-                  array('modal_delete_invoice', 'invoices/modal_delete_invoice'),
-                  array('modal_add_invoice_tax', 'invoices/modal_add_invoice_tax'),
-                  array('modal_add_payment', 'payments/modal_add_payment'),
-                  array('content', 'invoices/view_sumex')
-              )
-          );
+        if ($invoice->sumex_id != null) {
+            $this->layout->buffer(
+                array(
+                    array('modal_delete_invoice', 'invoices/modal_delete_invoice'),
+                    array('modal_add_invoice_tax', 'invoices/modal_add_invoice_tax'),
+                    array('modal_add_payment', 'payments/modal_add_payment'),
+                    array('content', 'invoices/view_sumex')
+                )
+            );
+        } else {
+            $this->layout->buffer(
+                array(
+                    array('modal_delete_invoice', 'invoices/modal_delete_invoice'),
+                    array('modal_add_invoice_tax', 'invoices/modal_add_invoice_tax'),
+                    array('modal_add_payment', 'payments/modal_add_payment'),
+                    array('content', 'invoices/view')
+                )
+            );
         }
-        else {
-          $this->layout->buffer(
-              array(
-                  array('modal_delete_invoice', 'invoices/modal_delete_invoice'),
-                  array('modal_add_invoice_tax', 'invoices/modal_add_invoice_tax'),
-                  array('modal_add_payment', 'payments/modal_add_payment'),
-                  array('content', 'invoices/view')
-              )
-          );
-       }
 
         $this->layout->render();
     }
@@ -279,7 +278,7 @@ class Invoices extends Admin_Controller
     {
         $this->load->helper('pdf');
 
-        if ($this->mdl_settings->setting('mark_invoices_sent_pdf') == 1) {
+        if (get_setting('mark_invoices_sent_pdf') == 1) {
             $this->mdl_invoices->mark_sent($invoice_id);
         }
 
@@ -301,23 +300,25 @@ class Invoices extends Admin_Controller
         $this->output->set_output($this->zugferdxml->xml());
     }
 
-    public function generate_sumex_pdf($invoice_id){
+    public function generate_sumex_pdf($invoice_id)
+    {
         $this->load->helper('pdf');
 
         generate_invoice_sumex($invoice_id);
     }
 
-    public function generate_sumex_copy($invoice_id){
+    public function generate_sumex_copy($invoice_id)
+    {
 
 
         $this->load->model('invoices/mdl_items');
         $this->load->library('Sumex', array(
-          'invoice' => $this->mdl_invoices->get_by_id($invoice_id),
-          'items' => $this->mdl_items->where('invoice_id', $invoice_id)->get()->result(),
-          'options' => array(
-            'copy' => "1",
-            'storno' => "0"
-          )
+            'invoice' => $this->mdl_invoices->get_by_id($invoice_id),
+            'items' => $this->mdl_items->where('invoice_id', $invoice_id)->get()->result(),
+            'options' => array(
+                'copy' => "1",
+                'storno' => "0"
+            )
         ));
 
         $this->output->set_content_type('application/pdf');

+ 1 - 1
application/modules/invoices/models/Mdl_invoice_amounts.php

@@ -110,7 +110,7 @@ class Mdl_Invoice_Amounts extends CI_Model
                 // Set to read-only if applicable
                 if (
                     $this->config->item('disable_read_only') == false
-                    && $invoice->invoice_status_id == $this->mdl_settings->setting('read_only_toggle')
+                    && $invoice->invoice_status_id == get_setting('read_only_toggle')
                 ) {
                     $this->db->where('invoice_id', $invoice_id);
                     $this->db->set('is_read_only', 1);

+ 8 - 8
application/modules/invoices/models/Mdl_invoices.php

@@ -195,11 +195,11 @@ class Mdl_Invoices extends Response_Model
 
         if ($include_invoice_tax_rates) {
             // Create the default invoice tax record if applicable
-            if ($this->mdl_settings->setting('default_invoice_tax_rate')) {
+            if (get_setting('default_invoice_tax_rate')) {
                 $db_array = array(
                     'invoice_id' => $invoice_id,
-                    'tax_rate_id' => $this->mdl_settings->setting('default_invoice_tax_rate'),
-                    'include_item_tax' => $this->mdl_settings->setting('default_include_item_tax', 0),
+                    'tax_rate_id' => get_setting('default_invoice_tax_rate'),
+                    'include_item_tax' => get_setting('default_include_item_tax', 0),
                     'invoice_tax_rate_amount' => 0
                 );
 
@@ -331,13 +331,13 @@ class Mdl_Invoices extends Response_Model
 
         $db_array['invoice_date_created'] = date_to_mysql($db_array['invoice_date_created']);
         $db_array['invoice_date_due'] = $this->get_date_due($db_array['invoice_date_created']);
-        $db_array['invoice_terms'] = $this->mdl_settings->setting('default_invoice_terms');
+        $db_array['invoice_terms'] = get_setting('default_invoice_terms');
 
         if (!isset($db_array['invoice_status_id'])) {
             $db_array['invoice_status_id'] = 1;
         }
 
-        $generate_invoice_number = $this->mdl_settings->setting('generate_invoice_number_for_draft');
+        $generate_invoice_number = get_setting('generate_invoice_number_for_draft');
 
         if ($db_array['invoice_status_id'] === 1 && $generate_invoice_number == 1) {
             $db_array['invoice_number'] = $this->get_invoice_number($db_array['invoice_group_id']);
@@ -363,7 +363,7 @@ class Mdl_Invoices extends Response_Model
     public function get_date_due($invoice_date_created)
     {
         $invoice_date_due = new DateTime($invoice_date_created);
-        $invoice_date_due->add(new DateInterval('P' . $this->mdl_settings->setting('invoices_due_after') . 'D'));
+        $invoice_date_due->add(new DateInterval('P' . get_setting('invoices_due_after') . 'D'));
         return $invoice_date_due->format('Y-m-d');
     }
 
@@ -503,7 +503,7 @@ class Mdl_Invoices extends Response_Model
             }
 
             // Set the invoice to read-only if feature is not disabled and setting is view
-            if ($this->config->item('disable_read_only') == false && $this->mdl_settings->setting('read_only_toggle') == 3) {
+            if ($this->config->item('disable_read_only') == false && get_setting('read_only_toggle') == 3) {
                 $this->db->where('invoice_id', $invoice_id);
                 $this->db->set('is_read_only', 1);
                 $this->db->update('ip_invoices');
@@ -529,7 +529,7 @@ class Mdl_Invoices extends Response_Model
             }
 
             // Set the invoice to read-only if feature is not disabled and setting is sent
-            if ($this->config->item('disable_read_only') == false && $this->mdl_settings->setting('read_only_toggle') == 2) {
+            if ($this->config->item('disable_read_only') == false && get_setting('read_only_toggle') == 2) {
                 $this->db->where('invoice_id', $invoice_id);
                 $this->db->set('is_read_only', 1);
                 $this->db->update('ip_invoices');

+ 10 - 10
application/modules/invoices/models/Mdl_invoices_recurring.php

@@ -18,16 +18,16 @@ class Mdl_Invoices_Recurring extends Response_Model
     public $table = 'ip_invoices_recurring';
     public $primary_key = 'ip_invoices_recurring.invoice_recurring_id';
     public $recur_frequencies = array(
-        '7D'    => 'calendar_week',
-        '14D'   => 'calendar_week_2',
-        '21D'   => 'calendar_week_3',
-        '28D'   => 'calendar_week_4',
-        '1M'    => 'calendar_month',
-        '2M'    => 'calendar_month_2',
-        '3M'    => 'quarter',
-        '4M'    => 'calendar_month_4',
-        '6M'    => 'six_months',
-        '1Y'    => 'year',
+        '7D' => 'calendar_week',
+        '14D' => 'calendar_week_2',
+        '21D' => 'calendar_week_3',
+        '28D' => 'calendar_week_4',
+        '1M' => 'calendar_month',
+        '2M' => 'calendar_month_2',
+        '3M' => 'quarter',
+        '4M' => 'calendar_month_4',
+        '6M' => 'six_months',
+        '1Y' => 'year',
     );
 
     public function default_select()

+ 2 - 1
application/modules/invoices/views/archive.php

@@ -7,7 +7,8 @@
             <div class="input-group">
                 <input name="invoice_number" id="invoice_number" type="text" class="form-control input-sm">
                 <span class="input-group-btn">
-                    <button class="btn btn-default btn-sm" type="submit"><?php echo trans('filter_invoices'); ?></button>
+                    <button class="btn btn-default btn-sm"
+                            type="submit"><?php echo trans('filter_invoices'); ?></button>
                 </span>
             </div>
         </form>

+ 5 - 7
application/modules/invoices/views/modal_change_client.php

@@ -14,7 +14,7 @@
                 placeholder: "<?php echo htmlentities(trans('client')); ?>",
                 allowClear: true
             });
-            $("#client_name").focus();
+            $("#client_id").focus();
         });
 
         // Creates the invoice
@@ -50,18 +50,16 @@
     <form class="modal-content">
         <div class="modal-header">
             <a data-dismiss="modal" class="close"><i class="fa fa-close"></i></a>
-
             <h3><?php echo trans('change_client'); ?></h3>
         </div>
         <div class="modal-body">
             <div class="form-group">
-                <select name="client_name" id="client_id" class="form-control" autofocus="autofocus">
-                    <option></option>
+                <select name="client_id" id="client_id" class="form-control" autofocus="autofocus">
                     <?php foreach ($clients as $client) { ?>
                         <option value="<?php echo $client->client_id; ?>"
-                                <?php if ($client_id == $client->client_id) { ?>selected="selected"<?php } ?>
-                        ><?php echo format_client($client); ?></option>
-
+                                <?php if ($client_id == $client->client_id) { ?>selected="selected"<?php } ?>>
+                            <?php echo format_client($client); ?>
+                        </option>
                     <?php } ?>
                 </select>
             </div>

+ 5 - 7
application/modules/invoices/views/modal_copy_invoice.php

@@ -79,11 +79,8 @@
             <div class="form-group">
                 <label for="invoice_password"><?php echo trans('invoice_password'); ?></label>
                 <input type="text" name="invoice_password" id="invoice_password" class="form-control"
-                       value="<?php if ($this->mdl_settings->setting('invoice_pre_password') == '') {
-                           echo '';
-                       } else {
-                           echo $this->mdl_settings->setting('invoice_pre_password');
-                       } ?>" style="margin: 0 auto;" autocomplete="off">
+                       value="<?php echo get_setting('invoice_pre_password') == '' ?: get_setting('invoice_pre_password') ?>"
+                       style="margin: 0 auto;" autocomplete="off">
             </div>
 
             <div class="form-group">
@@ -91,10 +88,11 @@
 
                 <div>
                     <select name="invoice_group_id" id="invoice_group_id" class="form-control simple-select">
-                        <option value=""></option>
                         <?php foreach ($invoice_groups as $invoice_group) { ?>
                             <option value="<?php echo $invoice_group->invoice_group_id; ?>"
-                                    <?php if ($this->mdl_settings->setting('default_invoice_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>><?php echo $invoice_group->invoice_group_name; ?></option>
+                                    <?php if (get_setting('default_invoice_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>>
+                                <?php echo $invoice_group->invoice_group_name; ?>
+                            </option>
                         <?php } ?>
                     </select>
                 </div>

+ 3 - 7
application/modules/invoices/views/modal_create_credit.php

@@ -56,18 +56,14 @@
             <div class="form-group">
                 <label for="invoice_password"><?php echo trans('invoice_password'); ?></label>
                 <input type="text" name="invoice_password" id="invoice_password" class="form-control"
-                       value="<?php if ($this->mdl_settings->setting('invoice_pre_password') == '') {
-                           echo '';
-                       } else {
-                           echo $this->mdl_settings->setting('invoice_pre_password');
-                       } ?>" style="margin: 0 auto;" autocomplete="off">
+                       value="<?php echo get_setting('invoice_pre_password') == '' ?: get_setting('invoice_pre_password'); ?>"
+                       style="margin: 0 auto;" autocomplete="off">
             </div>
 
             <select name="invoice_group_id" id="invoice_group_id" class="hidden">
-                <option value=""></option>
                 <?php foreach ($invoice_groups as $invoice_group) { ?>
                     <option value="<?php echo $invoice_group->invoice_group_id; ?>"
-                        <?php if ($this->mdl_settings->setting('default_invoice_group') == $invoice_group->invoice_group_id) {
+                        <?php if (get_setting('default_invoice_group') == $invoice_group->invoice_group_id) {
                             echo 'selected="selected"';
                             $credit_invoice_group = $invoice_group->invoice_group_name;
                         } ?>>

+ 6 - 5
application/modules/invoices/views/modal_create_invoice.php

@@ -55,7 +55,7 @@
         <div class="modal-body">
 
             <input class="hidden" id="payment_method_id"
-                   value="<?php echo $this->mdl_settings->setting('invoice_default_payment_method'); ?>">
+                   value="<?php echo get_setting('invoice_default_payment_method'); ?>">
 
             <div class="form-group">
                 <label for="client_id"><?php echo trans('client'); ?></label>
@@ -86,10 +86,10 @@
             <div class="form-group">
                 <label for="invoice_password"><?php echo trans('invoice_password'); ?></label>
                 <input type="text" name="invoice_password" id="invoice_password" class="form-control"
-                       value="<?php if ($this->mdl_settings->setting('invoice_pre_password') == '') {
+                       value="<?php if (get_setting('invoice_pre_password') == '') {
                            echo '';
                        } else {
-                           echo $this->mdl_settings->setting('invoice_pre_password');
+                           echo get_setting('invoice_pre_password');
                        } ?>" style="margin: 0 auto;" autocomplete="off">
             </div>
 
@@ -98,10 +98,11 @@
 
                 <div class="controls">
                     <select name="invoice_group_id" id="invoice_group_id" class="form-control simple-select">
-                        <option value=""></option>
                         <?php foreach ($invoice_groups as $invoice_group) { ?>
                             <option value="<?php echo $invoice_group->invoice_group_id; ?>"
-                                    <?php if ($this->mdl_settings->setting('default_invoice_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>><?php echo $invoice_group->invoice_group_name; ?></option>
+                                    <?php if (get_setting('default_invoice_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>>
+                                <?php echo $invoice_group->invoice_group_name; ?>
+                            </option>
                         <?php } ?>
                     </select>
                 </div>

+ 4 - 4
application/modules/invoices/views/partial_item_table.php

@@ -47,7 +47,7 @@
                     <span class="input-group-addon"><?php echo trans('item_discount'); ?></span>
                     <input type="text" name="item_discount_amount" class="input-sm form-control amount"
                            value="" data-toggle="tooltip" data-placement="bottom"
-                           title="<?php echo $this->mdl_settings->setting('currency_symbol') . ' ' . trans('per_item'); ?>">
+                           title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
                 </div>
             </td>
             <td class="td-amount">
@@ -57,7 +57,7 @@
                         <option value="0"><?php echo trans('none'); ?></option>
                         <?php foreach ($tax_rates as $tax_rate) { ?>
                             <option value="<?php echo $tax_rate->tax_rate_id; ?>"
-                                    <?php if ($this->mdl_settings->setting('default_item_tax_rate') == $tax_rate->tax_rate_id) { ?>selected="selected"<?php } ?>>
+                                    <?php if (get_setting('default_item_tax_rate') == $tax_rate->tax_rate_id) { ?>selected="selected"<?php } ?>>
                                 <?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
                             </option>
                         <?php } ?>
@@ -167,7 +167,7 @@
                         <input type="text" name="item_discount_amount" class="input-sm form-control amount"
                                value="<?php echo format_amount($item->item_discount_amount); ?>"
                                data-toggle="tooltip" data-placement="bottom"
-                               title="<?php echo $this->mdl_settings->setting('currency_symbol') . ' ' . trans('per_item'); ?>"
+                               title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>"
                             <?php if ($invoice->is_read_only == 1) {
                                 echo 'disabled="disabled"';
                             } ?>>
@@ -331,7 +331,7 @@
                                 } ?>>
 
                             <div
-                                    class="input-group-addon"><?php echo $this->mdl_settings->setting('currency_symbol'); ?></div>
+                                    class="input-group-addon"><?php echo get_setting('currency_symbol'); ?></div>
                         </div>
                     </div>
                     <div class="discount-field">

+ 2 - 1
application/modules/invoices/views/view.php

@@ -428,7 +428,8 @@ if ($this->config->item('disable_read_only') == true) {
 
                                 <div class="invoice-properties">
                                     <label><?php echo trans('payment_method'); ?></label>
-                                    <select name="payment_method" id="payment_method" class="form-control input-sm simple-select"
+                                    <select name="payment_method" id="payment_method"
+                                            class="form-control input-sm simple-select"
                                         <?php if ($invoice->is_read_only == 1 && $invoice->invoice_status_id == 4) {
                                             echo 'disabled="disabled"';
                                         } ?>>

+ 2 - 1
application/modules/invoices/views/view_sumex.php

@@ -441,7 +441,8 @@ if ($this->config->item('disable_read_only') == true) {
                                         }
                                         ?>
                                     </label>
-                                    <select name="invoice_status_id" id="invoice_status_id" class="form-control simple-select"
+                                    <select name="invoice_status_id" id="invoice_status_id"
+                                            class="form-control simple-select"
                                         <?php if ($invoice->is_read_only == 1 && $invoice->invoice_status_id == 4) {
                                             echo 'disabled="disabled"';
                                         } ?>>

+ 8 - 6
application/modules/layout/views/includes/head.php

@@ -1,7 +1,7 @@
 <title>
     <?php
-    if ($this->mdl_settings->setting('custom_title') != '') {
-        echo $this->mdl_settings->setting('custom_title');
+    if (get_setting('custom_title') != '') {
+        echo get_setting('custom_title');
     } else {
         echo 'InvoicePlane';
     } ?>
@@ -15,11 +15,13 @@
 
 <link rel="icon" type="image/png" href="<?php echo base_url(); ?>assets/core/img/favicon.png">
 
-<link rel="stylesheet" href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css">
+<link rel="stylesheet"
+      href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css">
 <link rel="stylesheet" href="<?php echo base_url(); ?>assets/core/css/custom.css">
 
-<?php if ($this->mdl_settings->setting('monospace_amounts') == 1) { ?>
-    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/monospace.css">
+<?php if (get_setting('monospace_amounts') == 1) { ?>
+    <link rel="stylesheet"
+          href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/monospace.css">
 <?php } ?>
 
 <!--[if lt IE 9]>
@@ -44,7 +46,7 @@
                 autoclose: true,
                 format: '<?php echo date_format_datepicker(); ?>',
                 language: '<?php echo trans('cldr'); ?>',
-                weekStart: '<?php echo $this->mdl_settings->setting('first_day_of_week'); ?>',
+                weekStart: '<?php echo get_setting('first_day_of_week'); ?>',
                 todayBtn: "linked"
             });
         });

+ 14 - 14
application/modules/layout/views/includes/navbar.php

@@ -16,8 +16,8 @@
                 <li class="dropdown">
                     <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                         <i class="fa fa-caret-down"></i> &nbsp;<span
-                            class="hidden-sm"><?php echo trans('clients'); ?></span><i
-                            class="visible-sm-inline fa fa-users"></i>
+                                class="hidden-sm"><?php echo trans('clients'); ?></span><i
+                                class="visible-sm-inline fa fa-users"></i>
                     </a>
                     <ul class="dropdown-menu">
                         <li><?php echo anchor('clients/form', trans('add_client')); ?></li>
@@ -28,8 +28,8 @@
                 <li class="dropdown">
                     <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                         <i class="fa fa-caret-down"></i> &nbsp;<span
-                            class="hidden-sm"><?php echo trans('quotes'); ?></span><i
-                            class="visible-sm-inline fa fa-file"></i>
+                                class="hidden-sm"><?php echo trans('quotes'); ?></span><i
+                                class="visible-sm-inline fa fa-file"></i>
                     </a>
                     <ul class="dropdown-menu">
                         <li><a href="#" class="create-quote"><?php echo trans('create_quote'); ?></a></li>
@@ -40,8 +40,8 @@
                 <li class="dropdown">
                     <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                         <i class="fa fa-caret-down"></i> &nbsp;<span
-                            class="hidden-sm"><?php echo trans('invoices'); ?></span><i
-                            class="visible-sm-inline fa fa-file-text"></i>
+                                class="hidden-sm"><?php echo trans('invoices'); ?></span><i
+                                class="visible-sm-inline fa fa-file-text"></i>
                     </a>
                     <ul class="dropdown-menu">
                         <li><a href="#" class="create-invoice"><?php echo trans('create_invoice'); ?></a></li>
@@ -53,8 +53,8 @@
                 <li class="dropdown">
                     <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                         <i class="fa fa-caret-down"></i> &nbsp;<span
-                            class="hidden-sm"><?php echo trans('products'); ?></span><i
-                            class="visible-sm-inline fa fa-database"></i>
+                                class="hidden-sm"><?php echo trans('products'); ?></span><i
+                                class="visible-sm-inline fa fa-database"></i>
                     </a>
                     <ul class="dropdown-menu">
                         <li><?php echo anchor('products/form', trans('create_product')); ?></li>
@@ -67,8 +67,8 @@
                 <li class="dropdown">
                     <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                         <i class="fa fa-caret-down"></i> &nbsp;<span
-                            class="hidden-sm"><?php echo trans('payments'); ?></span><i
-                            class="visible-sm-inline fa fa-credit-card"></i>
+                                class="hidden-sm"><?php echo trans('payments'); ?></span><i
+                                class="visible-sm-inline fa fa-credit-card"></i>
                     </a>
                     <ul class="dropdown-menu">
                         <li><?php echo anchor('payments/form', trans('enter_payment')); ?></li>
@@ -79,8 +79,8 @@
                 <li class="dropdown <?php echo get_setting('projects_enabled') == 1 ?: 'hidden'; ?>">
                     <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                         <i class="fa fa-caret-down"></i> &nbsp;<span
-                            class="hidden-sm"><?php echo trans('tasks'); ?></span><i
-                            class="visible-sm-inline fa fa-check-square-o"></i>
+                                class="hidden-sm"><?php echo trans('tasks'); ?></span><i
+                                class="visible-sm-inline fa fa-check-square-o"></i>
                     </a>
                     <ul class="dropdown-menu">
                         <li><?php echo anchor('tasks/form', trans('create_task')); ?></li>
@@ -92,8 +92,8 @@
                 <li class="dropdown">
                     <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                         <i class="fa fa-caret-down"></i> &nbsp;<span
-                            class="hidden-sm"><?php echo trans('reports'); ?></span><i
-                            class="visible-sm-inline fa fa-bar-chart"></i>
+                                class="hidden-sm"><?php echo trans('reports'); ?></span><i
+                                class="visible-sm-inline fa fa-bar-chart"></i>
                     </a>
                     <ul class="dropdown-menu">
                         <li><?php echo anchor('reports/invoice_aging', trans('invoice_aging')); ?></li>

+ 8 - 6
application/modules/layout/views/layout_guest.php

@@ -12,8 +12,8 @@
 <head>
     <title>
         <?php
-        if ($this->mdl_settings->setting('custom_title') != '') {
-            echo $this->mdl_settings->setting('custom_title');
+        if (get_setting('custom_title') != '') {
+            echo get_setting('custom_title');
         } else {
             echo 'InvoicePlane';
         } ?>
@@ -26,11 +26,13 @@
 
     <link rel="icon" type="image/png" href="<?php echo base_url(); ?>assets/core/img/favicon.png">
 
-    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css">
+    <link rel="stylesheet"
+          href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css">
     <link rel="stylesheet" href="<?php echo base_url(); ?>assets/core/css/custom.css">
 
-    <?php if ($this->mdl_settings->setting('monospace_amounts') == 1) { ?>
-        <link rel="stylesheet" href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/monospace.css">
+    <?php if (get_setting('monospace_amounts') == 1) { ?>
+        <link rel="stylesheet"
+              href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/monospace.css">
     <?php } ?>
 
     <!--[if lt IE 9]>
@@ -73,7 +75,7 @@
     </div>
 </nav>
 
-<div class="sidebar hidden-xs <?php if ($this->mdl_settings->setting('disable_sidebar') == 1) {
+<div class="sidebar hidden-xs <?php if (get_setting('disable_sidebar') == 1) {
     echo 'hidden';
 } ?>">
     <ul>

+ 2 - 2
application/modules/mailer/controllers/Mailer.php

@@ -78,7 +78,7 @@ class Mailer extends Admin_Controller
         $this->load->model('upload/mdl_uploads');
         $this->load->model('email_templates/mdl_email_templates');
 
-        $email_template_id = $this->mdl_settings->setting('email_quote_template');
+        $email_template_id = get_setting('email_quote_template');
 
         if ($email_template_id) {
             $email_template = $this->mdl_email_templates->where('email_template_id', $email_template_id)->get();
@@ -87,7 +87,7 @@ class Mailer extends Admin_Controller
             $this->layout->set('email_template', '{}');
         }
 
-        $this->layout->set('selected_pdf_template', $this->mdl_settings->setting('pdf_quote_template'));
+        $this->layout->set('selected_pdf_template', get_setting('pdf_quote_template'));
         $this->layout->set('selected_email_template', $email_template_id);
         $this->layout->set('email_templates', $this->mdl_email_templates->where('email_template_type', 'quote')->get()->result());
         $this->layout->set('quote', $this->mdl_quotes->where('ip_quotes.quote_id', $quote_id)->get()->row());

+ 9 - 9
application/modules/mailer/helpers/phpmailer_helper.php

@@ -33,28 +33,28 @@ function phpmail_send($from, $to, $subject, $message, $attachment_path = null, $
     $mail->CharSet = 'UTF-8';
     $mail->isHTML();
 
-    switch ($CI->mdl_settings->setting('email_send_method')) {
+    switch (get_setting('email_send_method')) {
         case 'smtp':
             $mail->IsSMTP();
 
             // Set the basic properties
-            $mail->Host = $CI->mdl_settings->setting('smtp_server_address');
-            $mail->Port = $CI->mdl_settings->setting('smtp_port');
+            $mail->Host = get_setting('smtp_server_address');
+            $mail->Port = get_setting('smtp_port');
 
             // Is SMTP authentication required?
-            if ($CI->mdl_settings->setting('smtp_authentication')) {
+            if (get_setting('smtp_authentication')) {
                 $mail->SMTPAuth = true;
 
                 $encoded = $CI->mdl_settings->get('smtp_password');
                 $decoded = $CI->crypt->decode($encoded);
 
-                $mail->Username = $CI->mdl_settings->setting('smtp_username');
+                $mail->Username = get_setting('smtp_username');
                 $mail->Password = $decoded;
             }
 
             // Is a security method required?
-            if ($CI->mdl_settings->setting('smtp_security')) {
-                $mail->SMTPSecure = $CI->mdl_settings->setting('smtp_security');
+            if (get_setting('smtp_security')) {
+                $mail->SMTPSecure = get_setting('smtp_security');
             }
 
             break;
@@ -106,7 +106,7 @@ function phpmail_send($from, $to, $subject, $message, $attachment_path = null, $
         }
     }
 
-    if ($CI->mdl_settings->setting('bcc_mails_to_admin') == 1) {
+    if (get_setting('bcc_mails_to_admin') == 1) {
         // Get email address of admin account and push it to the array
         $CI->load->model('users/mdl_users');
         $CI->db->where('user_id', 1);
@@ -115,7 +115,7 @@ function phpmail_send($from, $to, $subject, $message, $attachment_path = null, $
     }
 
     // Add the attachment if supplied
-    if ($attachment_path && $CI->mdl_settings->setting('email_pdf_attachment')) {
+    if ($attachment_path && get_setting('email_pdf_attachment')) {
         $mail->addAttachment($attachment_path);
     }
     // Add the other attachments if supplied

+ 6 - 4
application/modules/mailer/views/invoice.php

@@ -23,7 +23,7 @@
 
 <form method="post" class="form-horizontal"
       action="<?php echo site_url('mailer/send_invoice/' . $invoice->invoice_id) ?>">
-      <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
+    <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
 
     <div id="headerbar">
         <h1 class="headerbar-title"><?php echo trans('email_invoice'); ?></h1>
@@ -64,10 +64,12 @@
             </div>
             <div class="col-xs-12 col-sm-6">
                 <select name="email_template" id="email_template" class="form-control simple-select">
-                    <option value=""></option>
+                    <option value=""><?php echo trans('none'); ?></option>
                     <?php foreach ($email_templates as $email_template): ?>
                         <option value="<?php echo $email_template->email_template_id; ?>"
-                                <?php if ($selected_email_template == $email_template->email_template_id) { ?>selected="selected"<?php } ?>><?php echo $email_template->email_template_title; ?></option>
+                                <?php if ($selected_email_template == $email_template->email_template_id) { ?>selected="selected"<?php } ?>>
+                            <?php echo $email_template->email_template_title; ?>
+                        </option>
                     <?php endforeach; ?>
                 </select>
             </div>
@@ -129,7 +131,7 @@
             </div>
             <div class="col-xs-12 col-sm-6">
                 <select name="pdf_template" id="pdf_template" class="form-control simple-select">
-                    <option value=""></option>
+                    <option value=""><?php echo trans('none'); ?></option>
                     <?php foreach ($pdf_templates as $pdf_template): ?>
                         <option value="<?php echo $pdf_template; ?>"
                                 <?php if ($selected_pdf_template == $pdf_template):

+ 5 - 3
application/modules/mailer/views/quote.php

@@ -62,10 +62,12 @@
             </div>
             <div class="col-xs-12 col-sm-6">
                 <select name="email_template" id="email_template" class="form-control simple-select">
-                    <option value=""></option>
+                    <option value=""><?php echo trans('none'); ?></option>
                     <?php foreach ($email_templates as $email_template): ?>
                         <option value="<?php echo $email_template->email_template_id; ?>"
-                                <?php if ($selected_email_template == $email_template->email_template_id) { ?>selected="selected"<?php } ?>><?php echo $email_template->email_template_title; ?></option>
+                                <?php if ($selected_email_template == $email_template->email_template_id) { ?>selected="selected"<?php } ?>>
+                            <?php echo $email_template->email_template_title; ?>
+                        </option>
                     <?php endforeach; ?>
                 </select>
             </div>
@@ -127,7 +129,7 @@
             </div>
             <div class="col-xs-12 col-sm-6">
                 <select name="pdf_template" id="pdf_template" class="form-control simple-select">
-                    <option value=""></option>
+                    <option value=""><?php echo trans('none'); ?></option>
                     <?php foreach ($pdf_templates as $pdf_template): ?>
                         <option value="<?php echo $pdf_template; ?>"
                                 <?php if ($selected_pdf_template == $pdf_template):

+ 13 - 13
application/modules/payments/models/Mdl_payments.php

@@ -151,6 +151,19 @@ class Mdl_Payments extends Response_Model
     }
 
     /**
+     * @return array
+     */
+    public function db_array()
+    {
+        $db_array = parent::db_array();
+
+        $db_array['payment_date'] = date_to_mysql($db_array['payment_date']);
+        $db_array['payment_amount'] = standardize_amount($db_array['payment_amount']);
+
+        return $db_array;
+    }
+
+    /**
      * @param null $id
      */
     public function delete($id = null)
@@ -183,19 +196,6 @@ class Mdl_Payments extends Response_Model
     }
 
     /**
-     * @return array
-     */
-    public function db_array()
-    {
-        $db_array = parent::db_array();
-
-        $db_array['payment_date'] = date_to_mysql($db_array['payment_date']);
-        $db_array['payment_amount'] = standardize_amount($db_array['payment_amount']);
-
-        return $db_array;
-    }
-
-    /**
      * @param null $id
      * @return bool
      */

+ 3 - 2
application/modules/payments/views/form.php

@@ -46,10 +46,11 @@
             <div class="col-xs-12 col-sm-6">
                 <select name="invoice_id" id="invoice_id" class="form-control simple-select">
                     <?php if (!$payment_id) { ?>
-                        <option value=""></option>
                         <?php foreach ($open_invoices as $invoice) { ?>
                             <option value="<?php echo $invoice->invoice_id; ?>"
-                                    <?php if ($this->mdl_payments->form_value('invoice_id') == $invoice->invoice_id) { ?>selected="selected"<?php } ?>><?php echo $invoice->invoice_number . ' - ' . format_client($invoice) . ' - ' . format_currency($invoice->invoice_balance); ?></option>
+                                    <?php if ($this->mdl_payments->form_value('invoice_id') == $invoice->invoice_id) { ?>selected="selected"<?php } ?>>
+                                <?php echo $invoice->invoice_number . ' - ' . format_client($invoice) . ' - ' . format_currency($invoice->invoice_balance); ?>
+                            </option>
                         <?php } ?>
                     <?php } else { ?>
                         <option value="<?php echo $payment->invoice_id; ?>">

+ 1 - 1
application/modules/payments/views/modal_add_payment.php

@@ -90,7 +90,7 @@
 
                         <select name="payment_method_id" id="payment_method_id" class="form-control simple-select"
                             <?php echo(!empty($invoice_payment_method) ? 'disabled="disabled"' : ''); ?>>
-                            <option value=""></option>
+                            <option value=""><?php echo trans('none'); ?></option>
                             <?php foreach ($payment_methods as $payment_method) { ?>
                                 <option value="<?php echo $payment_method->payment_method_id; ?>"
                                     <?php if (isset($invoice_payment_method)

+ 4 - 4
application/modules/quotes/controllers/Quotes.php

@@ -148,9 +148,9 @@ class Quotes extends Admin_Controller
                 'custom_fields' => $custom_fields,
                 'custom_values' => $custom_values,
                 'custom_js_vars' => array(
-                    'currency_symbol' => $this->mdl_settings->setting('currency_symbol'),
-                    'currency_symbol_placement' => $this->mdl_settings->setting('currency_symbol_placement'),
-                    'decimal_point' => $this->mdl_settings->setting('decimal_point')
+                    'currency_symbol' => get_setting('currency_symbol'),
+                    'currency_symbol_placement' => get_setting('currency_symbol_placement'),
+                    'decimal_point' => get_setting('decimal_point')
                 ),
                 'quote_statuses' => $this->mdl_quotes->statuses()
             )
@@ -202,7 +202,7 @@ class Quotes extends Admin_Controller
     {
         $this->load->helper('pdf');
 
-        if ($this->mdl_settings->setting('mark_quotes_sent_pdf') == 1) {
+        if (get_setting('mark_quotes_sent_pdf') == 1) {
             $this->mdl_quotes->mark_sent($quote_id);
         }
 

+ 6 - 6
application/modules/quotes/models/Mdl_quotes.php

@@ -177,11 +177,11 @@ class Mdl_Quotes extends Response_Model
         $this->db->insert('ip_quote_amounts', $db_array);
 
         // Create the default invoice tax record if applicable
-        if ($this->mdl_settings->setting('default_invoice_tax_rate')) {
+        if (get_setting('default_invoice_tax_rate')) {
             $db_array = array(
                 'quote_id' => $quote_id,
-                'tax_rate_id' => $this->mdl_settings->setting('default_invoice_tax_rate'),
-                'include_item_tax' => $this->mdl_settings->setting('default_include_item_tax'),
+                'tax_rate_id' => get_setting('default_invoice_tax_rate'),
+                'include_item_tax' => get_setting('default_include_item_tax'),
                 'quote_tax_rate_amount' => 0
             );
 
@@ -255,13 +255,13 @@ class Mdl_Quotes extends Response_Model
         $db_array['quote_date_created'] = date_to_mysql($db_array['quote_date_created']);
         $db_array['quote_date_expires'] = $this->get_date_due($db_array['quote_date_created']);
 
-        $db_array['notes'] = $this->mdl_settings->setting('default_quote_notes');
+        $db_array['notes'] = get_setting('default_quote_notes');
 
         if (!isset($db_array['quote_status_id'])) {
             $db_array['quote_status_id'] = 1;
         }
 
-        $generate_quote_number = $this->mdl_settings->setting('generate_quote_number_for_draft');
+        $generate_quote_number = get_setting('generate_quote_number_for_draft');
 
         if ($db_array['quote_status_id'] === 1 && $generate_quote_number == 1) {
             $db_array['quote_number'] = $this->get_quote_number($db_array['invoice_group_id']);
@@ -280,7 +280,7 @@ class Mdl_Quotes extends Response_Model
     public function get_date_due($quote_date_created)
     {
         $quote_date_expires = new DateTime($quote_date_created);
-        $quote_date_expires->add(new DateInterval('P' . $this->mdl_settings->setting('quotes_expire_after') . 'D'));
+        $quote_date_expires->add(new DateInterval('P' . get_setting('quotes_expire_after') . 'D'));
         return $quote_date_expires->format('Y-m-d');
     }
 

+ 3 - 2
application/modules/quotes/views/modal_copy_quote.php

@@ -84,10 +84,11 @@
 
                 <div class="controls">
                     <select name="invoice_group_id" id="invoice_group_id" class="form-control simple-select">
-                        <option></option>
                         <?php foreach ($invoice_groups as $invoice_group) { ?>
                             <option value="<?php echo $invoice_group->invoice_group_id; ?>"
-                                    <?php if ($this->mdl_settings->setting('default_quote_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>><?php echo $invoice_group->invoice_group_name; ?></option>
+                                <?php echo get_setting('default_quote_group') != $invoice_group->invoice_group_id ?: 'selected="selected"' ?>>
+                                <?php echo $invoice_group->invoice_group_name; ?>
+                            </option>
                         <?php } ?>
                     </select>
                 </div>

+ 5 - 7
application/modules/quotes/views/modal_create_quote.php

@@ -84,21 +84,19 @@
             <div class="form-group">
                 <label for="quote_password"><?php echo trans('quote_password'); ?></label>
                 <input type="text" name="quote_password" id="quote_password" class="form-control"
-                       value="<?php if ($this->mdl_settings->setting('quote_pre_password') == '') {
-                           echo '';
-                       } else {
-                           echo $this->mdl_settings->setting('quote_pre_password');
-                       } ?>" style="margin: 0 auto;" autocomplete="off">
+                       value="<?php echo get_setting('quote_pre_password') == '' ?: get_setting('quote_pre_password') ?>"
+                       style="margin: 0 auto;" autocomplete="off">
             </div>
 
             <div class="form-group">
                 <label for="invoice_group_id"><?php echo trans('invoice_group'); ?>: </label>
                 <div class="controls">
                     <select name="invoice_group_id" id="invoice_group_id" class="form-control simple-select">
-                        <option></option>
                         <?php foreach ($invoice_groups as $invoice_group) { ?>
                             <option value="<?php echo $invoice_group->invoice_group_id; ?>"
-                                    <?php if ($this->mdl_settings->setting('default_quote_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>><?php echo $invoice_group->invoice_group_name; ?></option>
+                                    <?php if (get_setting('default_quote_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>>
+                                <?php echo $invoice_group->invoice_group_name; ?>
+                            </option>
                         <?php } ?>
                     </select>
                 </div>

+ 3 - 7
application/modules/quotes/views/modal_quote_to_invoice.php

@@ -67,11 +67,8 @@
             <div class="form-group">
                 <label for="invoice_password"><?php echo trans('invoice_password'); ?></label>
                 <input type="text" name="invoice_password" id="invoice_password" class="form-control"
-                       value="<?php if ($this->mdl_settings->setting('invoice_pre_password') == '') {
-                           echo '';
-                       } else {
-                           echo $this->mdl_settings->setting('invoice_pre_password');
-                       } ?>" style="margin: 0 auto;" autocomplete="off">
+                       value="<?php echo get_setting('invoice_pre_password') == '' ?: get_setting('invoice_pre_password') ?>"
+                       style="margin: 0 auto;" autocomplete="off">
             </div>
 
             <div class="form-group">
@@ -79,10 +76,9 @@
                     <?php echo trans('invoice_group'); ?>
                 </label>
                 <select name="invoice_group_id" id="invoice_group_id" class="form-control simple-select">
-                    <option value=""></option>
                     <?php foreach ($invoice_groups as $invoice_group) { ?>
                         <option value="<?php echo $invoice_group->invoice_group_id; ?>"
-                                <?php if ($this->mdl_settings->setting('default_invoice_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>>
+                                <?php if (get_setting('default_invoice_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>>
                             <?php echo $invoice_group->invoice_group_name; ?></option>
                     <?php } ?>
                 </select>

+ 3 - 3
application/modules/quotes/views/partial_item_table.php

@@ -45,7 +45,7 @@
                     <span class="input-group-addon"><?php echo trans('item_discount'); ?></span>
                     <input type="text" name="item_discount_amount" class="input-sm form-control amount"
                            value="" data-toggle="tooltip" data-placement="bottom"
-                           title="<?php echo $this->mdl_settings->setting('currency_symbol') . ' ' . trans('per_item'); ?>">
+                           title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
                 </div>
             </td>
             <td class="td-amount">
@@ -138,7 +138,7 @@
                         <input type="text" name="item_discount_amount" class="input-sm form-control amount"
                                value="<?php echo format_amount($item->item_discount_amount); ?>"
                                data-toggle="tooltip" data-placement="bottom"
-                               title="<?php echo $this->mdl_settings->setting('currency_symbol') . ' ' . trans('per_item'); ?>">
+                               title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
                     </div>
                 </td>
                 <td class="td-amount">
@@ -269,7 +269,7 @@
                                    value="<?php echo format_amount($quote->quote_discount_amount != 0 ? $quote->quote_discount_amount : ''); ?>">
 
                             <div
-                                    class="input-group-addon"><?php echo $this->mdl_settings->setting('currency_symbol'); ?></div>
+                                    class="input-group-addon"><?php echo get_setting('currency_symbol'); ?></div>
                         </div>
                     </div>
                     <div class="discount-field">

+ 5 - 5
application/modules/reports/controllers/Reports.php

@@ -29,9 +29,9 @@ class Reports extends Admin_Controller
     {
         if ($this->input->post('btn_submit')) {
             $data = array(
-                'results'   => $this->mdl_reports->sales_by_client($this->input->post('from_date'), $this->input->post('to_date')),
-				'from_date' => $this->input->post('from_date'),
-                'to_date'   => $this->input->post('to_date'),
+                'results' => $this->mdl_reports->sales_by_client($this->input->post('from_date'), $this->input->post('to_date')),
+                'from_date' => $this->input->post('from_date'),
+                'to_date' => $this->input->post('to_date'),
             );
 
             $html = $this->load->view('reports/sales_by_client', $data, true);
@@ -50,7 +50,7 @@ class Reports extends Admin_Controller
             $data = array(
                 'results' => $this->mdl_reports->payment_history($this->input->post('from_date'), $this->input->post('to_date')),
                 'from_date' => $this->input->post('from_date'),
-                'to_date'   => $this->input->post('to_date'),
+                'to_date' => $this->input->post('to_date'),
             );
 
             $html = $this->load->view('reports/payment_history', $data, true);
@@ -88,7 +88,7 @@ class Reports extends Admin_Controller
             $data = array(
                 'results' => $this->mdl_reports->sales_by_year($this->input->post('from_date'), $this->input->post('to_date'), $this->input->post('minQuantity'), $this->input->post('maxQuantity'), $this->input->post('checkboxTax')),
                 'from_date' => $this->input->post('from_date'),
-                'to_date'   => $this->input->post('to_date'),
+                'to_date' => $this->input->post('to_date'),
             );
 
             $html = $this->load->view('reports/sales_by_year', $data, true);

+ 63 - 61
application/modules/reports/views/sales_by_year_index.php

@@ -7,86 +7,88 @@
     <div class="row">
         <div class="col-xs-12 col-md-10 col-lg-8">
 
-    <?php $this->layout->load_view('layout/alerts'); ?>
+            <?php $this->layout->load_view('layout/alerts'); ?>
 
-    <div id="report_options" class="panel panel-default">
+            <div id="report_options" class="panel panel-default">
 
-        <div class="panel-heading">
-            <h3 class="panel-title">
-                <i class="fa fa-print fa-margin"></i>
-                <?php echo trans('report_options'); ?>
-            </h3>
-        </div>
+                <div class="panel-heading">
+                    <h3 class="panel-title">
+                        <i class="fa fa-print fa-margin"></i>
+                        <?php echo trans('report_options'); ?>
+                    </h3>
+                </div>
 
-        <div class="panel-body">
+                <div class="panel-body">
 
-            <form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>">
+                    <form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>">
 
-                <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
+                        <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
 
-                <div class="form-group has-feedback">
-                    <label for="from_date">
-                        <?php echo trans('from_date'); ?>
-                    </label>
+                        <div class="form-group has-feedback">
+                            <label for="from_date">
+                                <?php echo trans('from_date'); ?>
+                            </label>
 
-                    <div class="input-group">
-                        <input name="from_date" id="from_date" class="form-control datepicker">
-                        <span class="input-group-addon">
+                            <div class="input-group">
+                                <input name="from_date" id="from_date" class="form-control datepicker">
+                                <span class="input-group-addon">
                             <i class="fa fa-calendar fa-fw"></i>
                         </span>
-                    </div>
-                </div>
+                            </div>
+                        </div>
 
-                <div class="form-group has-feedback">
-                    <label for="to_date">
-                        <?php echo trans('to_date'); ?>
-                    </label>
+                        <div class="form-group has-feedback">
+                            <label for="to_date">
+                                <?php echo trans('to_date'); ?>
+                            </label>
 
-                    <div class="input-group">
-                        <input name="to_date" id="to_date" class="form-control datepicker">
-                        <span class="input-group-addon">
+                            <div class="input-group">
+                                <input name="to_date" id="to_date" class="form-control datepicker">
+                                <span class="input-group-addon">
                             <i class="fa fa-calendar fa-fw"></i>
                         </span>
-                    </div>
-                </div>
-
+                            </div>
+                        </div>
 
-                <div class="clearfix">
-                    <div class="col-xs-12 col-md-2" style="margin-right:10px; padding-left:0px;">
-                        <label for="minQuantity">
-                            <?php echo trans('min_quantity'); ?>
-                        </label>
 
-                        <div>
-                            <input type="number" id="minQuantity" name="minQuantity" min="0" class="form-control">
+                        <div class="clearfix">
+                            <div class="col-xs-12 col-md-2" style="margin-right:10px; padding-left:0px;">
+                                <label for="minQuantity">
+                                    <?php echo trans('min_quantity'); ?>
+                                </label>
+
+                                <div>
+                                    <input type="number" id="minQuantity" name="minQuantity" min="0"
+                                           class="form-control">
+                                </div>
+                            </div>
+
+                            <div class="col-xs-12 col-md-2" style=padding-left:0px;>
+                                <label for="maxQuantity">
+                                    <?php echo trans('max_quantity'); ?>
+                                </label>
+
+                                <div>
+                                    <input type="number" id="maxQuantity" name="maxQuantity" min="0"
+                                           class="form-control">
+                                </div>
+                            </div>
                         </div>
-                    </div>
 
-                    <div class="col-xs-12 col-md-2" style=padding-left:0px;>
-                        <label for="maxQuantity">
-                            <?php echo trans('max_quantity'); ?>
-                        </label>
-
-                        <div>
-                            <input type="number" id="maxQuantity" name="maxQuantity" min="0" class="form-control">
+                        <div class="form-group">
+                            <div class="checkbox">
+                                <label for="checkboxTax">
+                                    <input type="checkbox" id="checkboxTax" name="checkboxTax">
+                                    <?php echo trans('values_with_taxes'); ?>
+                                </label>
+                            </div>
                         </div>
-                    </div>
-                </div>
 
-                <div class="form-group">
-                    <div class="checkbox">
-                        <label for="checkboxTax">
-                            <input type="checkbox" id="checkboxTax" name="checkboxTax">
-                            <?php echo trans('values_with_taxes'); ?>
-                        </label>
-                    </div>
-                </div>
+                        <input type="submit" class="btn btn-success" name="btn_submit"
+                               value="<?php echo trans('run_report'); ?>">
 
-                <input type="submit" class="btn btn-success" name="btn_submit"
-                       value="<?php echo trans('run_report'); ?>">
+                    </form>
+                </div>
+            </div>
 
-            </form>
         </div>
-    </div>
-
-</div>

+ 8 - 8
application/modules/sessions/controllers/Sessions.php

@@ -23,7 +23,7 @@ class Sessions extends Base_Controller
     public function login()
     {
         $view_data = array(
-            'login_logo' => $this->mdl_settings->setting('login_logo')
+            'login_logo' => get_setting('login_logo')
         );
 
         if ($this->input->post('btn_login')) {
@@ -64,13 +64,6 @@ class Sessions extends Base_Controller
         $this->load->view('session_login', $view_data);
     }
 
-    public function logout()
-    {
-        $this->session->sess_destroy();
-
-        redirect('sessions/login');
-    }
-
     /**
      * @param $email_address
      * @param $password
@@ -87,6 +80,13 @@ class Sessions extends Base_Controller
         return false;
     }
 
+    public function logout()
+    {
+        $this->session->sess_destroy();
+
+        redirect('sessions/login');
+    }
+
     /**
      * @param null $token
      * @return mixed

+ 4 - 3
application/modules/sessions/views/session_login.php

@@ -12,8 +12,8 @@
 <head>
     <title>
         <?php
-        if ($this->mdl_settings->setting('custom_title') != '') {
-            echo $this->mdl_settings->setting('custom_title');
+        if (get_setting('custom_title') != '') {
+            echo get_setting('custom_title');
         } else {
             echo 'InvoicePlane';
         } ?>
@@ -26,7 +26,8 @@
 
     <link rel="icon" type="image/png" href="<?php echo base_url(); ?>assets/core/img/favicon.png">
 
-    <link href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css" rel="stylesheet">
+    <link href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css"
+          rel="stylesheet">
     <link href="<?php echo base_url(); ?>assets/core/css/custom.css" rel="stylesheet">
 
 </head>

+ 4 - 3
application/modules/sessions/views/session_new_password.php

@@ -12,8 +12,8 @@
 <head>
     <title>
         <?php
-        if ($this->mdl_settings->setting('custom_title') != '') {
-            echo $this->mdl_settings->setting('custom_title');
+        if (get_setting('custom_title') != '') {
+            echo get_setting('custom_title');
         } else {
             echo 'InvoicePlane';
         } ?>
@@ -26,7 +26,8 @@
 
     <link rel="icon" type="image/png" href="<?php echo base_url(); ?>assets/core/img/favicon.png">
 
-    <link href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css" rel="stylesheet">
+    <link href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css"
+          rel="stylesheet">
     <link href="<?php echo base_url(); ?>assets/core/css/custom.css" rel="stylesheet">
 
 </head>

+ 4 - 3
application/modules/sessions/views/session_passwordreset.php

@@ -12,8 +12,8 @@
 <head>
     <title>
         <?php
-        if ($this->mdl_settings->setting('custom_title') != '') {
-            echo $this->mdl_settings->setting('custom_title');
+        if (get_setting('custom_title') != '') {
+            echo get_setting('custom_title');
         } else {
             echo 'InvoicePlane';
         } ?>
@@ -26,7 +26,8 @@
 
     <link rel="icon" type="image/png" href="<?php echo base_url(); ?>assets/core/img/favicon.png">
 
-    <link href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css" rel="stylesheet">
+    <link href="<?php echo base_url(); ?>assets/<?php echo get_setting('system_theme', 'invoiceplane'); ?>/css/style.css"
+          rel="stylesheet">
     <link href="<?php echo base_url(); ?>assets/core/css/custom.css" rel="stylesheet">
 
 </head>

+ 2 - 1
application/modules/settings/controllers/Ajax.php

@@ -26,7 +26,8 @@ class Ajax extends Admin_Controller
         echo random_string('alnum', 16);
     }
 
-    public function test_mail(){
+    public function test_mail()
+    {
         $this->load->helper('mailer');
         email_invoice(1, 'InvoicePlane', 'denys@denv.it', 'denys@denv.it', 'Test', 'Some text');
     }

+ 2 - 2
application/modules/settings/controllers/Settings.php

@@ -31,7 +31,7 @@ class Settings extends Admin_Controller
             $settings = $this->input->post('settings');
 
             // Only execute if the setting is different
-            if ($settings['tax_rate_decimal_places'] <> $this->mdl_settings->setting('tax_rate_decimal_places')) {
+            if ($settings['tax_rate_decimal_places'] != get_setting('tax_rate_decimal_places')) {
                 $this->db->query("
                     ALTER TABLE `ip_tax_rates` CHANGE `tax_rate_percent` `tax_rate_percent`
                     DECIMAL( 5, {$settings['tax_rate_decimal_places']} ) NOT null"
@@ -153,7 +153,7 @@ class Settings extends Admin_Controller
      */
     public function remove_logo($type)
     {
-        unlink('./uploads/' . $this->mdl_settings->setting($type . '_logo'));
+        unlink('./uploads/' . get_setting($type . '_logo'));
 
         $this->mdl_settings->save($type . '_logo', '');
 

+ 18 - 24
application/modules/settings/views/partial_settings_email.php

@@ -26,17 +26,14 @@
         </label>
         <select name="settings[email_send_method]" id="email_send_method"
                 class=" form-control simple-select">
-            <option value=""></option>
-            <option value="phpmail"
-                    <?php if ($this->mdl_settings->setting('email_send_method') == 'phpmail') { ?>selected="selected"<?php } ?>>
+            <option value=""><?php echo trans('none'); ?></option>
+            <option value="phpmail" <?php check_select(get_setting('email_send_method'), 'phpmail'); ?>>
                 <?php echo trans('email_send_method_phpmail'); ?>
             </option>
-            <option value="sendmail"
-                    <?php if ($this->mdl_settings->setting('email_send_method') == 'sendmail') { ?>selected="selected"<?php } ?>>
+            <option value="sendmail" <?php check_select(get_setting('email_send_method'), 'sendmail'); ?>>
                 <?php echo trans('email_send_method_sendmail'); ?>
             </option>
-            <option value="smtp"
-                    <?php if ($this->mdl_settings->setting('email_send_method') == 'smtp') { ?>selected="selected"<?php } ?>>
+            <option value="smtp" <?php check_select(get_setting('email_send_method'), 'smtp'); ?>>
                 <?php echo trans('email_send_method_smtp'); ?>
             </option>
         </select>
@@ -49,7 +46,7 @@
             <?php echo trans('smtp_server_address'); ?>
         </label>
         <input type="text" name="settings[smtp_server_address]" class=" form-control"
-               value="<?php echo $this->mdl_settings->setting('smtp_server_address'); ?>">
+               value="<?php echo get_setting('smtp_server_address'); ?>">
     </div>
 
     <div class="form-group">
@@ -57,12 +54,10 @@
             <?php echo trans('smtp_requires_authentication'); ?>
         </label>
         <select name="settings[smtp_authentication]" class=" form-control simple-select">
-            <option value="0"
-                    <?php if (!$this->mdl_settings->setting('smtp_authentication')) { ?>selected="selected"<?php } ?>>
+            <option value="0">
                 <?php echo trans('no'); ?>
             </option>
-            <option value="1"
-                    <?php if ($this->mdl_settings->setting('smtp_authentication')) { ?>selected="selected"<?php } ?>>
+            <option value="1" <?php check_select(get_setting('smtp_authentication'), null, '!e'); ?>>
                 <?php echo trans('yes'); ?>
             </option>
         </select>
@@ -73,7 +68,7 @@
             <?php echo trans('smtp_username'); ?>
         </label>
         <input type="text" name="settings[smtp_username]" class=" form-control"
-               value="<?php echo $this->mdl_settings->setting('smtp_username'); ?>">
+               value="<?php echo get_setting('smtp_username'); ?>">
     </div>
 
     <div class="form-group">
@@ -90,7 +85,7 @@
                 <?php echo trans('smtp_port'); ?>
             </label>
             <input type="text" name="settings[smtp_port]" class=" form-control"
-                   value="<?php echo $this->mdl_settings->setting('smtp_port'); ?>">
+                   value="<?php echo get_setting('smtp_port'); ?>">
         </div>
     </div>
 
@@ -99,12 +94,13 @@
             <?php echo trans('smtp_security'); ?>
         </label>
         <select name="settings[smtp_security]" class=" form-control simple-select">
-            <option value=""
-                    <?php if (!$this->mdl_settings->setting('smtp_security')) { ?>selected="selected"<?php } ?>><?php echo trans('none'); ?></option>
-            <option value="ssl"
-                    <?php if ($this->mdl_settings->setting('smtp_security') == 'ssl') { ?>selected="selected"<?php } ?>><?php echo trans('smtp_ssl'); ?></option>
-            <option value="tls"
-                    <?php if ($this->mdl_settings->setting('smtp_security') == 'tls') { ?>selected="selected"<?php } ?>><?php echo trans('smtp_tls'); ?></option>
+            <option value=""><?php echo trans('none'); ?></option>
+            <option value="ssl" <?php check_select(get_setting('smtp_security'), 'ssl'); ?>>
+                <?php echo trans('smtp_ssl'); ?>
+            </option>
+            <option value="tls" <?php check_select(get_setting('smtp_security'), 'tls'); ?>>
+                <?php echo trans('smtp_tls'); ?>
+            </option>
         </select>
     </div>
 </div>
@@ -114,12 +110,10 @@
         <?php echo trans('email_pdf_attachment'); ?>
     </label>
     <select name="settings[email_pdf_attachment]" class=" form-control simple-select">
-        <option value="0"
-                <?php if (!$this->mdl_settings->setting('email_pdf_attachment')) { ?>selected="selected"<?php } ?>>
+        <option value="0">
             <?php echo trans('no'); ?>
         </option>
-        <option value="1"
-                <?php if ($this->mdl_settings->setting('email_pdf_attachment')) { ?>selected="selected"<?php } ?>>
+        <option value="1" <?php check_select(get_setting('email_pdf_attachment')); ?>>
             <?php echo trans('yes'); ?>
         </option>
     </select>

+ 88 - 70
application/modules/settings/views/partial_settings_general.php

@@ -18,10 +18,9 @@
                 </label>
                 <select name="settings[default_language]" class=" form-control simple-select">
                     <?php foreach ($languages as $language) {
-                        $sys_lang = $this->mdl_settings->setting('default_language');
+                        $sys_lang = get_setting('default_language');
                         ?>
-                        <option value="<?php echo $language; ?>"
-                            <?php echo $sys_lang == $language ? 'selected="selected"' : '' ?>>
+                        <option value="<?php echo $language; ?>" <?php check_select($sys_lang, $language) ?>>
                             <?php echo ucfirst($language); ?>
                         </option>
                     <?php } ?>
@@ -36,8 +35,7 @@
                 </label>
                 <select name="settings[system_theme]" class=" form-control simple-select">
                     <?php foreach ($available_themes as $theme_key => $theme_name) { ?>
-                        <option value="<?php echo $theme_key; ?>"
-                                <?php if (get_setting('system_theme') == $theme_key) { ?>selected="selected"<?php } ?>>
+                        <option value="<?php echo $theme_key; ?>" <?php check_select(get_setting('system_theme'), $theme_key); ?>>
                             <?php echo $theme_name; ?>
                         </option>
                     <?php } ?>
@@ -55,7 +53,9 @@
                 <select name="settings[first_day_of_week]" class=" form-control simple-select">
                     <?php foreach ($first_days_of_weeks as $first_day_of_week_id => $first_day_of_week_name) { ?>
                         <option value="<?php echo $first_day_of_week_id; ?>"
-                                <?php if ($this->mdl_settings->setting('first_day_of_week') == $first_day_of_week_id) { ?>selected="selected"<?php } ?>><?php echo $first_day_of_week_name; ?></option>
+                            <?php check_select(get_setting('first_day_of_week'), $first_day_of_week_id); ?>>
+                            <?php echo $first_day_of_week_name; ?>
+                        </option>
                     <?php } ?>
                 </select>
             </div>
@@ -69,7 +69,9 @@
                 <select name="settings[date_format]" class=" form-control simple-select">
                     <?php foreach ($date_formats as $date_format) { ?>
                         <option value="<?php echo $date_format['setting']; ?>"
-                                <?php if ($this->mdl_settings->setting('date_format') == $date_format['setting']) { ?>selected="selected"<?php } ?>><?php echo $current_date->format($date_format['setting']); ?></option>
+                            <?php check_select(get_setting('date_format'), $date_format['setting']); ?>>
+                            <?php echo $current_date->format($date_format['setting']); ?>
+                        </option>
                     <?php } ?>
                 </select>
             </div>
@@ -83,10 +85,9 @@
                     <?php echo trans('default_country'); ?>
                 </label>
                 <select name="settings[default_country]" class=" form-control simple-select">
-                    <option></option>
+                    <option value=""><?php echo trans('none'); ?></option>
                     <?php foreach ($countries as $cldr => $country) { ?>
-                        <option value="<?php echo $cldr; ?>"
-                                <?php if ($this->mdl_settings->setting('default_country') == $cldr) { ?>selected="selected"<?php } ?>>
+                        <option value="<?php echo $cldr; ?>" <?php check_select(get_setting('default_country'), $cldr); ?>>
                             <?php echo $country ?>
                         </option>
                     <?php } ?>
@@ -106,7 +107,7 @@
                     <?php echo trans('currency_symbol'); ?>
                 </label>
                 <input type="text" name="settings[currency_symbol]" class=" form-control"
-                       value="<?php echo $this->mdl_settings->setting('currency_symbol'); ?>">
+                       value="<?php echo get_setting('currency_symbol'); ?>">
             </div>
         </div>
 
@@ -116,12 +117,15 @@
                     <?php echo trans('currency_symbol_placement'); ?>
                 </label>
                 <select name="settings[currency_symbol_placement]" class=" form-control simple-select">
-                    <option value="before"
-                            <?php if ($this->mdl_settings->setting('currency_symbol_placement') == 'before') { ?>selected="selected"<?php } ?>><?php echo trans('before_amount'); ?></option>
-                    <option value="after"
-                            <?php if ($this->mdl_settings->setting('currency_symbol_placement') == 'after') { ?>selected="selected"<?php } ?>><?php echo trans('after_amount'); ?></option>
-                    <option value="afterspace"
-                            <?php if ($this->mdl_settings->setting('currency_symbol_placement') == 'afterspace') { ?>selected="selected"<?php } ?>><?php echo trans('after_amount_space'); ?></option>
+                    <option value="before" <?php check_select(get_setting('currency_symbol_placement'), 'before'); ?>>
+                        <?php echo trans('before_amount'); ?>
+                    </option>
+                    <option value="after" <?php check_select(get_setting('currency_symbol_placement'), 'after'); ?>>
+                        <?php echo trans('after_amount'); ?>
+                    </option>
+                    <option value="afterspace" <?php check_select(get_setting('currency_symbol_placement'), 'afterspace'); ?>>
+                        <?php echo trans('after_amount_space'); ?>
+                    </option>
                 </select>
             </div>
         </div>
@@ -134,7 +138,7 @@
                     <?php echo trans('thousands_separator'); ?>
                 </label>
                 <input type="text" name="settings[thousands_separator]" class=" form-control"
-                       value="<?php echo $this->mdl_settings->setting('thousands_separator'); ?>">
+                       value="<?php echo get_setting('thousands_separator'); ?>">
             </div>
         </div>
 
@@ -144,7 +148,7 @@
                     <?php echo trans('decimal_point'); ?>
                 </label>
                 <input type="text" name="settings[decimal_point]" class=" form-control"
-                       value="<?php echo $this->mdl_settings->setting('decimal_point'); ?>">
+                       value="<?php echo get_setting('decimal_point'); ?>">
             </div>
         </div>
     </div>
@@ -157,12 +161,10 @@
                 </label>
                 <select name="settings[tax_rate_decimal_places]" class=" form-control simple-select"
                         id="tax_rate_decimal_places">
-                    <option value="2"
-                            <?php if ($this->mdl_settings->setting('tax_rate_decimal_places') == '2') { ?>selected="selected"<?php } ?>>
+                    <option value="2" <?php check_select(get_setting('tax_rate_decimal_places'), '2'); ?>>
                         2
                     </option>
-                    <option value="3"
-                            <?php if ($this->mdl_settings->setting('tax_rate_decimal_places') == '3') { ?>selected="selected"<?php } ?>>
+                    <option value="3" <?php check_select(get_setting('tax_rate_decimal_places'), '3'); ?>>
                         3
                     </option>
                 </select>
@@ -176,20 +178,16 @@
                 </label>
                 <select name="settings[default_list_limit]" class=" form-control simple-select"
                         id="default_list_limit">
-                    <option value="15"
-                            <?php if ($this->mdl_settings->setting('default_list_limit') == '15') { ?>selected="selected"<?php } ?>>
+                    <option value="15" <?php check_select(get_setting('default_list_limit'), '15'); ?>>
                         15
                     </option>
-                    <option value="25"
-                            <?php if ($this->mdl_settings->setting('default_list_limit') == '25') { ?>selected="selected"<?php } ?>>
+                    <option value="25" <?php check_select(get_setting('default_list_limit'), '25'); ?>>
                         25
                     </option>
-                    <option value="50"
-                            <?php if ($this->mdl_settings->setting('default_list_limit') == '50') { ?>selected="selected"<?php } ?>>
+                    <option value="50" <?php check_select(get_setting('default_list_limit'), '50'); ?>>
                         50
                     </option>
-                    <option value="100"
-                            <?php if ($this->mdl_settings->setting('default_list_limit') == '100') { ?>selected="selected"<?php } ?>>
+                    <option value="100" <?php check_select(get_setting('default_list_limit'), '100'); ?>>
                         100
                     </option>
                 </select>
@@ -204,7 +202,7 @@
                     <?php echo trans('currency_code'); ?>
                 </label>
                 <input type="text" name="settings[currency_code]" class=" form-control"
-                       value="<?php echo $this->mdl_settings->setting('currency_code'); ?>">
+                       value="<?php echo get_setting('currency_code'); ?>">
             </div>
         </div>
     </div>
@@ -220,18 +218,24 @@
                     <?php echo trans('quote_overview_period'); ?>
                 </label>
                 <select name="settings[quote_overview_period]" class=" form-control simple-select">
-                    <option value="this-month"
-                            <?php if ($this->mdl_settings->setting('quote_overview_period') == 'this-month') { ?>selected="selected"<?php } ?>><?php echo trans('this_month'); ?></option>
-                    <option value="last-month"
-                            <?php if ($this->mdl_settings->setting('quote_overview_period') == 'last-month') { ?>selected="selected"<?php } ?>><?php echo trans('last_month'); ?></option>
-                    <option value="this-quarter"
-                            <?php if ($this->mdl_settings->setting('quote_overview_period') == 'this-quarter') { ?>selected="selected"<?php } ?>><?php echo trans('this_quarter'); ?></option>
-                    <option value="last-quarter"
-                            <?php if ($this->mdl_settings->setting('quote_overview_period') == 'last-quarter') { ?>selected="selected"<?php } ?>><?php echo trans('last_quarter'); ?></option>
-                    <option value="this-year"
-                            <?php if ($this->mdl_settings->setting('quote_overview_period') == 'this-year') { ?>selected="selected"<?php } ?>><?php echo trans('this_year'); ?></option>
-                    <option value="last-year"
-                            <?php if ($this->mdl_settings->setting('quote_overview_period') == 'last-year') { ?>selected="selected"<?php } ?>><?php echo trans('last_year'); ?></option>
+                    <option value="this-month" <?php check_select(get_setting('quote_overview_period'), 'this-month'); ?>>
+                        <?php echo trans('this_month'); ?>
+                    </option>
+                    <option value="last-month" <?php check_select(get_setting('quote_overview_period'), 'last-month'); ?>>
+                        <?php echo trans('last_month'); ?>
+                    </option>
+                    <option value="this-quarter" <?php check_select(get_setting('quote_overview_period'), 'this-quarter'); ?>>
+                        <?php echo trans('this_quarter'); ?>
+                    </option>
+                    <option value="last-quarter" <?php check_select(get_setting('quote_overview_period'), 'last-quarter'); ?>>
+                        <?php echo trans('last_quarter'); ?>
+                    </option>
+                    <option value="this-year" <?php check_select(get_setting('quote_overview_period'), 'this-year'); ?>>
+                        <?php echo trans('this_year'); ?>
+                    </option>
+                    <option value="last-year" <?php check_select(get_setting('quote_overview_period'), 'last-year'); ?>>
+                        <?php echo trans('last_year'); ?>
+                    </option>
                 </select>
             </div>
         </div>
@@ -242,18 +246,24 @@
                     <?php echo trans('invoice_overview_period'); ?>
                 </label>
                 <select name="settings[invoice_overview_period]" class=" form-control simple-select">
-                    <option value="this-month"
-                            <?php if ($this->mdl_settings->setting('invoice_overview_period') == 'this-month') { ?>selected="selected"<?php } ?>><?php echo trans('this_month'); ?></option>
-                    <option value="last-month"
-                            <?php if ($this->mdl_settings->setting('invoice_overview_period') == 'last-month') { ?>selected="selected"<?php } ?>><?php echo trans('last_month'); ?></option>
-                    <option value="this-quarter"
-                            <?php if ($this->mdl_settings->setting('invoice_overview_period') == 'this-quarter') { ?>selected="selected"<?php } ?>><?php echo trans('this_quarter'); ?></option>
-                    <option value="last-quarter"
-                            <?php if ($this->mdl_settings->setting('invoice_overview_period') == 'last-quarter') { ?>selected="selected"<?php } ?>><?php echo trans('last_quarter'); ?></option>
-                    <option value="this-year"
-                            <?php if ($this->mdl_settings->setting('invoice_overview_period') == 'this-year') { ?>selected="selected"<?php } ?>><?php echo trans('this_year'); ?></option>
-                    <option value="last-year"
-                            <?php if ($this->mdl_settings->setting('invoice_overview_period') == 'last-year') { ?>selected="selected"<?php } ?>><?php echo trans('last_year'); ?></option>
+                    <option value="this-month" <?php check_select(get_setting('invoice_overview_period'), 'this-month'); ?>>
+                        <?php echo trans('this_month'); ?>
+                    </option>
+                    <option value="last-month" <?php check_select(get_setting('invoice_overview_period'), 'last-month'); ?>>
+                        <?php echo trans('last_month'); ?>
+                    </option>
+                    <option value="this-quarter" <?php check_select(get_setting('invoice_overview_period'), 'this-quarter'); ?>>
+                        <?php echo trans('this_quarter'); ?>
+                    </option>
+                    <option value="last-quarter" <?php check_select(get_setting('invoice_overview_period'), 'last-quarter'); ?>>
+                        <?php echo trans('last_quarter'); ?>
+                    </option>
+                    <option value="this-year" <?php check_select(get_setting('invoice_overview_period'), 'this-year'); ?>>
+                        <?php echo trans('this_year'); ?>
+                    </option>
+                    <option value="last-year" <?php check_select(get_setting('invoice_overview_period'), 'last-year'); ?>>
+                        <?php echo trans('last_year'); ?>
+                    </option>
                 </select>
             </div>
         </div>
@@ -267,10 +277,12 @@
                 </label>
                 <select name="settings[disable_quickactions]" class=" form-control simple-select"
                         id="disable_quickactions">
-                    <option value="0"
-                            <?php if (!$this->mdl_settings->setting('disable_quickactions')) { ?>selected="selected"<?php } ?>><?php echo trans('no'); ?></option>
-                    <option value="1"
-                            <?php if ($this->mdl_settings->setting('disable_quickactions')) { ?>selected="selected"<?php } ?>><?php echo trans('yes'); ?></option>
+                    <option value="0">
+                        <?php echo trans('no'); ?>
+                    </option>
+                    <option value="1" <?php check_select(get_setting('disable_quickactions')); ?>>
+                        <?php echo trans('yes'); ?>
+                    </option>
                 </select>
             </div>
         </div>
@@ -288,10 +300,12 @@
                 </label>
                 <select name="settings[disable_sidebar]" class=" form-control simple-select"
                         id="disable_sidebar">
-                    <option value="0"
-                            <?php if (!$this->mdl_settings->setting('disable_sidebar')) { ?>selected="selected"<?php } ?>><?php echo trans('no'); ?></option>
-                    <option value="1"
-                            <?php if ($this->mdl_settings->setting('disable_sidebar')) { ?>selected="selected"<?php } ?>><?php echo trans('yes'); ?></option>
+                    <option value="0">
+                        <?php echo trans('no'); ?>
+                    </option>
+                    <option value="1" <?php check_select(get_setting('disable_sidebar')); ?>>
+                        <?php echo trans('yes'); ?>
+                    </option>
                 </select>
             </div>
         </div>
@@ -302,7 +316,7 @@
                     <?php echo trans('custom_title'); ?>
                 </label>
                 <input type="text" name="settings[custom_title]" class=" form-control"
-                       value="<?php echo $this->mdl_settings->setting('custom_title'); ?>">
+                       value="<?php echo get_setting('custom_title'); ?>">
             </div>
         </div>
     </div>
@@ -315,7 +329,9 @@
                 id="monospace_amounts">
             <option value="0"><?php echo trans('no'); ?></option>
             <option value="1"
-                    <?php if ($this->mdl_settings->setting('monospace_amounts') == 1) { ?>selected="selected"<?php } ?>><?php echo trans('yes'); ?></option>
+                    <?php check_select(get_setting('monospace_amounts')); ?>>
+                <?php echo trans('yes'); ?>
+            </option>
         </select>
 
         <p class="help-block">
@@ -330,8 +346,8 @@
         <label class="control-label">
             <?php echo trans('login_logo'); ?>
         </label>
-        <?php if ($this->mdl_settings->setting('login_logo')) { ?>
-            <img src="<?php echo base_url(); ?>uploads/<?php echo $this->mdl_settings->setting('login_logo'); ?>"><br>
+        <?php if (get_setting('login_logo')) { ?>
+            <img src="<?php echo base_url(); ?>uploads/<?php echo get_setting('login_logo'); ?>"><br>
             <?php echo anchor('settings/remove_logo/login', 'Remove Logo'); ?><br>
         <?php } ?>
         <input type="file" name="login_logo" size="40" class=" form-control"/>
@@ -348,7 +364,9 @@
         <select name="settings[bcc_mails_to_admin]" class=" form-control simple-select">
             <option value="0"><?php echo trans('no'); ?></option>
             <option value="1"
-                    <?php if ($this->mdl_settings->setting('bcc_mails_to_admin') == 1) { ?>selected="selected"<?php } ?>><?php echo trans('yes'); ?></option>
+                    <?php check_select(get_setting('bcc_mails_to_admin')); ?>>
+                <?php echo trans('yes'); ?>
+            </option>
         </select>
 
         <p class="help-block"><?php echo trans('bcc_mails_to_admin_hint'); ?></p>
@@ -363,7 +381,7 @@
             <div class="col-xs-8 col-sm-9">
                 <input type="text" name="settings[cron_key]" id="cron_key"
                        class=" form-control"
-                       value="<?php echo $this->mdl_settings->setting('cron_key'); ?>">
+                       value="<?php echo get_setting('cron_key'); ?>">
             </div>
             <div class="col-xs-4 col-sm-3">
                 <input id="btn_generate_cron_key" value="<?php echo trans('generate'); ?>"

+ 64 - 77