openstamanager/modules/fatture/crea_autofattura.php

62 lines
3.2 KiB
PHP
Raw Normal View History

2022-05-13 13:23:15 +02:00
<?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';
2024-03-05 16:01:45 +01:00
use Models\Module;
2024-10-21 13:42:45 +02:00
use Modules\Fatture\Tipo;
use Modules\Fatture\Fattura;
$fattura = Fattura::find($id_record);
2022-05-13 13:23:15 +02:00
2024-06-11 16:58:27 +02:00
$id_module_fatture_vendita = Module::where('name', 'Fatture di vendita')->first()->id;
2022-05-13 13:23:15 +02:00
echo '
<form action="" method="post" id="crea-autofattura">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="autofattura">
<div class="row">
<div class="col-md-6">
2024-10-21 13:42:45 +02:00
{[ "type": "select", "label": "'.tr('Tipo documento').'", "name": "idtipodocumento_autofattura", "required": 1, "values": "query=SELECT `co_tipidocumento`.`id`, CONCAT(`co_tipidocumento`.`codice_tipo_documento_fe`, \" - \", `co_tipidocumento_lang`.`title`) AS descrizione, `co_tipidocumento`.`id_segment`, `zz_segments_lang`.`title` as name_segment FROM `co_tipidocumento` LEFT JOIN `co_tipidocumento_lang` ON (`co_tipidocumento`.`id`=`co_tipidocumento_lang`.`id_record` AND `co_tipidocumento_lang`.`id_lang`= '.prepare(Models\Locale::getDefault()->id).') INNER JOIN `fe_tipi_documento` ON `co_tipidocumento`.`codice_tipo_documento_fe` = `fe_tipi_documento`.`codice` INNER JOIN `zz_segments` ON `zz_segments`.`id` = `co_tipidocumento`.`id_segment` LEFT JOIN `zz_segments_lang` ON (`zz_segments`.`id` = `zz_segments_lang`.`id_record` AND `zz_segments_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `dir`=\"entrata\" AND `fe_tipi_documento`.`is_autofattura` = 1 ORDER BY `fe_tipi_documento`.`codice`", "value": "'.$idtipodocumento.'" ]}
2022-05-13 13:23:15 +02:00
</div>
<div class="col-md-6">
2024-10-21 13:42:45 +02:00
{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment_autofattura", "required": 1, "ajax-source": "segmenti", "select-options": '.json_encode(['id_module' => $id_module_fatture_vendita, 'is_sezionale' => 1]).', "value": "'.Tipo::where('id', $idtipodocumento)->where('dir', 'entrata')->first()->id_segment.'" ]}
2022-05-13 13:23:15 +02:00
</div>
</div>
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary">
<i class="fa fa-magic"></i> '.tr('Crea autofattura').'
</button>
</div>
</div>
</form>
2024-10-21 13:42:45 +02:00
<script>
$(document).ready(function () {
init();
input("idtipodocumento_autofattura").change(function () {
$("#id_segment_autofattura").selectSetNew($(this).selectData().id_segment, $(this).selectData().name_segment);
});
});
</script>';