mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 11:30:55 +01:00
Introduzione importazione Preventivi e Contratti in Attività
This commit is contained in:
parent
6bda396b75
commit
62e250873f
@ -634,7 +634,7 @@ if (!$block_edit) {
|
||||
|
||||
echo '
|
||||
<div class="tip" data-toggle="tooltip" title="'.tr('Attività completate non collegate a preventivi o contratti e che non siano già state fatturate.').'">
|
||||
<a class="btn btn-sm btn-primary '.(!empty($interventi) ? '' : ' disabled').'" data-href="'.base_path().'/modules/fatture/add_intervento.php?id_module='.$id_module.'&id_record='.$id_record.'" data-title="'.tr('Aggiungi attività').'">
|
||||
<a class="btn btn-sm btn-primary '.(!empty($interventi) ? '' : ' disabled').'" data-href="'.$structure->fileurl('add_intervento.php').'?id_module='.$id_module.'&id_record='.$id_record.'" data-title="'.tr('Aggiungi attività').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Attività').'
|
||||
</a>
|
||||
</div>';
|
||||
@ -644,7 +644,7 @@ if (!$block_edit) {
|
||||
$preventivi = $dbo->fetchArray($prev_query)[0]['tot'];
|
||||
echo '
|
||||
<div class="tip">
|
||||
<a class="btn btn-sm btn-primary '.(!empty($preventivi) ? '' : ' disabled').'" data-href="'.base_path().'/modules/fatture/add_preventivo.php?id_module='.$id_module.'&id_record='.$id_record.'" data-title="'.tr('Aggiungi preventivo').'" data-toggle="tooltip">
|
||||
<a class="btn btn-sm btn-primary '.(!empty($preventivi) ? '' : ' disabled').'" data-href="'.$structure->fileurl('add_preventivo.php').'?id_module='.$id_module.'&id_record='.$id_record.'" data-title="'.tr('Aggiungi preventivo').'" data-toggle="tooltip">
|
||||
<i class="fa fa-plus"></i> '.tr('Preventivo').'
|
||||
</a>
|
||||
</div>';
|
||||
@ -654,7 +654,7 @@ if (!$block_edit) {
|
||||
$contratti = $dbo->fetchArray($contr_query)[0]['tot'];
|
||||
echo '
|
||||
<div class="tip">
|
||||
<a class="btn btn-sm btn-primary '.(!empty($contratti) ? '' : ' disabled').'" data-href="'.base_path().'/modules/fatture/add_contratto.php?id_module='.$id_module.'&id_record='.$id_record.'" data-title="'.tr('Aggiungi contratto').'">
|
||||
<a class="btn btn-sm btn-primary '.(!empty($contratti) ? '' : ' disabled').'" data-href="'.$structure->fileurl('add_contratto.php').'?id_module='.$id_module.'&id_record='.$id_record.'" data-title="'.tr('Aggiungi contratto').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Contratto').'
|
||||
</a>
|
||||
</div>';
|
||||
@ -672,17 +672,21 @@ if (!$block_edit) {
|
||||
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/fatture/add_ddt.php?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="tooltip" data-title="'.tr('Aggiungi ddt').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Ddt').'
|
||||
</a>';
|
||||
<div class="tip">
|
||||
<a class="btn btn-sm btn-primary'.(!empty($ddt) ? '' : ' disabled').'" data-href="'.$structure->fileurl('add_ddt.php').'.php?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="tooltip" data-title="'.tr('Aggiungi ddt').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Ddt').'
|
||||
</a>
|
||||
</div>';
|
||||
|
||||
// Lettura ordini (cliente o fornitore)
|
||||
$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'];
|
||||
echo '
|
||||
<a class="btn btn-sm btn-primary'.(!empty($ordini) ? '' : ' disabled').'" data-href="'.base_path().'/modules/fatture/add_ordine.php?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="tooltip" data-title="'.tr('Aggiungi ordine').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Ordine').'
|
||||
</a>';
|
||||
<div class="tip">
|
||||
<a class="btn btn-sm btn-primary'.(!empty($ordini) ? '' : ' disabled').'" data-href="'.$structure->fileurl('add_ordine.php').'?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="tooltip" data-title="'.tr('Aggiungi ordine').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Ordine').'
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Lettura articoli
|
||||
|
86
modules/interventi/add_contratto.php
Normal file
86
modules/interventi/add_contratto.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?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\Contratti\Contratto;
|
||||
use Modules\Interventi\Intervento;
|
||||
|
||||
$documento_finale = Intervento::find($id_record);
|
||||
$dir = $documento_finale->direzione;
|
||||
|
||||
$id_documento = get('id_documento');
|
||||
if (!empty($id_documento)) {
|
||||
$documento = Contratto::find($id_documento);
|
||||
|
||||
$options = [
|
||||
'op' => 'add_documento',
|
||||
'type' => 'contratto',
|
||||
'button' => tr('Aggiungi'),
|
||||
'documento' => $documento,
|
||||
'documento_finale' => $documento_finale,
|
||||
'tipo_documento_finale' => Intervento::class,
|
||||
'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'),
|
||||
];
|
||||
|
||||
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('Contratto').'", "name": "id_documento", "ajax-source": "contratti", "select-options": {"idanagrafica": '.$id_anagrafica.', "stato": "is_fatturabile"} ]}
|
||||
</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>';
|
86
modules/interventi/add_preventivo.php
Normal file
86
modules/interventi/add_preventivo.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?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\Interventi\Intervento;
|
||||
use Modules\Preventivi\Preventivo;
|
||||
|
||||
$documento_finale = Intervento::find($id_record);
|
||||
$dir = $documento_finale->direzione;
|
||||
|
||||
$id_documento = get('id_documento');
|
||||
if (!empty($id_documento)) {
|
||||
$documento = Preventivo::find($id_documento);
|
||||
|
||||
$options = [
|
||||
'op' => 'add_documento',
|
||||
'type' => 'preventivo',
|
||||
'button' => tr('Aggiungi'),
|
||||
'documento' => $documento,
|
||||
'documento_finale' => $documento_finale,
|
||||
'tipo_documento_finale' => Intervento::class,
|
||||
'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'),
|
||||
];
|
||||
|
||||
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('Preventivo').'", "name": "id_documento", "ajax-source": "preventivi", "select-options": {"idanagrafica": '.$id_anagrafica.', "stato": "is_fatturabile"} ]}
|
||||
</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>';
|
@ -416,6 +416,26 @@ echo '
|
||||
<?php
|
||||
|
||||
if (!$block_edit) {
|
||||
// Lettura preventivi accettati, in attesa di conferma o in lavorazione
|
||||
$prev_query = 'SELECT COUNT(*) AS tot FROM co_preventivi WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN(SELECT id FROM co_statipreventivi WHERE is_fatturabile = 1) AND default_revision=1 AND co_preventivi.id IN (SELECT idpreventivo FROM co_righe_preventivi WHERE co_righe_preventivi.idpreventivo = co_preventivi.id AND (qta - qta_evasa) > 0)';
|
||||
$preventivi = $dbo->fetchArray($prev_query)[0]['tot'];
|
||||
echo '
|
||||
<div class="tip" data-toggle="tooltip" title="'.tr("L'aggiunta del documento secondo questa procedura non associa l'attività al relativo consuntivo del documento: utilizzare i campi soprastanti a questo fine").'.">
|
||||
<a class="btn btn-sm btn-primary '.(!empty($preventivi) ? '' : ' disabled').'" data-href="'.$structure->fileurl('add_preventivo.php').'?id_module='.$id_module.'&id_record='.$id_record.'" data-title="'.tr('Aggiungi preventivo').'" data-toggle="tooltip">
|
||||
<i class="fa fa-plus"></i> '.tr('Preventivo').'
|
||||
</a>
|
||||
</div>';
|
||||
|
||||
// Lettura contratti accettati, in attesa di conferma o in lavorazione
|
||||
$contr_query = 'SELECT COUNT(*) AS tot FROM co_contratti WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN( SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND co_contratti.id IN (SELECT idcontratto FROM co_righe_contratti WHERE co_righe_contratti.idcontratto = co_contratti.id AND (qta - qta_evasa) > 0)';
|
||||
$contratti = $dbo->fetchArray($contr_query)[0]['tot'];
|
||||
echo '
|
||||
<div class="tip" data-toggle="tooltip" title="'.tr("L'aggiunta del documento secondo questa procedura non associa l'attività al relativo consuntivo del documento: utilizzare i campi soprastanti a questo fine").'.">
|
||||
<a class="btn btn-sm btn-primary '.(!empty($contratti) ? '' : ' disabled').'" data-href="'.$structure->fileurl('add_contratto.php').'?id_module='.$id_module.'&id_record='.$id_record.'" data-title="'.tr('Aggiungi contratto').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Contratto').'
|
||||
</a>
|
||||
</div>';
|
||||
|
||||
// Lettura ddt (entrata o uscita)
|
||||
$ddt_query = 'SELECT COUNT(*) AS tot FROM dt_ddt
|
||||
LEFT JOIN `dt_causalet` ON `dt_causalet`.`id` = `dt_ddt`.`idcausalet`
|
||||
@ -428,8 +448,8 @@ if (!$block_edit) {
|
||||
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 '
|
||||
<div class="tip" data-toggle="tooltip" title="'.tr('DDT in uscita per il Cliente che si trovano nello stato di Evaso o Parzialmente Evaso con una Causale importabile.').'">
|
||||
<button type="button" class="btn btn-sm btn-primary'.(!empty($ddt) ? '' : ' disabled').'" data-href="'.base_path().'/modules/interventi/add_ddt.php?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="tooltip" data-title="'.tr('Aggiungi DDT in uscita').'">
|
||||
<div class="tip" data-toggle="tooltip" title="'.tr('DDT in uscita per il Cliente che si trovano nello stato di Evaso o Parzialmente Evaso con una Causale importabile').'. '.tr("L'aggiunta del documento secondo questa procedura non associa l'attività al relativo consuntivo del documento: utilizzare i campi soprastanti a questo fine").'.">
|
||||
<button type="button" class="btn btn-sm btn-primary'.(!empty($ddt) ? '' : ' disabled').'" data-href="'.$structure->fileurl('add_ddt.php').'?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="tooltip" data-title="'.tr('Aggiungi DDT in uscita').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Ddt').'
|
||||
</button>
|
||||
</div>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user