Introduzione stampa cespiti
This commit is contained in:
parent
2cbbea902b
commit
132579719c
|
@ -0,0 +1,59 @@
|
|||
<?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';
|
||||
|
||||
// Trovo id_print della stampa
|
||||
if(!empty(setting('Magazzino cespiti'))){
|
||||
|
||||
$id_print = $dbo->fetchOne('SELECT zz_prints.id FROM zz_prints INNER JOIN zz_modules ON zz_prints.id_module=zz_modules.id WHERE zz_modules.name="Articoli" AND zz_prints.name="Inventario cespiti"')['id'];
|
||||
|
||||
echo '
|
||||
<form action="'.base_path().'/pdfgen.php?id_print='.$id_print.'" method="post" target="_blank">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Articoli da stampare').'", "name": "tipo", "required": "1", "values": "list=\"full\": \"'.tr('Tutti').'\", \"nozero\": \"'.tr('Solo esistenti').'\"", "value": "full" ]}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary btn-block">
|
||||
<i class="fa fa-print"></i> '.tr('Stampa').'
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
}else{
|
||||
|
||||
echo '
|
||||
<div class="alert alert-danger" style="margin:0px;">
|
||||
'.tr('Seleziona il magazzino cespiti dalle impostazioni per visualizzare la stampa.').'
|
||||
</div>';
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
<?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/>.
|
||||
*/
|
||||
|
||||
use Util\Query;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if(!empty(setting('Magazzino cespiti'))){
|
||||
|
||||
$id_module = Modules::get('Articoli')['id'];
|
||||
$structure = Modules::get($id_module);
|
||||
|
||||
// RISULTATI VISIBILI
|
||||
Util\Query::setSegments(false);
|
||||
$query = Query::getQuery($structure, $where, 0, []);
|
||||
|
||||
$query = Modules::replaceAdditionals($id_module, $query);
|
||||
|
||||
$query = preg_replace('/FROM `mg_articoli`/', ' FROM mg_articoli LEFT JOIN (SELECT idarticolo, SUM(qta) AS qta_totale FROM mg_movimenti WHERE idsede='.setting('Magazzino cespiti').' GROUP BY idarticolo) movimenti ON movimenti.idarticolo=mg_articoli.id ', $query);
|
||||
|
||||
// Modifiche alla query principale
|
||||
$query = preg_replace('/^SELECT /', 'SELECT mg_articoli.prezzo_vendita,', $query);
|
||||
$query = preg_replace('/^SELECT /', 'SELECT mg_articoli.um,', $query);
|
||||
$query = preg_replace('/^SELECT /', 'SELECT movimenti.qta_totale,', $query);
|
||||
|
||||
$query = str_replace('1=1', '1=1 AND cespiti=1', $query);
|
||||
$query = str_replace('cespiti=0', 'cespiti=1', $query);
|
||||
|
||||
if (post('tipo') == 'nozero') {
|
||||
$query = str_replace('2=2', '2=2 AND mg_articoli.qta > 0', $query);
|
||||
}
|
||||
|
||||
$data = Query::executeAndCount($query);
|
||||
|
||||
echo '
|
||||
<h3>'.tr('Inventario cespiti').'</h3>
|
||||
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center" width="150">'.tr('Codice', [], ['upper' => true]).'</th>
|
||||
<th class="text-center">'.tr('Categoria', [], ['upper' => true]).'</th>
|
||||
<th class="text-center">'.tr('Descrizione', [], ['upper' => true]).'</th>
|
||||
<th class="text-center" width="70">'.tr('Prezzo di vendita', [], ['upper' => true]).'</th>
|
||||
<th class="text-center" width="70">'.tr('Q.tà', [], ['upper' => true]).'</th>
|
||||
<th class="text-center" width="70">'.tr('Prezzo di acquisto', [], ['upper' => true]).'</th>
|
||||
<th class="text-center" width="90">'.tr('Valore totale', [], ['upper' => true]).'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
$totale_qta = 0;
|
||||
$totali = [];
|
||||
foreach ($data['results'] as $r) {
|
||||
$valore_magazzino = $r['acquisto'] * $r['qta_totale'];
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$r['Codice'].'</td>
|
||||
<td>'.$r['Categoria'].'</td>
|
||||
<td>'.$r['Descrizione'].'</td>
|
||||
<td class="text-right">'.moneyFormat($r['prezzo_vendita']).'</td>
|
||||
<td class="text-right">'.Translator::numberToLocale($r['qta_totale']).' '.$r['um'].'</td>
|
||||
<td class="text-right">'.moneyFormat($r['acquisto']).'</td>
|
||||
<td class="text-right">'.moneyFormat($valore_magazzino).'</td>
|
||||
</tr>';
|
||||
|
||||
$totale_qta += $r['qta_totale'];
|
||||
$totali[] = $valore_magazzino;
|
||||
}
|
||||
|
||||
// Totali
|
||||
$totale_acquisto = sum($totali);
|
||||
echo '
|
||||
</tbody>
|
||||
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top"><b>'.tr('Totale', [], ['upper' => true]).':</b></td>
|
||||
<td class="border-top"></td>
|
||||
<td class="text-right border-top"><b>'.Translator::numberToLocale($totale_qta).'</b></td>
|
||||
<td class="border-top"></td>
|
||||
<td class="text-right border-top"><b>'.moneyFormat($totale_acquisto).'</b></td>
|
||||
</tr>
|
||||
</table>';
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header di default.
|
||||
* I contenuti di questo file vengono utilizzati per generare l'header delle stampe nel caso non esista un file header.php all'interno della stampa.
|
||||
*
|
||||
* Per modificare l'header della stampa basta aggiungere un file header.php all'interno della cartella della stampa con i contenuti da mostrare (vedasi templates/fatture/header.php).
|
||||
*
|
||||
* La personalizzazione specifica dell'header deve comunque seguire lo standard della cartella custom: anche se il file header.php non esiste nella stampa originaria, se si vuole personalizzare l'header bisogna crearlo all'interno della cartella custom.
|
||||
*/
|
||||
|
||||
echo '
|
||||
<div class="row" style="'.((!empty($settings['header-font-size'])) ? 'font-size:'.($settings['header-font-size']).'px;' : '').'" >
|
||||
<div class="col-xs-12 text-right" >
|
||||
<p><b>'.$f_ragionesociale.'</b></p>
|
||||
<p>'.$f_indirizzo.'</p>
|
||||
<p>'.$f_citta_full.'</p>
|
||||
<p>'.(!empty($f_piva) ? tr('P.Iva').': '.$f_piva : '').'</p>
|
||||
<p>'.(!empty($f_codicefiscale) ? tr('C.F.').': '.$f_codicefiscale : '').'</p>
|
||||
<p>'.(!empty($f_capsoc) ? tr('Cap.Soc.').': '.$f_capsoc : '').'</p>
|
||||
<p>'.(!empty($f_telefono) ? tr('Tel').': '.$f_telefono : '').'</p>
|
||||
<p>'.(!empty($f_email) ? tr('Email').': '.$f_email : '').'</p>
|
||||
<p>'.(!empty($f_pec) ? tr('PEC').': '.$f_pec : '').'</p>
|
||||
<p>'.(!empty($f_sitoweb) ? tr('Web').': '.$f_sitoweb : '').'</p>
|
||||
</div>
|
||||
</div>';
|
|
@ -0,0 +1,23 @@
|
|||
<?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/>.
|
||||
*/
|
||||
|
||||
return [
|
||||
'orientation' => 'L',
|
||||
'font-size' => '11pt',
|
||||
];
|
|
@ -1725,3 +1725,29 @@ ALTER TABLE `or_tipiordine`
|
|||
ALTER TABLE `or_tipiordine` CHANGE `id` `id` INT NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `or_tipiordine_lang` ADD CONSTRAINT `or_tipiordine_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `or_tipiordine`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
|
||||
|
||||
-- Aggiunta tabella zz_cache_lang
|
||||
CREATE TABLE IF NOT EXISTS `zz_cache_lang` (
|
||||
`id` int NOT NULL,
|
||||
`id_lang` int NOT NULL,
|
||||
`id_record` int NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL
|
||||
);
|
||||
ALTER TABLE `zz_cache_lang`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `zz_cache_lang`
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
INSERT INTO `zz_cache_lang` (`id`, `id_lang`, `id_record`, `name`) SELECT NULL, (SELECT `id` FROM `zz_langs` WHERE `iso_code` = 'it'), `id`, `name` FROM `zz_cache`;
|
||||
|
||||
ALTER TABLE `zz_cache`
|
||||
DROP `name`;
|
||||
|
||||
ALTER TABLE `zz_cache_lang` ADD CONSTRAINT `zz_cache_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `zz_cache`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
|
||||
|
||||
-- Introduzione stampa cespiti
|
||||
INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Magazzino cespiti', '', 'query=SELECT id, nomesede AS descrizione FROM an_sedi WHERE idanagrafica=(SEELCT valore FROM zz_settings WHERE name=\'Azienda predefinita\')', '1', 'Magazzino', NULL, 'Magazzino cespiti per la stampa dei cespiti dal modulo articoli');
|
||||
|
||||
INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`, `help`) VALUES
|
||||
(NULL, 'Stampa cespiti', 'print', 21, 'controller_top', 'col-md-12', '', '#45a9f1', 'fa fa-print', '', './modules/articoli/widgets/stampa_cespiti.php', 'popup', '', 'Stampa cespiti', 1, 1, NULL);
|
||||
|
|
Loading…
Reference in New Issue