Aggiunta gestione marca e modello su Impianti
This commit is contained in:
parent
540fe7b4d2
commit
857a8694f9
|
@ -23,17 +23,17 @@ use Modules\Impianti\Categoria;
|
|||
$subcategorie = Categoria::where('parent', '=', $id_record)->get();
|
||||
|
||||
foreach ($subcategorie as $sub) {
|
||||
$n_impianti = $dbo->fetchNum('SELECT * FROM `my_impianti` WHERE `id_sottocategoria`='.prepare($sub->id).' AND deleted_at IS NULL');
|
||||
$impianti = $dbo->fetchArray('SELECT * FROM `my_impianti` WHERE `id_sottocategoria`='.prepare($sub->id));
|
||||
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_impianti > 0) ? 'disabled tip' : '').'" data-backto="record-edit" data-id="'.$sub->id.'" title="'.(($n_impianti > 0) ? 'Sottocategoria collegata a '.$n_impianti.' articoli' : '').'">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
<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 '.((!empty($impianti)) ? 'disabled tip' : '').'" data-backto="record-edit" data-id="'.$sub->id.'" title="'.(($n_impianti > 0) ? 'Sottocategoria collegata a '.$n_impianti.' articoli' : '').'">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ switch ($op) {
|
|||
'matricola' => $matricola,
|
||||
'id_categoria' => post('id_categoria') ?: null,
|
||||
'id_sottocategoria' => post('id_sottocategoria') ?: null,
|
||||
'id_marca' => post('id_marca') ?: null,
|
||||
'id_modello' => post('id_modello') ?: null,
|
||||
'descrizione' => post('descrizione'),
|
||||
'idsede' => post('idsede'),
|
||||
'data' => post('data') ?: null,
|
||||
|
|
|
@ -140,7 +140,7 @@ switch ($resource) {
|
|||
*/
|
||||
case 'sottocategorie_imp':
|
||||
if (isset($superselect['id_categoria'])) {
|
||||
$query = 'SELECT ``my_impianti_categorie`.`id`, `my_impianti_categorie_lang`.`title` AS descrizione FROM `my_impianti_categorie` LEFT JOIN `my_impianti_categorie_lang` ON (`my_impianti_categorie`.`id`=`my_impianti_categorie_lang`.`id_record` AND `my_impianti_categorie_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
|
||||
$query = 'SELECT `my_impianti_categorie`.`id`, `my_impianti_categorie_lang`.`title` AS descrizione FROM `my_impianti_categorie` LEFT JOIN `my_impianti_categorie_lang` ON (`my_impianti_categorie`.`id`=`my_impianti_categorie_lang`.`id_record` AND `my_impianti_categorie_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = '`my_impianti_categorie`.`id`='.prepare($element);
|
||||
|
@ -153,4 +153,35 @@ switch ($resource) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'marca':
|
||||
$query = 'SELECT `my_impianti_marche`.`id`, `my_impianti_marche_lang`.`title` AS descrizione FROM `my_impianti_marche` LEFT JOIN `my_impianti_marche_lang` ON (`my_impianti_marche`.`id`=`my_impianti_marche_lang`.`id_record` AND `my_impianti_marche_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = '`my_impianti_marche`.`id`='.prepare($element);
|
||||
}
|
||||
|
||||
$where[] = '`parent` = 0';
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'modello':
|
||||
if (isset($superselect['id_marca'])) {
|
||||
$query = 'SELECT `my_impianti_marche`.`id`, `my_impianti_marche_lang`.`title` AS descrizione FROM `my_impianti_marche` LEFT JOIN `my_impianti_marche_lang` ON (`my_impianti_marche`.`id`=`my_impianti_marche_lang`.`id_record` AND `my_impianti_marche_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = '`my_impianti_marche`.`id`='.prepare($element);
|
||||
}
|
||||
|
||||
$where[] = '`parent`='.prepare($superselect['id_marca']);
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -79,10 +79,10 @@ if (!empty($record['immagine'])) {
|
|||
</div>
|
||||
<div class ="row">
|
||||
<div class="col-md-4">
|
||||
<!--{[ "type": "select", "label": "<?php echo tr('Marca'); ?>", "name": "id_marca", "value": "$id_marca$", "ajax-source": "marca", "icon-after": "add|<?php echo $id_modulo_marca_impianti; ?>" ]}-->
|
||||
{[ "type": "select", "label": "<?php echo tr('Marca'); ?>", "name": "id_marca", "value": "$id_marca$", "ajax-source": "marca", "icon-after": "add|<?php echo $id_modulo_marca_impianti; ?>" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<!--{[ "type": "text", "label": "<?php echo tr('Modello'); ?>", "name": "modello", "value": "$modello$" ]}-->
|
||||
{[ "type": "select", "label": "<?php echo tr('Modello'); ?>", "name": "id_modello", "value": "$id_modello$","ajax-source": "modello", "select-options": <?php echo json_encode(['id_marca' => $record['id_marca']]); ?>, "icon-after": "add|<?php echo $id_modulo_marca_impianti; ?>|id_original=<?php echo $record['id_marca']; ?>" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Proprietario'); ?>", "name": "proprietario", "value": "$proprietario$" ]}
|
||||
|
@ -205,10 +205,14 @@ $(document).ready(function() {
|
|||
.selectReset();
|
||||
});
|
||||
|
||||
$("#id_categoria").change(function() {
|
||||
updateSelectOption("id_categoria", $(this).val());
|
||||
$("#id_categoria").on("change", function() {
|
||||
updateSelectOption("id_categoria", $(this).val());
|
||||
$("#id_sottocategoria").val(null).trigger("change");
|
||||
});
|
||||
|
||||
$("#id_sottocategoria").val(null).trigger("change");
|
||||
$("#id_marca").on("change", function() {
|
||||
updateSelectOption("id_marca", $(this).val());
|
||||
$("#id_modello").val(null).trigger("change");
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<?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\Impianti;
|
||||
|
||||
use Common\SimpleModelTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Traits\HierarchyTrait;
|
||||
use Traits\RecordTrait;
|
||||
|
||||
class Marca extends Model
|
||||
{
|
||||
use SimpleModelTrait;
|
||||
use HierarchyTrait;
|
||||
use RecordTrait;
|
||||
protected $table = 'my_impianti_marche';
|
||||
protected static $parent_identifier = 'parent';
|
||||
|
||||
protected static $translated_fields = [
|
||||
'title',
|
||||
];
|
||||
|
||||
public static function build()
|
||||
{
|
||||
$model = new static();
|
||||
$model->save();
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function impianti()
|
||||
{
|
||||
return $this->hasMany(Impianto::class, 'id_marca');
|
||||
}
|
||||
|
||||
public function getModuleAttribute()
|
||||
{
|
||||
return 'Marche impianti';
|
||||
}
|
||||
|
||||
public static function getTranslatedFields()
|
||||
{
|
||||
return self::$translated_fields;
|
||||
}
|
||||
}
|
|
@ -19,53 +19,87 @@
|
|||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
switch (post('op')) {
|
||||
use Models\Module;
|
||||
use Modules\Impianti\Marca;
|
||||
|
||||
$id_modulo_marca_impianti = (new Module())->getByField('title', 'Marche Impianti', Models\Locale::getPredefined()->id);
|
||||
|
||||
switch (filter('op')) {
|
||||
case 'update':
|
||||
$id_marca = post('id_record');
|
||||
$name = post('name');
|
||||
$title = filter('title');
|
||||
$id_original = filter('id_original') ?: 0;
|
||||
|
||||
// Verifico che il nome non esista già
|
||||
$n = $dbo->fetchNum('SELECT `id` FROM `my_impianti_marche` WHERE (`title`='.prepare($name).' AND `id` !='.prepare($id_marca));
|
||||
if (isset($title)) {
|
||||
$marca->parent = $id_original;
|
||||
$marca->setTranslation('title', $title);
|
||||
$marca->save();
|
||||
|
||||
// Marca già esistente
|
||||
if ($n > 0) {
|
||||
flash()->error(tr('Marca già esistente!'));
|
||||
flash()->info(tr('Salvataggio completato!'));
|
||||
} else {
|
||||
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
|
||||
}
|
||||
// Marca non esistente
|
||||
else {
|
||||
$dbo->query('UPDATE `my_impianti_marche` SET `title`='.prepare($name).' WHERE `id`='.prepare($id_marca));
|
||||
flash()->info(tr('Informazioni salvate correttamente!'));
|
||||
|
||||
// Redirect alla marca se si sta modificando una sottomarca
|
||||
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':
|
||||
$name = post('name');
|
||||
$title = filter('title');
|
||||
$id_original = filter('id_original') ?: null;
|
||||
|
||||
// Verifico che il nome non sia duplicato
|
||||
$n = $dbo->fetchNum('SELECT `id` FROM `my_impianti_marche` WHERE `title`='.prepare($name));
|
||||
|
||||
if ($n > 0) {
|
||||
flash()->error(tr('Nome già esistente!'));
|
||||
$marca_new = Marca::where('id', '=', (new Marca())->getByField('title', $title));
|
||||
if (!empty($id_original)) {
|
||||
$marca_new = $marca_new->where('parent', '=', $id_original);
|
||||
} else {
|
||||
$query = 'INSERT INTO my_impianti_marche (`title`) VALUES ('.prepare($name).')';
|
||||
$dbo->query($query);
|
||||
$marca_new = $marca_new->whereNull('parent');
|
||||
}
|
||||
$marca_new = $marca_new->first();
|
||||
|
||||
if (!empty($marca_new)) {
|
||||
flash()->error(tr('Questo nome è già stato utilizzato per un altra marca.'));
|
||||
} else {
|
||||
$marca = Marca::build();
|
||||
$id_record = $dbo->lastInsertedID();
|
||||
$marca->parent = $id_original ?: 0;
|
||||
$marca->setTranslation('title', $title);
|
||||
$marca->save();
|
||||
|
||||
if (isAjaxRequest()) {
|
||||
echo json_encode(['id' => $id_record, 'text' => $name]);
|
||||
}
|
||||
flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [
|
||||
'_TYPE_' => 'marca',
|
||||
]));
|
||||
}
|
||||
|
||||
flash()->info(tr('Aggiunta una nuova marca!'));
|
||||
if (isAjaxRequest()) {
|
||||
echo json_encode(['id' => $id_record, 'text' => $title]);
|
||||
} else {
|
||||
// Redirect alla marca se si sta aggiungendo un modello
|
||||
$database->commitTransaction();
|
||||
redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.($id_original ?: $id_record));
|
||||
exit;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$dbo->query('DELETE FROM `my_impianti_marche` WHERE `id`='.prepare($id_record));
|
||||
$id = filter('id');
|
||||
if (empty($id)) {
|
||||
$id = $id_record;
|
||||
}
|
||||
|
||||
flash()->info(tr('Marca eliminata!'));
|
||||
if (empty($dbo->fetchArray('SELECT * FROM `my_impianti` WHERE (`id_marca`='.prepare($id).' OR `id_modello`='.prepare($id).' OR `id_modello` IN (SELECT `id` FROM `my_impianti_marche` WHERE `parent`='.prepare($id).'))'))) {
|
||||
$dbo->query('DELETE FROM `my_impianti_marche` WHERE `id`='.prepare($id));
|
||||
|
||||
flash()->info(tr('_TYPE_ eliminata con successo!', [
|
||||
'_TYPE_' => 'marca',
|
||||
]));
|
||||
} else {
|
||||
flash()->error(tr('Esistono alcuni impianti collegati a questa marca. Impossibile eliminarla.'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -19,20 +19,45 @@
|
|||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?><form action="" method="post" id="add-form">
|
||||
<input type="hidden" name="op" value="add">
|
||||
$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-12">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": 1 ]}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "title", "required": 1, "value": "$title$" ]}
|
||||
</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>
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?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';
|
||||
|
||||
switch ($resource) {
|
||||
case 'marca':
|
||||
$query = 'SELECT `id`, `title` AS `descrizione` FROM `my_impianti_marche` |where| ORDER BY `descrizione` ASC';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = '`id`='.prepare($element);
|
||||
}
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
|
@ -19,19 +19,92 @@
|
|||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?>
|
||||
<form action="" method="post" id="edit-form">
|
||||
<input type="hidden" name="op" value="update">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
|
||||
use Models\Module;
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": 1, "value": "$title$" ]}
|
||||
?><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="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><?php echo tr('Dati'); ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "title", "required": 1, "value": "$title$" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<a class="btn btn-danger ask" data-backto="record-list">
|
||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||
</a>
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><?php echo tr('Modelli'); ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-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-toggle="modal" data-title="<?php echo tr('Aggiungi riga'); ?>"><i class="fa fa-plus"></i> <?php echo tr('Modello'); ?></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 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>
|
||||
<?php
|
||||
|
||||
$elementi = $dbo->fetchArray('SELECT `my_impianti`.`id`, `my_impianti`.`matricola`, `my_impianti`.`nome` FROM `my_impianti` WHERE (`id_marca`='.prepare($id_record).' OR `id_modello`='.prepare($id_record).' OR `id_modello` IN (SELECT `id` FROM `my_impianti_marche` WHERE `parent`='.prepare($id_record).'))');
|
||||
|
||||
if (!empty($elementi)) {
|
||||
echo '
|
||||
<div class="box box-warning collapsable collapsed-box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class="fa fa-warning"></i> '.tr('Impianti collegati: _NUM_', [
|
||||
'_NUM_' => count($elementi),
|
||||
]).'</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<ul>';
|
||||
|
||||
foreach ($elementi as $elemento) {
|
||||
$descrizione = tr('Impianto _MATRICOLA_', [
|
||||
'_MATRICOLA_' => $elemento['matricola'],
|
||||
]);
|
||||
$modulo = 'Impianti';
|
||||
$id = $elemento['id'];
|
||||
|
||||
echo '
|
||||
<li>'.Modules::link($modulo, $id, $descrizione).'</li>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</ul>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
echo '
|
||||
<a class="btn btn-danger ask" data-backto="record-list">
|
||||
<i class="fa fa-trash"></i> '.tr('Elimina').'
|
||||
</a>';
|
||||
}
|
||||
|
|
|
@ -18,7 +18,10 @@
|
|||
*/
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
use Modules\Impianti\Marca;
|
||||
|
||||
if (!empty($id_record)) {
|
||||
$record = $dbo->fetchOne('SELECT * FROM `my_impianti_marche` WHERE `id`='.prepare($id_record));
|
||||
$record = $dbo->fetchOne('SELECT * FROM `my_impianti_marche` LEFT JOIN `my_impianti_marche_lang` ON (`my_impianti_marche`.`id`=`my_impianti_marche_lang`.`id_record` AND `my_impianti_marche_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `my_impianti_marche`.`id`='.prepare($id_record));
|
||||
|
||||
$marca = Marca::find($id_record);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?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\Impianti\Marca;
|
||||
|
||||
$modelli = Marca::where('parent', '=', $id_record)->get();
|
||||
|
||||
foreach ($modelli as $modello) {
|
||||
$n_impianti = $dbo->fetchNum('SELECT * FROM `my_impianti` WHERE `id_modello`='.prepare($modello->id));
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$modello->getTranslation('title').'</td>
|
||||
<td>
|
||||
<a class="btn btn-warning btn-sm" title="Modifica riga" onclick="launch_modal(\''.tr('Modifica modello').'\', \''.base_path().'/add.php?id_module='.$id_module.'&id_record='.$modello->id.'&id_original='.$id_record.'\');"><i class="fa fa-edit"></i></a>
|
||||
<a class="btn btn-sm btn-danger ask '.(($n_impianti > 0) ? 'disabled tip' : '').'" data-backto="record-edit" data-id="'.$modello->id.'" title="'.(($n_impianti > 0) ? 'Modello collegata a '.$n_impianti.' impianti' : '').'">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
|
@ -78,3 +78,27 @@ INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES
|
|||
|
||||
-- Aggiunta flag per calcolo media su viste
|
||||
ALTER TABLE `zz_views` ADD `avg` BOOLEAN NOT NULL DEFAULT FALSE AFTER `summable`;
|
||||
|
||||
-- Aggiunta tabella my_impianti_marche_lang
|
||||
CREATE TABLE IF NOT EXISTS `my_impianti_marche_lang` (
|
||||
`id` int NOT NULL,
|
||||
`id_lang` int NOT NULL,
|
||||
`id_record` int NOT NULL,
|
||||
`title` VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE `my_impianti_marche_lang`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `my_impianti_marche_lang`
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `my_impianti_marche_lang` ADD CONSTRAINT `my_impianti_marche_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `my_impianti_marche`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
|
||||
ALTER TABLE `my_impianti_marche_lang` ADD CONSTRAINT `my_impianti_marche_lang_ibfk_2` FOREIGN KEY (`id_lang`) REFERENCES `zz_langs`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
|
||||
|
||||
ALTER TABLE `my_impianti_marche` DROP `nota`;
|
||||
|
||||
UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `my_impianti_marche` LEFT JOIN `my_impianti_marche_lang` ON (my_impianti_marche.id = my_impianti_marche_lang.id_record AND my_impianti_marche_lang.|lang|) WHERE 1=1 AND parent = 0 HAVING 2=2' WHERE `zz_modules`.`name` = 'Marche impianti';
|
||||
|
||||
UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`query` = 'my_impianti_marche.id' WHERE `zz_modules`.`name` = 'Marche impianti' AND `zz_views`.`name` = 'id';
|
||||
UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`query` = 'my_impianti_marche_lang.title' WHERE `zz_modules`.`name` = 'Marche impianti' AND `zz_views`.`name` = 'Nome';
|
Loading…
Reference in New Issue