Compare commits

...

3 Commits

Author SHA1 Message Date
valentina 248edcbe1e Miglioria footer fatture di vendita 2024-09-30 17:32:35 +02:00
Beppe df469372ff Merge branch 'master' of https://github.com/devcode-it/openstamanager 2024-09-30 14:54:30 +02:00
Beppe a07ad860b3 Aggiunta marchi articoli 2024-09-30 14:54:27 +02:00
9 changed files with 370 additions and 78 deletions

View File

@ -148,6 +148,7 @@ switch (post('op')) {
$articolo->servizio = post('servizio'); $articolo->servizio = post('servizio');
$articolo->volume = post('volume'); $articolo->volume = post('volume');
$articolo->peso_lordo = post('peso_lordo'); $articolo->peso_lordo = post('peso_lordo');
$articolo->id_marchio = post('id_marchio');
$articolo->um_secondaria = post('um_secondaria'); $articolo->um_secondaria = post('um_secondaria');
$articolo->fattore_um_secondaria = post('fattore_um_secondaria'); $articolo->fattore_um_secondaria = post('fattore_um_secondaria');

View File

@ -50,15 +50,20 @@ use Modules\Iva\Aliquota;
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?php echo (!empty($record['id_categoria'])) ? <?php echo (!empty($record['id_categoria'])) ?
Modules::link('Categorie articoli', $record['id_categoria'], null, null, 'class="pull-right"') : ''; ?> Modules::link('Categorie articoli', $record['id_categoria'], null, null, 'class="pull-right"') : ''; ?>
{[ "type": "select", "label": "<?php echo tr('Categoria'); ?>", "name": "categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie", "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>" ]} {[ "type": "select", "label": "<?php echo tr('Categoria'); ?>", "name": "categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie", "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>" ]}
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
{[ "type": "select", "label": "<?php echo tr('Sottocategoria'); ?>", "name": "subcategoria", "value": "$id_sottocategoria$", "ajax-source": "sottocategorie", "select-options": <?php echo json_encode(['id_categoria' => $record['id_categoria']]); ?>, "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>|id_original=<?php echo $record['id_categoria']; ?>" ]} {[ "type": "select", "label": "<?php echo tr('Sottocategoria'); ?>", "name": "subcategoria", "value": "$id_sottocategoria$", "ajax-source": "sottocategorie", "select-options": <?php echo json_encode(['id_categoria' => $record['id_categoria']]); ?>, "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>|id_original=<?php echo $record['id_categoria']; ?>" ]}
</div> </div>
<div class="col-md-4">
<?php echo ( !empty($record['id_marchio']) ? Modules::link('Marchi', $record['id_marchio'], null, null, 'class="pull-right"') : '' ) ?>
{[ "type": "select", "label": "<?php echo tr('Marchio'); ?>", "name": "id_marchio", "value":"$id_marchio$", "values": "query=SELECT id, nome AS descrizione FROM mg_marchi ORDER BY descrizione ASC" ]}
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,53 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
switch (post('op')) {
// Aggiorno informazioni di base impianto
case 'update':
$dbo->update('mg_marchi',[
'nome' => post('nome'),
],['id' => $id_record]);
flash()->info(tr('Informazioni salvate correttamente!'));
break;
// Aggiungo impianto
case 'add':
$dbo->insert('mg_marchi',[
'nome' => post('nome'),
]);
$id_record = $dbo->lastInsertedID();
flash()->info(tr('Aggiunto nuovo marchio!'));
break;
// Rimuovo impianto e scollego tutti i suoi componenti
case 'delete':
$dbo->query('DELETE FROM mg_marchi WHERE id='.prepare($id_record));
flash()->info(tr('Marchio eliminato!'));
break;
}

40
modules/marchi/add.php Normal file
View File

@ -0,0 +1,40 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
$id_anagrafica = filter('id_anagrafica');
?><form action="" method="post" id="add-form">
<input type="hidden" name="op" value="add">
<input type="hidden" name="backto" value="record-edit">
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "validation": "nome" ]}
</div>
</div>
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
</div>
</div>
</form>

78
modules/marchi/edit.php Normal file
View File

@ -0,0 +1,78 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
?><form action="" method="post" id="edit-form" enctype="multipart/form-data">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="update">
<input type="hidden" name="matricola" value="<?php echo $id_record; ?>">
<!-- DATI ANAGRAFICI -->
<div class="card card-primary">
<div class="card-header">
<h3 class="panel-title"><?php echo tr('Dati marchio'); ?></h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "value":"$nome$", "required": 1, "validation": "nome" ]}
</div>
</div>
</div>
</div>
</form>
<?php
$elementi = $dbo->fetchArray('SELECT `mg_articoli`.`id`, CONCAT(`mg_articoli`.`codice`, " - ", `mg_articoli_lang`.`title`) AS `descrizione` FROM `mg_articoli` INNER JOIN mg_articoli_lang ON (`mg_articoli_lang`.`id_record` = `mg_articoli`.`id` AND `mg_articoli_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `mg_articoli`.`id_marchio` = '.prepare($id_record));
$class = '';
if (!empty($elementi)) {
echo '
<div class="card card-warning collapsable collapsed-card">
<div class="card-header with-border">
<h3 class="card-title"><i class="fa fa-warning"></i> '.tr('Articoli collegati: _NUM_', [
'_NUM_' => count($elementi),
]).'</h3>
<div class="card-tools pull-right">
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fa fa-plus"></i></button>
</div>
</div>
<div class="card-body">
<ul>';
foreach ($elementi as $elemento) {
echo '
<li>'.Modules::link('Articoli', $elemento['id'], $elemento['descrizione']).'</li>';
}
$class = 'disabled';
echo '
</ul>
</div>
</div>';
}
echo '
<a class="btn btn-danger ask '.$class.'" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';

24
modules/marchi/init.php Normal file
View File

@ -0,0 +1,24 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
if (isset($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM mg_marchi WHERE id='.prepare($id_record));
}

View File

@ -0,0 +1,40 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
$name = filter('name');
$value = filter('value');
switch ($name) {
case 'nome':
$disponibile = $dbo->table('mg_marchi')->where([
['nome', $value],
['id', '<>', $id_record],
])->count() == 0;
$message = $disponibile ? tr('Il nome è disponbile') : tr('Il nome è già utilizzato in un altro marchio');
$response = [
'result' => $disponibile,
'message' => $message,
];
break;
}

View File

@ -21,21 +21,10 @@ if (!$is_last_page) {
return; return;
} }
// Calcoli
// $imponibile = abs($documento->imponibile);
// $sconto = $documento->sconto;
// $totale_imponibile = abs($documento->totale_imponibile);
// $totale_iva = abs($documento->iva);
// $totale = abs($documento->totale) - $rivalsa;
$totale_imponibile = 0; $imponibile = 0;
foreach ($v_totale as $key => $v) { foreach ($v_totale as $key => $v) {
$totale_imponibile += $v; $totale_scontato += $v;
}
$totale_iva = 0;
foreach ($v_iva as $key => $v) {
$totale_iva += $v;
} }
$sconto = 0; $sconto = 0;
@ -43,8 +32,21 @@ foreach ($righe as $riga) {
$sconto += floatval($riga->sconto); $sconto += floatval($riga->sconto);
} }
$rivalsa = floatval($record['rivalsainps']); $imponibile = $totale_scontato+$sconto;
$imponibile = $totale_imponibile + $sconto;
$rivalsa = 0;
foreach ($righe as $riga) {
$rivalsa += floatval($riga->rivalsainps);
}
$totale_imponibile = $totale_scontato + $rivalsa;
$totale_iva = 0;
foreach ($righe as $riga) {
$aliquota = $database->fetchOne('SELECT percentuale FROM co_iva WHERE id = '.prepare($riga->idiva))['percentuale'];
$totale_iva += $totale_imponibile * $aliquota / 100;
}
$totale = $totale_iva + $totale_imponibile; $totale = $totale_iva + $totale_imponibile;
$show_sconto = $sconto > 0; $show_sconto = $sconto > 0;
@ -54,14 +56,14 @@ $peso_lordo = $documento->peso ?: $documento->peso_calcolato;
$width = round(100 / ($show_sconto ? 5 : 3), 2); $width = round(100 / ($show_sconto ? 5 : 3), 2);
$has_rivalsa = !empty($record['rivalsainps']); $has_rivalsa = !empty($rivalsa);
$has_ritenuta = !empty($record['ritenutaacconto']) || !empty($documento->totale_ritenuta_contributi) || !empty($record['split_payment']); $has_ritenuta = !empty($record['ritenutaacconto']) || !empty($documento->totale_ritenuta_contributi) || !empty($record['split_payment']);
$has_split_payment = !empty($record['split_payment']); $has_split_payment = !empty($record['split_payment']);
$has_sconto_finale = !empty($sconto_finale); $has_sconto_finale = !empty($sconto_finale);
$etichette = [ $etichette = [
'totale' => tr('Totale', [], ['upper' => true]), 'totale' => tr('Totale imponibile', [], ['upper' => true]),
'totale_parziale' => tr('Totale parziale', [], ['upper' => true]), 'totale_parziale' => tr('Totale documento', [], ['upper' => true]),
'totale_finale' => tr('Netto a pagare', [], ['upper' => true]), 'totale_finale' => tr('Netto a pagare', [], ['upper' => true]),
]; ];
@ -206,12 +208,18 @@ echo '
* Se sconto: Imponibile | Sconto | Totale imponibile | Totale IVA | Totale * Se sconto: Imponibile | Sconto | Totale imponibile | Totale IVA | Totale
* Altrimenti: Imponibile | Totale IVA | Totale * Altrimenti: Imponibile | Totale IVA | Totale
*/ */
if ($has_ritenuta || $show_sconto || $has_rivalsa) {
echo " echo "
<tr> <tr>
<th class='text-center small' style='width:".$width."'> <th class='text-center small' style='width:".$width."'>
".tr('Imponibile', [], ['upper' => true]).' ".tr('Imponibile', [], ['upper' => true])."
</th>'; </th>";
} else {
echo "
<tr>
<th class='text-center small' style='width:".$width."'>
</th>";
}
if ($show_sconto) { if ($show_sconto) {
echo " echo "
<th class='text-center small' style='width:".$width."'> <th class='text-center small' style='width:".$width."'>
@ -219,53 +227,82 @@ if ($show_sconto) {
</th> </th>
<th class='text-center small' style='width:".$width."'> <th class='text-center small' style='width:".$width."'>
".tr('Totale imponibile', [], ['upper' => true]).' ".tr('Totale scontato', [], ['upper' => true]).'
</th>'; </th>';
} }
if ($has_rivalsa) {
echo " echo "
<th class='text-center small' style='width:".$width."'> <th class='text-center small' style='width:".$width."'>
".tr('Totale IVA', [], ['upper' => true])." ".tr('Cassa Previdenziale', [], ['upper' => true])."
</th> </th>";
} else {
echo "
<th class='text-center small' style='width:".$width."'> <th class='text-center small' style='width:".$width."'>
".(!$has_rivalsa && !$has_ritenuta && !$has_split_payment && !$has_sconto_finale ? $etichette['totale'] : $etichette['totale_parziale'])." </th>";
}
echo "
<th class='text-center small' style='width:".$width."'>
".(($show_sconto) ? $etichette['totale_parziale'] : $etichette['totale'])."
</th> </th>
</tr> </tr>";
if ($has_ritenuta || $show_sconto) {
echo "
<tr> <tr>
<td class='cell-padded text-center'> <td class='cell-padded text-center'>
".moneyFormat($show_sconto ? $imponibile : $totale_imponibile, $d_totali).' ".moneyFormat($imponibile, $d_totali).'
</td>'; </td>';
} else {
echo "
<tr>
<td class='cell-padded text-center'>
</td>";
}
if ($show_sconto) { if ($show_sconto) {
echo " echo "
<td class='cell-padded text-center'> <td class='cell-padded text-center'>
".moneyFormat(abs($sconto), $d_totali)." ".moneyFormat(abs($sconto), $d_totali)."
</td> </td>
<td class='cell-padded text-center'> <td class='cell-padded text-center'>
".moneyFormat($totale_imponibile, $d_totali).' ".moneyFormat($totale_scontato, $d_totali).'
</td>'; </td>';
} } else if (!$has_rivalsa) {
echo " echo "
<td class='cell-padded text-center'> <td class='cell-padded text-center'>
".moneyFormat($totale_iva, $d_totali)." </td>";
</td> }
<td class='cell-padded text-center'>
".moneyFormat($totale, $d_totali).'
</td>
</tr>';
/* /*
* Riga di riepilogo della Rivalsa INPS. * Riga di riepilogo della Rivalsa INPS.
* Rivalsa INPS | Totale (+ Rivalsa INPS) * Rivalsa INPS | Totale (+ Rivalsa INPS)
*/ */
if ($has_rivalsa) { if ($has_rivalsa) {
$rs2 = $dbo->fetchArray('SELECT percentuale FROM co_rivalse WHERE id=(SELECT idrivalsainps FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND idrivalsainps!=0 LIMIT 0,1)'); $rs2 = $dbo->fetchOne('SELECT percentuale, descrizione FROM co_rivalse WHERE id=(SELECT idrivalsainps FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND idrivalsainps!=0)');
echo '
<td class="cell-padded text-center">
'.moneyFormat($rivalsa, 2).'
<p class="text-muted small-bold">'.$rs2['descrizione'].'</p>
</td>
<td class="cell-padded text-center">
'.moneyFormat($totale_imponibile, $d_totali).'
</td>
</tr>';
} else if ($show_sconto) {
echo '
<td class="cell-padded text-center">
</td>
<td class="cell-padded text-center">
'.moneyFormat($totale_imponibile, $d_totali).'
</td>
</tr>';
} else {
echo '
<td class="cell-padded text-center">
'.moneyFormat($totale_imponibile, $d_totali).'
</td>';
}
$first_colspan = 3; $first_colspan = 3;
$second_colspan = 2; $second_colspan = 2;
@ -278,12 +315,8 @@ if ($has_rivalsa) {
echo ' echo '
<tr> <tr>
<th class="text-center small" colspan="'.$first_colspan.'"> <th class="text-center small" colspan="'.$first_colspan.'">
'.tr('Rivalsa _PRC_%', [ '.tr('Totale IVA', [], ['upper' => true]).'
'_PRC_' => Translator::numberToLocale($rs2[0]['percentuale'], 0), </th>
], ['upper' => true]).'
</th>';
echo '
<th class="text-center small" colspan="'.$second_colspan.'"> <th class="text-center small" colspan="'.$second_colspan.'">
'.(!$has_ritenuta && !$has_split_payment && !$has_sconto_finale ? $etichette['totale_finale'] : $etichette['totale_parziale']).' '.(!$has_ritenuta && !$has_split_payment && !$has_sconto_finale ? $etichette['totale_finale'] : $etichette['totale_parziale']).'
@ -292,17 +325,14 @@ if ($has_rivalsa) {
<tr> <tr>
<td class="cell-padded text-center" colspan="'.$first_colspan.'"> <td class="cell-padded text-center" colspan="'.$first_colspan.'">
'.moneyFormat($rivalsa, 2).' '.moneyFormat($totale_iva, $d_totali).'
</td>'; </td>
$totale = $totale + $rivalsa;
echo '
<td class="cell-padded text-center" colspan="'.$second_colspan.'"> <td class="cell-padded text-center" colspan="'.$second_colspan.'">
'.moneyFormat($totale, 2).' '.moneyFormat($totale, $d_totali).'
</td> </td>
</tr>'; </tr>';
}
/* /*
* Riga di riepilogo di Ritenuta d'acconto e Ritenuta contributi. * Riga di riepilogo di Ritenuta d'acconto e Ritenuta contributi.
@ -443,8 +473,7 @@ if ($has_sconto_finale) {
<td class="cell-padded text-center" colspan="'.$first_colspan.'"> <td class="cell-padded text-center" colspan="'.$first_colspan.'">
'.moneyFormat($sconto_finale, 2).' '.moneyFormat($sconto_finale, 2).'
</td> </td>
<td class="cell-padded text-center" colspan="'.$second_colspan.'" style="background-color: #FFFFCC;">
<td class="cell-padded text-center" colspan="'.$second_colspan.'">
'.moneyFormat($totale, 2).' '.moneyFormat($totale, 2).'
</td> </td>
</tr>'; </tr>';

22
update/2_5_6.sql Normal file
View File

@ -0,0 +1,22 @@
-- Aggiunta Marchio articolo
ALTER TABLE `mg_articoli` ADD `id_marchio` INT NULL DEFAULT NULL;
CREATE TABLE `mg_marchi` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)) ENGINE = InnoDB;
INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES (NULL, 'Marchi', 'marchi', 'SELECT |select| FROM `mg_marchi` WHERE 1=1 HAVING 2=2 ORDER BY `mg_marchi`.`nome`', '', 'fa fa-angle-right', '2.5.6', '2.5.6', '7', (SELECT `id` FROM `zz_modules` AS `t` WHERE `name` = 'Articoli'), '1', '1', '1', '1');
INSERT INTO `zz_modules_lang` (`id`, `id_lang`, `id_record`, `title`) VALUES (NULL, '1', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'Marchi');
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `html_format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'id', 'mg_marchi.id', '0', '0', '0', '0', '0', '', '', '0', '0', '0'),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'Nome', 'mg_marchi.nome', '1', '0', '0', '0', '0', '', '', '1', '0', '0');
INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES
(1, (SELECT `id` FROM `zz_views` WHERE `name` = 'id' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi')), 'id'),
(1, (SELECT `id` FROM `zz_views` WHERE `name` = 'Nome' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi')), 'Nome');