This commit is contained in:
MatteoPistorello 2024-03-14 10:50:50 +01:00
commit ba90d10567
16 changed files with 51 additions and 34 deletions

View File

@ -166,8 +166,6 @@ $translator->addLocalePath(base_dir().'/locale');
$translator->addLocalePath(base_dir().'/modules/*/locale');
$translator->setLocale($lang, $formatter);
App::setLang(setting('Lingua'));
// Individuazione di versione e revisione del progetto
$version = Update::getVersion();
$revision = Update::getRevision();
@ -305,3 +303,7 @@ $list = array_merge($files, $custom_files);
foreach ($list as $file) {
include_once $file;
}
if (database()->tableExists('zz_settings')) {
App::setLang(setting('Lingua'));
}

View File

@ -24,7 +24,7 @@ include_once __DIR__.'/../../core.php';
$id_nazione_italia = (new Nazione())->getByName('Italia')->id_record;
$tipo = get('tipoanagrafica');
if (!empty($tipo)) {
$rs = $dbo->fetchArray('SELECT `an_tipianagrafiche`.`id`, `an_tipianagrafiche_lang`.`name` as descrizione FROM `an_tipianagrafiche` LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche`.`id` = `an_tipianagrafiche_lang`.`id_record` AND `an_tipianagrafiche_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE name='.prepare($tipo));
$rs = $dbo->fetchArray('SELECT `an_tipianagrafiche`.`id`, `an_tipianagrafiche_lang`.`name` as descrizione FROM `an_tipianagrafiche` LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche`.`id` = `an_tipianagrafiche_lang`.`id_record` AND `an_tipianagrafiche_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `name`='.prepare($tipo));
$idtipoanagrafica = $rs[0]['id'];
}

View File

@ -28,7 +28,7 @@ foreach ($rs as $riga) {
${'id_'.strtolower($riga->name)} = $riga->id;
}
if (isset($id_record)) {
if (!empty($id_record)) {
$anagrafica = Anagrafica::withTrashed()->find($id_record);
$record = $dbo->fetchOne('SELECT

View File

@ -92,7 +92,7 @@ class Anagrafica extends Model
$tipologia = (new TipoAnagrafica())->getByName($type)->id_record;
$anagrafiche = self::whereHas('tipi', function ($query) use ($tipologia) {
$query->where('an_tipianagrafiche.id', '=', $tipologia->id);
$query->where('an_tipianagrafiche.id', '=', $tipologia);
});
return $anagrafiche;

View File

@ -36,7 +36,7 @@ class Categoria extends Model
$model = new static();
$model->save();
$gruppi = Group::get();
$gruppi = Group::get()->toArray();
$model->syncPermessi(array_column($gruppi, 'id'));
return $model;

View File

@ -22,7 +22,7 @@ include_once __DIR__.'/../../../core.php';
use Modules\Interventi\Stato;
use Modules\Interventi\Intervento;
$rs = Intervento::where('idstatointervento', '=', Stato::where('codice', '=', 'WIP')->first()->id)->get();
$rs = Intervento::where('idstatointervento', '=', Stato::where('codice', '=', 'WIP')->first()->id)->get()->toArray();
if (!empty($rs)) {
echo '
@ -33,13 +33,13 @@ if (!empty($rs)) {
</tr>';
foreach ($rs as $r) {
$data_richiesta = !empty($r->data_richiesta) ? Translator::dateToLocale($r->data_richiesta) : '';
$data_richiesta = $r['data_richiesta'] ? date('d/m/Y', strtotime($r['data_richiesta'])) : '';
echo '
<tr >
<td>
'.Modules::link('Interventi', $r->id, 'Intervento n. '.$r['codice'].' del '.$data_richiesta).'<br>
<small class="help-block">'.$r->ragione_sociale.'</small>
'.Modules::link('Interventi', $r['id'], 'Intervento n. '.$r['codice'].' del '.$data_richiesta).'<br>
<small class="help-block">'.$r['ragione_sociale'].'</small>
</td>
<td class="text-center">'.$data_richiesta.'</td>
</tr>';

View File

@ -11,7 +11,7 @@ $length = filter('length');
$tot_articoli = $dbo->select('mg_listini_articoli', '*', [], ['id_listino' => $id_listino]);
if (empty($search)) {
$articoli = $dbo->fetchArray('SELECT `mg_listini_articoli`.*, `mg_articoli`.`codice`, `mg_articoli_lang`.`name` AS descrizione, `mg_articoli`.'.($prezzi_ivati ? 'minimo_vendita_ivato' : 'minimo_vendita').' AS minimo_vendita FROM `mg_listini_articoli` LEFT JOIN `mg_articoli` ON `mg_listini_articoli`.`id_articolo`=`mg_articoli`.`id` WHERE `id_listino`='.prepare($id_listino).' LIMIT '.$start.', '.$length);
$articoli = $dbo->fetchArray('SELECT `mg_listini_articoli`.*, `mg_articoli`.`codice`, `mg_articoli_lang`.`name` AS descrizione, `mg_articoli`.'.($prezzi_ivati ? 'minimo_vendita_ivato' : 'minimo_vendita').' AS minimo_vendita FROM `mg_listini_articoli` LEFT JOIN `mg_articoli` ON `mg_listini_articoli`.`id_articolo`=`mg_articoli`.`id` LEFT JOIN `mg_articoli_lang` ON (`mg_articoli_lang`.`id_record` = `mg_articoli`.`id` AND `mg_articoli_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `id_listino`='.prepare($id_listino).' LIMIT '.$start.', '.$length);
} else {
$resource = 'articoli_listino';
include_once __DIR__.'/select.php';

View File

@ -23,7 +23,7 @@ use Modules\ListiniCliente\Listino;
if (isset($id_record)) {
$listino = Listino::find($id_record);
$record = $dbo->fetchOne('SELECT * FROM `mg_listini` WHERE id='.prepare($id_record));
$record = $dbo->fetchOne('SELECT * FROM `mg_listini` WHERE `id`='.prepare($id_record));
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
}

View File

@ -73,38 +73,37 @@ echo '
// Tipi di interventi
foreach ($tipi_interventi as $tipo_intervento) {
$tipo = Tipo::find($tipo_intervento['id']);
echo '
<tr>
<td>'.$tipo->name.'</td>
<td>'.$tipo_intervento['name'].'</td>
<td>
{[ "type": "number", "name": "costo_ore['.$tipo->id.']", "required": 1, "value": "'.$tipo->costo_ore.'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
{[ "type": "number", "name": "costo_ore['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_ore'].'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
</td>
<td>
{[ "type": "number", "name": "costo_km['.$tipo->id.']", "required": 1, "value": "'.$tipo->costo_km.'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
{[ "type": "number", "name": "costo_km['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_km'].'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
</td>
<td>
{[ "type": "number", "name": "costo_dirittochiamata['.$tipo->id.']", "required": 1, "value": "'.$tipo->costo_dirittochiamata.'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
{[ "type": "number", "name": "costo_dirittochiamata['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_dirittochiamata'].'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
</td>
<td>
{[ "type": "number", "name": "costo_ore_tecnico['.$tipo->id.']", "required": 1, "value": "'.$tipo->costo_ore_tecnico.'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
{[ "type": "number", "name": "costo_ore_tecnico['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_ore_tecnico'].'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
</td>
<td>
{[ "type": "number", "name": "costo_km_tecnico['.$tipo->id.']", "required": 1, "value": "'.$tipo->costo_km_tecnico.'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
{[ "type": "number", "name": "costo_km_tecnico['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_km_tecnico'].'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
</td>
<td>
{[ "type": "number", "name": "costo_dirittochiamata_tecnico['.$tipo->id.']", "required": 1, "value": "'.$tipo->costo_dirittochiamata_tecnico.'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
{[ "type": "number", "name": "costo_dirittochiamata_tecnico['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_dirittochiamata_tecnico'].'", "icon-after": "<i class=\'fa fa-euro\'></i>" ]}
</td>
<td>
<a class="btn btn-warning ask" data-backto="record-edit" data-method="post" data-op="import" data-idtipointervento="'.$tipo->id.'" data-msg="'.tr('Vuoi importare la tariffa standard?').'" data-button="'.tr('Importa').'" data-class="btn btn-lg btn-info">
<a class="btn btn-warning ask" data-backto="record-edit" data-method="post" data-op="import" data-idtipointervento="'.$tipo_intervento['id'].'" data-msg="'.tr('Vuoi importare la tariffa standard?').'" data-button="'.tr('Importa').'" data-class="btn btn-lg btn-info">
<i class="fa fa-download"></i>
</a>
</td>

View File

@ -22,5 +22,17 @@ include_once __DIR__.'/../../core.php';
if (isset($id_record)) {
$record = $dbo->fetchOne('SELECT `idanagrafica`, `ragione_sociale`, `colore` FROM `an_anagrafiche` WHERE `idanagrafica` = '.prepare($id_record));
$tipi_interventi = $dbo->fetchArray('SELECT *, `in_tipiintervento`.`id`, `in_tariffe`.`idtipointervento` AS esiste FROM `in_tipiintervento` LEFT JOIN `in_tipiintervento_lang` ON (`in_tipiintervento`.`id` = `in_tipiintervento_lang`.`id_record` AND `in_tipiintervento_lang`.`id_lang` = '.prepare(\App::getLang()).') LEFT JOIN `in_tariffe` ON `in_tipiintervento`.`id` = `in_tariffe`.`idtipointervento` AND `in_tariffe`.`idtecnico` = '.prepare($id_record).' WHERE `in_tipiintervento`.`deleted_at` IS NULL ORDER BY `name`');
$tipi_interventi = $dbo->fetchArray('SELECT
`in_tariffe`.*,
`in_tipiintervento_lang`.`name`,
`in_tipiintervento`.`id`,
`in_tariffe`.`idtipointervento` AS esiste
FROM
`in_tipiintervento`
LEFT JOIN `in_tipiintervento_lang` ON (`in_tipiintervento`.`id` = `in_tipiintervento_lang`.`id_record` AND `in_tipiintervento_lang`.`id_lang` = '.prepare(\App::getLang()).')
LEFT JOIN `in_tariffe` ON `in_tipiintervento`.`id` = `in_tariffe`.`idtipointervento` AND `in_tariffe`.`idtecnico` = '.prepare($id_record).'
WHERE
`in_tipiintervento`.`deleted_at` IS NULL
ORDER BY
`name`');
}

View File

@ -16,12 +16,12 @@
* 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\Fatture\Tipo;
if (isset($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM `co_tipidocumento` LEFT JOIN `co_tipidocumento_lang` ON (`co_tipidocumento_lang`.`id_record` = `co_tipidocumento`.`id` AND `co_tipidocumento_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `co_tipidocumento`.`id`='.prepare($id_record));
include_once __DIR__.'/../../core.php';
if (($id_record)) {
$record = $dbo->fetchOne('SELECT `co_tipidocumento`.*, `co_tipidocumento_lang`.`name` FROM `co_tipidocumento` LEFT JOIN `co_tipidocumento_lang` ON (`co_tipidocumento_lang`.`id_record` = `co_tipidocumento`.`id` AND `co_tipidocumento_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `co_tipidocumento`.`id`='.prepare($id_record));
$tipo = Tipo::find($id_record);
}

View File

@ -90,10 +90,10 @@ switch (filter('op')) {
'clause' => 'co_scadenziario.tipo="'.$nome.'"',
'position' => 'WHR',
]);
$id_record = $dbo->lastInsertedID();
$dbo->insert('zz_segments', [
$id_segment = $dbo->lastInsertedID();
$dbo->insert('zz_segments_lang', [
'name' => 'Scadenzario '.$nome,
'id_record' => $id_record,
'id_record' => $id_segment,
'id_lang' => \App::getLang(),
]);

View File

@ -117,13 +117,13 @@ switch ($resource) {
break;
case 'gruppi':
$query = 'SELECT `zz_groups`.`id`, `zz_groups`.`name` AS descrizione FROM `zz_groups` LEFT JOIN `zz_groups_lang` ON `zz_groups`.`id`=`zz_groups_lang`.`id_record` AND `zz_groups_lang`.`id_lang`='.prepare(\App::getLang()).' |where| ORDER BY `name`';
$query = 'SELECT `zz_groups`.`id`, `zz_groups_lang`.`name` AS descrizione FROM `zz_groups` LEFT JOIN `zz_groups_lang` ON `zz_groups`.`id`=`zz_groups_lang`.`id_record` AND `zz_groups_lang`.`id_lang`='.prepare(\App::getLang()).' |where| ORDER BY `name`';
foreach ($elements as $element) {
$filter[] = '`zz_groups`.`id`='.prepare($element);
}
if (!empty($search)) {
$search_fields[] = '`zz_groups`.`name` LIKE '.prepare('%'.$search.'%');
$search_fields[] = '`zz_groups_lang`.`name` LIKE '.prepare('%'.$search.'%');
}
break;

View File

@ -64,7 +64,7 @@ if (!function_exists('menuSelection')) {
$submenus = $element['all_children'];
if (!empty($submenus)) {
foreach ($submenus as $submenu) {
$result .= menuSelection($submenu, $group_id, $depth, $permessi_disponibili, $perms_names);
$result .= menuSelection($submenu, $group_id, $depth, $permessi_disponibili);
}
}

View File

@ -17,6 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use Models\View;
echo '
<form action="" method="post" role="form">
@ -28,7 +30,7 @@ echo '
<div class="data">';
$key = 0;
$fields = $dbo->fetchArray('SELECT * FROM `zz_views` LEFT JOIN `zz_views_lang` ON (`zz_views`.`id` = `zz_views_lang`.`id_record` AND `zz_views_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `id_module`='.prepare($record->id).' ORDER BY `order` ASC');
$fields = View::where('id_module', '=', $record->id)->orderBy('order', 'asc')->get();
foreach ($fields as $key => $field) {
$editable = !($field['default'] && $enable_readonly);

View File

@ -585,6 +585,7 @@ FROM
`co_tipidocumento`
LEFT JOIN `co_tipidocumento_lang` ON (`co_tipidocumento`.`id` = `co_tipidocumento_lang`.`id_record` AND `co_tipidocumento_lang`.|lang|)
LEFT JOIN `zz_segments` ON `co_tipidocumento`.`id_segment` = `zz_segments`.`id`
LEFT JOIN `zz_segments_lang` ON (`zz_segments`.`id` = `zz_segments_lang`.`id_record` AND `zz_segments_lang`.|lang|)
WHERE
1=1 AND `deleted_at` IS NULL
HAVING
@ -1858,7 +1859,7 @@ SELECT
|select|
FROM
`an_anagrafiche`
INNER JOIN `an_tipianzz_settings_langgrafiche_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `an_tipianagrafiche_anagrafiche`.`idanagrafica`
INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `an_tipianagrafiche_anagrafiche`.`idanagrafica`
LEFT JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` = `an_tipianagrafiche`.`id`
LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche_lang`.`id_record` = `an_tipianagrafiche`.`id` AND |lang|)
WHERE
@ -2058,6 +2059,7 @@ HAVING
ORDER BY `zz_segments_lang`.`name`,
`zz_segments`.`id_module`" WHERE `zz_modules`.`id` = (SELECT `id_record` FROM `zz_modules_lang` WHERE `name` = 'Segmenti');
UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` LEFT JOIN `zz_modules_lang` ON (`zz_modules_lang`.`id_record` = `zz_modules`.`id` AND `zz_modules_lang`.`id_lang` = (SELECT `valore` FROM `zz_settings` WHERE `nome` = "Lingua")) SET `zz_views`.`query` = '`zz_segments_lang`.`name`' WHERE `zz_modules_lang`.`name` = 'Segmenti' AND `zz_views`.`name` = 'Nome';
UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` LEFT JOIN `zz_modules_lang` ON (`zz_modules_lang`.`id_record` = `zz_modules`.`id` AND `zz_modules_lang`.`id_lang` = (SELECT `valore` FROM `zz_settings` WHERE `nome` = "Lingua")) SET `zz_views`.`query` = '`zz_segments_lang`.`name`' WHERE `zz_modules_lang`.`name` = 'Segmenti' AND `zz_views`.`name` = 'Tipi documento';
-- Aggiunta tabella zz_views_lang
CREATE TABLE IF NOT EXISTS `zz_views_lang` (