Gestione visualizzazione articoli distinta inline nei documenti

This commit is contained in:
MatteoPistorello 2024-03-15 12:33:20 +01:00
parent d321458d25
commit 44021dfa8b
7 changed files with 135 additions and 23 deletions

View File

@ -366,4 +366,20 @@ function getSearchValues($id_module) {
}
}
return $result;
}
/**
* Funzione PHP che controlla se l'articolo ha una distinta
*
* @param int $id_articolo
*
* @return boolean
*/
function hasArticoliFiglio($id_articolo)
{
if (function_exists('renderDistinta')) {
return database()->fetchOne('SELECT qta FROM mg_articoli_distinte WHERE id_articolo='.prepare($id_articolo));
} else {
return false;
}
}

View File

@ -19,6 +19,8 @@
include_once __DIR__.'/init.php';
use Models\Plugin;
$block_edit = $record['is_completato'];
$order_row_desc = $_SESSION['module_'.$id_module]['order_row_desc'];
$righe = $order_row_desc ? $contratto->getRighe()->sortByDesc('created_at') : $contratto->getRighe();
@ -207,6 +209,13 @@ foreach ($righe as $riga) {
echo '
<td class="text-center">
<div class="btn-group">';
if (hasArticoliFiglio($riga->idarticolo)) {
echo '
<a class="btn btn-xs btn-info" title="'.tr('Distinta base').'" onclick="viewDistinta('.$riga->idarticolo.')">
<i class="fa fa-eye"></i>
</a>';
}
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
echo '
<a class="btn btn-primary btn-xs" title="'.tr('Modifica seriali della riga').'" onclick="modificaSeriali(this)">
@ -608,5 +617,13 @@ function modificaSeriali(button) {
openModal("'.tr('Aggiorna SN').'", globals.rootdir + "/modules/fatture/add_serial.php?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
}
init();
</script>';
init();';
if (Plugin::find((new Plugin())->getByName('Distinta base')->id_record)) {
echo '
async function viewDistinta(id_articolo) {
openModal("'.tr('Distinta base').'", "'.Plugin::find((new Plugin())->getByName('Distinta base')->id_record)->fileurl('view.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&id_articolo=" + id_articolo);
}';
}
echo '
</script>';

View File

@ -19,6 +19,8 @@
include_once __DIR__.'/init.php';
use Models\Plugin;
$block_edit = $record['flag_completato'];
$order_row_desc = $_SESSION['module_'.$id_module]['order_row_desc'];
$righe = $order_row_desc ? $ddt->getRighe()->sortByDesc('created_at') : $ddt->getRighe();
@ -235,6 +237,12 @@ foreach ($righe as $riga) {
echo '
<td class="text-center">
<div class="input-group-btn">';
if (hasArticoliFiglio($riga->idarticolo)) {
echo '
<a class="btn btn-xs btn-info" title="'.tr('Distinta base').'" onclick="viewDistinta('.$riga->idarticolo.')">
<i class="fa fa-eye"></i>
</a>';
}
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
echo '
@ -647,5 +655,13 @@ function aggiornaInline(id) {
}
});
}
init();
</script>';
init();';
if (Plugin::find((new Plugin())->getByName('Distinta base')->id_record)) {
echo '
async function viewDistinta(id_articolo) {
openModal("'.tr('Distinta base').'", "'.Plugin::find((new Plugin())->getByName('Distinta base')->id_record)->fileurl('view.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&id_articolo=" + id_articolo);
}';
}
echo '
</script>';

View File

@ -21,6 +21,8 @@ use Modules\Interventi\Intervento;
include_once __DIR__.'/init.php';
use Models\Plugin;
$block_edit = !empty($note_accredito) || in_array($record['stato'], ['Emessa', 'Pagato', 'Parzialmente pagato']) || !$abilita_genera;
$order_row_desc = $_SESSION['module_'.$id_module]['order_row_desc'];
$righe = $order_row_desc ? $fattura->getRighe()->sortByDesc('created_at') : $fattura->getRighe();
@ -280,6 +282,13 @@ foreach ($righe as $riga) {
<td class="text-center">
<div class="input-group-btn">';
if (hasArticoliFiglio($riga->idarticolo)) {
echo '
<a class="btn btn-xs btn-info" title="'.tr('Distinta base').'" onclick="viewDistinta('.$riga->idarticolo.')">
<i class="fa fa-eye"></i>
</a>';
}
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
echo '
<a class="btn btn-primary btn-xs" title="'.tr('Modifica seriali della riga').'" onclick="modificaSeriali(this)">
@ -770,5 +779,13 @@ function aggiornaInline(id) {
}
});
}
init();
</script>';
init();';
if (Plugin::find((new Plugin())->getByName('Distinta base')->id_record)) {
echo '
async function viewDistinta(id_articolo) {
openModal("'.tr('Distinta base').'", "'.Plugin::find((new Plugin())->getByName('Distinta base')->id_record)->fileurl('view.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&id_articolo=" + id_articolo);
}';
}
echo '
</script>';

View File

@ -18,7 +18,8 @@
*/
include_once __DIR__.'/init.php';
use Models\Module;
use Models\Plugin;
$block_edit = $record['flag_completato'];
$righe = $intervento->getRighe();
@ -176,6 +177,12 @@ foreach ($righe as $riga) {
echo '
<td class="text-center">
<div class="input-group-btn">';
if (hasArticoliFiglio($riga->idarticolo)) {
echo '
<a class="btn btn-xs btn-info" title="'.tr('Distinta base').'" onclick="viewDistinta('.$riga->idarticolo.')">
<i class="fa fa-eye"></i>
</a>';
}
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
echo '
@ -514,5 +521,13 @@ function aggiornaInline(id) {
}
});
}
init();
</script>';
init();';
if (Plugin::find((new Plugin())->getByName('Distinta base')->id_record)) {
echo '
async function viewDistinta(id_articolo) {
openModal("'.tr('Distinta base').'", "'.Plugin::find((new Plugin())->getByName('Distinta base')->id_record)->fileurl('view.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&id_articolo=" + id_articolo);
}';
}
echo '
</script>';

View File

@ -21,6 +21,7 @@ include_once __DIR__.'/init.php';
use Modules\Articoli\Articolo;
use Models\Module;
use Models\Plugin;
$block_edit = $record['flag_completato'];
$order_row_desc = $_SESSION['module_'.$id_module]['order_row_desc'];
@ -289,6 +290,13 @@ foreach ($righe as $riga) {
echo '
<td class="text-center">
<div class="input-group-btn">';
if (hasArticoliFiglio($riga->idarticolo)) {
echo '
<a class="btn btn-xs btn-info" title="'.tr('Distinta base').'" onclick="viewDistinta('.$riga->idarticolo.')">
<i class="fa fa-eye"></i>
</a>';
}
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
echo '
<a class="btn btn-primary btn-xs" title="'.tr('Modifica seriali della riga').'" onclick="modificaSeriali(this)">
@ -738,5 +746,13 @@ function aggiornaInline(id) {
}
});
}
init();
</script>';
init();';
if (Plugin::find((new Plugin())->getByName('Distinta base')->id_record)) {
echo '
async function viewDistinta(id_articolo) {
openModal("'.tr('Distinta base').'", "'.Plugin::find((new Plugin())->getByName('Distinta base')->id_record)->fileurl('view.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&id_articolo=" + id_articolo);
}';
}
echo '
</script>';

View File

@ -19,6 +19,8 @@
include_once __DIR__.'/init.php';
use Models\Plugin;
$block_edit = $record['is_completato'];
$order_row_desc = $_SESSION['module_'.$id_module]['order_row_desc'];
$righe = $order_row_desc ? $preventivo->getRighe()->sortByDesc('created_at') : $preventivo->getRighe();
@ -44,7 +46,7 @@ echo '
<th class="text-center" width="180">'.tr('Prezzo unitario').'</th>
<th class="text-center" width="140">'.tr('Sconto unitario').'</th>
<th class="text-center" width="130">'.tr('Importo').'</th>
<th width="80"></th>
<th width="100"></th>
</tr>
</thead>
<tbody class="sortable" id="righe">';
@ -238,11 +240,17 @@ foreach ($righe as $key => $riga) {
// Possibilità di rimuovere una riga solo se il preventivo non è stato pagato
echo '
<td class="text-center">';
<td class="text-center">
<div class="btn-group">';
if (hasArticoliFiglio($riga->idarticolo)) {
echo '
<a class="btn btn-xs btn-info" title="'.tr('Distinta base').'" onclick="viewDistinta('.$riga->idarticolo.')">
<i class="fa fa-eye"></i>
</a>';
}
if (empty($record['is_completato'])) {
echo '
<div class="btn-group">
if (empty($record['is_completato'])) {
echo '
<a class="btn btn-xs btn-warning" title="'.tr('Modifica riga').'" onclick="modificaRiga(this)">
<i class="fa fa-edit"></i>
</a>
@ -253,11 +261,10 @@ foreach ($righe as $key => $riga) {
<a class="btn btn-xs btn-default handle '.($order_row_desc ? 'disabled' : '').'" title="'.tr('Modifica ordine delle righe').'">
<i class="fa fa-sort"></i>
</a>
</div>';
}
echo '
</a>';
}
echo '
</div>
</td>
</tr>';
@ -689,5 +696,13 @@ function aggiornaInline(id) {
}
});
}
init();
</script>';
init();';
if (Plugin::find((new Plugin())->getByName('Distinta base')->id_record)) {
echo '
async function viewDistinta(id_articolo) {
openModal("'.tr('Distinta base').'", "'.Plugin::find((new Plugin())->getByName('Distinta base')->id_record)->fileurl('view.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&id_articolo=" + id_articolo);
}';
}
echo '
</script>';