Aggiunta stampa liquidazione provvigioni

This commit is contained in:
Pek5892 2023-05-05 18:28:36 +02:00
parent fed45af5ae
commit 8a485ca14b
7 changed files with 340 additions and 0 deletions

View File

@ -74,4 +74,10 @@ if (in_array($id_cliente, $tipi_anagrafica) or in_array($id_fornitore, $tipi_ana
echo '
</ul>
</div>';
} else if (in_array($id_agente, $tipi_anagrafica)) {
//Aggiunta liquidazione provvigioni per agente
echo'
<button type="button" class="btn btn-primary" data-title="'.tr('Liquida Provvigioni').'" data-href="'.base_path().'/modules/anagrafiche/liquida_provvigioni.php?nome_stampa=Provvigioni&id_record='.$id_record.'" ><i class="fa fa-print"></i>'.tr(' Liquida Provvigioni').'</button>
</div>';
}

View File

@ -0,0 +1,116 @@
<?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';
use Models\Module;
use Carbon\Carbon;
$id_record = filter('id_record');
$dir = filter('dir');
$nome_stampa = filter('nome_stampa');
$id_print = $dbo->fetchOne('SELECT id FROM zz_prints WHERE name='.prepare($nome_stampa))['id'];
$id_module = Module::pool('Stampe contabili')->id;
$year = (new Carbon($_SESSION['period_end']))->format('Y');
// Trovo id_print della stampa
$link = Prints::getHref($nome_stampa, $id_record);
echo '
<div class="alert alert-info hidden" id="period">
<i class="fa fa-exclamation-circle"></i> '.tr('Non è possibile creare la stampa definitiva nel periodo selezionato, è necessario prima impostare un periodo!').'
</div>
<form action="" method="post" id="form" >
<div class="row">';
echo '
<div class="col-md-4">
{[ "type": "date", "label": "'.tr('Data inizio').'", "required": "1", "name": "date_start", "value": "'.$_SESSION['period_start'].'" ]}
</div>
<div class="col-md-4">
{[ "type": "date", "label": "'.tr('Data fine').'", "required": "1", "name": "date_end", "value": "'.$_SESSION['period_end'].'" ]}
</div>
<div class="col-md-4">
{[ "type": "checkbox", "label": "'.tr('Includi emesse').'", "name": "is_emessa" ]}
</div>
</div>
<div class="row">
<div class="col-md-4">
{[ "type": "select", "label": "'.tr('Formato').'", "name": "format", "required": "1", "values": "list=\"A4\": \"'.tr('A4').'\", \"A3\": \"'.tr('A3').'\"", "value": "'.$_SESSION['stampe_contabili']['format'].'" ]}
</div>
<div class="col-md-4">
{[ "type": "select", "label": "'.tr('Orientamento').'", "name": "orientation", "required": "1", "values": "list=\"L\": \"'.tr('Orizzontale').'\", \"P\": \"'.tr('Verticale').'\"", "value": "'.$_SESSION['stampe_contabili']['orientation'].'" ]}
</div>
<div class="col-md-4">
{[ "type": "checkbox", "label": "'.tr('Includi parzialmente pagate').'", "name": "is_parz_pagata" ]}
</div>
';
echo '
<div class="col-md-4 pull-right">
<p style="line-height:14px;">&nbsp;</p>
<button type="button" class="btn btn-primary btn-block" onclick="if($(\'#form\').parsley().validate()) { return avvia_stampa(); }">
<i class="fa fa-print"></i> '.tr('Stampa').'
</button>
</div>
</div>
</form>
<br>';
echo '
<script>
$(document).ready(init);
function avvia_stampa (){
var is_emessa = $("#is_emessa").is(":checked");
var is_parz_pagata = $("#is_parz_pagata").is(":checked");
window.open("'.$link.'&dir='.$dir.'&is_emessa="+is_emessa+"&is_parz_pagata="+is_parz_pagata+"&notdefinitiva=1&id_sezionale="+$("#id_sezionale").val()+"&date_start="+$("#date_start").val()+"&date_end="+$("#date_end").val()+"");
$("#modals > div").modal("hide");
}
$("#format").change(function() {
session_set("stampe_contabili,format", $(this).val(), 0, 0);
});
$("#orientation").change(function() {
session_set("stampe_contabili,orientation", $(this).val(), 0, 0);
});
$("#periodo").change(function() {
if ($(this).val()=="manuale") {
input("date_start").enable();
input("date_end").enable();
} else {
$("#date_start").data("DateTimePicker").date(new Date(input("periodo").getData().date_start));
$("#date_end").data("DateTimePicker").date(new Date(input("periodo").getData().date_end));
input("date_start").disable();
input("date_end").disable();
}';
if ($nome_stampa != 'Liquidazione IVA') {
echo 'eseguiControlli();';
}
echo '
});
</script>';

View File

@ -0,0 +1,32 @@
<?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';
$totale_provvigioni = sum(array_column($records, 'provvigione'));
echo '
<tr>
<td colspan="4" class="text-right">
<b>'.tr('Totale provvigioni', [], ['upper' => true]).':</b>
</td>
<td class="text-center">'.moneyFormat($totale_provvigioni, 2).'</td>
</tr>
</tbody>
</table>';

View File

@ -0,0 +1,72 @@
<?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';
$module = Modules::get('Fatture di vendita');
$id_module = $module['id'];
$module_query = '
SELECT
numero_esterno,
an_anagrafiche.ragione_sociale,
prezzo_unitario,
provvigione_percentuale,
provvigione
FROM
`co_documenti`
LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`
LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id`
LEFT JOIN (SELECT `iddocumento`, SUM(`subtotale` - `sconto`) AS `totale_imponibile`, SUM(`iva`) AS `iva` FROM `co_righe_documenti` GROUP BY `iddocumento`) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento`
LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id`
LEFT JOIN an_anagrafiche as agenti ON agenti.idanagrafica = co_documenti.idagente
LEFT JOIN co_righe_documenti ON co_righe_documenti.iddocumento = co_documenti.id
WHERE
1=1
GROUP BY
co_documenti.id, co_righe_documenti.id
HAVING
2=2
ORDER BY
`co_documenti`.`data` DESC';
if(!empty(get('date_start'))){
$module_query = str_replace('1=1', '1=1 AND DATE_FORMAT(`data`, "%Y%m%d") >= "'.date('Ymd', strtotime(get('date_start'))).'"', $module_query);
$date_start = get('date_start');
}
if(!empty(get('date_end'))){
$module_query = str_replace('1=1', '1=1 AND DATE_FORMAT(`data`, "%Y%m%d") <= "'.date('Ymd', strtotime(get('date_end'))).'"', $module_query);
$date_end = get('date_end');
}
$module_query = str_replace('1=1', '1=1 AND co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione = "Pagato")', $module_query);
if(get('is_emessa')=='true' && get('is_parz_pagata')=='true'){
$module_query = str_replace('1=1 AND co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione = "Pagato")', '1=1 AND co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione = "Pagato" OR descrizione = "Emessa" OR descrizione = "Parzialmente pagato")', $module_query);
} else if(get('is_emessa')=='true'){
$module_query = str_replace('1=1 AND co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione = "Pagato")', '1=1 AND co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione = "Pagato" OR descrizione = "Emessa")', $module_query);
} else if(get('is_parz_pagata')=='true'){
$module_query = str_replace('1=1 AND co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione = "Pagato")', '1=1 AND co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione = "Pagato" OR descrizione = "Parzialmente pagato")', $module_query);
}
$module_query = str_replace('1=1', '1=1 AND co_documenti.idagente='.prepare($id_record), $module_query);
$records = $dbo->fetchArray($module_query);

View File

@ -0,0 +1,29 @@
<?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';
echo '
<tr>
<td> Fattura n. '.$record['numero_esterno'].'</td>
<td>'.$record['ragione_sociale'].'</td>
<td class="text-center">'.moneyFormat($record['prezzo_unitario'], 2).'</td>
<td class="text-center">'.numberFormat($record['provvigione_percentuale'], 0).' % </td>
<td class="text-center">'.moneyFormat($record['provvigione'], 2).'</td>
</tr>';

View File

@ -0,0 +1,27 @@
<?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/>.
*/
$format = (isset($_SESSION['stampe_contabili']['format'])) ? $_SESSION['stampe_contabili']['format'] : 'A4';
$orientation = (isset($_SESSION['stampe_contabili']['orientation'])) ? $_SESSION['stampe_contabili']['orientation'] : 'L';
return [
'format' => $format,
'orientation' => $orientation,
'font-size' => '11pt',
];

View File

@ -0,0 +1,58 @@
<?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';
use Modules\Anagrafiche\Anagrafica;
$agente = Anagrafica::where([
['idanagrafica', '=', $id_record],
])->first();
echo '
<h4><b>'.tr('Liquidazione provvigioni agente _ANAG_', [
'_ANAG_' => $agente->ragione_sociale,
], ['upper' => true]).'</b></h4>';
if(!empty($date_start) AND !empty($date_end)) {
echo '
<h4><b>'.tr('Provvigioni dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($date_start),
'_END_' => Translator::dateToLocale($date_end),
], ['upper' => true]).'</b>
</h4>';
}else{
echo '
<h5><b>'.tr('Provvigioni').'</b>
</h5>';
}
echo '
<table class="table table-striped table-bordered" id="contents">
<thead>
<tr>
<th width="20%">'.tr('Documento', [], ['upper' => true]).'</th>
<th width="50%">'.tr('Anagrafica', [], ['upper' => true]).'</th>
<th width="10%" class="text-center">'.tr('Importo', [], ['upper' => true]).'</th>
<th width="10%" class="text-center">'.tr('Percentuale', [], ['upper' => true]).'</th>
<th width="10%" class="text-center">'.tr('Provvigione', [], ['upper' => true]).'</th>
</tr>
</thead>
<tbody>';