Aggiunta possibilità di importare ddt in entrata nei ddt in uscita

This commit is contained in:
MatteoPistorello 2021-01-25 12:37:53 +01:00
parent a9030b75a5
commit a1329d1cee
3 changed files with 94 additions and 1 deletions

View File

@ -20,7 +20,7 @@
// Inizializzazione
$documento = $options['documento'];
$documento_finale = $options['documento_finale'];
if (empty($documento) || (!empty($documento_finale) && $documento_finale->direzione != $documento->direzione)) {
if (empty($documento)) {
return;
}

84
modules/ddt/add_ddt.php Normal file
View File

@ -0,0 +1,84 @@
<?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\DDT\DDT;
$documento_finale = DDT::find($id_record);
$dir = $documento_finale->direzione;
$id_documento = get('id_documento');
if (!empty($id_documento)) {
$documento = DDT::find($id_documento);
$options = [
'op' => 'add_documento',
'button' => tr('Aggiungi'),
'serials' => true,
'documento' => $documento,
'documento_finale' => $documento_finale,
'tipo_documento_finale' => DDT::class,
];
echo App::load('importa.php', [], $options, true);
return;
}
$id_anagrafica = $documento_finale->idanagrafica;
echo '
<div class="row">
<div class="col-md-12">
{[ "type": "select", "label": "'.tr('Ddt').'", "name": "id_documento", "values": "query=SELECT dt_ddt.id, CONCAT(IF(numero_esterno != \'\', numero_esterno, numero), \' del \', DATE_FORMAT(data, \'%d-%m-%Y\')) AS descrizione FROM dt_ddt WHERE idstatoddt IN (SELECT id FROM dt_statiddt WHERE descrizione IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoddt=(SELECT id FROM dt_tipiddt WHERE dir=\'uscita\' LIMIT 0,1) AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0) ORDER BY data DESC, numero DESC" ]}
</div>
</div>
<div id="righe_documento">
</div>
<div class="alert alert-info" id="box-loading">
<i class="fa fa-spinner fa-spin"></i> '.tr('Caricamento in corso').'...
</div>';
$file = basename(__FILE__);
echo '
<script>$(document).ready(init)</script>
<script>
var content = $("#righe_documento");
var loader = $("#box-loading");
$(document).ready(function() {
loader.hide();
});
$("#id_documento").on("change", function() {
loader.show();
var id = $(this).selectData() ? $(this).selectData().id : "";
content.html("");
content.load("'.$structure->fileurl($file).'?id_module='.$id_module.'&id_record='.$id_record.'&id_documento=" + id, function() {
loader.hide();
});
});
</script>';

View File

@ -314,6 +314,15 @@ if (!$block_edit) {
$ordini_query = 'SELECT COUNT(*) AS tot FROM or_ordini WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstatoordine IN (SELECT id FROM or_statiordine WHERE descrizione IN(\'Accettato\', \'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoordine=(SELECT id FROM or_tipiordine WHERE dir='.prepare($dir).') AND or_ordini.id IN (SELECT idordine FROM or_righe_ordini WHERE or_righe_ordini.idordine = or_ordini.id AND (qta - qta_evasa) > 0)';
$ordini = $dbo->fetchArray($ordini_query)[0]['tot'];
if($dir == 'entrata'){
$ddt_query = 'SELECT COUNT(*) AS tot FROM dt_ddt WHERE idstatoddt IN (SELECT id FROM dt_statiddt WHERE descrizione IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoddt=(SELECT id FROM or_tipiordine WHERE dir="uscita") AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0)';
$ddt = $dbo->fetchArray($ddt_query)[0]['tot'];
echo '
<a class="btn btn-sm btn-primary'.(!empty($ddt) ? '' : ' disabled').'" data-href="'.base_path().'/modules/ddt/add_ddt.php?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="modal" data-title="Aggiungi ddt">
<i class="fa fa-plus"></i> '.tr('Ddt').'
</a>';
}
echo '
<a class="btn btn-sm btn-primary'.(!empty($ordini) ? '' : ' disabled').'" data-href="'.base_path().'/modules/ddt/add_ordine.php?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="modal" data-title="Aggiungi ordine">
<i class="fa fa-plus"></i> '.tr('Ordine').'