mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-12 01:20:36 +01:00
Aggiunta filtri stampa scadenzario
This commit is contained in:
parent
a0f1594e5e
commit
8d2d077280
@ -63,7 +63,6 @@ switch (post('op')) {
|
||||
flash()->info(tr('Fatture eliminate!'));
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'genera-xml':
|
||||
|
||||
@ -101,6 +100,7 @@ switch (post('op')) {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'export-xml-bulk':
|
||||
$dir = DOCROOT.'/files/export_fatture/';
|
||||
directory($dir.'tmp/');
|
||||
|
@ -52,7 +52,7 @@ include_once $docroot.'/templates/pdfgen_variables.php';
|
||||
// LEFT OUTER JOIN mg_categorie ON (mg_categorie.id=mg_articoli.id_categoria AND mg_categorie.parent = 0) OR (mg_categorie.id=mg_articoli.id_sottocategoria AND mg_categorie.parent = 1)
|
||||
$period_end = $_SESSION['period_end'];
|
||||
|
||||
$query = 'SELECT *, mg_articoli.id AS id_articolo, (SELECT nome FROM mg_categorie WHERE mg_categorie.parent = 0 AND mg_categorie.id = mg_articoli.id_categoria) AS categoria, (SELECT nome FROM mg_categorie WHERE mg_categorie.parent = 1 AND mg_categorie.id = mg_articoli.id_sottocategoria) AS subcategoria, (SELECT SUM(qta) FROM mg_movimenti WHERE mg_movimenti.idarticolo=mg_articoli.id AND (mg_movimenti.idintervento IS NULL) AND data <= '.prepare($period_end).' ) AS qta FROM mg_articoli WHERE 1=1 '.$add_where.' HAVING 2=2 AND qta > 0 '.$add_having.' ORDER BY codice ASC';
|
||||
$query = 'SELECT *, mg_articoli.id AS id_articolo, (SELECT nome FROM mg_categorie WHERE mg_categorie.parent = 0 AND mg_categorie.id = mg_articoli.id_categoria) AS categoria, (SELECT nome FROM mg_categorie WHERE mg_categorie.parent = 1 AND mg_categorie.id = mg_articoli.id_sottocategoria) AS subcategoria, (SELECT SUM(qta) FROM mg_movimenti WHERE mg_movimenti.idarticolo=mg_articoli.id AND (mg_movimenti.idintervento IS NULL) AND data <= '.prepare($period_end).' ) AS qta FROM mg_articoli WHERE 1=1 '.$add_where.' HAVING 2=2 AND servizio = 0 AND attivo = 1'.$add_having.' ORDER BY codice ASC';
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$totrows = sizeof($rs);
|
||||
|
||||
@ -75,7 +75,7 @@ for ($r = 0; $r < sizeof($rs); ++$r) {
|
||||
$body .= " <td class='first_cell cell-padded'>".$rs[$r]['codice']."</td>\n";
|
||||
$body .= " <td class='table_cell cell-padded'>".$rs[$r]['descrizione']."</td>\n";
|
||||
$body .= " <td class='table_cell text-right cell-padded'>".moneyFormat($rs[$r]['prezzo_vendita'])."</td>\n";
|
||||
$body .= " <td class='table_cell text-right cell-padded'>".$rs[$r]['um'].' '.Translator::numberToLocale($rs[$r]['qta'])."</td>\n";
|
||||
$body .= " <td class='table_cell text-right cell-padded'>".Translator::numberToLocale($rs[$r]['qta'])." ".$rs[$r]['um']."</td>\n";
|
||||
$body .= " <td class='table_cell text-right cell-padded'>".moneyFormat($rs[$r]['prezzo_acquisto'])."</td>\n";
|
||||
$body .= " <td class='table_cell text-right cell-padded'>".moneyFormat(($rs[$r]['prezzo_acquisto'] * $rs[$r]['qta']))."</td>\n";
|
||||
$body .= "</tr>\n";
|
||||
|
@ -3,10 +3,43 @@
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$module_name = 'Scadenzario';
|
||||
|
||||
$date_start = $_SESSION['period_start'];
|
||||
$date_end = $_SESSION['period_end'];
|
||||
|
||||
|
||||
|
||||
$module = Modules::get('Scadenzario');
|
||||
$id_module = $module['id'];
|
||||
|
||||
$total = Util\Query::readQuery($module);
|
||||
|
||||
|
||||
// Lettura parametri modulo
|
||||
$module_query = $total['query'];
|
||||
|
||||
$search_filters = [];
|
||||
|
||||
if (is_array($_SESSION['module_'.$id_module])) {
|
||||
foreach ($_SESSION['module_'.$id_module] as $field => $value) {
|
||||
if (!empty($value) && starts_with($field, 'search_')) {
|
||||
$field_name = str_replace('search_', '', $field);
|
||||
$field_name = str_replace('__', ' ', $field_name);
|
||||
$field_name = str_replace('-', ' ', $field_name);
|
||||
array_push($search_filters, '`'.$field_name.'` LIKE "%'.$value.'%"');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search_filters)) {
|
||||
$module_query = str_replace('2=2', '2=2 AND ('.implode(' AND ', $search_filters).') ', $module_query);
|
||||
}
|
||||
|
||||
// Filtri derivanti dai permessi (eventuali)
|
||||
$module_query = Modules::replaceAdditionals($id_module, $module_query);
|
||||
|
||||
$scadenze = $dbo->fetchArray($module_query);
|
||||
|
||||
|
||||
// carica report html
|
||||
$report = file_get_contents($docroot.'/templates/scadenzario/scadenzario.html');
|
||||
$body = file_get_contents($docroot.'/templates/scadenzario/scadenzario_body.html');
|
||||
@ -14,7 +47,7 @@ $body = file_get_contents($docroot.'/templates/scadenzario/scadenzario_body.html
|
||||
include_once $docroot.'/templates/pdfgen_variables.php';
|
||||
|
||||
//Filtro in base al segmento
|
||||
$id_segment = $_SESSION['module_18']['id_segment'];
|
||||
$id_segment = $_SESSION['module_'.$id_module]['id_segment'];
|
||||
$rs_segment = $dbo->fetchArray('SELECT * FROM zz_segments WHERE id='.prepare($id_segment));
|
||||
|
||||
$add_where = 'AND '.$rs_segment[0]['clause'];
|
||||
@ -36,25 +69,25 @@ $body .= "</thead>\n";
|
||||
|
||||
$body .= "<tbody>\n";
|
||||
|
||||
$rs = $dbo->fetchArray("SELECT co_scadenziario.id AS id, ragione_sociale AS `Anagrafica`, co_pagamenti.descrizione AS `Tipo di pagamento`, CONCAT( co_tipidocumento.descrizione, CONCAT( ' numero ', IF(numero_esterno<>'', numero_esterno, numero) ) ) AS `Documento`, DATE_FORMAT(data_emissione, '%d/%m/%Y') AS `Data emissione`, DATE_FORMAT(scadenza, '%d/%m/%Y') AS `Data scadenza`, da_pagare AS `Importo`, pagato AS `Pagato`, IF(scadenza<NOW(), '#ff7777', '') AS _bg_ FROM co_scadenziario
|
||||
/*$rs = $dbo->fetchArray("SELECT co_scadenziario.id AS id, ragione_sociale AS `Anagrafica`, co_pagamenti.descrizione AS `Tipo di pagamento`, CONCAT( co_tipidocumento.descrizione, CONCAT( ' numero ', IF(numero_esterno<>'', numero_esterno, numero) ) ) AS `Documento`, DATE_FORMAT(data_emissione, '%d/%m/%Y') AS `Data emissione`, DATE_FORMAT(scadenza, '%d/%m/%Y') AS `Data scadenza`, da_pagare AS `Importo`, pagato AS `Pagato`, IF(scadenza<NOW(), '#ff7777', '') AS _bg_ FROM co_scadenziario
|
||||
INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id
|
||||
INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica
|
||||
INNER JOIN co_pagamenti ON co_documenti.idpagamento=co_pagamenti.id
|
||||
INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id
|
||||
WHERE ABS(pagato) < ABS(da_pagare) ".$add_where." AND scadenza >= '".$date_start."' AND scadenza <= '".$date_end."' ORDER BY scadenza ASC");
|
||||
WHERE ABS(pagato) < ABS(da_pagare) ".$add_where." AND scadenza >= '".$date_start."' AND scadenza <= '".$date_end."' ORDER BY scadenza ASC");*/
|
||||
|
||||
for ($i = 0; $i < sizeof($rs); ++$i) {
|
||||
for ($i = 0; $i < sizeof($scadenze); ++$i) {
|
||||
$body .= ' <tr>';
|
||||
$body .= ' <td>'.$rs[$i]['Documento'].'<br><small>'.$rs[$i]['Data emissione']."</small></td>\n";
|
||||
$body .= ' <td>'.$rs[$i]['Anagrafica']."</td>\n";
|
||||
$body .= ' <td>'.$rs[$i]['Tipo di pagamento']."</td>\n";
|
||||
$body .= " <td align='center'>".$rs[$i]['Data scadenza']."</td>\n";
|
||||
$body .= " <td align='right'>".moneyFormat($rs[$i]['Importo'], 2)."</td>\n";
|
||||
$body .= " <td align='right'>".moneyFormat($rs[$i]['Pagato'], 2)."</td>\n";
|
||||
$body .= ' <td>'.$scadenze[$i]['Documento'].'<br><small>'.$scadenze[$i]['Data emissione']."</small></td>\n";
|
||||
$body .= ' <td>'.$scadenze[$i]['Anagrafica']."</td>\n";
|
||||
$body .= ' <td>'.$scadenze[$i]['Tipo di pagamento']."</td>\n";
|
||||
$body .= " <td align='center'>".Translator::dateToLocale($scadenze[$i]['Data scadenza'])."</td>\n";
|
||||
$body .= " <td align='right'>".moneyFormat($scadenze[$i]['Importo'], 2)."</td>\n";
|
||||
$body .= " <td align='right'>".moneyFormat($scadenze[$i]['Pagato'], 2)."</td>\n";
|
||||
$body .= " </tr>\n";
|
||||
|
||||
$totale_da_pagare += $rs[$i]['Importo'];
|
||||
$totale_pagato += $rs[$i]['Pagato'];
|
||||
$totale_da_pagare += $scadenze[$i]['Importo'];
|
||||
$totale_pagato += $scadenze[$i]['Pagato'];
|
||||
}
|
||||
|
||||
$body .= " <tr>\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user