Browse Source

Merge pull request #492 from InvoicePlane/v1.5.2

v1.5.2
Kovah 2 years ago
parent
commit
3cd04a62bf
53 changed files with 503 additions and 210 deletions
  1. 3 3
      README.md
  2. 2 2
      application/core/MY_Model.php
  3. 2 2
      application/core/User_Controller.php
  4. 2 2
      application/helpers/date_helper.php
  5. 28 11
      application/helpers/diacritics_helper.php
  6. 4 3
      application/helpers/invoice_helper.php
  7. 6 4
      application/helpers/mailer_helper.php
  8. 2 3
      application/helpers/mpdf_helper.php
  9. 3 2
      application/helpers/pdf_helper.php
  10. 1 1
      application/helpers/redirect_helper.php
  11. 8 6
      application/helpers/trans_helper.php
  12. 1 0
      application/language/english/gateway_lang.php
  13. 6 1
      application/language/english/ip_lang.php
  14. 3 0
      application/libraries/Sumex.php
  15. 15 1
      application/libraries/ZugferdXml.php
  16. 4 4
      application/modules/clients/controllers/Ajax.php
  17. 9 9
      application/modules/clients/models/Mdl_clients.php
  18. 1 1
      application/modules/custom_fields/models/Mdl_custom_fields.php
  19. 3 3
      application/modules/custom_values/models/Mdl_custom_values.php
  20. 3 2
      application/modules/guest/controllers/Payment_Handler.php
  21. 18 10
      application/modules/guest/controllers/Payment_Information.php
  22. 3 1
      application/modules/guest/controllers/View.php
  23. 173 39
      application/modules/guest/views/payment_information.php
  24. 2 1
      application/modules/import/models/Mdl_import.php
  25. 3 1
      application/modules/invoices/controllers/Cron.php
  26. 1 2
      application/modules/invoices/models/Mdl_invoices.php
  27. 3 1
      application/modules/invoices/views/partial_item_table.php
  28. 4 1
      application/modules/layout/views/includes/head.php
  29. 4 4
      application/modules/layout/views/includes/navbar.php
  30. 12 4
      application/modules/mailer/controllers/Mailer.php
  31. 12 2
      application/modules/mailer/helpers/phpmailer_helper.php
  32. 3 0
      application/modules/quotes/models/Mdl_quotes.php
  33. 13 5
      application/modules/reports/models/Mdl_reports.php
  34. 2 1
      application/modules/reports/views/invoice_aging_index.php
  35. 2 1
      application/modules/reports/views/payment_history_index.php
  36. 2 1
      application/modules/reports/views/sales_by_client_index.php
  37. 2 1
      application/modules/reports/views/sales_by_year_index.php
  38. 0 24
      application/modules/settings/controllers/Settings.php
  39. 3 1
      application/modules/settings/models/Mdl_settings.php
  40. 15 3
      application/modules/settings/views/partial_settings_email.php
  41. 17 0
      application/modules/settings/views/partial_settings_general.php
  42. 1 1
      application/modules/setup/controllers/Setup.php
  43. 1 1
      application/modules/setup/models/Mdl_setup.php
  44. 1 0
      application/modules/setup/sql/025_1.5.2.sql
  45. 5 3
      application/modules/setup/views/create_user.php
  46. 3 1
      application/modules/tasks/views/form.php
  47. 2 2
      application/modules/upload/controllers/Upload.php
  48. 2 1
      application/modules/users/views/form.php
  49. 6 3
      application/modules/users/views/form_change_password.php
  50. 9 4
      application/views/reports/sales_by_year.php
  51. 2 1
      composer.json
  52. 59 11
      composer.lock
  53. 12 19
      index.php

+ 3 - 3
README.md

@@ -1,5 +1,5 @@
 ![InvoicePlane](http://invoiceplane.com/content/logo/PNG/logo_300x150.png)
-#### _Version 1.5.1_
+#### _Version 1.5.2_
 
 InvoicePlane is a self-hosted open source application for managing your invoices, clients and payments.    
 For more information visit __[InvoicePlane.com](https://invoiceplane.com)__ or try the __[demo](https://demo.invoiceplane.com)__.
@@ -15,11 +15,11 @@ For more information visit __[InvoicePlane.com](https://invoiceplane.com)__ or t
 5. Open `http://your-invoiceplane-domain.com/index.php/setup` and follow the instructions.
 
 
-_Notice: We strongly disadvise to download the InvoicePlane package from Github, except you are a Developer who wants to help us. If you are a developer, read the [development guide](DEVELOPMENT.md)._
+_Notice: Please download InvoicePlane from our [website](https://invoiceplane.com/downloads) only as the packages contain additional needed components. If you are a developer, read the [development guide](DEVELOPMENT.md)._
 
 #### Remove `index.php` from the URL
 
-If you want to remove `index.php` from the URL, follow these instructions. However, this is not a requirement for InvoicePlane to run. If it's not working correctly, move back and use the application with out removint that part from the URL.
+If you want to remove `index.php` from the URL, follow these instructions. However, this is not a requirement for InvoicePlane to run. If it's not working correctly, take a step back and use the application with out removing that part from the URL.
 
 1. Make sure that [mod_rewrite](https://go.invoiceplane.com/apachemodrewrite) is enabled on your web server.
 2. Set the `REMOVE_INDEXPHP` setting in your `ipconfig.php` to `true`.

+ 2 - 2
application/core/MY_Model.php

@@ -319,7 +319,7 @@ class MY_Model extends CI_Model
      * Used to retrieve record by ID and populate $this->form_values
      *
      * @param int $id
-     * @return boolean
+     * @return boolean|null
      */
     public function prep_form($id = null)
     {
@@ -396,7 +396,7 @@ class MY_Model extends CI_Model
     }
 
     /**
-     * @param $key
+     * @param string $key
      * @param $value
      */
     public function set_form_value($key, $value)

+ 2 - 2
application/core/User_Controller.php

@@ -17,8 +17,8 @@ class User_Controller extends Base_Controller
 {
     /**
      * User_Controller constructor.
-     * @param $required_key
-     * @param $required_val
+     * @param string $required_key
+     * @param integer $required_val
      */
     public function __construct($required_key, $required_val)
     {

+ 2 - 2
application/helpers/date_helper.php

@@ -128,7 +128,7 @@ function is_date($date)
 }
 
 /**
- * @return mixed
+ * @return string
  */
 function date_format_setting()
 {
@@ -142,7 +142,7 @@ function date_format_setting()
 }
 
 /**
- * @return mixed
+ * @return string
  */
 function date_format_datepicker()
 {

+ 28 - 11
application/helpers/diacritics_helper.php

@@ -11,7 +11,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
  */
 
 /**
- * @param $str
+ * @param string $str
  * @return bool
  */
 function diacritics_seems_utf8($str)
@@ -19,16 +19,32 @@ function diacritics_seems_utf8($str)
     $length = strlen($str);
     for ($i = 0; $i < $length; $i++) {
         $c = ord($str[$i]);
-        if ($c < 0x80) $n = 0; # 0bbbbbbb
-        elseif (($c & 0xE0) == 0xC0) $n = 1; # 110bbbbb
-        elseif (($c & 0xF0) == 0xE0) $n = 2; # 1110bbbb
-        elseif (($c & 0xF8) == 0xF0) $n = 3; # 11110bbb
-        elseif (($c & 0xFC) == 0xF8) $n = 4; # 111110bb
-        elseif (($c & 0xFE) == 0xFC) $n = 5; # 1111110b
-        else return false; # Does not match any model
+        if ($c < 0x80) {
+            $n = 0;
+        } # 0bbbbbbb
+        elseif (($c & 0xE0) == 0xC0) {
+            $n = 1;
+        } # 110bbbbb
+        elseif (($c & 0xF0) == 0xE0) {
+            $n = 2;
+        } # 1110bbbb
+        elseif (($c & 0xF8) == 0xF0) {
+            $n = 3;
+        } # 11110bbb
+        elseif (($c & 0xFC) == 0xF8) {
+            $n = 4;
+        } # 111110bb
+        elseif (($c & 0xFE) == 0xFC) {
+            $n = 5;
+        } # 1111110b
+        else {
+            return false;
+        }
+        # Does not match any model
         for ($j = 0; $j < $n; $j++) { # n bytes matching 10bbbbbb follow ?
-            if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80))
+            if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80)) {
                 return false;
+            }
         }
     }
     return true;
@@ -44,8 +60,9 @@ function diacritics_seems_utf8($str)
  */
 function diacritics_remove_accents($string)
 {
-    if (!preg_match('/[\x80-\xff]/', $string))
+    if (!preg_match('/[\x80-\xff]/', $string)) {
         return $string;
+    }
 
     if (diacritics_seems_utf8($string)) {
         $chars = array(
@@ -174,7 +191,7 @@ function diacritics_remove_accents($string)
 }
 
 /**
- * @param $text
+ * @param string $text
  * @return string
  */
 function diacritics_remove_diacritics($text)

+ 4 - 3
application/helpers/invoice_helper.php

@@ -47,9 +47,9 @@ function invoice_logo_pdf()
  * Returns a Swiss IS / IS+ code line
  * Documentation: https://www.postfinance.ch/binp/postfinance/public/dam.M26m_i6_6ceYcN2XtAN4w8OHMynQG7FKxJVK8TtQzr0.spool/content/dam/pf/de/doc/consult/manual/dlserv/inpayslip_isr_man_en.pdf
  *
- * @param $slipType
+ * @param string $slipType
  * @param $amount
- * @param $rnumb
+ * @param string $rnumb
  * @param $subNumb
  * @return string
  * @throws Error
@@ -89,7 +89,8 @@ function invoice_genCodeline($slipType, $amount, $rnumb, $subNumb)
  * See https://www.postfinance.ch/binp/postfinance/public/dam.Ii-X5NgtAixO8cQPvja46blV6d7cZCyGUscxO15L5S8.spool/content/dam/pf/de/doc/consult/manual/dldata/efin_recdescr_man_en.pdf
  * Page 5
  *
- * @return string
+ * @param string $in
+ * @return integer
  */
 function invoice_recMod10($in)
 {

+ 6 - 4
application/helpers/mailer_helper.php

@@ -33,7 +33,7 @@ function mailer_configured()
  * @param $from
  * @param $to
  * @param $subject
- * @param $body
+ * @param string $body
  * @param null $cc
  * @param null $bcc
  * @param null $attachments
@@ -75,7 +75,7 @@ function email_invoice($invoice_id, $invoice_template, $from, $to, $subject, $bo
  * @param $from
  * @param $to
  * @param $subject
- * @param $body
+ * @param string $body
  * @param null $cc
  * @param null $bcc
  * @param null $attachments
@@ -107,7 +107,7 @@ function email_quote($quote_id, $quote_template, $from, $to, $subject, $body, $c
 /**
  * Send an email if the status of an email changed
  * @param $quote_id
- * @param $status string "accepted" or "rejected"
+ * @param string $status string "accepted" or "rejected"
  * @return bool if the email was sent
  */
 function email_quote_status($quote_id, $status)
@@ -115,7 +115,9 @@ function email_quote_status($quote_id, $status)
     ini_set('display_errors', 'on');
     error_reporting(E_ALL);
 
-    if (!mailer_configured()) return false;
+    if (!mailer_configured()) {
+        return false;
+    }
 
     $CI = &get_instance();
     $CI->load->helper('mailer/phpmailer');

+ 2 - 3
application/helpers/mpdf_helper.php

@@ -14,10 +14,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
  * Create a PDF
  *
  * @param $html
- * @param $filename
+ * @param string $filename
  * @param bool $stream
  * @param null $password
- * @param null $isInvoice
+ * @param boolean $isInvoice
  * @param null $is_guest
  * @param bool $zugferd_invoice
  * @param null $associated_files
@@ -36,7 +36,6 @@ function pdf_create($html, $filename, $stream = true, $password = null, $isInvoi
         define('_MPDF_TTFONTDATAPATH', FCPATH . 'uploads/temp/mpdf/');
     }
 
-    require_once(FCPATH . 'vendor/autoload.php');
     $mpdf = new \Mpdf\Mpdf();
 
     // mPDF configuration

+ 3 - 2
application/helpers/pdf_helper.php

@@ -43,7 +43,9 @@ function generate_invoice_pdf($invoice_id, $stream = true, $invoice_template = n
     }
 
     $payment_method = $CI->mdl_payment_methods->where('payment_method_id', $invoice->payment_method)->get()->row();
-    if ($invoice->payment_method == 0) $payment_method = false;
+    if ($invoice->payment_method == 0) {
+        $payment_method = false;
+    }
 
     // Determine if discounts should be displayed
     $items = $CI->mdl_items->where('invoice_id', $invoice_id)->get()->result();
@@ -115,7 +117,6 @@ function generate_invoice_sumex($invoice_id, $stream = true, $client = false)
     // Append a copy at the end and change the title:
     // WARNING: The title depends on what invoice type is (TP, TG)
     // and is language-dependant. Fix accordingly if you really need this hack
-    require FCPATH . '/vendor/autoload.php';
     $temp = tempnam("/tmp", "invsumex_");
     $tempCopy = tempnam("/tmp", "invsumex_");
     $pdf = new FPDI();

+ 1 - 1
application/helpers/redirect_helper.php

@@ -13,7 +13,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * Redirect the user to a given URL
  *
- * @param $fallback_url_string
+ * @param string $fallback_url_string
  * @param bool $redirect
  * @return mixed
  */

+ 8 - 6
application/helpers/trans_helper.php

@@ -57,13 +57,14 @@ function set_language($language)
     $CI->lang->language = array();
 
     // Load system language if no custom language is set
-    $language = $language == 'system' ? $CI->mdl_settings->setting('default_language') : $language;
+    $default_lang = isset($CI->mdl_settings) ? $CI->mdl_settings->setting('default_language') : 'english';
+    $new_language = ($language == 'system' ? $default_lang : $language);
 
     // Set the new language
-    $CI->lang->load('ip', $language);
-    $CI->lang->load('form_validation', $language);
-    $CI->lang->load('custom', $language);
-    $CI->lang->load('gateway', $language);
+    $CI->lang->load('ip', $new_language);
+    $CI->lang->load('form_validation', $new_language);
+    $CI->lang->load('custom', $new_language);
+    $CI->lang->load('gateway', $new_language);
 }
 
 /**
@@ -79,7 +80,8 @@ function reset_language()
     $CI->lang->language = array();
 
     // Reset to the default language
-    $default_lang = $CI->mdl_settings->setting('default_language');
+    $default_lang = isset($CI->mdl_settings) ? $CI->mdl_settings->setting('default_language') : 'english';
+
     $CI->lang->load('ip', $default_lang);
     $CI->lang->load('form_validation', $default_lang);
     $CI->lang->load('custom', $default_lang);

+ 1 - 0
application/language/english/gateway_lang.php

@@ -7,6 +7,7 @@ $lang = array(
     'online_payment'                     => 'Online Payment',
     'online_payments'                    => 'Online Payments',
     'online_payment_for'                 => 'Online Payment for',
+    'online_payment_for_invoice'         => 'Online Payment for Invoice',
     'online_payment_method'              => 'Online Payment Method',
     'online_payment_creditcard_hint'     => 'If you want to pay via credit card please enter the information below.<br/>The credit card information are not stored on our servers and will be transferred to the online payment gateway using a secure connection.',
     'enable_online_payments'             => 'Enable Online Payments',

+ 6 - 1
application/language/english/ip_lang.php

@@ -49,7 +49,7 @@ $lang = array(
     'calendar_week_4'                              => '4 Weeks',
     'calendar_month_1'                             => '1 Month',
     'calendar_month_2'                             => '2 Months',
-    'calendar_month_3'                             => '2 Months',
+    'calendar_month_3'                             => '3 Months',
     'calendar_month_4'                             => '4 Months',
     'calendar_month_5'                             => '5 Months',
     'calendar_month_6'                             => '6 Months',
@@ -173,6 +173,7 @@ $lang = array(
     'email_template_tags'                          => 'Email Template Tags',
     'email_template_tags_instructions'             => 'Template tags can be used to add dynamic information like the client name or an invoice number to the email template. Click on the Body textfield and then select a tag from the drop down. It will be automatically inserted into the textfield.',
     'email_templates'                              => 'Email Templates',
+    'enabled'                                      => 'Enabled',
     'enable_debug_mode'                            => 'Enable the Debug Mode',
     'end_date'                                     => 'End Date',
     'enter_payment'                                => 'Enter Payment',
@@ -310,6 +311,7 @@ $lang = array(
     'open'                                         => 'Open',
     'open_invoices'                                => 'Open Invoices',
     'open_quotes'                                  => 'Open Quotes',
+    'open_reports_in_new_tab'                      => 'Open Reports in a new Browser Tab',
     'optional'                                     => 'Optional',
     'options'                                      => 'Options',
     'order'                                        => 'Order',
@@ -325,6 +327,7 @@ $lang = array(
     'password_reset_info'                          => 'You will get an Email with a link to reset your password.',
     'password_reset_failed'                        => 'An error occurred while trying to send your password reset email. Please review the application logs or contact the system administrator.',
     'pay_now'                                      => 'Pay Now',
+    'pay_now_for'                                  => 'Pay Now for',
     'payment'                                      => 'Payment',
     'payment_cannot_exceed_balance'                => 'Payment amount cannot exceed invoice balance.',
     'payment_date'                                 => 'Payment Date',
@@ -480,6 +483,7 @@ $lang = array(
     'smtp_ssl'                                     => 'SSL',
     'smtp_tls'                                     => 'TLS',
     'smtp_username'                                => 'SMTP Username',
+    'smtp_verify_certs'                            => 'Verify SMTP certificates',
     'sql_file'                                     => 'SQL File',
     'start_date'                                   => 'Start Date',
     'state'                                        => 'State',
@@ -566,6 +570,7 @@ $lang = array(
     'year_prefix'                                  => 'Year Prefix',
     'years'                                        => 'Years',
     'yes'                                          => 'Yes',
+    'zip'                                          => 'Zip Code',
     'zip_code'                                     => 'Zip Code',
 
     //Time Management

+ 3 - 0
application/libraries/Sumex.php

@@ -625,6 +625,9 @@ class Sumex
         return $node;
     }
 
+    /**
+     * @param integer $recordId
+     */
     protected function generateRecord($recordId, $item)
     {
         $node = $this->doc->createElement('invoice:record_other');

+ 15 - 1
application/libraries/ZugferdXml.php

@@ -88,6 +88,9 @@ class ZugferdXml
         return $el;
     }
 
+    /**
+     * @return string|null
+     */
     function zugferdFormattedDate($date)
     {
         if ($date && $date <> '0000-00-00') {
@@ -155,6 +158,9 @@ class ZugferdXml
         return $node;
     }
 
+    /**
+     * @param string $schemeID
+     */
     protected function xmlSpecifiedTaxRegistration($schemeID, $content)
     {
         $node = $this->doc->createElement('ram:SpecifiedTaxRegistration');
@@ -200,7 +206,9 @@ class ZugferdXml
     {
         $result = [];
         foreach ($this->items as $item) {
-            if ($item->item_tax_rate_percent == 0) continue;
+            if ($item->item_tax_rate_percent == 0) {
+                continue;
+            }
 
             if (!isset($result[$item->item_tax_rate_percent])) {
                 $result[$item->item_tax_rate_percent] = 0;
@@ -221,6 +229,9 @@ class ZugferdXml
         return $node;
     }
 
+    /**
+     * @param string $name
+     */
     protected function currencyElement($name, $amount, $nb_decimals = 2)
     {
         $el = $this->doc->createElement($name, $this->zugferdFormattedFloat($amount, $nb_decimals));
@@ -300,6 +311,9 @@ class ZugferdXml
         return $node;
     }
 
+    /**
+     * @param string $name
+     */
     protected function quantityElement($name, $quantity)
     {
         $el = $this->doc->createElement($name, $this->zugferdFormattedFloat($quantity, 4));

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

@@ -34,12 +34,12 @@ class Ajax extends Admin_Controller
 
         // Search for clients
         $escapedQuery = $this->db->escape_str($query);
-        $escapedQuery = str_replace("%","",$escapedQuery);
+        $escapedQuery = str_replace("%", "", $escapedQuery);
         $clients = $this->mdl_clients
             ->where('client_active', 1)
-            ->having('client_name LIKE \''.$escapedQuery.'%\'')
-            ->or_having('client_surname LIKE \''.$escapedQuery.'%\'')
-            ->or_having('client_fullname LIKE \''.$escapedQuery.'%\'')
+            ->having('client_name LIKE \'' . $escapedQuery . '%\'')
+            ->or_having('client_surname LIKE \'' . $escapedQuery . '%\'')
+            ->or_having('client_fullname LIKE \'' . $escapedQuery . '%\'')
             ->order_by('client_name')
             ->get()
             ->result();

+ 9 - 9
application/modules/clients/models/Mdl_clients.php

@@ -23,9 +23,9 @@ class Mdl_Clients extends Response_Model
     public function default_select()
     {
         $this->db->select(
-          'SQL_CALC_FOUND_ROWS '.$this->table.'.*, '.
-          'CONCAT('.$this->table.'.client_name, " ", '.$this->table.'.client_surname) as client_fullname'
-        , false);
+            'SQL_CALC_FOUND_ROWS ' . $this->table . '.*, ' .
+            'CONCAT(' . $this->table . '.client_name, " ", ' . $this->table . '.client_surname) as client_fullname'
+            , false);
     }
 
     public function default_order_by()
@@ -220,12 +220,6 @@ class Mdl_Clients extends Response_Model
         return $this;
     }
 
-    public function is_active()
-    {
-        $this->filter_where('client_active', 1);
-        return $this;
-    }
-
     public function is_inactive()
     {
         $this->filter_where('client_active', 0);
@@ -255,4 +249,10 @@ class Mdl_Clients extends Response_Model
         return $this->get()->result();
     }
 
+    public function is_active()
+    {
+        $this->filter_where('client_active', 1);
+        return $this;
+    }
+
 }

+ 1 - 1
application/modules/custom_fields/models/Mdl_custom_fields.php

@@ -31,7 +31,7 @@ class Mdl_Custom_Fields extends MY_Model
     }
 
     /**
-     * @return array
+     * @return string[]
      */
     public static function custom_types()
     {

+ 3 - 3
application/modules/custom_values/models/Mdl_custom_values.php

@@ -19,7 +19,7 @@ class Mdl_Custom_Values extends MY_Model
     public $primary_key = 'ip_custom_values.custom_values_id';
 
     /**
-     * @return array
+     * @return string[]
      */
     public static function custom_types()
     {
@@ -27,7 +27,7 @@ class Mdl_Custom_Values extends MY_Model
     }
 
     /**
-     * @return array
+     * @return string[]
      */
     public static function user_input_types()
     {
@@ -39,7 +39,7 @@ class Mdl_Custom_Values extends MY_Model
     }
 
     /**
-     * @return array
+     * @return string[]
      */
     public static function custom_value_fields()
     {

+ 3 - 2
application/modules/guest/controllers/Payment_Handler.php

@@ -166,7 +166,9 @@ class Payment_Handler extends Base_Controller
             $key = str_replace('gateway_' . $d, '', $key);
 
             // skip empty key
-            if (!$key) continue;
+            if (!$key) {
+                continue;
+            }
 
             // Decode password fields and checkboxes
             if (isset($gateway_settings[$key]) && $gateway_settings[$key]['type'] == 'password') {
@@ -181,7 +183,6 @@ class Payment_Handler extends Base_Controller
         }
 
         // Load Omnipay and initialize the gateway
-        require_once(FCPATH . 'vendor/autoload.php');
         $gateway = \Omnipay\Omnipay::create($driver);
         $gateway->initialize($gateway_init);
 

+ 18 - 10
application/modules/guest/controllers/Payment_Information.php

@@ -17,7 +17,7 @@ if (!defined('BASEPATH')) {
  * 
  */
 
-class Payment_Information extends Guest_Controller
+class Payment_Information extends Base_Controller
 {
     public function __construct()
     {
@@ -28,11 +28,11 @@ class Payment_Information extends Guest_Controller
 
     public function form($invoice_url_key)
     {
+        $this->load->model('payment_methods/mdl_payment_methods');
         $disable_form = false;
 
         // Check if the invoice exists and is billable
         $invoice = $this->mdl_invoices->where('ip_invoices.invoice_url_key', $invoice_url_key)
-            ->where_in('ip_invoices.client_id', $this->user_clients)
             ->get()->row();
 
         if (!$invoice) {
@@ -65,16 +65,24 @@ class Payment_Information extends Guest_Controller
             }
         }
 
-        $this->layout->set(
-            array(
-                'disable_form' => $disable_form,
-                'invoice' => $invoice,
-                'gateways' => $available_drivers,
-            )
+        // Get additional invoice information
+        $payment_method = $this->mdl_payment_methods->where('payment_method_id', $invoice->payment_method)->get()->row();
+        if ($invoice->payment_method == 0) {
+            $payment_method = null;
+        }
+
+        $is_overdue = ($invoice->invoice_balance > 0 && strtotime($invoice->invoice_date_due) < time() ? true : false);
+
+        // Return the view
+        $view_data = array(
+            'disable_form' => $disable_form,
+            'invoice' => $invoice,
+            'gateways' => $available_drivers,
+            'payment_method' => $payment_method,
+            'is_overdue' => $is_overdue,
         );
 
-        $this->layout->buffer('content', 'guest/payment_information');
-        $this->layout->render('layout_guest');
+        $this->load->view('guest/payment_information', $view_data);
 
     }
 

+ 3 - 1
application/modules/guest/controllers/View.php

@@ -36,7 +36,9 @@ class View extends Base_Controller
             }
 
             $payment_method = $this->mdl_payment_methods->where('payment_method_id', $invoice->payment_method)->get()->row();
-            if ($invoice->payment_method == 0) $payment_method = null;
+            if ($invoice->payment_method == 0) {
+                $payment_method = null;
+            }
 
             // Attachments
             $attachments = $this->get_attachments($invoice_url_key);

+ 173 - 39
application/modules/guest/views/payment_information.php

@@ -1,40 +1,157 @@
-<script>
-    $('.simple-select').select2();
-</script>
-
-<div id="headerbar">
-    <h1 class="headerbar-title"><?php _trans('online_payment_for'); ?> #<?php echo $invoice->invoice_number; ?></h1>
-
-    <div class="headerbar-item pull-right">
-        <a href="<?php echo site_url('guest/invoices/generate_pdf/'); ?>"
-           class="btn btn-sm btn-default">
-            <i class="fa fa-print"></i> <?php _trans('download_pdf'); ?>
-        </a>
+<!doctype html lang="<?php _trans('cldr'); ?>">
+
+<!--[if lt IE 7]>
+<html class="no-js ie6 oldie" lang="<?php _trans('cldr'); ?>"> <![endif]-->
+<!--[if IE 7]>
+<html class="no-js ie7 oldie" lang="<?php _trans('cldr'); ?>"> <![endif]-->
+<!--[if IE 8]>
+<html class="no-js ie8 oldie" lang="<?php _trans('cldr'); ?>"> <![endif]-->
+<!--[if gt IE 8]><!-->
+<html class="no-js" lang="<?php _trans('cldr'); ?>"> <!--<![endif]-->
+
+<head>
+    <title>
+        <?php
+        if (get_setting('custom_title') != '') {
+            echo get_setting('custom_title', '', true);
+        } else {
+            echo 'InvoicePlane';
+        } ?>
+    </title>
+
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport" content="width=device-width,initial-scale=1">
+    <meta name="robots" content="NOINDEX,NOFOLLOW">
+    <meta name="_csrf" content="<?php echo $this->security->get_csrf_hash() ?>">
+
+    <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/core/css/custom.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]>
+    <script src="<?php echo base_url(); ?>assets/core/js/legacy.min.js"></script>
+    <![endif]-->
+
+    <script src="<?php echo base_url(); ?>assets/core/js/dependencies.min.js"></script>
+
+    <script>
+        $('.simple-select').select2();
+    </script>
+
+</head>
+<body>
+
+<nav class="navbar navbar-default ">
+    <div class="container">
+
+        <div class="navbar-brand">
+            <?php _trans('online_payment_for_invoice'); ?> #<?php echo $invoice->invoice_number; ?>
+        </div>
+
+        <ul class="nav navbar-nav navbar-right">
+            <li>
+                <a href="<?php echo site_url('guest/invoices/generate_pdf/'); ?>">
+                    <i class="fa fa-print"></i> <?php _trans('download_pdf'); ?>
+                </a>
+            </li>
+        </ul>
+
     </div>
+</nav>
 
-</div>
+<div class="container">
 
-<div id="content">
+    <div class="row">
+        <div class="col-xs-12 col-md-8 col-md-offset-2">
 
-    <?php echo $this->layout->load_view('layout/alerts'); ?>
+            <br>
+            <?php
+            $logo = invoice_logo();
+            if ($logo) {
+                echo $logo . '<br><br>';
+            }
+            ?>
 
-    <?php if ($disable_form === false) { ?>
+            <?php echo $this->layout->load_view('layout/alerts'); ?>
+
+            <div class="panel panel-default">
+
+                <div class="panel-body">
+
+                    <div class="row">
+                        <div class="col-xs-12 col-md-7">
+                            <h4>
+                                <?php _htmlsc(format_client($invoice)) ?>
+                            </h4>
+                            <div class="client-address">
+                                <?php $this->layout->load_view('clients/partial_client_address', array('client' => $invoice)); ?>
+                            </div>
+                        </div>
+
+                        <div class="col-xs-12 col-md-5">
+                            <div class="hidden-md hidden-lg"><br></div>
+                            <div class="table-responsive">
+                                <table class="table table-bordered table-condensed no-margin">
+                                    <tbody>
+                                    <tr>
+                                        <td><?php echo trans('invoice_date'); ?></td>
+                                        <td style="text-align:right;"><?php echo date_from_mysql($invoice->invoice_date_created); ?></td>
+                                    </tr>
+                                    <tr class="<?php echo($is_overdue ? 'overdue' : '') ?>">
+                                        <td><?php echo trans('due_date'); ?></td>
+                                        <td class="text-right">
+                                            <?php echo date_from_mysql($invoice->invoice_date_due); ?>
+                                        </td>
+                                    </tr>
+                                    <tr class="<?php echo($is_overdue ? 'overdue' : '') ?>">
+                                        <td><?php echo trans('total'); ?></td>
+                                        <td style="text-align:right;"><?php echo format_currency($invoice->invoice_total); ?></td>
+                                    </tr>
+                                    <tr class="<?php echo($is_overdue ? 'overdue' : '') ?>">
+                                        <td><?php echo trans('balance'); ?></td>
+                                        <td style="text-align:right;"><?php echo format_currency($invoice->invoice_balance); ?></td>
+                                    </tr>
+                                    <?php if ($payment_method): ?>
+                                        <tr>
+                                            <td><?php echo trans('payment_method') . ': '; ?></td>
+                                            <td><?php _htmlsc($payment_method->payment_method_name); ?></td>
+                                        </tr>
+                                    <?php endif; ?>
+                                    </tbody>
+                                </table>
+                            </div>
+                        </div>
+                        <?php if (!empty($invoice->invoice_terms)) : ?>
+                            <div class="col-xs-12 text-muted">
+                                <br>
+                                <h4><?php echo trans('terms'); ?></h4>
+                                <div><?php echo nl2br(htmlsc($invoice->invoice_terms)); ?></div>
+                            </div>
+                        <?php endif; ?>
+                    </div>
 
-        <h4><?php _trans('total') . ': ' . format_currency($invoice->invoice_total); ?></h4>
-        <br>
-        <h4><?php _trans('balance') . ': ' . format_currency($invoice->invoice_balance); ?></h4>
-        <hr>
+                </div>
+            </div>
 
-        <form action="<?php echo site_url('guest/payment_handler/make_payment/'); ?>"
-              method="post" id="payment-information-form">
+            <?php if ($disable_form === false) { ?>
+                <br>
 
-            <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
+                <form action="<?php echo site_url('guest/payment_handler/make_payment/'); ?>"
+                      method="post" id="payment-information-form">
 
-            <div class="row">
-                <div class="col-xs-12 col-sm-8 col-md-6">
+                    <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
 
                     <div class="form-group">
-                        <input type="hidden" name="invoice_url_key" value="<?php echo $invoice->invoice_url_key; ?>">
+                        <input type="hidden" name="invoice_url_key"
+                               value="<?php echo $invoice->invoice_url_key; ?>">
 
                         <label for="gateway-select"><?php _trans('online_payment_method'); ?></label>
                         <select name="gateway" id="gateway-select" class="form-control simple-select">
@@ -55,8 +172,10 @@
                         </div>
 
                         <div class="panel-body">
-                            <div class="alert alert-info">
-                                <?php _trans('online_payment_creditcard_hint'); ?>
+                            <div class="form-group">
+                                <div class="alert alert-info no-margin">
+                                    <?php _trans('online_payment_creditcard_hint'); ?>
+                                </div>
                             </div>
 
                             <div class="form-group">
@@ -82,7 +201,8 @@
                                         <label class="control-label">
                                             <?php _trans('creditcard_expiry_year'); ?>
                                         </label>
-                                        <input type="number" name="creditcard_expiry_year" class="input-sm form-control"
+                                        <input type="number" name="creditcard_expiry_year"
+                                               class="input-sm form-control"
                                                min="<?php echo date('Y'); ?>" max="<?php echo date('Y') + 20; ?>">
                                     </div>
                                 </div>
@@ -99,17 +219,31 @@
 
                     </div>
 
-                </div>
-            </div>
 
-            <div class="form-group">
-                <button class="btn btn-success ajax-loader" type="submit">
-                    <i class="fa fa-credit-card fa-margin">&nbsp;</i><?php _trans('pay_now'); ?>
-                </button>
-            </div>
+                    <div class="form-group">
+                        <button class="btn btn-success btn-lg ajax-loader" type="submit">
+                            <i class="fa fa-credit-card fa-margin"></i>
+                            <?php echo trans('pay_now_for') . ' ' . format_currency($invoice->invoice_balance); ?>
+                        </button>
+                    </div>
 
-        </form>
+                </form>
 
-    <?php } ?>
+            <?php } ?>
+
+        </div>
+    </div>
+
+</div>
+
+<div id="modal-placeholder"></div>
+
+<?php echo $this->layout->load_view('layout/includes/fullpage-loader'); ?>
+
+<script defer src="<?php echo base_url(); ?>assets/core/js/scripts.min.js"></script>
+<?php if (trans('cldr') != 'en') { ?>
+    <script src="<?php echo base_url(); ?>assets/core/js/locales/bootstrap-datepicker.<?php _trans('cldr'); ?>.js"></script>
+<?php } ?>
 
-</div>
+</body>
+</html>

+ 2 - 1
application/modules/import/models/Mdl_import.php

@@ -124,8 +124,9 @@ class Mdl_Import extends Response_Model
             $fileheaders = null;
             if ($row == 1) {
                 foreach ($headers as $header) {
-                    if (!in_array($header, $data))
+                    if (!in_array($header, $data)) {
                         return false;
+                    }
                 }
                 $fileheaders = $data;
             } elseif ($row > 1) {

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

@@ -22,7 +22,9 @@ class Cron extends Base_Controller
     {
         // Check the provided cron key
         if ($cron_key != get_setting('cron_key')) {
-            if (IP_DEBUG) log_message('error', 'Wrong cron key provided!');
+            if (IP_DEBUG) {
+                log_message('error', 'Wrong cron key provided!');
+            }
             exit('Wrong cron key!');
         }
 

+ 1 - 2
application/modules/invoices/models/Mdl_invoices.php

@@ -358,7 +358,7 @@ class Mdl_Invoices extends Response_Model
     }
 
     /**
-     * @param $invoice_date_created
+     * @param string $invoice_date_created
      * @return string
      */
     public function get_date_due($invoice_date_created)
@@ -408,7 +408,6 @@ class Mdl_Invoices extends Response_Model
     }
 
     /**
-     * @param int $invoice_id
      * @return mixed
      */
     public function get_custom_values($id)

+ 3 - 1
application/modules/invoices/views/partial_item_table.php

@@ -128,7 +128,9 @@
                             echo 'disabled="disabled"';
                         } ?>>
                     <input type="hidden" name="item_task_id" class="item-task-id"
-                           value="<?php if ($item->item_task_id) echo $item->item_task_id; ?>">
+                           value="<?php if ($item->item_task_id) {
+                               echo $item->item_task_id;
+                           } ?>">
                     <input type="hidden" name="item_product_id" value="<?php echo $item->item_product_id; ?>">
 
                     <div class="input-group">

+ 4 - 1
application/modules/layout/views/includes/head.php

@@ -72,7 +72,10 @@
         $(document).on('click', '#btn_copy_quote', function () {
             var quote_id = $(this).data('quote-id');
             var client_id = $(this).data('client-id');
-            $('#modal-placeholder').load("<?php echo site_url('quotes/ajax/modal_copy_quote'); ?>", {quote_id: quote_id, client_id: client_id});
+            $('#modal-placeholder').load("<?php echo site_url('quotes/ajax/modal_copy_quote'); ?>", {
+                quote_id: quote_id,
+                client_id: client_id
+            });
         });
 
         $(document).on('click', '.client-create-invoice', function () {

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

@@ -153,16 +153,16 @@
                         $this->session->userdata('user_id')); ?>"
                        class="tip icon" data-placement="bottom"
                        title="<?php
-                       print($this->session->userdata('user_name'));
+                       _htmlsc($this->session->userdata('user_name'));
                        if ($this->session->userdata('user_company')) {
-                           print(" (" . $this->session->userdata('user_company') . ")");
+                           print(" (" . htmlsc($this->session->userdata('user_company')) . ")");
                        }
                        ?>">
                         <i class="fa fa-user"></i>
                         <span class="visible-xs">&nbsp;<?php
-                            print($this->session->userdata('user_name'));
+                            _htmlsc($this->session->userdata('user_name'));
                             if ($this->session->userdata('user_company')) {
-                                print(" (" . $this->session->userdata('user_company') . ")");
+                                print(" (" . htmlsc($this->session->userdata('user_company')) . ")");
                             }
                             ?></span>
                     </a>

+ 12 - 4
application/modules/mailer/controllers/Mailer.php

@@ -39,7 +39,9 @@ class Mailer extends Admin_Controller
      */
     public function invoice($invoice_id)
     {
-        if (!$this->mailer_configured) return;
+        if (!$this->mailer_configured) {
+            return;
+        }
 
         $this->load->model('invoices/mdl_templates');
         $this->load->model('invoices/mdl_invoices');
@@ -79,7 +81,9 @@ class Mailer extends Admin_Controller
      */
     public function quote($quote_id)
     {
-        if (!$this->mailer_configured) return;
+        if (!$this->mailer_configured) {
+            return;
+        }
 
         $this->load->model('invoices/mdl_templates');
         $this->load->model('quotes/mdl_quotes');
@@ -122,7 +126,9 @@ class Mailer extends Admin_Controller
             redirect('invoices/view/' . $invoice_id);
         }
 
-        if (!$this->mailer_configured) return;
+        if (!$this->mailer_configured) {
+            return;
+        }
 
         $to = $this->input->post('to_email');
 
@@ -169,7 +175,9 @@ class Mailer extends Admin_Controller
             redirect('quotes/view/' . $quote_id);
         }
 
-        if (!$this->mailer_configured) return;
+        if (!$this->mailer_configured) {
+            return;
+        }
 
         $to = $this->input->post('to_email');
 

+ 12 - 2
application/modules/mailer/helpers/phpmailer_helper.php

@@ -45,8 +45,7 @@ function phpmail_send($from, $to, $subject, $message, $attachment_path = null, $
             if (get_setting('smtp_authentication')) {
                 $mail->SMTPAuth = true;
 
-                $encoded = $CI->mdl_settings->get('smtp_password');
-                $decoded = $CI->crypt->decode($encoded);
+                $decoded = $CI->crypt->decode($CI->mdl_settings->get('smtp_password'));
 
                 $mail->Username = get_setting('smtp_username');
                 $mail->Password = $decoded;
@@ -57,6 +56,17 @@ function phpmail_send($from, $to, $subject, $message, $attachment_path = null, $
                 $mail->SMTPSecure = get_setting('smtp_security');
             }
 
+            // Check if certificates should not be verified
+            if (!get_setting('smtp_verify_certs', true)) {
+                $mail->SMTPOptions = array(
+                    'ssl' => array(
+                        'verify_peer' => false,
+                        'verify_peer_name' => false,
+                        'allow_self_signed' => true
+                    )
+                );
+            }
+
             break;
         case 'sendmail':
             $mail->IsMail();

+ 3 - 0
application/modules/quotes/models/Mdl_quotes.php

@@ -277,6 +277,9 @@ class Mdl_Quotes extends Response_Model
         return $db_array;
     }
 
+    /**
+     * @param string $quote_date_created
+     */
     public function get_date_due($quote_date_created)
     {
         $quote_date_expires = new DateTime($quote_date_created);

+ 13 - 5
application/modules/reports/models/Mdl_reports.php

@@ -197,13 +197,21 @@ class Mdl_Reports extends CI_Model
      */
     public function sales_by_year($from_date = null, $to_date = null, $minQuantity = null, $maxQuantity = null, $taxChecked = False)
     {
-        if ($minQuantity == "") $minQuantity = 0;
+        if ($minQuantity == "") {
+            $minQuantity = 0;
+        }
 
-        if ($from_date == "") $from_date = date("Y-m-d");
-        else $from_date = date_to_mysql($from_date);
+        if ($from_date == "") {
+            $from_date = date("Y-m-d");
+        } else {
+            $from_date = date_to_mysql($from_date);
+        }
 
-        if ($to_date == "") $to_date = date("Y-m-d");
-        else $to_date = date_to_mysql($to_date);
+        if ($to_date == "") {
+            $to_date = date("Y-m-d");
+        } else {
+            $to_date = date_to_mysql($to_date);
+        }
 
         $from_date_year = intval(substr($from_date, 0, 4));
         $to_date_year = intval(substr($to_date, 0, 4));

+ 2 - 1
application/modules/reports/views/invoice_aging_index.php

@@ -17,7 +17,8 @@
                 </div>
 
                 <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()); ?>"
+                        <?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
 
                         <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
 

+ 2 - 1
application/modules/reports/views/payment_history_index.php

@@ -18,7 +18,8 @@
 
                 <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()); ?>"
+                        <?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
 
                         <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
 

+ 2 - 1
application/modules/reports/views/sales_by_client_index.php

@@ -18,7 +18,8 @@
 
                 <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()); ?>"
+                        <?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
 
                         <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
 

+ 2 - 1
application/modules/reports/views/sales_by_year_index.php

@@ -18,7 +18,8 @@
 
                 <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()); ?>"
+                        <?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
 
                         <input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
 

+ 0 - 24
application/modules/settings/controllers/Settings.php

@@ -120,30 +120,6 @@ class Settings extends Admin_Controller
 
         $this->load->helper('country');
 
-        // Load Omnipay
-        require_once(FCPATH . 'vendor/autoload.php');
-
-//        echo '<pre>';
-//        foreach ($gateways as $d => $setting) {
-//            $g = \Omnipay\Omnipay::create($d);
-//            echo "'$d' => array(\n";
-//            foreach ($g->getDefaultParameters() as $s => $val) {
-//                if (is_string($s)) {
-//                    echo "    '$s' => array(\n";
-//                    if ($s == 'testMode' || $s == 'developerMode' ) {
-//                        echo "        'type' => 'checkbox',\n";
-//                    } else {
-//                        echo "        'type' => 'text',\n";
-//                    }
-//                    echo "        'label' => '" . ucwords(implode(' ', preg_split('/(?=[A-Z])/', $s))) . "',\n";
-//                    echo "    ),\n";
-//                }
-//            }
-//            echo "),\n";
-//        }
-//        echo '</pre>';
-//        exit;
-
         // Collect the list of templates
         $pdf_invoice_templates = $this->mdl_templates->get_invoice_templates('pdf');
         $public_invoice_templates = $this->mdl_templates->get_invoice_templates('public');

+ 3 - 1
application/modules/settings/models/Mdl_settings.php

@@ -112,7 +112,9 @@ class Mdl_Settings extends CI_Model
         $themes = [];
 
         foreach ($found_folders as $theme) {
-            if ($theme == 'core') continue;
+            if ($theme == 'core') {
+                continue;
+            }
 
             // Get the theme info file
             $theme = str_replace('/', '', $theme);

+ 15 - 3
application/modules/settings/views/partial_settings_email.php

@@ -35,9 +35,7 @@
                         </label>
                         <select name="settings[email_pdf_attachment]" id="settings[email_pdf_attachment]"
                                 class="form-control simple-select">
-                            <option value="0">
-                                <?php _trans('no'); ?>
-                            </option>
+                            <option value="0"><?php _trans('no'); ?></option>
                             <option value="1" <?php check_select(get_setting('email_pdf_attachment'), '1'); ?>>
                                 <?php _trans('yes'); ?>
                             </option>
@@ -135,6 +133,20 @@
                                 </option>
                             </select>
                         </div>
+
+                        <div class="form-group">
+                            <label for="settings[smtp_verify_certs]">
+                                <?php _trans('smtp_verify_certs'); ?>
+                            </label>
+                            <select name="settings[smtp_verify_certs]" id="settings[smtp_verify_certs]"
+                                    class="form-control simple-select">
+                                <option value="1"><?php _trans('yes'); ?></option>
+                                <option value="0" <?php check_select(get_setting('smtp_verify_certs'), '0'); ?>>
+                                    <?php _trans('no'); ?>
+                                </option>
+                            </select>
+                        </div>
+
                     </div>
 
                 </div>

+ 17 - 0
application/modules/settings/views/partial_settings_general.php

@@ -380,6 +380,23 @@
                     </div>
 
                 </div>
+                <div class="col-xs-12 col-md-6">
+
+                    <div class="form-group">
+                        <label for="settings[reports_in_new_tab]">
+                            <?php _trans('open_reports_in_new_tab'); ?>
+                        </label>
+                        <select name="settings[reports_in_new_tab]" id="settings[reports_in_new_tab]"
+                                class="form-control simple-select">
+                            <option value="0"><?php _trans('no'); ?></option>
+                            <option value="1" <?php check_select(get_setting('reports_in_new_tab'), '1'); ?>>
+                                <?php _trans('yes'); ?>
+                            </option>
+                        </select>
+                    </div>
+
+
+                </div>
             </div>
 
         </div>

+ 1 - 1
application/modules/setup/controllers/Setup.php

@@ -335,7 +335,7 @@ class Setup extends MX_Controller
         $this->load_ci_database();
 
         // Set a new encryption key if none exists
-        if (empty(env('ENCRYPTION_KEY'))) {
+        if (env('ENCRYPTION_KEY') === null) {
             $this->set_encryption_key();
         }
 

+ 1 - 1
application/modules/setup/models/Mdl_setup.php

@@ -40,7 +40,7 @@ class Mdl_Setup extends CI_Model
     }
 
     /**
-     * @param $contents
+     * @param string $contents
      */
     private function execute_contents($contents)
     {

+ 1 - 0
application/modules/setup/sql/025_1.5.2.sql

@@ -0,0 +1 @@
+# Added for versioning

+ 5 - 3
application/modules/setup/views/create_user.php

@@ -7,7 +7,7 @@
 
         var password_input = $('.passwordmeter-input');
         if (password_input) {
-            password_input.on('input', function(){
+            password_input.on('input', function () {
                 var strength = zxcvbn(password_input.val());
 
                 $('.passmeter-2, .passmeter-3').hide();
@@ -66,8 +66,10 @@
                        class="form-control passwordmeter-input">
                 <div class="progress" style="height:3px;">
                     <div class="progress-bar progress-bar-danger passmeter passmeter-1" style="width: 33%"></div>
-                    <div class="progress-bar progress-bar-warning passmeter passmeter-2" style="display: none; width: 33%"></div>
-                    <div class="progress-bar progress-bar-success passmeter passmeter-3" style="display: none; width: 34%"></div>
+                    <div class="progress-bar progress-bar-warning passmeter passmeter-2"
+                         style="display: none; width: 33%"></div>
+                    <div class="progress-bar progress-bar-success passmeter passmeter-3"
+                         style="display: none; width: 34%"></div>
                 </div>
 
                 <span class="help-block"><?php _trans('setup_user_password_info'); ?></span>

+ 3 - 1
application/modules/tasks/views/form.php

@@ -91,7 +91,9 @@ if ($this->mdl_tasks->form_value('task_id') && $this->mdl_tasks->form_value('tas
                             <label for="task_status"><?php _trans('status'); ?></label>
                             <select name="task_status" id="task_status" class="form-control simple-select">
                                 <?php foreach ($task_statuses as $key => $status) {
-                                    if ($this->mdl_tasks->form_value('task_status') != 4 && $key == 4) continue; ?>
+                                    if ($this->mdl_tasks->form_value('task_status') != 4 && $key == 4) {
+                                        continue;
+                                    } ?>
                                     <option value="<?php echo $key; ?>" <?php check_select($key, $this->mdl_tasks->form_value('task_status')); ?>>
                                         <?php echo $status['label']; ?>
                                     </option>

+ 2 - 2
application/modules/upload/controllers/Upload.php

@@ -41,7 +41,7 @@ class Upload extends Admin_Controller
     /**
      * @param $customerId
      * @param $url_key
-     * @return bool
+     * @return boolean|null
      */
     public function upload_file($customerId, $url_key)
     {
@@ -85,7 +85,7 @@ class Upload extends Admin_Controller
     }
 
     /**
-     * @param $path
+     * @param string $path
      * @param string $chmod
      * @return bool
      */

+ 2 - 1
application/modules/users/views/form.php

@@ -96,7 +96,8 @@ $cv = $this->controller->view_data["custom_values"];
                                 </div>
                             <?php } else { ?>
                                 <div class="form-group">
-                                    <a href="<?php echo site_url('users/change_password/' . $id); ?>" class="btn btn-default">
+                                    <a href="<?php echo site_url('users/change_password/' . $id); ?>"
+                                       class="btn btn-default">
                                         <?php _trans('change_password'); ?>
                                     </a>
                                 </div>

+ 6 - 3
application/modules/users/views/form_change_password.php

@@ -29,9 +29,12 @@
                             <input type="password" name="user_password" id="user_password"
                                    class="form-control passwordmeter-input">
                             <div class="progress" style="height:3px;">
-                                <div class="progress-bar progress-bar-danger passmeter passmeter-1" style="width: 33%"></div>
-                                <div class="progress-bar progress-bar-warning passmeter passmeter-2" style="display: none; width: 33%"></div>
-                                <div class="progress-bar progress-bar-success passmeter passmeter-3" style="display: none; width: 34%"></div>
+                                <div class="progress-bar progress-bar-danger passmeter passmeter-1"
+                                     style="width: 33%"></div>
+                                <div class="progress-bar progress-bar-warning passmeter passmeter-2"
+                                     style="display: none; width: 33%"></div>
+                                <div class="progress-bar progress-bar-success passmeter passmeter-3"
+                                     style="display: none; width: 34%"></div>
                             </div>
                         </div>
 

+ 9 - 4
application/views/reports/sales_by_year.php

@@ -90,10 +90,15 @@
                 <tr>
                     <td style="border-bottom: none;">&nbsp;</td>
                     <td style="border-bottom: none;text-align:center;"><?php
-                        if ($quarter == "t1") echo trans('Q1') . "/" . $year;
-                        else if ($quarter == "t2") echo trans('Q2') . "/" . $year;
-                        else if ($quarter == "t3") echo trans('Q3') . "/" . $year;
-                        else if ($quarter == "t4") echo trans('Q4') . "/" . $year;
+                        if ($quarter == "t1") {
+                            echo trans('Q1') . "/" . $year;
+                        } else if ($quarter == "t2") {
+                            echo trans('Q2') . "/" . $year;
+                        } else if ($quarter == "t3") {
+                            echo trans('Q3') . "/" . $year;
+                        } else if ($quarter == "t4") {
+                            echo trans('Q4') . "/" . $year;
+                        }
                         ?></td>
                     <td style="border-bottom: none;text-align:center;"><?php if ($value > 0) {
                             echo format_currency($value);

+ 2 - 1
composer.json

@@ -11,6 +11,7 @@
     "vlucas/phpdotenv": "^2.4",
     "setasign/fpdi-fpdf": "^1.6.1",
     "codeigniter/framework": "^3.1",
-    "omnipay/omnipay": "~2.0"
+    "omnipay/omnipay": "~2.0",
+    "paragonie/random_compat": "^2.0"
   }
 }

+ 59 - 11
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "0c3d98b589ee7034870f26d33bfc6f62",
+    "content-hash": "1a2453d93bd48c4f513f4ca4f61dc6f1",
     "packages": [
         {
             "name": "codeigniter/framework",
@@ -1922,6 +1922,54 @@
             "time": "2016-01-28T12:55:58+00:00"
         },
         {
+            "name": "paragonie/random_compat",
+            "version": "v2.0.10",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/paragonie/random_compat.git",
+                "reference": "634bae8e911eefa89c1abfbf1b66da679ac8f54d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/paragonie/random_compat/zipball/634bae8e911eefa89c1abfbf1b66da679ac8f54d",
+                "reference": "634bae8e911eefa89c1abfbf1b66da679ac8f54d",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.2.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "4.*|5.*"
+            },
+            "suggest": {
+                "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "lib/random.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Paragon Initiative Enterprises",
+                    "email": "security@paragonie.com",
+                    "homepage": "https://paragonie.com"
+                }
+            ],
+            "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
+            "keywords": [
+                "csprng",
+                "pseudorandom",
+                "random"
+            ],
+            "time": "2017-03-13T16:27:32+00:00"
+        },
+        {
             "name": "phpmailer/phpmailer",
             "version": "v5.2.23",
             "source": {
@@ -2178,16 +2226,16 @@
         },
         {
             "name": "symfony/event-dispatcher",
-            "version": "v2.8.19",
+            "version": "v2.8.20",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/event-dispatcher.git",
-                "reference": "88b65f0ac25355090e524aba4ceb066025df8bd2"
+                "reference": "7fc8e2b4118ff316550596357325dfd92a51f531"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/88b65f0ac25355090e524aba4ceb066025df8bd2",
-                "reference": "88b65f0ac25355090e524aba4ceb066025df8bd2",
+                "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7fc8e2b4118ff316550596357325dfd92a51f531",
+                "reference": "7fc8e2b4118ff316550596357325dfd92a51f531",
                 "shasum": ""
             },
             "require": {
@@ -2234,20 +2282,20 @@
             ],
             "description": "Symfony EventDispatcher Component",
             "homepage": "https://symfony.com",
-            "time": "2017-04-03T20:37:06+00:00"
+            "time": "2017-04-26T16:56:54+00:00"
         },
         {
             "name": "symfony/http-foundation",
-            "version": "v2.8.19",
+            "version": "v2.8.20",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/http-foundation.git",
-                "reference": "0717efd2f2264dbd3d8e1bc69a0418c2fd6295d2"
+                "reference": "cfa9013809ad18514855144d14bb321cf4673561"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0717efd2f2264dbd3d8e1bc69a0418c2fd6295d2",
-                "reference": "0717efd2f2264dbd3d8e1bc69a0418c2fd6295d2",
+                "url": "https://api.github.com/repos/symfony/http-foundation/zipball/cfa9013809ad18514855144d14bb321cf4673561",
+                "reference": "cfa9013809ad18514855144d14bb321cf4673561",
                 "shasum": ""
             },
             "require": {
@@ -2289,7 +2337,7 @@
             ],
             "description": "Symfony HttpFoundation Component",
             "homepage": "https://symfony.com",
-            "time": "2017-04-04T15:24:26+00:00"
+            "time": "2017-05-01T14:31:55+00:00"
         },
         {
             "name": "symfony/polyfill-mbstring",

+ 12 - 19
index.php

@@ -11,7 +11,9 @@
  *---------------------------------------------------------------
  */
 
-if (!file_exists('ipconfig.php')) exit("The <b>ipconfig.php</b> file is missing! Please make a copy of the <b>ipconfig.php.example</b> file and rename it to <b>ipconfig.php</b>");
+if (!file_exists('ipconfig.php')) {
+    exit("The <b>ipconfig.php</b> file is missing! Please make a copy of the <b>ipconfig.php.example</b> file and rename it to <b>ipconfig.php</b>");
+}
 
 require ('vendor/autoload.php');
 $dotenv = new \Dotenv\Dotenv(__DIR__, 'ipconfig.php');
@@ -83,8 +85,7 @@ switch (ENVIRONMENT)
         if (version_compare(PHP_VERSION, '5.3', '>='))
         {
             error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
-        }
-        else
+        } else
         {
             error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
         }
@@ -212,8 +213,7 @@ if (defined('STDIN'))
 if (($_temp = realpath($system_path)) !== FALSE)
 {
     $system_path = $_temp.DIRECTORY_SEPARATOR;
-}
-else
+} else
 {
     // Ensure there's a trailing slash
     $system_path = strtr(
@@ -254,8 +254,7 @@ if (is_dir($application_folder))
     if (($_temp = realpath($application_folder)) !== FALSE)
     {
         $application_folder = $_temp;
-    }
-    else
+    } else
     {
         $application_folder = strtr(
             rtrim($application_folder, '/\\'),
@@ -263,16 +262,14 @@ if (is_dir($application_folder))
             DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
         );
     }
-}
-elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
+} elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
 {
     $application_folder = BASEPATH.strtr(
             trim($application_folder, '/\\'),
             '/\\',
             DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
         );
-}
-else
+} else
 {
     header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
     echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
@@ -285,14 +282,12 @@ define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
 if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
 {
     $view_folder = APPPATH.'views';
-}
-elseif (is_dir($view_folder))
+} elseif (is_dir($view_folder))
 {
     if (($_temp = realpath($view_folder)) !== FALSE)
     {
         $view_folder = $_temp;
-    }
-    else
+    } else
     {
         $view_folder = strtr(
             rtrim($view_folder, '/\\'),
@@ -300,16 +295,14 @@ elseif (is_dir($view_folder))
             DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
         );
     }
-}
-elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
+} elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
 {
     $view_folder = APPPATH.strtr(
             trim($view_folder, '/\\'),
             '/\\',
             DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
         );
-}
-else
+} else
 {
     header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
     echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;