Skip to content

Commit

Permalink
parametro per invio email a referenti su chiusura ordine. closes #238
Browse files Browse the repository at this point in the history
  • Loading branch information
madbob committed Nov 25, 2023
1 parent 7ab9d24 commit 726efae
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 150 deletions.
59 changes: 59 additions & 0 deletions code/app/Formatters/GenericProductFormat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace App\Formatters;

class GenericProductFormat extends Formatter
{
protected function genericColumns()
{
return [
'name' => (object) [
'name' => _i('Nome'),
'checked' => true,
],
'supplier_code' => (object) [
'name' => _i('Codice Fornitore'),
],
'measure' => (object) [
'name' => _i('Unità di Misura'),
],
'category' => (object) [
'name' => _i('Categoria'),
],
'price' => (object) [
'name' => _i('Prezzo Unitario'),
'checked' => true,
],
'active' => (object) [
'name' => _i('Ordinabile'),
],
'vat_rate' => (object) [
'name' => _i('Aliquota IVA'),
],
'portion_quantity' => (object) [
'name' => _i('Pezzatura'),
],
'variable' => (object) [
'name' => _i('Variabile'),
],
'package_size' => (object) [
'name' => _i('Dimensione Confezione'),
],
'weight' => (object) [
'name' => _i('Peso'),
],
'multiple' => (object) [
'name' => _i('Multiplo'),
],
'min_quantity' => (object) [
'name' => _i('Minimo'),
],
'max_quantity' => (object) [
'name' => _i('Massimo Consigliato'),
],
'max_available' => (object) [
'name' => _i('Disponibile'),
],
];
}
}
65 changes: 8 additions & 57 deletions code/app/Formatters/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Formatters;

class Product extends Formatter
class Product extends GenericProductFormat
{
public static function formatMeasure($obj, $context)
{
Expand Down Expand Up @@ -41,62 +41,13 @@ public static function formatVariable($obj, $context)

public static function formattableColumns($type = null)
{
$ret = [
'name' => (object) [
'name' => _i('Nome'),
'checked' => true,
],
'supplier_code' => (object) [
'name' => _i('Codice Fornitore'),
],
'measure' => (object) [
'name' => _i('Unità di Misura'),
'format' => 'static::formatMeasure',
],
'category' => (object) [
'name' => _i('Categoria'),
'format' => 'static::formatCategory',
],
'price' => (object) [
'name' => _i('Prezzo Unitario'),
'format' => 'static::formatPrice',
'checked' => true,
],
'active' => (object) [
'name' => _i('Ordinabile'),
'format' => 'static::formatActive',
],
'vat_rate' => (object) [
'name' => _i('Aliquota IVA'),
'format' => 'static::formatVat',
],
'portion_quantity' => (object) [
'name' => _i('Pezzatura'),
],
'variable' => (object) [
'name' => _i('Variabile'),
'format' => 'static::formatVariable',
],
'package_size' => (object) [
'name' => _i('Dimensione Confezione'),
],
'weight' => (object) [
'name' => _i('Peso'),
],
'multiple' => (object) [
'name' => _i('Multiplo'),
],
'min_quantity' => (object) [
'name' => _i('Minimo'),
],
'max_quantity' => (object) [
'name' => _i('Massimo Consigliato'),
],
'max_available' => (object) [
'name' => _i('Disponibile'),
],
];

$ret = $this->genericColumns();
$ret['measure']->format = 'static::formatMeasure';
$ret['category']->format = 'static::formatCategory';
$ret['price']->format = 'static::formatPrice';
$ret['active']->format = 'static::formatActive';
$ret['vat_rate']->format = 'static::formatVat';
$ret['variable']->format = 'static::formatVariable';
return $ret;
}

Expand Down
83 changes: 17 additions & 66 deletions code/app/Formatters/VariantCombo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Formatters;

class VariantCombo extends Formatter
class VariantCombo extends GenericProductFormat
{
public static function formatName($obj, $context)
{
Expand Down Expand Up @@ -86,71 +86,22 @@ public static function formatAvailable($obj, $context)

public static function formattableColumns($type = null)
{
$ret = [
'name' => (object) [
'name' => _i('Nome'),
'checked' => true,
'format' => 'static::formatName',
],
'supplier_code' => (object) [
'name' => _i('Codice Fornitore'),
'format' => 'static::formatCode',
],
'measure' => (object) [
'name' => _i('Unità di Misura'),
'format' => 'static::formatMeasure',
],
'category' => (object) [
'name' => _i('Categoria'),
'format' => 'static::formatCategory',
],
'price' => (object) [
'name' => _i('Prezzo Unitario'),
'checked' => true,
'format' => 'static::formatPrice',
],
'active' => (object) [
'name' => _i('Ordinabile'),
'format' => 'static::formatActive',
],
'vat_rate' => (object) [
'name' => _i('Aliquota IVA'),
'format' => 'static::formatVat',
],
'portion_quantity' => (object) [
'name' => _i('Pezzatura'),
'format' => 'static::formatPortion',
],
'variable' => (object) [
'name' => _i('Variabile'),
'format' => 'static::formatVariable',
],
'package_size' => (object) [
'name' => _i('Dimensione Confezione'),
'format' => 'static::formatPackage',
],
'weight' => (object) [
'name' => _i('Peso'),
'format' => 'static::formatWeight',
],
'multiple' => (object) [
'name' => _i('Multiplo'),
'format' => 'static::formatMultipe',
],
'min_quantity' => (object) [
'name' => _i('Minimo'),
'format' => 'static::formatMinimum',
],
'max_quantity' => (object) [
'name' => _i('Massimo Consigliato'),
'format' => 'static::formatMaximum',
],
'max_available' => (object) [
'name' => _i('Disponibile'),
'format' => 'static::formatAvailable',
],
];

$ret = $this->genericColumns();
$ret['name']->format = 'static::formatName';
$ret['supplier_code']->format = 'static::formatCode';
$ret['measure']->format = 'static::formatMeasure';
$ret['category']->format = 'static::formatCategory';
$ret['price']->format = 'static::formatPrice';
$ret['active']->format = 'static::formatActive';
$ret['vat_rate']->format = 'static::formatVat';
$ret['portion_quantity']->format = 'static::formatPortion';
$ret['variable']->format = 'static::formatVariable';
$ret['package_size']->format = 'static::formatPackage';
$ret['weight']->format = 'static::formatWeight';
$ret['multiple']->format = 'static::formatMultipe';
$ret['min_quantity']->format = 'static::formatMinimum';
$ret['max_quantity']->format = 'static::formatMaximum';
$ret['max_available']->format = 'static::formatAvailable';
return $ret;
}
}
1 change: 1 addition & 0 deletions code/app/Http/Controllers/GasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ private function configMails($gas, $request)
$gas->setConfig('notify_all_new_orders', $request->has('notify_all_new_orders') ? '1' : '0');
$gas->setConfig('send_order_reminder', $request->has('enable_send_order_reminder') ? $request->input('send_order_reminder') : '0');
$gas->setConfig('auto_user_order_summary', $request->has('auto_user_order_summary') ? '1' : '0');
$gas->setConfig('auto_referent_order_summary', $request->has('auto_referent_order_summary') ? '1' : '0');
$gas->setConfig('auto_supplier_order_summary', $request->has('auto_supplier_order_summary') ? '1' : '0');

foreach(systemParameters('MailTypes') as $identifier => $metadata) {
Expand Down
12 changes: 7 additions & 5 deletions code/app/Jobs/NotifyClosedOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ protected function realHandle()
}

foreach($notifiable_users as $notifiable) {
try {
$notifiable->user->notify(new ClosedOrdersNotification($notifiable->orders, $notifiable->files));
}
catch(\Exception $e) {
Log::error('Errore in notifica chiusura ordine: ' . $e->getMessage());
if ($notifiable->gas->auto_referent_order_summary) {
try {
$notifiable->user->notify(new ClosedOrdersNotification($notifiable->orders, $notifiable->files));
}
catch(\Exception $e) {
Log::error('Errore in notifica chiusura ordine: ' . $e->getMessage());
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions code/app/Parameters/Config/AutoReferentOrderSummery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Parameters\Config;

class AutoReferentOrderSummery extends Config
{
public function identifier()
{
return 'auto_referent_order_summary';
}

public function type()
{
return 'boolean';
}

public function default()
{
return 0;
}
}
2 changes: 1 addition & 1 deletion code/public/css/gasdotto.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion code/public/css/gasdotto.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion code/public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/gasdotto.js": "/js/gasdotto.js?id=a09d9e89336a27cced111ddfd20c181f",
"/css/gasdotto.css": "/css/gasdotto.css?id=997e46c44b439912f20b9c87e677eb7b"
"/css/gasdotto.css": "/css/gasdotto.css?id=0151594e1431026defac81030890d060"
}
15 changes: 15 additions & 0 deletions code/resources/assets/sass/gasdotto.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ html, body {

.alert {
margin-bottom: 0;

p:last-of-type {
margin-bottom: 0;
}

ul:last-of-type {
margin-bottom: 0;
}
}

.iblock {
Expand Down Expand Up @@ -157,6 +165,13 @@ table {
&.fixed-table {
table-layout: fixed;
}

&.inline-cells {
td > * {
display: inline-block;
vertical-align: middle;
}
}
}

.dynamic-table {
Expand Down
Loading

0 comments on commit 726efae

Please sign in to comment.