Skip to content

Commit

Permalink
Installation Testing 1: Flash and Alert modification
Browse files Browse the repository at this point in the history
Controller Constructs:
Move session into arguments of the construct for controllers.
Initialize flash with session. eg. $this->flash = new Flash($session)

Controller Functions:
Modify the alert  and change the flash function to flash_message.

Views:
Include echo $alert in all indexes.

````
/**
   * @return string
   */
   private function alert(): string {
     return $this->viewRenderer->renderPartialAsString('/invoice/layout/alert',
     [
       'flash' => $this->flash,
       'errors' => [],
     ]);
   }

    /**
     * @param string $level
     * @param string $message
     * @return Flash
     */
    private function flash_message(string $level, string $message): Flash {
      $this->flash->add($level, $message, true);
      return $this->flash;
    }
````

Include additional messages in resources/messages/en/app.php and src/Invoice/Language/English/app_lang.php

Psalm Level 1 tested.
  • Loading branch information
rossaddison committed Sep 12, 2023
1 parent a07d1dc commit fb5bf01
Show file tree
Hide file tree
Showing 137 changed files with 4,635 additions and 3,545 deletions.
43 changes: 41 additions & 2 deletions resources/messages/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'invoice.client.contract.period.end' => 'Period End',
'invoice.client.contract.reference' => 'Contract Reference',
'invoice.client.custom' => 'Client Custom',
'invoice.client.delete.history.exits.no' => 'Cannot delete. Client History exists.',
'invoice.client.detail.changes' => 'Please send us an email if this detail changes.',
'invoice.client.note' => 'Client Note',
'invoice.client.number' => 'Client Number',
Expand Down Expand Up @@ -70,6 +71,8 @@
'invoice.company.public' => 'Company Public',
'invoice.company.private' => 'Company Private',
'invoice.company.private.logo' => 'Company Logo',
'invoice.company.deleted' => 'Company has been deleted',
'invoice.company.not.deleted' => 'Company has not been deleted because you have a Company Profile attached to it.',
'invoice.create' => 'Create',
'invoice.curl.store.cove.api.setup.successful' => 'Store Cove Setup Api Call Successful',
'invoice.curl.store.cove.api.setup.legal.entity.successful' => 'Store Cove Setup Api Call - Legal Entity Successful',
Expand Down Expand Up @@ -98,20 +101,27 @@
'invoice.email.template' => 'Email Template',
'invoice.family' => 'Family',
'invoice.family.add' => 'Family Add',
'invoice.family.history' => 'Family History exists. Cannot delete',
'invoice.faq' => 'FAQ\'s',
'invoice.faq.taxpoint' => 'How to determine what the Tax Point is?',
'invoice.faq.business.rules' => 'What are the Peppol Business Rules?',
'invoice.first.reset' => 'First delete the test quotes and invoices that you created for testing. Then the test data can be deleted.',
'invoice.generator' => 'Generator',
'invoice.generator.add' => 'Generator Add',
'invoice.generator.file.type.not.found' => 'File type not found.',
'invoice.generators.relation' => 'Generators Relation',
'invoice.generator.relations.add' => 'Generators Relation Add',
'invoice.generator.generate' => 'Generate',
'invoice.generator.generated' => ' generated at ',
'invoice.generator.google.translate.ip' => 'Translate English\ip_lang.php',
'invoice.generator.google.translate.gateway' => 'Translate English\gateway_lang.php',
'invoice.generator.google.translate.app' => 'Translate messages\en\app.php',
'invoice.generator.history' => 'This record has existing Generator Relations so it cannot be deleleted. Delete these relations first.',
'invoice.group' => 'Group',
'invoice.group.add' => 'Group Add',
'invoice.group.history' => 'Group History exists. Cannot delete',
'invoice.home' => 'Home',
'invoice.index.showing' => 'Showing %s out of %s',
'invoice.install.test.data' => 'Settings...General...Install Test Data',
'invoice.invalid.amount' => 'Invalid Amount',
'invoice.invalid.subscriber.number' => 'Invalid Subscriber Number',
Expand Down Expand Up @@ -139,8 +149,11 @@
'invoice.invoice.attachment.list' => 'Attachment List',
'invoice.invoice.custom' => 'Invoice Custom',
'invoice.invoice.contract' => 'Contract',
'invoice.invoice.contracts' => 'Contracts',
'invoice.invoice.contract.add' => 'Add a Contract',
'invoice.invoice.contract.create' => 'Create your Contracts via. Invoice...View...Options...Edit. A contract will be created for the client that the Invoice is being made out to. Link this contract to future invoices.',
'invoice.invoice.contract.contracts' => 'Contracts',
'invoice.invoice.contract.index.button.list' => 'Invoices',
'invoice.invoice.contract.name' => 'Name',
'invoice.invoice.contract.none' => 'Reminder: No Contract has been setup for this invoice',
'invoice.invoice.contract.period.start' => 'Period Start',
Expand All @@ -152,8 +165,10 @@
'invoice.invoice.delivery.add' => 'Add Delivery',
'invoice.invoice.delivery.location' => 'Delivery Location',
'invoice.invoice.delivery.location.add' => 'Delivery Location Add',
'invoice.invoice.delivery.location.add.in.invoice' => 'Add the delivery location under Invoice ... View ... Options ... Edit',
'invoice.invoice.delivery.location.client' => 'Delivery Locations of Client',
'invoice.invoice.delivery.location.edit' => 'Delivery Location Edit',
'invoice.invoice.delivery.location.index.button.list' => 'Invoices',
'invoice.invoice.delivery.location.view' => 'Delivery Location View',
'invoice.invoice.delivery.location.delete' => 'Delivery Location Delete',
'invoice.invoice.delivery.location.none' => 'No delivery location has been linked to this invoice',
Expand Down Expand Up @@ -198,6 +213,8 @@
'invoice.invoice.delivery.start.date' => 'Start Date of Delivery/Invoice Period',
'invoice.invoice.delivery.end.date' => 'End Date of Delivery/Invoice Period',
'invoice.invoice.document.description' => 'Peppol Document Description',
'invoice.invoice.draft.number.off' => 'New draft Invoices will have no Invoice Number. Mark as sent to get Invoice Number',
'invoice.invoice.draft.number.on' => 'New draft Invoices will have an Invoice Number',
'invoice.invoice.enable.vat' => 'Enable VAT',
'invoice.invoice.enable.vat.message' => 'Display VAT reminder message above options button on views',
'invoice.invoice.enable.vat.warning.line.1' => '1. With VAT enabled, only individual line items on the invoice are taxed with vat. ie. Quote/Invoice Taxes will not appear on the invoice and will be reduced to 0.',
Expand All @@ -209,6 +226,7 @@
'invoice.invoice.mpdf' => 'Mpdf',
'invoice.invoice.note' => 'Note',
'invoice.invoice.paymentterm' => 'Payment Term',
'invoice.invoice.recurring.deleted' => 'Deleted',
'invoice.invoice.showing.of' => 'Showing %s out of %s ',
'invoice.invoice.storecove' => 'Storecove',
'invoice.invoice.tax.rate.percent' => 'Invoice Tax Rate Percent',
Expand All @@ -229,8 +247,12 @@
'invoice.payment.custom.add' => 'Payment Custom Add',
'invoice.payment.add' => 'Payment Add',
'invoice.payment' => 'Payment',
'invoice.payment.method' => 'Payment Method',
'invoice.payment.cannot.delete' => 'Cannot delete payment',
'invoice.payment.custom' => 'Payment Custom',
'invoice.payment.deleted' => 'Payment Deleted',
'invoice.payment.method' => 'Payment Method',
'invoice.payment.method.history' => 'Cannot delete. Payment Method history exists.',
'invoice.payment.no.invoice.sent' => 'No invoices have been sent by us or viewed by the customer.',
'invoice.paymentpeppol.reference.plural' => 'Payment References using Peppol',
'invoice.payment.terms.default' => 'Pay within 14 days',
'invoice.payments' => 'Payments',
Expand Down Expand Up @@ -315,6 +337,7 @@
'invoice.product.country.of.origin.code' => 'Peppol Country of Origin Code using ISO-3166-1:Alpha2 Country Codes',
'invoice.product.custom.fields' => 'Product Custom Fields (eg. Peppol: AdditionalItemProperty multiple choice field colour value black)',
'invoice.product.edit' => 'Edit Product',
'invoice.product.history' => 'Cannot delete. This product is on an invoice or quote.',
'invoice.product.id' => 'Product Id',
'invoice.product.item.classification.code.scheme.id.not.found' => 'Product Item Classification Code Scheme Id not found',
'invoice.product.peppol.unit' => 'Unit with Peppol',
Expand All @@ -332,6 +355,11 @@
'invoice.product.icc.id' => 'Peppol Item Classification Code ID eg. 9873242',
'invoice.product.unit.code.not.found' => 'Product does not have a unit Code associated with it. Product ... Edit ... Unit with Peppol.',
'invoice.products' => 'Products',
'invoice.profile.new' => 'Create a profile with a new email address, or mobile number, make it active, '.
'and select the company details you wish to link it to. This information will automatically appear on the documentation eg. quotes and invoices.',
'invoice.profile.deleted' => 'Profile has been deleted',
'invoice.profile.not.deleted' => 'Profile has not been deleted',
'invoice.profile.history' => 'Cannot delete Profile. History exists',
'invoice.project.add' => 'Project Add',
'invoice.quote' => 'Quote',
'invoice.quote.approve' => 'Approve',
Expand All @@ -341,6 +369,7 @@
'invoice.quote.to.so' => 'Quote to Sales Order',
'invoice.quote.to.so.password' => 'Sales Order Password',
'invoice.quote.item' => 'Quote Item',
'invoice.quote.item.cannot.delete' => 'Cannot delete quote item',
'invoice.quote.custom' => 'Quote Custom',
'invoice.quote.custom.add' => 'Quote Custom Add',
'invoice.quote.delivery.location.none' => 'No delivery location has been linked to this quote.',
Expand All @@ -349,11 +378,13 @@
'invoice.quote.amount' => 'Quote Amount',
'invoice.quote.item.amount' => 'Quote Item Amount',
'invoice.quote.tax.rate' => 'Quote Tax Rate',
'invoice.quote.tax.rate.cannot.delete' => 'Cannot delete Quote Tax Rate',
'invoice.quote.add' => 'Quote Add',
'invoice.quote.id' => 'Quote ID ',
'invoice.quote.item.add' => 'Quote Item Add',
'invoice.quote.item.amount.add' => 'Quote Item Amount Add',
'invoice.quote.amount.add' => 'Quote Amount Add',
'invoice.quote.email.templates.not.configured' => 'Email templates not configured. Settings...Quotes...Quote Templates...Default Email Template',
'invoice.quote.tax.rate.add' => 'Quote Tax Rate Add',
'invoice.quote.number' => 'Quote Number',
'invoice.quote.number.status' => 'Quote Number Status',
Expand All @@ -362,6 +393,7 @@
'invoice.quote.with.purchase.order.person' => 'Person/Department placing the order',
'invoice.quote.vat.quote' => 'VAT Quote',
'invoice.quotes' => 'Quotes',
'invoice.records.no' => 'No Records',
'invoice.recurring' => 'Recurring',
'invoice.rules.peppol.en16931.001' => 'Business Process or the Profile ID must be provided. Refer to config/common/params.php search ProfileID',
'invoice.salesorder' => 'Sales Order',
Expand Down Expand Up @@ -392,12 +424,18 @@
'invoice.salesorder.vat.salesorder' => 'VAT Sales Order',
'invoice.salesorders' => 'Sales Orders',
'invoice.setting' => 'Setting',
'invoice.setting.assets.cleared.at' => 'Assets cleared at ',
'invoice.setting.assets.were.not.cleared.at' => 'Assets were not cleared at ',
'invoice.setting.as.a.result.of ' => ' as a result of ',
'invoice.setting.company' => 'Company Public Details',
'invoice.setting.company.private' => 'Company Private Details',
'invoice.setting.company.profile' => 'Changing Profile eg. mobile and email address',
'invoice.setting.translator.key' => 'Translator Key',
'invoice.setting.error.on.the.public.assets.folder' => ' error on the public assets folder.',
'invoice.setting.section' => 'Section',
'invoice.setting.subsection' => 'Subsection',
'invoice.setting.translator.key' => 'Translator Key',
'invoice.setting.you.have.cleared.the.cache' => 'You have cleared the cache.',
'invoice.setting.you.have.not.cleared.the.cache.due.to.a' => 'You have not cleared the cache to a ',
'invoice.storecove.advisory.to.developer.field.easily.missed' => 'Field easily missed by customer',
'invoice.storecove.create.a.sender.legal.entity.country' => '1.1.4. Create a sender - Legal Entity Country',
'invoice.storecove.invoice.json.encoded' => 'StoreCove Json Encoded Invoice',
Expand Down Expand Up @@ -450,6 +488,7 @@
'invoice.unit' => 'Unit',
'invoice.unit.add' => 'Unit Add',
'invoice.unit.description.not.provided' => 'Description not provided',
'invoice.unit.history' => 'Cannot delete. History exists.',
'invoice.unit.peppol' => 'Peppol',
'invoice.unit.peppol.index' => 'Unit Peppol Index',
'invoice.unit.peppol.add' => 'Unit Peppol Add',
Expand Down
9 changes: 4 additions & 5 deletions resources/views/invoice/client/guest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use App\Widget\OffsetPagination;
use Yiisoft\Html\Html;

echo $alert;

$this->setTitle($s->trans('clients'));

$pagination = OffsetPagination::widget()
Expand Down Expand Up @@ -47,9 +49,6 @@ class="btn <?= $active == 0 ? 'btn-primary' : 'btn-default' ?>">
</div>
</div>
</div>
<div>
<?= $alert ?>
</div>
<div id="content" class="table-content">
<?php
if ($pagination->isRequired()) {
Expand Down Expand Up @@ -133,11 +132,11 @@ class="btn <?= $active == 0 ? 'btn-primary' : 'btn-default' ?>">
$pageSize = $paginator->getCurrentPageSize();
if ($pageSize > 0) {
echo Html::p(
sprintf('Showing %s out of %s clients', $pageSize, $paginator->getTotalItems()),
sprintf($translator->translate('invoice.index.footer.showing').' clients', $pageSize, $paginator->getTotalItems()),
['class' => 'text-muted']
);
} else {
echo Html::p('No records');
echo Html::p($translator->translate('invoice.records.no'));
}
?>

Expand Down
9 changes: 4 additions & 5 deletions resources/views/invoice/client/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use App\Widget\OffsetPagination;
use Yiisoft\Html\Html;

echo $alert;

$this->setTitle($s->trans('clients'));

$pagination = OffsetPagination::widget()
Expand Down Expand Up @@ -51,9 +53,6 @@ class="btn <?= $active == 0 ? 'btn-primary' : 'btn-default' ?>">
</div>
</div>
</div>
<div>
<?= $alert ?>
</div>
<div id="content" class="table-content">
<?php
if ($pagination->isRequired()) {
Expand Down Expand Up @@ -135,11 +134,11 @@ class="btn <?= $active == 0 ? 'btn-primary' : 'btn-default' ?>">
$pageSize = $paginator->getCurrentPageSize();
if ($pageSize > 0) {
echo Html::p(
sprintf('Showing %s out of %s clients', $pageSize, $paginator->getTotalItems()),
sprintf($translator->translate('invoice.index.footer.showing').' clients', $pageSize, $paginator->getTotalItems()),
['class' => 'text-muted']
);
} else {
echo Html::p('No records');
echo Html::p($translator->translate('invoice.records.no'));
}
?>

Expand Down
66 changes: 3 additions & 63 deletions resources/views/invoice/clientnote/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,14 @@

declare(strict_types=1);

use Yiisoft\Html\Html;
use Yiisoft\Yii\Bootstrap5\Alert;
use Yiisoft\Yii\Bootstrap5\Modal;

/**
* @var \App\Invoice\Entity\ClientNote $clientnote
* @var \Yiisoft\Router\UrlGeneratorInterface $urlGenerator
* @var bool $canEdit
* @var string $id
* @var \Yiisoft\Session\Flash\FlashInterface $flash
*/

echo $alert;
?>
<h1>Clientnote</h1>
<?php
$danger = $flash->get('danger');
if ($danger != null) {
$alert = Alert::widget()
->body($danger)
->options(['class' => ['alert-danger shadow'],])
->render();
echo $alert;
}
$info = $flash->get('info');
if ($info != null) {
$alert = Alert::widget()
->body($info)
->options(['class' => ['alert-info shadow'],])
->render();
echo $alert;
}
$warning = $flash->get('warning');
if ($warning != null) {
$alert = Alert::widget()
->body($warning)
->options(['class' => ['alert-warning shadow'],])
->render();
echo $alert;
}


?>
<h1><?= $translator->translate('invoice.client.note'); ?></h1>

<div>
<?php
if ($canEdit) {
echo Html::a('Add',
$urlGenerator->generate('clientnote/add'),
['class' => 'btn btn-outline-secondary btn-md-12 mb-3']
);
//list all the items
foreach ($clientnotes as $clientnote){
echo Html::br();
$label = $clientnote->getId() . " ";
echo Html::label($label);
echo Html::a('Edit',
$urlGenerator->generate('clientnote/edit', ['id' => $clientnote->getId()]),
['class' => 'btn btn-info btn-sm ms-2']
);
echo Html::a('View',
$urlGenerator->generate('clientnote/view', ['id' => $clientnote->getId()]),
['class' => 'btn btn-warning btn-sm ms-2']
);
//modal delete button
echo Html::a('Delete',
$urlGenerator->generate('clientnote/delete', ['id' => $clientnote->getId()]),
['class' => 'btn btn-danger btn-sm ms-2', 'onclick'=>"return confirm('".$s->trans('delete').'?'."')" ]
);
}
}
?>
</div>
11 changes: 11 additions & 0 deletions resources/views/invoice/clientpeppol/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

echo $alert;
?>

<h1><?= $translator->translate('invoice.client.peppol'); ?></h1>

<div>
</div>
Loading

0 comments on commit fb5bf01

Please sign in to comment.