1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-03-12 01:00:13 +01:00

Formattazione codice

This commit is contained in:
Pek5892 2023-09-21 17:34:30 +02:00
parent 2c532f2254
commit 0f5dfcccfd
21 changed files with 58 additions and 69 deletions
include
modules
anagrafiche/src/API/v1
articoli/src/API/v1
checklists/src
emails/src
impianti/src/API/v1
interventi
newsletter
preventivi/widgets
src
templates/preventivi

@ -65,8 +65,8 @@ if (Auth::check()) {
<style>'.$custom_css.'</style>'; <style>'.$custom_css.'</style>';
} }
// Hooks // Hooks
echo ' echo '
<script> <script>
$(document).ready(function() { $(document).ready(function() {
// Toast // Toast
@ -75,18 +75,18 @@ if (Auth::check()) {
// Orologio // Orologio
clock();'; clock();';
// Hooks // Hooks
if (!$config['disable_hooks']) { if (!$config['disable_hooks']) {
echo ' echo '
setTimeout("startHooks();", 1000);'; setTimeout("startHooks();", 1000);';
} }
// Abilitazione del cron autonoma // Abilitazione del cron autonoma
if (!$config['disable_cron']) { if (!$config['disable_cron']) {
echo ' echo '
$.get(globals.rootdir + "/cron.php");'; $.get(globals.rootdir + "/cron.php");';
} }
echo ' echo '
}); });
</script>'; </script>';
} }

@ -39,4 +39,4 @@ if ($module['name'] == 'Preventivi' && $options['op'] == 'manage_descrizione') {
{[ "type": "checkbox", "label": "'.tr('Utilizza come titolo del gruppo').'", "name": "is_titolo", "value": '.json_encode($result['is_titolo']).', "help": "'.tr('').'" ]} {[ "type": "checkbox", "label": "'.tr('Utilizza come titolo del gruppo').'", "name": "is_titolo", "value": '.json_encode($result['is_titolo']).', "help": "'.tr('').'" ]}
</div> </div>
</div>'; </div>';
} }

@ -22,7 +22,7 @@ include_once __DIR__.'/../../core.php';
if ($config['maintenance_ip'] != $_SERVER['REMOTE_ADDR']) { if ($config['maintenance_ip'] != $_SERVER['REMOTE_ADDR']) {
include_once App::filepath('include|custom|', 'top.php'); include_once App::filepath('include|custom|', 'top.php');
$img = App::getPaths()['img']; $img = App::getPaths()['img'];
echo ' echo '
<div class="box box-center-large box-danger"> <div class="box box-center-large box-danger">
<div class="box-header with-border text-center"> <div class="box-header with-border text-center">

@ -24,7 +24,6 @@ use API\Interfaces\DeleteInterface;
use API\Interfaces\RetrieveInterface; use API\Interfaces\RetrieveInterface;
use API\Interfaces\UpdateInterface; use API\Interfaces\UpdateInterface;
use API\Resource; use API\Resource;
use Modules;
use Modules\Anagrafiche\Anagrafica; use Modules\Anagrafiche\Anagrafica;
class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface, UpdateInterface, DeleteInterface class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface, UpdateInterface, DeleteInterface
@ -35,13 +34,13 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface
$select = [ $select = [
'an_anagrafiche.*', 'an_anagrafiche.*',
'an_nazioni.nome AS nazione' 'an_nazioni.nome AS nazione',
]; ];
$joins[] = [ $joins[] = [
'an_nazioni', 'an_nazioni',
'an_anagrafiche.id_nazione', 'an_anagrafiche.id_nazione',
'an_nazioni.id' 'an_nazioni.id',
]; ];
$where[] = ['an_anagrafiche.deleted_at', '=', null]; $where[] = ['an_anagrafiche.deleted_at', '=', null];
@ -54,13 +53,13 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface
$joins[] = [ $joins[] = [
'an_tipianagrafiche_anagrafiche', 'an_tipianagrafiche_anagrafiche',
'an_anagrafiche.idanagrafica', 'an_anagrafiche.idanagrafica',
'an_tipianagrafiche_anagrafiche.idanagrafica' 'an_tipianagrafiche_anagrafiche.idanagrafica',
]; ];
$joins[] = [ $joins[] = [
'an_tipianagrafiche', 'an_tipianagrafiche',
'an_tipianagrafiche_anagrafiche.idtipoanagrafica', 'an_tipianagrafiche_anagrafiche.idtipoanagrafica',
'an_tipianagrafiche.idtipoanagrafica' 'an_tipianagrafiche.idtipoanagrafica',
]; ];
$where[] = ['an_tipianagrafiche.descrizione', '=', $type]; $where[] = ['an_tipianagrafiche.descrizione', '=', $type];
@ -71,9 +70,8 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface
'select' => $select, 'select' => $select,
'joins' => $joins, 'joins' => $joins,
'where' => $where, 'where' => $where,
'order' => $order 'order' => $order,
]; ];
} }
public function create($request) public function create($request)

@ -29,7 +29,7 @@ class Sedi extends Resource implements RetrieveInterface
$table = 'an_sedi'; $table = 'an_sedi';
return [ return [
'table' => $table 'table' => $table,
]; ];
} }
} }

@ -34,21 +34,21 @@ class Articoli extends Resource implements RetrieveInterface, UpdateInterface, C
$select = [ $select = [
'mg_articoli.*', 'mg_articoli.*',
'categorie.nome AS categoria', 'categorie.nome AS categoria',
'sottocategorie.nome AS sottocategoria' 'sottocategorie.nome AS sottocategoria',
]; ];
$joins[] = [ $joins[] = [
'mg_categorie AS categorie', 'mg_categorie AS categorie',
'mg_articoli.id_categoria', 'mg_articoli.id_categoria',
'categorie.id' 'categorie.id',
]; ];
$joins[] = [ $joins[] = [
'mg_categorie AS sottocategorie', 'mg_categorie AS sottocategorie',
'mg_articoli.id_sottocategoria', 'mg_articoli.id_sottocategoria',
'sottocategorie.id' 'sottocategorie.id',
]; ];
$where[] = ['mg_articoli.deleted_at', '=', NULL ]; $where[] = ['mg_articoli.deleted_at', '=', null];
$whereraw = []; $whereraw = [];
@ -60,7 +60,7 @@ class Articoli extends Resource implements RetrieveInterface, UpdateInterface, C
'joins' => $joins, 'joins' => $joins,
'where' => $where, 'where' => $where,
'whereraw' => $whereraw, 'whereraw' => $whereraw,
'order' => $order 'order' => $order,
]; ];
} }

@ -127,7 +127,6 @@ class Check extends Model
} }
*/ */
/** /**
* Rimuove tutte le check di un determinato modulo/plugin e record. * Rimuove tutte le check di un determinato modulo/plugin e record.
* *
@ -137,7 +136,7 @@ class Check extends Model
{ {
database()->delete('zz_checks', $data); database()->delete('zz_checks', $data);
} }
/* Relazioni Eloquent */ /* Relazioni Eloquent */
public function user() public function user()

@ -187,14 +187,13 @@ class Mail extends Model
$id_templates = []; $id_templates = [];
foreach($templates as $template) { foreach ($templates as $template) {
$id_templates[] = $template->id; $id_templates[] = $template->id;
} }
database()->table('em_emails')->where('id_record', $data['id_record'])->whereIn('id_template', $id_templates)->delete(); database()->table('em_emails')->where('id_record', $data['id_record'])->whereIn('id_template', $id_templates)->delete();
} }
/* Relazioni Eloquent */ /* Relazioni Eloquent */
public function account() public function account()

@ -33,7 +33,7 @@ class Impianti extends Resource implements RetrieveInterface
'my_impianti.idanagrafica', 'my_impianti.idanagrafica',
'my_impianti.matricola', 'my_impianti.matricola',
'my_impianti.nome', 'my_impianti.nome',
'my_impianti.descrizione' 'my_impianti.descrizione',
]; ];
$where = []; $where = [];
@ -50,7 +50,7 @@ class Impianti extends Resource implements RetrieveInterface
'where' => $where, 'where' => $where,
'whereraw' => $whereraw, 'whereraw' => $whereraw,
'order' => $order, 'order' => $order,
'group' => $group 'group' => $group,
]; ];
} }
} }

@ -288,7 +288,6 @@ switch (post('op')) {
// Eliminazione associazione interventi e my_impianti // Eliminazione associazione interventi e my_impianti
$dbo->query('DELETE FROM my_impianti_interventi WHERE idintervento='.prepare($id_record)); $dbo->query('DELETE FROM my_impianti_interventi WHERE idintervento='.prepare($id_record));
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
} }
} }

@ -37,15 +37,15 @@ class Articoli extends Resource implements RetrieveInterface, CreateInterface
'in_righe_interventi.idarticolo AS id_articolo', 'in_righe_interventi.idarticolo AS id_articolo',
'in_righe_interventi.idintervento AS id_intervento', 'in_righe_interventi.idintervento AS id_intervento',
'in_righe_interventi.qta', 'in_righe_interventi.qta',
'in_righe_interventi.created_at as data' 'in_righe_interventi.created_at as data',
]; ];
$where = [['in_righe_interventi.idarticolo', '!=', NULL ], ['in_righe_interventi.idintervento', '=', $request['id_intervento']]]; $where = [['in_righe_interventi.idarticolo', '!=', null], ['in_righe_interventi.idintervento', '=', $request['id_intervento']]];
return [ return [
'table' => $table, 'table' => $table,
'select' => $select, 'select' => $select,
'where' => $where 'where' => $where,
]; ];
} }
@ -66,4 +66,3 @@ class Articoli extends Resource implements RetrieveInterface, CreateInterface
$articolo->save(); $articolo->save();
} }
} }

@ -25,7 +25,6 @@ use Models\Upload;
class Firma extends Resource implements UpdateInterface class Firma extends Resource implements UpdateInterface
{ {
// TODO: Da rivedere con upload in base64 // TODO: Da rivedere con upload in base64
public function update($request) public function update($request)
{ {

@ -31,7 +31,7 @@ class Impianti extends Resource implements RetrieveInterface, CreateInterface
$select = [ $select = [
'idimpianto AS id_impianto', 'idimpianto AS id_impianto',
'idintervento AS id_intervento' 'idintervento AS id_intervento',
]; ];
$where[] = ['my_impianti_interventi.idintervento', '=', $request['id_intervento']]; $where[] = ['my_impianti_interventi.idintervento', '=', $request['id_intervento']];
@ -39,7 +39,7 @@ class Impianti extends Resource implements RetrieveInterface, CreateInterface
return [ return [
'table' => $table, 'table' => $table,
'select' => $select, 'select' => $select,
'where' => $where 'where' => $where,
]; ];
} }

@ -24,7 +24,6 @@ use API\Interfaces\RetrieveInterface;
use API\Interfaces\UpdateInterface; use API\Interfaces\UpdateInterface;
use API\Resource; use API\Resource;
use Auth; use Auth;
use Modules;
use Modules\Anagrafiche\Anagrafica; use Modules\Anagrafiche\Anagrafica;
use Modules\Interventi\Intervento; use Modules\Interventi\Intervento;
use Modules\Interventi\Stato; use Modules\Interventi\Stato;
@ -43,36 +42,36 @@ class Interventi extends Resource implements RetrieveInterface, CreateInterface,
'in_interventi.*', 'in_interventi.*',
'MAX(in_interventi_tecnici.orario_fine) as data', 'MAX(in_interventi_tecnici.orario_fine) as data',
'GROUP_CONCAT(DISTINCT b.ragione_sociale SEPARATOR \', \') AS tecnici', 'GROUP_CONCAT(DISTINCT b.ragione_sociale SEPARATOR \', \') AS tecnici',
'in_statiintervento.descrizione AS stato' 'in_statiintervento.descrizione AS stato',
]; ];
$joins[] = [ $joins[] = [
'in_statiintervento', 'in_statiintervento',
'in_interventi.idstatointervento', 'in_interventi.idstatointervento',
'in_statiintervento.idstatointervento' 'in_statiintervento.idstatointervento',
]; ];
$joins[] = [ $joins[] = [
'an_anagrafiche', 'an_anagrafiche',
'in_interventi.idanagrafica', 'in_interventi.idanagrafica',
'an_anagrafiche.idanagrafica' 'an_anagrafiche.idanagrafica',
]; ];
$joins[] = [ $joins[] = [
'in_interventi_tecnici', 'in_interventi_tecnici',
'in_interventi_tecnici.idintervento', 'in_interventi_tecnici.idintervento',
'in_interventi.id' 'in_interventi.id',
]; ];
$joins[] = [ $joins[] = [
'an_anagrafiche as b', 'an_anagrafiche as b',
'in_interventi_tecnici.idtecnico', 'in_interventi_tecnici.idtecnico',
'b.ragione_sociale' 'b.ragione_sociale',
]; ];
$where = []; $where = [];
if(!$user->is_admin){ if (!$user->is_admin) {
$where[] = ['in_interventi_tecnici.idtecnico', '=', $user->idanagrafica]; $where[] = ['in_interventi_tecnici.idtecnico', '=', $user->idanagrafica];
} }

@ -52,10 +52,10 @@ switch (filter('op')) {
flash()->info(tr('Campagna newsletter salvata!')); flash()->info(tr('Campagna newsletter salvata!'));
if($newsletter->state = "OK") { if ($newsletter->state = 'OK') {
$newsletter->completed_at = $newsletter -> updated_at; $newsletter->completed_at = $newsletter->updated_at;
}; }
$newsletter->save(); $newsletter->save();
break; break;

@ -23,7 +23,7 @@ use Modules\Preventivi\Stato;
$id_module = Modules::get('Preventivi')['id']; $id_module = Modules::get('Preventivi')['id'];
$rs = $dbo->fetchArray("SELECT *, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_preventivi.idanagrafica) AS ragione_sociale FROM co_preventivi WHERE idstato IN (SELECT id FROM co_statipreventivi WHERE is_fatturabile = 1) AND default_revision = 1 ORDER BY data_conclusione ASC"); $rs = $dbo->fetchArray('SELECT *, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_preventivi.idanagrafica) AS ragione_sociale FROM co_preventivi WHERE idstato IN (SELECT id FROM co_statipreventivi WHERE is_fatturabile = 1) AND default_revision = 1 ORDER BY data_conclusione ASC');
if (!empty($rs)) { if (!empty($rs)) {
echo " echo "
@ -39,7 +39,7 @@ if (!empty($rs)) {
$data_accettazione = ($preventivo['data_accettazione'] != '0000-00-00') ? Translator::dateToLocale($preventivo['data_accettazione']) : ''; $data_accettazione = ($preventivo['data_accettazione'] != '0000-00-00') ? Translator::dateToLocale($preventivo['data_accettazione']) : '';
$data_conclusione = ($preventivo['data_conclusione'] != '0000-00-00') ? Translator::dateToLocale($preventivo['data_conclusione']) : ''; $data_conclusione = ($preventivo['data_conclusione'] != '0000-00-00') ? Translator::dateToLocale($preventivo['data_conclusione']) : '';
$stato_preventivo = Stato::find($preventivo['idstato'])->descrizione; $stato_preventivo = Stato::find($preventivo['idstato'])->descrizione;
if (strtotime($preventivo['data_conclusione']) < strtotime(date('Y-m-d')) && $data_conclusione != '') { if (strtotime($preventivo['data_conclusione']) < strtotime(date('Y-m-d')) && $data_conclusione != '') {
$attr = ' class="danger"'; $attr = ' class="danger"';
} else { } else {

@ -91,22 +91,22 @@ class Manager
$value = trim($value, ']'); $value = trim($value, ']');
$values = explode(',', $value); $values = explode(',', $value);
foreach ($values as $value){ foreach ($values as $value) {
// Filtro per LIKE se il valore contiene % // Filtro per LIKE se il valore contiene %
if (string_contains($value, '%')) { if (string_contains($value, '%')) {
$where[] = [ $where[] = [
$key, $key,
'LIKE', 'LIKE',
$value $value,
]; ];
} }
// Filtro preciso se il valore non contiene % // Filtro preciso se il valore non contiene %
else { else {
$where[] = [ $where[] = [
$key, $key,
'=', '=',
$value $value,
]; ];
} }
} }
@ -137,7 +137,7 @@ class Manager
'order' => $order, 'order' => $order,
'page' => $page, 'page' => $page,
'length' => $length, 'length' => $length,
'whereraw' => $whereraw 'whereraw' => $whereraw,
]); ]);
$response = $this->getResponse($data); $response = $this->getResponse($data);
@ -147,10 +147,10 @@ class Manager
$joins = $response['joins']; $joins = $response['joins'];
$group = $response['group']; $group = $response['group'];
if(!empty($response['where'])){ if (!empty($response['where'])) {
$where = array_merge($where, $response['where']); $where = array_merge($where, $response['where']);
} }
if(!empty($response['whereraw'])){ if (!empty($response['whereraw'])) {
$whereraw = $response['whereraw']; $whereraw = $response['whereraw'];
} }
@ -180,7 +180,7 @@ class Manager
foreach ($select as $s) { foreach ($select as $s) {
$query->selectRaw($s); $query->selectRaw($s);
} }
foreach ($joins as $join) { foreach ($joins as $join) {
$query->leftJoin($join[0], $join[1], $join[2]); $query->leftJoin($join[0], $join[1], $join[2]);
} }
@ -197,7 +197,6 @@ class Manager
$query->groupBy($group); $query->groupBy($group);
} }
$count = $query->count(); $count = $query->count();
// Composizione query finale // Composizione query finale

@ -295,7 +295,7 @@ abstract class Document extends Model implements ReferenceInterface, DocumentInt
$id_fields = []; $id_fields = [];
foreach($fields as $field) { foreach ($fields as $field) {
$id_fields[] = $field->id; $id_fields[] = $field->id;
} }
database()->table('zz_field_record')->where('id_record', $this->id)->whereIn('id_field', $id_fields)->delete(); database()->table('zz_field_record')->where('id_record', $this->id)->whereIn('id_field', $id_fields)->delete();

@ -469,7 +469,7 @@ class Database extends Util\Singleton
$select = !empty($select) ? $select : ['*']; $select = !empty($select) ? $select : ['*'];
$statement = Capsule::table($table); $statement = Capsule::table($table);
foreach ($joins as $join) { foreach ($joins as $join) {
$statement = $statement->leftJoin($join[0], $join[1], $join[2]); $statement = $statement->leftJoin($join[0], $join[1], $join[2]);
} }
@ -480,7 +480,6 @@ class Database extends Util\Singleton
$statement->where($conditions); $statement->where($conditions);
foreach ($select as $s) { foreach ($select as $s) {
$statement->selectRaw($s); $statement->selectRaw($s);
} }

@ -70,7 +70,6 @@ class Note extends Model
database()->delete('zz_notes', $data); database()->delete('zz_notes', $data);
} }
/* Relazioni Eloquent */ /* Relazioni Eloquent */
public function user() public function user()

@ -172,7 +172,7 @@ if ($options['pricing']) {
echo " echo "
<th class='text-center' style='width:15%'>".tr('Prezzo unitario', [], ['upper' => true])."</th> <th class='text-center' style='width:15%'>".tr('Prezzo unitario', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true])." (%)</th> <th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true])." (%)</th>
<th class='text-center' style='width:15%'>".($options['hide-total'] ? tr('Importo ivato', [], ['upper' => true]) : tr('Importo', [], ['upper' => true]))."</th>"; <th class='text-center' style='width:15%'>".($options['hide-total'] ? tr('Importo ivato', [], ['upper' => true]) : tr('Importo', [], ['upper' => true])).'</th>';
} }
echo ' echo '
@ -280,8 +280,8 @@ foreach ($righe as $key => $riga) {
'.Translator::numberToLocale($riga->aliquota->percentuale, 2).' '.Translator::numberToLocale($riga->aliquota->percentuale, 2).'
</td>'; </td>';
// Imponibile // Imponibile
echo ' echo '
<td class="text-right" style="vertical-align: middle" > <td class="text-right" style="vertical-align: middle" >
'.(($options['hide-total'] || $prezzi_ivati) ? moneyFormat($riga->totale) : moneyFormat($riga->totale_imponibile)).' '.(($options['hide-total'] || $prezzi_ivati) ? moneyFormat($riga->totale) : moneyFormat($riga->totale_imponibile)).'
</td>'; </td>';