mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-18 20:40:36 +01:00
Compare commits
2 Commits
996e9027fa
...
b154dc5d3e
Author | SHA1 | Date | |
---|---|---|---|
|
b154dc5d3e | ||
|
dd5e3a0c5e |
108
modules/categorie_contratti/actions.php
Normal file
108
modules/categorie_contratti/actions.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?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\CategoriaContratto AS Categoria;
|
||||
|
||||
switch (filter('op')) {
|
||||
case 'update':
|
||||
$nome = filter('nome');
|
||||
$nota = filter('nota');
|
||||
$colore = filter('colore');
|
||||
$id_original = filter('id_original') ?: null;
|
||||
|
||||
if (isset($nome) && isset($nota) && isset($colore)) {
|
||||
$categoria->colore = $colore;
|
||||
$categoria->parent = $id_original ?: null;
|
||||
$categoria->setTranslation('title', $nome);
|
||||
$categoria->setTranslation('note', $nota);
|
||||
$categoria->save();
|
||||
|
||||
flash()->info(tr('Salvataggio completato!'));
|
||||
} else {
|
||||
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
|
||||
}
|
||||
|
||||
// Redirect alla categoria se si sta modificando una sottocategoria
|
||||
if (!empty($id_original)) {
|
||||
$database->commitTransaction();
|
||||
redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.($id_original ?: $id_record));
|
||||
exit;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
$nome = filter('nome');
|
||||
$nota = filter('nota');
|
||||
$colore = filter('colore');
|
||||
$id_original = filter('id_original') ?: null;
|
||||
|
||||
$categoria_new = Categoria::where('id', '=', (new Categoria())->getByField('title', $nome));
|
||||
if (!empty($id_original)) {
|
||||
$categoria_new = $categoria_new->where('parent', '=', $id_original);
|
||||
} else {
|
||||
$categoria_new = $categoria_new->whereNull('parent');
|
||||
}
|
||||
$categoria_new = $categoria_new->first();
|
||||
|
||||
if (!empty($categoria_new)) {
|
||||
flash()->error(tr('Questo nome è già stato utilizzato per un altra categoria.'));
|
||||
} else {
|
||||
$categoria = Categoria::build($colore);
|
||||
$id_record = $dbo->lastInsertedID();
|
||||
$categoria->parent = $id_original;
|
||||
$categoria->setTranslation('note', $nota);
|
||||
$categoria->setTranslation('title', $nome);
|
||||
$categoria->save();
|
||||
|
||||
flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [
|
||||
'_TYPE_' => 'categoria',
|
||||
]));
|
||||
}
|
||||
|
||||
if (isAjaxRequest()) {
|
||||
echo json_encode(['id' => $id_record, 'text' => $nome]);
|
||||
} else {
|
||||
// Redirect alla categoria se si sta aggiungendo una sottocategoria
|
||||
$database->commitTransaction();
|
||||
redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.($id_original ?: $id_record));
|
||||
exit;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$id = filter('id');
|
||||
if (empty($id)) {
|
||||
$id = $id_record;
|
||||
}
|
||||
|
||||
if ($dbo->fetchNum('SELECT * FROM `co_contratti` WHERE (`id_categoria`='.prepare($id).' OR `id_sottocategoria`='.prepare($id).' OR `id_sottocategoria` IN (SELECT `id` FROM `co_categorie` WHERE `parent`='.prepare($id).')) AND `deleted_at` IS NULL') == 0) {
|
||||
$dbo->query('DELETE FROM `co_categorie` WHERE `id`='.prepare($id));
|
||||
|
||||
flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [
|
||||
'_TYPE_' => 'categoria',
|
||||
]));
|
||||
} else {
|
||||
flash()->error(tr('Esistono alcuni contratti collegati a questa categoria. Impossibile eliminarla.'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
89
modules/categorie_contratti/add.php
Normal file
89
modules/categorie_contratti/add.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?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';
|
||||
|
||||
$id_original = filter('id_original');
|
||||
|
||||
if (!empty($id_record)) {
|
||||
include __DIR__.'/init.php';
|
||||
}
|
||||
|
||||
?><form action="<?php
|
||||
if (isset($id_original)) {
|
||||
echo base_path().'/controller.php?id_module='.$id_module;
|
||||
|
||||
if (!empty($id_record)) {
|
||||
echo '&id_record='.$id_record;
|
||||
}
|
||||
}
|
||||
?>" method="post" id="add-form">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="id_original" value="<?php echo $id_original; ?>">
|
||||
<input type="hidden" name="op" value="<?php echo $id_record ? 'update' : 'add'; ?>">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "value": "$title$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Colore'); ?>", "name": "colore", "id": "colore_", "class": "colorpicker text-center", "value": "<?php echo $categoria->colore; ?>", "extra": "maxlength=\"7\"", "icon-after": "<div class='img-circle square'></div>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "<?php echo tr('Nota'); ?>", "name": "nota", "value": "<?php echo $categoria->nota; ?>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<?php
|
||||
if (!empty($id_record)) {
|
||||
?>
|
||||
<button type="submit" class="btn btn-success"><i class="fa fa-save"></i> <?php echo tr('Salva'); ?></button>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( function() {
|
||||
$('#modals > div .colorpicker').colorpicker({ format: 'hex' }).on('changeColor', function() {
|
||||
$('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val());
|
||||
});
|
||||
|
||||
$('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val());
|
||||
|
||||
$('#modals > div .colorpicker').colorpicker({ format: 'hex' }).on('changeColor', function() {
|
||||
$('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val());
|
||||
});
|
||||
|
||||
$('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val());
|
||||
});
|
||||
</script>
|
95
modules/categorie_contratti/edit.php
Normal file
95
modules/categorie_contratti/edit.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?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 Models\Module;
|
||||
|
||||
?><form action="" method="post" id="edit-form">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="op" value="update">
|
||||
|
||||
<!-- DATI -->
|
||||
<div class="card card-primary">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?php echo tr('Dati'); ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "value": "$title$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Colore'); ?>", "name": "colore", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "<div class='img-circle square'></div>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "<?php echo tr('Nota'); ?>", "name": "nota", "value": "$note$" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="card card-primary">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?php echo tr('Sottocategorie'); ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="pull-left">
|
||||
<a class="btn btn-primary" data-href="<?php echo base_path(); ?>/add.php?id_module=<?php echo $id_module; ?>&id_original=<?php echo $id_record; ?>" data-card-widget="modal" data-title="<?php echo tr('Aggiungi riga'); ?>"><i class="fa fa-plus"></i> <?php echo tr('Sottocategoria'); ?></a><br>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th><?php echo tr('Nome'); ?></th>
|
||||
<th><?php echo tr('Colore'); ?></th>
|
||||
<th><?php echo tr('Nota'); ?></th>
|
||||
<th width="20%"><?php echo tr('Opzioni'); ?></th>
|
||||
</tr>
|
||||
|
||||
<?php include base_dir().'/modules/'.Module::find($id_module)->directory.'/row-list.php'; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.colorpicker').colorpicker({ format: 'hex' }).on('changeColor', function() {
|
||||
$(this).parent().find('.square').css('background', $(this).val());
|
||||
});
|
||||
$('.colorpicker').parent().find('.square').css('background', $('.colorpicker').val());
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
echo '
|
||||
<a class="btn btn-danger ask" data-backto="record-list">
|
||||
<i class="fa fa-trash"></i> '.tr('Elimina').'
|
||||
</a>';
|
27
modules/categorie_contratti/init.php
Normal file
27
modules/categorie_contratti/init.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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\CategoriaContratto AS Categoria;
|
||||
|
||||
if (!empty($id_record)) {
|
||||
$record = $dbo->fetchOne('SELECT * FROM `co_categorie_contratti` LEFT JOIN `co_categorie_contratti_lang` ON (`co_categorie_contratti`.`id`=`co_categorie_contratti_lang`.`id_record` AND `co_categorie_contratti_lang`.`id_lang`='.prepare(Models\Locale::getDefault()->id).') WHERE `co_categorie_contratti`.`id`='.prepare($id_record));
|
||||
|
||||
$categoria = Categoria::find($id_record);
|
||||
}
|
41
modules/categorie_contratti/row-list.php
Normal file
41
modules/categorie_contratti/row-list.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?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\Contratti\CategoriaContratto AS Categoria;
|
||||
|
||||
$subcategorie = Categoria::where('parent', '=', $id_record)->get();
|
||||
|
||||
foreach ($subcategorie as $sub) {
|
||||
$n_contratti = Contratto::where('id_sottocategoria', '=', $sub['id'])->count();
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$sub->getTranslation('title').'</td>
|
||||
<td>'.$sub->colore.'</td>
|
||||
<td>'.$sub->nota.'</td>
|
||||
<td>
|
||||
<a class="btn btn-warning btn-sm" title="Modifica riga" onclick="launch_modal(\''.tr('Modifica sottocategoria').'\', \''.base_path().'/add.php?id_module='.$id_module.'&id_record='.$sub->id.'&id_original='.$id_record.'\');"><i class="fa fa-edit"></i></a>
|
||||
<a class="btn btn-sm btn-danger ask '.(($n_articoli > 0) ? 'disabled tip' : '').'" data-backto="record-edit" data-id="'.$sub['id'].'" title="'.(($n_articoli > 0) ? 'Sottocategoria collegata a '.$n_articoli.' articoli' : '').'">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
@ -51,6 +51,8 @@ switch (post('op')) {
|
||||
$contratto->rinnovo_automatico = post('rinnovo_automatico_add');
|
||||
$contratto->giorni_preavviso_rinnovo = post('giorni_preavviso_rinnovo');
|
||||
$contratto->ore_preavviso_rinnovo = post('ore_preavviso_rinnovo');
|
||||
$contratto->id_categoria = post('id_categoria');
|
||||
$contratto->id_sottocategoria = post('id_sottocategoria');
|
||||
$contratto->save();
|
||||
|
||||
$id_record = $contratto->id;
|
||||
@ -87,6 +89,8 @@ switch (post('op')) {
|
||||
$contratto->idreferente = post('idreferente');
|
||||
$contratto->condizioni_fornitura = post('condizioni_fornitura');
|
||||
$contratto->informazioniaggiuntive = post('informazioniaggiuntive');
|
||||
$contratto->id_categoria = post('id_categoria');
|
||||
$contratto->id_sottocategoria = post('id_sottocategoria');
|
||||
|
||||
// Informazioni sulle date del documento
|
||||
$contratto->data_bozza = post('data_bozza') ?: null;
|
||||
|
@ -55,6 +55,15 @@ echo '
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Categoria').'", "name": "id_categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie_contratti" ]}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Sottocategoria').'", "name": "id_sottocategoria", "required": 0, "value": "$id_sottocategoria$", "ajax-source": "sottocategorie_contratti", "select-options": '.json_encode(['id_categoria' => null]).' ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "date", "label": "'.tr('Data accettazione').'", "name": "data_accettazione" ]}
|
||||
@ -128,4 +137,10 @@ echo '
|
||||
data_accettazione.data("DateTimePicker").date(e.date);
|
||||
}
|
||||
});
|
||||
|
||||
$("#id_categoria").change(function() {
|
||||
updateSelectOption("id_categoria", $(this).val());
|
||||
|
||||
$("#id_sottocategoria").val(null).trigger("change");
|
||||
});
|
||||
</script>';
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
include_once __DIR__.'/../../../core.php';
|
||||
|
||||
use Modules\Contratti\Contratto;
|
||||
|
||||
switch ($resource) {
|
||||
/*
|
||||
* Opzioni utilizzate:
|
||||
@ -43,5 +45,70 @@ switch ($resource) {
|
||||
$search_fields[] = '`co_contratti`.`nome` LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
|
||||
$query = str_replace('|where|', !empty($where) ? 'WHERE '.implode(' AND ', $where) : '', $query);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
|
||||
foreach ($rs as $r) {
|
||||
$contratto = Contratto::find($r['id']);
|
||||
$ore_erogate = $contratto->interventi->sum('ore_totali');
|
||||
$ore_previste = $contratto->getRighe()->where('um', 'ore')->sum('qta');
|
||||
$perc_ore = $ore_previste != 0 ? ($ore_erogate * 100) / ($ore_previste ?: 1) : 0;
|
||||
|
||||
if( $ore_previste ){
|
||||
if ($perc_ore < 75) {
|
||||
$color = '#81f794';
|
||||
} elseif ($perc_ore <= 100) {
|
||||
$color = '#f5cb78';
|
||||
}
|
||||
}
|
||||
|
||||
$descrizione = ($ore_previste>0 ? $r['descrizione']." - ".tr('_EROGATE_/_PREVISTE_ ore',[
|
||||
'_EROGATE_' => Translator::numberToLocale($ore_erogate,2),
|
||||
'_PREVISTE_' => Translator::numberToLocale($ore_previste,2),
|
||||
]) : $r['descrizione']);
|
||||
|
||||
$results[] = [
|
||||
'id' => $r['id'],
|
||||
'text' => $descrizione,
|
||||
'descrizione' => $descrizione,
|
||||
'_bgcolor_' => $color,
|
||||
];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'categorie_contratti':
|
||||
$query = 'SELECT `co_categorie_contratti`.`id`, `title` AS descrizione FROM `co_categorie_contratti` LEFT JOIN `co_categorie_contratti_lang` ON (`co_categorie_contratti`.`id` = `co_categorie_contratti_lang`.`id_record` AND `co_categorie_contratti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = '`co_categorie_contratti`.`id`='.prepare($element);
|
||||
}
|
||||
|
||||
$where[] = '`parent` IS NULL';
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
/*
|
||||
* Opzioni utilizzate:
|
||||
* - id_categoria
|
||||
*/
|
||||
case 'sottocategorie_contratti':
|
||||
if (isset($superselect['id_categoria'])) {
|
||||
$query = 'SELECT `co_categorie_contratti`.`id`, `title` AS descrizione FROM `co_categorie_contratti` LEFT JOIN `co_categorie_contratti_lang` ON (`co_categorie_contratti`.`id` = `co_categorie_contratti_lang`.`id_record` AND `co_categorie_contratti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = '`co_categorie_contratti`.`id`='.prepare($element);
|
||||
}
|
||||
|
||||
$where[] = '`parent`='.prepare($superselect['id_categoria']);
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -131,6 +131,17 @@ echo '
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<?php echo (!empty($record['id_categoria']) ? Modules::link('Categorie contratti', $record['id_categoria'], null, null, 'class="pull-right"') : '');?>
|
||||
{[ "type": "select", "label": "<?php echo tr('Categoria');?>", "name": "id_categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie_contratti" ]}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<?php echo (!empty($record['id_sottocategoria']) ? Modules::link('Categorie contratti', $record['id_categoria'], null, null, 'class="pull-right"') : '');?>
|
||||
{[ "type": "select", "label": "<?php echo tr('Sottocategoria');?>", "name": "id_sottocategoria", "required": 0, "value": "$id_sottocategoria$", "ajax-source": "sottocategorie_contratti", "select-options": <?php echo json_encode(['id_categoria' => $record['id_categoria']]);?> ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "textarea", "label": "<?php echo tr('Esclusioni'); ?>", "name": "esclusioni", "class": "autosize", "value": "$esclusioni$", "extra": "rows='5'" ]}
|
||||
@ -663,4 +674,10 @@ input("ordinamento").on("change", function(){
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#id_categoria").change(function() {
|
||||
updateSelectOption("id_categoria", $(this).val());
|
||||
|
||||
$("#id_sottocategoria").val(null).trigger("change");
|
||||
});
|
||||
</script>';
|
||||
|
63
modules/contratti/src/CategoriaContratto.php
Normal file
63
modules/contratti/src/CategoriaContratto.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?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/>.
|
||||
*/
|
||||
|
||||
namespace Modules\Contratti;
|
||||
|
||||
use Common\SimpleModelTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Traits\HierarchyTrait;
|
||||
use Traits\RecordTrait;
|
||||
|
||||
class CategoriaContratto extends Model
|
||||
{
|
||||
use SimpleModelTrait;
|
||||
use HierarchyTrait;
|
||||
use RecordTrait;
|
||||
|
||||
protected $table = 'co_categorie_contratti';
|
||||
protected static $translated_fields = [
|
||||
'title',
|
||||
];
|
||||
|
||||
protected static $parent_identifier = 'parent';
|
||||
|
||||
public static function build($colore = null)
|
||||
{
|
||||
$model = new static();
|
||||
$model->colore = $colore;
|
||||
$model->save();
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function articoli()
|
||||
{
|
||||
return $this->hasMany(Contratto::class, 'id_categoria');
|
||||
}
|
||||
|
||||
public function getModuleAttribute()
|
||||
{
|
||||
return 'Categorie contratti';
|
||||
}
|
||||
|
||||
public static function getTranslatedFields()
|
||||
{
|
||||
return self::$translated_fields;
|
||||
}
|
||||
}
|
@ -125,4 +125,49 @@ CREATE TABLE `mg_scorte_sedi` (
|
||||
`id_articolo` INT NOT NULL,
|
||||
`id_sede` INT NOT NULL,
|
||||
`threshold_qta` DECIMAL(15,6) NOT NULL,
|
||||
PRIMARY KEY (`id`));
|
||||
PRIMARY KEY (`id`));
|
||||
|
||||
-- Aggiunta modulo categorie contratti
|
||||
CREATE TABLE `co_categorie_contratti` (
|
||||
`id` int NOT NULL,
|
||||
`colore` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`parent` int DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE `co_categorie_contratti_lang` (
|
||||
`id` int NOT NULL,
|
||||
`id_lang` int NOT NULL,
|
||||
`id_record` int NOT NULL,
|
||||
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`note` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
);
|
||||
ALTER TABLE `co_categorie_contratti`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `parent` (`parent`),
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `co_categorie_contratti_lang`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `mg_categorie_lang_ibfk_1` (`id_record`),
|
||||
ADD KEY `mg_categorie_lang_ibfk_2` (`id_lang`),
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
INSERT INTO `zz_modules` (`name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES
|
||||
('Categorie contratti', 'categorie_contratti', '\r\nSELECT\r\n |select|\r\nFROM \r\n `co_categorie_contratti`\r\n LEFT JOIN `co_categorie_contratti_lang` ON (`co_categorie_contratti`.`id` = `co_categorie_contratti_lang`.`id_record` AND `co_categorie_contratti_lang`.|lang|)\r\nWHERE \r\n 1=1 AND `parent` IS NULL \r\nHAVING \r\n 2=2', '', 'fa fa-briefcase', '2.5.5', '2.5.5', 1, 40, 1, 1, 0, 0);
|
||||
INSERT INTO `zz_modules_lang` (`id`, `id_lang`, `id_record`, `title`) VALUES (NULL, '1', (SELECT `id` FROM `zz_modules` WHERE name='Categorie contratti'), 'Categorie contratti');
|
||||
|
||||
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `html_format`, `search_inside`, `order_by`, `visible`, `summable`, `avg`, `default`) VALUES
|
||||
((SELECT `id` FROM `zz_modules` WHERE name='Categorie contratti'), 'id', '`co_categorie_contratti`.`id`', 3, 1, 0, 0, 0, NULL, NULL, 0, 0, 0, 0),
|
||||
((SELECT `id` FROM `zz_modules` WHERE name='Categorie contratti'), 'Nome', '`co_categorie_contratti_lang`.`title`', 2, 1, 0, 0, 0, NULL, NULL, 1, 0, 0, 0);
|
||||
|
||||
INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES
|
||||
(1, (SELECT `zz_views`.`id` FROM `zz_views` WHERE `zz_views`.`name` = 'id' AND `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Categorie contratti')), 'id'),
|
||||
(1, (SELECT `zz_views`.`id` FROM `zz_views` WHERE `zz_views`.`name` = 'Nome' AND `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Categorie contratti')), 'Nome');
|
||||
|
||||
ALTER TABLE `co_contratti`
|
||||
ADD `id_categoria` INT NULL DEFAULT NULL ,
|
||||
ADD `id_sottocategoria` INT NULL DEFAULT NULL ;
|
Loading…
x
Reference in New Issue
Block a user