mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 19:40:44 +01:00
Introduzione campi personalizzati su applicazione + fix minori api
This commit is contained in:
parent
61199687d3
commit
a3d1313469
@ -53,7 +53,7 @@ if ($user['gruppo'] == 'Tecnici' && !empty($user['idanagrafica'])) {
|
||||
// Se è indicata un'anagrafica relativa, si carica il tipo di intervento di default impostato
|
||||
if (!empty($id_anagrafica)) {
|
||||
$anagrafica = $dbo->fetchOne('SELECT idtipointervento_default, idzona FROM an_anagrafiche WHERE idanagrafica='.prepare($id_anagrafica));
|
||||
$id_tipo ??= $anagrafica['idtipointervento_default'];
|
||||
$id_tipo = $anagrafica['idtipointervento_default'];
|
||||
$id_zona = $anagrafica['idzona'];
|
||||
}
|
||||
|
||||
@ -128,10 +128,10 @@ if (!empty($impianti_collegati)) {
|
||||
}
|
||||
|
||||
// Impostazione della data se mancante
|
||||
$data ??= filter('data') ?? date('Y-m-d');
|
||||
$data = (!empty(filter('data')) ? filter('data') : date('Y-m-d'));
|
||||
|
||||
// Impostazione della data di fine da Dashboard
|
||||
$data_fine ??= filter('data_fine') ?? $data;
|
||||
$data_fine = (!empty(filter('data')) ? filter('data') : $data);
|
||||
|
||||
$inizio_sessione = $data.' '.$orario_inizio;
|
||||
$fine_sessione = $data_fine.' '.$orario_fine;
|
||||
|
65
src/API/App/v1/CampiPersonalizzati.php
Normal file
65
src/API/App/v1/CampiPersonalizzati.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?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 API\App\v1;
|
||||
|
||||
use API\App\AppResource;
|
||||
use Models\Module;
|
||||
|
||||
class CampiPersonalizzati extends AppResource
|
||||
{
|
||||
public function getCleanupData($last_sync_at)
|
||||
{
|
||||
return $this->getDeleted('zz_fields', 'id', $last_sync_at);
|
||||
}
|
||||
|
||||
public function getModifiedRecords($last_sync_at)
|
||||
{
|
||||
$module = (new Module())->getByName('Interventi');
|
||||
|
||||
$query = 'SELECT `zz_fields`.`id`, `zz_fields`.`updated_at` FROM `zz_fields` WHERE id_module='.prepare($module->id_record);
|
||||
|
||||
// Filtro per data
|
||||
if ($last_sync_at) {
|
||||
$query .= ' AND zz_fields.updated_at > '.prepare($last_sync_at);
|
||||
}
|
||||
|
||||
$records = database()->fetchArray($query);
|
||||
|
||||
return $this->mapModifiedRecords($records);
|
||||
}
|
||||
|
||||
public function retrieveRecord($id)
|
||||
{
|
||||
// Gestione della visualizzazione dei dettagli del record
|
||||
$query = 'SELECT
|
||||
`zz_fields`.`id` AS id,
|
||||
`zz_fields`.`name`,
|
||||
`zz_fields`.`html_name`,
|
||||
`zz_fields`.`order`
|
||||
FROM
|
||||
`zz_fields`
|
||||
WHERE
|
||||
`zz_fields`.`id` = '.prepare($id);
|
||||
|
||||
$record = database()->fetchOne($query);
|
||||
|
||||
return $record;
|
||||
}
|
||||
}
|
75
src/API/App/v1/CampiPersonalizzatiValori.php
Normal file
75
src/API/App/v1/CampiPersonalizzatiValori.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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 API\App\v1;
|
||||
|
||||
use API\App\AppResource;
|
||||
use Models\Module;
|
||||
|
||||
class CampiPersonalizzatiValori extends AppResource
|
||||
{
|
||||
public function getCleanupData($last_sync_at)
|
||||
{
|
||||
return $this->getDeleted('zz_field_record', 'id', $last_sync_at);
|
||||
}
|
||||
|
||||
public function getModifiedRecords($last_sync_at)
|
||||
{
|
||||
|
||||
$module = (new Module())->getByName('Interventi');
|
||||
|
||||
$query = 'SELECT `zz_field_record`.`id`, `zz_field_record`.`updated_at` FROM `zz_field_record` INNER JOIN `zz_fields` ON `zz_field_record`.`id_field` = `zz_fields`.`id` WHERE id_module='.prepare($module->id_record);
|
||||
|
||||
// Filtro per data
|
||||
if ($last_sync_at) {
|
||||
$query .= ' AND zz_field_record.updated_at > '.prepare($last_sync_at);
|
||||
}
|
||||
|
||||
$records = database()->fetchArray($query);
|
||||
|
||||
return $this->mapModifiedRecords($records);
|
||||
}
|
||||
|
||||
public function retrieveRecord($id)
|
||||
{
|
||||
// Gestione della visualizzazione dei dettagli del record
|
||||
$query = 'SELECT
|
||||
`zz_field_record`.`id` AS id,
|
||||
`zz_field_record`.`id_field`,
|
||||
`zz_field_record`.`id_record`,
|
||||
`zz_field_record`.`value`
|
||||
FROM
|
||||
`zz_field_record`
|
||||
WHERE
|
||||
`zz_field_record`.`id` = '.prepare($id);
|
||||
|
||||
$record = database()->fetchOne($query);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
public function updateRecord($data)
|
||||
{
|
||||
$id = $data['id'];
|
||||
|
||||
database()->query("UPDATE `zz_field_record` SET `value` = ".prepare($data['value'])." WHERE `id` = ".prepare($id));
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -31,18 +31,21 @@ class Impianti extends AppResource
|
||||
// TODO: modificare introducendo deleted_at su my_impianti
|
||||
return database()
|
||||
->table('zz_operations')
|
||||
->select('id_record')
|
||||
->select('zz_operations.id_record')
|
||||
->distinct()
|
||||
->join('zz_modules', 'zz_modules.id', '=', 'zz_operations.id_module')
|
||||
->leftJoin('zz_modules_lang', function ($join) use ($last_sync_at) {
|
||||
$join->on('zz_modules.id', '=', 'zz_modules_lang.id_record')
|
||||
->where('zz_modules.id_lang', '=', setting('Lingua'));
|
||||
->where('zz_modules_lang.id_lang', '=', setting('Lingua'));
|
||||
})
|
||||
->where('zz_modules_lang.name', '=', "Impianti")
|
||||
->where('zz_operations.op', '=', "delete")
|
||||
->whereNotNull('zz_operations.options')
|
||||
->where('zz_operations.created_at', '>', $last_sync_at)
|
||||
->pluck('id_record')
|
||||
->toArray();
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getModifiedRecords($last_sync_at)
|
||||
|
@ -24,7 +24,7 @@ use API\Resource;
|
||||
|
||||
class Revisione extends Resource implements RetrieveInterface
|
||||
{
|
||||
public const REVISION = '7';
|
||||
public const REVISION = '8';
|
||||
|
||||
public function retrieve($request)
|
||||
{
|
||||
|
@ -32,19 +32,21 @@ class SessioniInterventi extends AppResource
|
||||
// TODO: modificare introducendo deleted_at su sessioni
|
||||
return database()
|
||||
->table('zz_operations')
|
||||
->select('zz_operations.options')
|
||||
->select('zz_operations.id_record')
|
||||
->distinct()
|
||||
->join('zz_modules', 'zz_modules.id', '=', 'zz_operations.id_module')
|
||||
->leftJoin('zz_modules_lang', function ($join) use ($last_sync_at) {
|
||||
$join->on('zz_modules.id', '=', 'zz_modules_lang.id_record')
|
||||
->where('zz_modules.id_lang', '=', setting('Lingua'));
|
||||
->where('zz_modules_lang.id_lang', '=', setting('Lingua'));
|
||||
})
|
||||
->where('zz_modules_lang.name', '=', 'Interventi')
|
||||
->where('zz_operations.op', '=', 'delete_sessione')
|
||||
->whereNotNull('zz_operations.options')
|
||||
->where('zz_operations.created_at', '>', $last_sync_at)
|
||||
->pluck('zz_operations.options')
|
||||
->pluck('zz_operations.id_record')
|
||||
->toArray();
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getModifiedRecords($last_sync_at)
|
||||
|
@ -47,11 +47,11 @@ class StatiIntervento extends AppResource
|
||||
// Gestione della visualizzazione dei dettagli del record
|
||||
$query = 'SELECT `in_statiintervento`.`id`,
|
||||
`in_statiintervento`.`codice`,
|
||||
`in_statiintervento_lang`.`name`,
|
||||
`in_statiintervento_lang`.`name` AS `descrizione`,
|
||||
`in_statiintervento`.`colore`,
|
||||
`in_statiintervento`.`is_completato`
|
||||
FROM `in_statiintervento`
|
||||
LEFT JOIN `in_statiiintervento_lang` ON (`in_statiintervento`.`id` = `in_statiintervento_lang`.`id_record` AND `in_statiintervento_lang`.`id_lang` = "'.prepare(setting('Lingua')).'")
|
||||
LEFT JOIN `in_statiintervento_lang` ON (`in_statiintervento`.`id` = `in_statiintervento_lang`.`id_record` AND `in_statiintervento_lang`.`id_lang` = '.prepare(setting('Lingua')).')
|
||||
WHERE `in_statiintervento`.`id` = '.prepare($id);
|
||||
|
||||
$record = database()->fetchOne($query);
|
||||
|
@ -47,7 +47,7 @@ class TipiIntervento extends AppResource
|
||||
// Gestione della visualizzazione dei dettagli del record
|
||||
$query = 'SELECT
|
||||
`in_tipiintervento`.`id`,
|
||||
`in_tipiintervento_lang`.`name`,
|
||||
`in_tipiintervento_lang`.`name` AS `descrizione`,
|
||||
`costo_orario` AS prezzo_orario,
|
||||
`costo_km` AS prezzo_chilometrico,
|
||||
`costo_diritto_chiamata` AS prezzo_diritto_chiamata
|
||||
|
@ -1934,4 +1934,14 @@ UPDATE `zz_plugins` SET `options` = '{ \"main_query\": [ { \"type\": \"table\",
|
||||
DROP TABLE IF EXISTS `in_vociservizio`;
|
||||
|
||||
DELETE FROM `zz_modules` WHERE `id` = (SELECT `id_record` FROM `zz_modules_lang` WHERE `name` = 'Voci di servizio');
|
||||
DELETE FROM `zz_modules_lang` WHERE `name` = 'Voci di servizio';
|
||||
DELETE FROM `zz_modules_lang` WHERE `name` = 'Voci di servizio';
|
||||
=======
|
||||
-- Api per campi personalizzati
|
||||
INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES (NULL, 'app-v1', 'retrieve', 'campi_personalizzati', 'API\\App\\v1\\CampiPersonalizzati', '1', NULL, NULL);
|
||||
INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES (NULL, 'app-v1', 'retrieve', 'campi-personalizzati-cleanup', 'API\\App\\v1\\CampiPersonalizzati', '1', NULL, NULL);
|
||||
|
||||
INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES
|
||||
(NULL, 'app-v1', 'retrieve', 'campi-personalizzati-valori', 'API\\App\\v1\\CampiPersonalizzatiValori', 1),
|
||||
(NULL, 'app-v1', 'retrieve', 'campi-personalizzati-valori-cleanup', 'API\\App\\v1\\CampiPersonalizzatiValori', 1),
|
||||
(NULL, 'app-v1', 'update', 'campi-personalizzati-valori', 'API\\App\\v1\\CampiPersonalizzatiValori', 1);
|
||||
>>>>>>> 2d20ed2df (Introduzione campi personalizzati su applicazione + fix minori api)
|
||||
|
Loading…
x
Reference in New Issue
Block a user