Skip to content

Commit

Permalink
Merge branch 'InvoicePlane:development' into Preview-PDF-in-Modal-Inv…
Browse files Browse the repository at this point in the history
  • Loading branch information
Verony-makesIT authored Nov 15, 2023
2 parents 6571479 + 4a51627 commit 3aed7de
Show file tree
Hide file tree
Showing 34 changed files with 1,549 additions and 949 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ name: Frontend Testing
on:
pull_request:
branches:
- master
- development

jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest]
node: ['8', '10', '12']
node: ['16', '18']
name: Node ${{ matrix.node }} build testing
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install frontend dependencies
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ name: PHP Testing
on:
pull_request:
branches:
- master
- development

jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.1', '7.2', '7.3', '7.4']
php-versions: ['8.1']

name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring
Expand All @@ -29,7 +29,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down
4 changes: 2 additions & 2 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@
$config['sess_table_name'] = env('SESS_DRIVER', 'ip_sessions');
$config['sess_cookie_name'] = env('SESS_DRIVER', 'ip_session');
$config['sess_expiration'] = env('SESS_EXPIRATION', 864000);
$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = env('SESS_MATCH_IP', true);
$config['sess_save_path'] = env('SESS_SAVE_PATH', sys_get_temp_dir());
$config['sess_match_ip'] = env_bool('SESS_MATCH_IP', true);
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

Expand Down
24 changes: 24 additions & 0 deletions application/helpers/invoice_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,27 @@ function invoice_recMod10($in)

return (10 - $carry) % 10;
}

/**
* Returns a QR code for invoice payments
*
* @param number invoice-id
* @return string
*/
function invoice_qrcode($invoice_id) {
$CI = &get_instance();

if (
$CI->mdl_settings->setting('qr_code')
&& $CI->mdl_settings->setting('qr_code_iban')
&& $CI->mdl_settings->setting('qr_code_bic')
) {
$invoice = $CI->mdl_invoices->get_by_id($invoice_id);
$CI->load->library('QrCode', [ 'invoice' => $invoice ]);
$qrcode_data_uri = $CI->qrcode->generate();

return '<img src="' . $qrcode_data_uri . '" alt="QR Code" id="invoice-qr-code">';
}

return '';
}
8 changes: 8 additions & 0 deletions application/language/english/ip_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@
'Q2' => 'Q2',
'Q3' => 'Q3',
'Q4' => 'Q4',
'qr_code_settings' => 'QR Code Settings',
'qr_code_settings_bic' => 'BIC',
'qr_code_settings_enable' => 'Enable QR Code',
'qr_code_settings_enable_hint' => 'Enabling this option will include a QR code for invoice PDFs. You have to fill out recipient, IBAN and a <em>correct</em> BIC down below to work correctly. Otherwise the QR code won\'t be displayed.',
'qr_code_settings_iban' => 'IBAN',
'qr_code_settings_recipient' => 'Recipient',
'qr_code_settings_remittance_text' => 'Remittance Text',
'qr_code_settings_remittance_text_tags' => 'Remittance Text Tags',
'qty' => 'Qty',
'quantity' => 'Quantity',
'quarter' => 'Quarter',
Expand Down
55 changes: 55 additions & 0 deletions application/libraries/QrCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}

use SepaQr\Data;
use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelMedium;

class QrCode {
public $invoice;
public $recipient;
public $iban;
public $bic;
public $currencyCode;
public $remittance_text;

public function __construct($params) {
$CI = &get_instance();

$CI->load->helper('template');

$this->invoice = $params['invoice'];
$this->recipient = $CI->mdl_settings->setting('qr_code_recipient');
$this->iban = $CI->mdl_settings->setting('qr_code_iban');
$this->bic = $CI->mdl_settings->setting('qr_code_bic');
$this->currencyCode = $CI->mdl_settings->setting('currency_code');
$this->remittance_text = parse_template(
$this->invoice,
$CI->mdl_settings->setting('qr_code_remittance_text')
);
}

public function paymentData() {
$paymentData = Data::create()
->setName($this->recipient)
->setIban($this->iban)
->setBic($this->bic)
->setCurrency($this->currencyCode)
->setRemittanceText($this->remittance_text)
->setAmount($this->invoice->invoice_total);

return $paymentData;
}

public function generate() {
$qrCodeDataUri = Builder::create()
->data($this->paymentData())
->errorCorrectionLevel(new ErrorCorrectionLevelMedium()) // required by EPC standard
->build()
->getDataUri();

return $qrCodeDataUri;
}
}
4 changes: 3 additions & 1 deletion application/modules/clients/models/Mdl_clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function validation_rules()
'client_language' => array(
'field' => 'client_language',
'label' => trans('language'),
'rules' => 'trim'
),
'client_address_1' => array(
'field' => 'client_address_1'
Expand All @@ -68,7 +69,8 @@ public function validation_rules()
'field' => 'client_zip'
),
'client_country' => array(
'field' => 'client_country'
'field' => 'client_country',
'rules' => 'trim'
),
'client_phone' => array(
'field' => 'client_phone'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public function validation_rules()
),
'email_template_from_name' => array(
'field' => 'email_template_from_name',
'label' => trans('from_name')
'label' => trans('from_name'),
'rules' => 'trim'
),
'email_template_from_email' => array(
'field' => 'email_template_from_email',
Expand Down
9 changes: 6 additions & 3 deletions application/modules/email_templates/views/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,12 @@ class="form-control simple-select">
</span>
</div>

<textarea name="email_template_body" id="email_template_body" rows="8"
class="email-template-body form-control taggable"><?php echo $this->mdl_email_templates->form_value('email_template_body', true); ?>
</textarea>
<textarea
name="email_template_body"
id="email_template_body"
rows="8"
class="email-template-body form-control taggable"
><?php echo $this->mdl_email_templates->form_value('email_template_body', true); ?></textarea>

<br>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<div class="form-group">
<label for="tags_invoice"><?php _trans('invoices'); ?></label>
<select id="tags_invoice" class="tag-select form-control">
<option value="{{{invoice_number}}}">
<?php _trans('id'); ?>
</option>
<option value="{{{invoice_status}}}">
<?php _trans('status'); ?>
</option>
<optgroup label="<?php _trans('invoice_dates'); ?>">
<option value="{{{invoice_date_due}}}">
<?php _trans('due_date'); ?>
</option>
<option value="{{{invoice_date_created}}}">
<?php _trans('invoice_date'); ?>
</option>
</optgroup>
<optgroup label="<?php _trans('invoice_amounts'); ?>">
<option value="{{{invoice_item_subtotal}}}">
<?php _trans('subtotal'); ?>
</option>
<option value="{{{invoice_item_tax_total}}}">
<?php _trans('invoice_tax'); ?>
</option>
<option value="{{{invoice_total}}}">
<?php _trans('total'); ?>
</option>
<option value="{{{invoice_paid}}}">
<?php _trans('total_paid'); ?>
</option>
<option value="{{{invoice_balance}}}">
<?php _trans('balance'); ?>
</option>
</optgroup>
<optgroup label="<?php _trans('extra_information'); ?>">
<option value="{{{invoice_terms}}}">
<?php _trans('invoice_terms'); ?>
</option>
<option value="{{{invoice_guest_url}}}">
<?php _trans('guest_url'); ?>
</option>
<!-- <option value="{{{payment_method}}}"> -->
<!-- <?php _trans('payment_method'); ?> -->
<!-- </option> -->
</optgroup>

<optgroup label="<?php _trans('custom_fields'); ?>">
<?php foreach ($custom_fields['ip_invoice_custom'] as $custom) { ?>
<option value="{{{<?php echo 'ip_cf_' . $custom->custom_field_id; ?>}}}">
<?php echo $custom->custom_field_label . ' (ID ' . $custom->custom_field_id . ')'; ?>
</option>
<?php } ?>
</optgroup>
</select>
</div>
56 changes: 1 addition & 55 deletions application/modules/email_templates/views/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,61 +147,7 @@
</select>
</div>

<div class="form-group">
<label for="tags_invoice"><?php _trans('invoices'); ?></label>
<select id="tags_invoice" class="tag-select form-control">
<option value="{{{invoice_number}}}">
<?php _trans('id'); ?>
</option>
<option value="{{{invoice_status}}}">
<?php _trans('status'); ?>
</option>
<optgroup label="<?php _trans('invoice_dates'); ?>">
<option value="{{{invoice_date_due}}}">
<?php _trans('due_date'); ?>
</option>
<option value="{{{invoice_date_created}}}">
<?php _trans('invoice_date'); ?>
</option>
</optgroup>
<optgroup label="<?php _trans('invoice_amounts'); ?>">
<option value="{{{invoice_item_subtotal}}}">
<?php _trans('subtotal'); ?>
</option>
<option value="{{{invoice_item_tax_total}}}">
<?php _trans('invoice_tax'); ?>
</option>
<option value="{{{invoice_total}}}">
<?php _trans('total'); ?>
</option>
<option value="{{{invoice_paid}}}">
<?php _trans('total_paid'); ?>
</option>
<option value="{{{invoice_balance}}}">
<?php _trans('balance'); ?>
</option>
</optgroup>
<optgroup label="<?php _trans('extra_information'); ?>">
<option value="{{{invoice_terms}}}">
<?php _trans('invoice_terms'); ?>
</option>
<option value="{{{invoice_guest_url}}}">
<?php _trans('guest_url'); ?>
</option>
<!-- <option value="{{{payment_method}}}"> -->
<!-- <?php _trans('payment_method'); ?> -->
<!-- </option> -->
</optgroup>

<optgroup label="<?php _trans('custom_fields'); ?>">
<?php foreach ($custom_fields['ip_invoice_custom'] as $custom) { ?>
<option value="{{{<?php echo 'ip_cf_' . $custom->custom_field_id; ?>}}}">
<?php echo $custom->custom_field_label . ' (ID ' . $custom->custom_field_id . ')'; ?>
</option>
<?php } ?>
</optgroup>
</select>
</div>
<?php $this->layout->load_view('email_templates/template-tags-invoices'); ?>

<div class="form-group">
<label for="tags_quote"><?php _trans('quotes'); ?></label>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/filter/controllers/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function filter_clients()

foreach ($keywords as $keyword) {
if ($keyword) {
$keyword = strtolower($keyword);
$keyword = trim(strtolower($keyword));
$this->mdl_clients->like("CONCAT_WS('^',LOWER(client_name),LOWER(client_surname),LOWER(client_email),client_phone,client_active)", $keyword);
}
}
Expand Down
1 change: 1 addition & 0 deletions application/modules/guest/controllers/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function invoice($invoice_url_key = '')
$this->load->model('invoices/mdl_invoice_tax_rates');
$this->load->model('payment_methods/mdl_payment_methods');
$this->load->model('custom_fields/mdl_custom_fields');
$this->load->helper('template');

$invoice = $invoice->row();

Expand Down
Loading

0 comments on commit 3aed7de

Please sign in to comment.