Aggiunto pulsante per importare preventivi dall' ordine

This commit is contained in:
MatteoP 2020-12-22 11:09:33 +01:00
parent cfa573ccb8
commit 5767206b3c
2 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,85 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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\Ordini\Ordine;
use Modules\Preventivi\Preventivo;
$documento_finale = Ordine::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' => Ordine::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('Preventivo').'", "name": "id_documento", "ajax-source": "preventivi", "select-options": {"idanagrafica": '.$id_anagrafica.', "stato": "is_fatturabile=1 OR is_completato"} ]}
</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

@ -194,7 +194,17 @@ echo '
if (!$block_edit) {
echo '
<div class="pull-left">';
$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'];
if($dir=='entrata'){
echo '
<div class="tip">
<a class="btn btn-sm btn-primary '.(!empty($preventivi) ? '' : ' disabled').'" data-href="'.base_path().'/modules/ordini/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>';
}
echo '
<button type="button" class="btn btn-sm btn-primary tip" title="'.tr('Aggiungi articolo').'" onclick="gestioneArticolo(this)">
<i class="fa fa-plus"></i> '.tr('Articolo').'