diff --git a/include/bottom.php b/include/bottom.php index ac9575111..3f5f6c59c 100644 --- a/include/bottom.php +++ b/include/bottom.php @@ -80,11 +80,11 @@ if (Auth::check()) { }); '; -} -echo ' + echo ' '; +} echo ' diff --git a/modules/anagrafiche/src/API/v1/Anagrafiche.php b/modules/anagrafiche/src/API/v1/Anagrafiche.php index 3b448cf1d..dc2459f8f 100644 --- a/modules/anagrafiche/src/API/v1/Anagrafiche.php +++ b/modules/anagrafiche/src/API/v1/Anagrafiche.php @@ -40,12 +40,10 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface WHERE 1=1 AND an_anagrafiche.deleted_at IS NULL'; - $types = $request['filter']['type']; - $types = explode(',', $types); - $types = array_clean($types); - $filters = []; - foreach ($types as $type) { + if ($request['resource'] != 'anagrafiche'){ + $type = 'Cliente'; + $filters[] = 'an_anagrafiche.idanagrafica IN (SELECT idanagrafica FROM an_tipianagrafiche_anagrafiche WHERE idtipoanagrafica = (SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione = '.prepare($type).'))'; } $query .= !empty($filters) ? ' AND ('.implode('OR ', $filters).')' : ''; diff --git a/modules/anagrafiche/src/API/v1/Sedi.php b/modules/anagrafiche/src/API/v1/Sedi.php new file mode 100644 index 000000000..11d4daeaf --- /dev/null +++ b/modules/anagrafiche/src/API/v1/Sedi.php @@ -0,0 +1,21 @@ + 'an_sedi', + ]; + } +} diff --git a/modules/stati_intervento/src/API/v1/StatiInterventi.php b/modules/stati_intervento/src/API/v1/StatiInterventi.php index f335e3f18..338f2fdbb 100644 --- a/modules/stati_intervento/src/API/v1/StatiInterventi.php +++ b/modules/stati_intervento/src/API/v1/StatiInterventi.php @@ -11,10 +11,13 @@ class StatiInterventi extends Resource implements RetrieveInterface { $table = 'in_statiintervento'; - $select = [ - '*', - 'id' => 'idstatointervento', - ]; + $select = $request['select']; + if (empty($select)) { + $select = [ + '*', + 'id' => 'idstatointervento', + ]; + } $where = $request['where']; if (empty($where['deleted_at'])) { diff --git a/modules/tipi_intervento/src/API/v1/TipiInterventi.php b/modules/tipi_intervento/src/API/v1/TipiInterventi.php index 59edf2805..7e254e41d 100644 --- a/modules/tipi_intervento/src/API/v1/TipiInterventi.php +++ b/modules/tipi_intervento/src/API/v1/TipiInterventi.php @@ -11,10 +11,13 @@ class TipiInterventi extends Resource implements RetrieveInterface { $table = 'in_tipiintervento'; - $select = [ - '*', - 'id' => 'idtipointervento', - ]; + $select = $request['select']; + if (empty($select)) { + $select = [ + '*', + 'id' => 'idtipointervento', + ]; + } return [ 'select' => $select, diff --git a/src/API/Manager.php b/src/API/Manager.php index b6982a993..729777981 100644 --- a/src/API/Manager.php +++ b/src/API/Manager.php @@ -55,12 +55,11 @@ class Manager { $user = Auth::user(); - $select = '*'; $where = []; $order = []; // Selezione personalizzata - $select = !empty($request['display']) ? explode(',', substr($request['display'], 1, -1)) : $select; + $select = !empty($request['display']) ? explode(',', substr($request['display'], 1, -1)) : null; // Ricerca personalizzata $values = isset($request['filter']) ? (array) $request['filter'] : []; @@ -94,7 +93,11 @@ class Manager $response = $this->getResponse($data); $parameters = $response['parameters']; + $table = $response['table']; + $select = $response['select'] ?: $select; + $select = $select ?: '*'; + $query = $response['query']; try { diff --git a/update/2_4_11.sql b/update/2_4_11.sql index 7c1abef9d..f950ffab1 100644 --- a/update/2_4_11.sql +++ b/update/2_4_11.sql @@ -122,10 +122,12 @@ DELETE FROM `zz_settings` WHERE `nome` = 'Tabelle escluse per la sincronizzazion INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES (NULL, 'v1', 'create', 'allegato', 'Api\\Common\\Allegato', '1'), +(NULL, 'v1', 'retrieve', 'clienti', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), (NULL, 'v1', 'retrieve', 'anagrafiche', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), (NULL, 'v1', 'create', 'anagrafica', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), (NULL, 'v1', 'update', 'anagrafica', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), (NULL, 'v1', 'delete', 'anagrafica', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), +(NULL, 'v1', 'retrieve', 'sedi', 'Modules\\Anagrafiche\\API\\v1\\Sedi', '1'), (NULL, 'v1', 'create', 'movimento_articolo', 'Modules\\Articoli\\API\\v1\\Movimenti', '1'), (NULL, 'v1', 'retrieve', 'articoli', 'Modules\\Articoli\\API\\v1\\Articoli', '1'), (NULL, 'v1', 'create', 'login', 'Modules\\Utenti\\API\\v1\\Login', '1'),