Miglioramenti minori

This commit is contained in:
Thomas Zilio 2019-07-19 16:51:52 +02:00
parent 7b589c530c
commit 7b03a2f3e5
20 changed files with 75 additions and 24 deletions

View File

@ -281,3 +281,18 @@ $list = array_merge($files, $custom_files);
foreach ($list as $file) {
include_once $file;
}
// Inclusione dei file vendor/autoload.php di Composer
$files = glob(__DIR__.'/{modules,plugins}/*/vendor/autoload.php', GLOB_BRACE);
$custom_files = glob(__DIR__.'/{modules,plugins}/*/custom/vendor/autoload.php', GLOB_BRACE);
foreach ($custom_files as $key => $value) {
$index = array_search(str_replace('custom/', '', $value), $files);
if ($index !== false) {
unset($files[$index]);
}
}
$list = array_merge($files, $custom_files);
foreach ($list as $file) {
include_once $file;
}

View File

@ -6,10 +6,11 @@ use API\Interfaces\CreateInterface;
use API\Interfaces\DeleteInterface;
use API\Interfaces\RetrieveInterface;
use API\Interfaces\UpdateInterface;
use API\Resource;
use Modules;
use Modules\Anagrafiche\Anagrafica;
class Anagrafiche implements RetrieveInterface, CreateInterface, UpdateInterface, DeleteInterface
class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface, UpdateInterface, DeleteInterface
{
public function retrieve($request)
{

View File

@ -3,8 +3,9 @@
namespace Modules\Articoli\API\v1;
use API\Interfaces\RetrieveInterface;
use API\Resource;
class Articoli implements RetrieveInterface
class Articoli extends Resource implements RetrieveInterface
{
public function retrieve($request)
{

View File

@ -3,9 +3,10 @@
namespace Modules\Articoli\API\v1;
use API\Interfaces\CreateInterface;
use API\Resource;
use Modules\Articoli\Articolo;
class Movimenti implements CreateInterface
class Movimenti extends Resource implements CreateInterface
{
public function create($request)
{

View File

@ -4,11 +4,12 @@ namespace Modules\Interventi\API\v1;
use API\Interfaces\CreateInterface;
use API\Interfaces\RetrieveInterface;
use API\Resource;
use Modules\Articoli\Articolo as ArticoloOriginale;
use Modules\Interventi\Components\Articolo;
use Modules\Interventi\Intervento;
class Articoli implements RetrieveInterface, CreateInterface
class Articoli extends Resource implements RetrieveInterface, CreateInterface
{
public function retrieve($request)
{

View File

@ -3,8 +3,9 @@
namespace Modules\Interventi\API\v1;
use API\Interfaces\UpdateInterface;
use API\Resource;
class Firma implements UpdateInterface
class Firma extends Resource implements UpdateInterface
{
public function update($request)
{

View File

@ -5,12 +5,13 @@ namespace Modules\Interventi\API\v1;
use API\Interfaces\CreateInterface;
use API\Interfaces\RetrieveInterface;
use API\Interfaces\UpdateInterface;
use API\Resource;
use Modules\Anagrafiche\Anagrafica;
use Modules\Interventi\Intervento;
use Modules\Interventi\Stato;
use Modules\TipiIntervento\Tipo as TipoSessione;
class Interventi implements RetrieveInterface, CreateInterface, UpdateInterface
class Interventi extends Resource implements RetrieveInterface, CreateInterface, UpdateInterface
{
public function retrieve($request)
{

View File

@ -5,12 +5,13 @@ namespace Modules\Interventi\API\v1;
use API\Interfaces\CreateInterface;
use API\Interfaces\DeleteInterface;
use API\Interfaces\RetrieveInterface;
use API\Resource;
class Sessioni implements RetrieveInterface, CreateInterface, DeleteInterface
class Sessioni extends Resource implements RetrieveInterface, CreateInterface, DeleteInterface
{
public function retrieve($request)
{
$user = auth()->getUser();
$user = $this->getUser();
$query = 'SELECT id, idtecnico AS id_tecnico, idintervento AS id_intervento, orario_inizio, orario_fine FROM in_interventi_tecnici WHERE `idintervento` = :id_intervento';
@ -31,7 +32,7 @@ class Sessioni implements RetrieveInterface, CreateInterface, DeleteInterface
public function create($request)
{
$user = auth()->getUser();
$user = $this->getUser();
$data = $request['data'];
add_tecnico($data['id_intervento'], $user['idanagrafica'], $data['orario_inizio'], $data['orario_fine']);
@ -40,7 +41,7 @@ class Sessioni implements RetrieveInterface, CreateInterface, DeleteInterface
public function delete($request)
{
$database = database();
$user = auth()->getUser();
$user = $this->getUser();
$database->query('DELETE FROM `in_interventi_tecnici` WHERE `idintervento` = :id_intervento AND `idtecnico` = :id_tecnico', [
':id_intervento' => $request['id_intervento'],

View File

@ -4,17 +4,18 @@ namespace Modules\Interventi\API\v1;
use API\Interfaces\RetrieveInterface;
use API\Interfaces\UpdateInterface;
use API\Resource;
use Carbon\Carbon;
use DateTime;
use iCalEasyReader;
use Update;
class Sync implements RetrieveInterface, UpdateInterface
class Sync extends Resource implements RetrieveInterface, UpdateInterface
{
public function retrieve($request)
{
$database = database();
$user = auth()->getUser();
$user = $this->getUser();
// Normalizzazione degli interventi a database
$database->query('UPDATE in_interventi_tecnici SET summary = (SELECT ragione_sociale FROM an_anagrafiche INNER JOIN in_interventi ON an_anagrafiche.idanagrafica=in_interventi.idanagrafica WHERE in_interventi.id=in_interventi_tecnici.idintervento) WHERE summary IS NULL');
@ -63,7 +64,7 @@ class Sync implements RetrieveInterface, UpdateInterface
public function update($request)
{
$database = database();
$user = auth()->getUser();
$user = $this->getUser();
// Normalizzazione degli interventi a database
$database->query('UPDATE in_interventi_tecnici SET summary = (SELECT ragione_sociale FROM an_anagrafiche INNER JOIN in_interventi ON an_anagrafiche.idanagrafica=in_interventi.idanagrafica WHERE in_interventi.id=in_interventi_tecnici.idintervento) WHERE summary IS NULL');

View File

@ -3,8 +3,9 @@
namespace Modules\StatiContratto\API\v1;
use API\Interfaces\RetrieveInterface;
use API\Resource;
class StatiContratti implements RetrieveInterface
class StatiContratti extends Resource implements RetrieveInterface
{
public function retrieve($request)
{

View File

@ -3,8 +3,9 @@
namespace Modules\StatiIntervento\API\v1;
use API\Interfaces\RetrieveInterface;
use API\Resource;
class StatiInterventi implements RetrieveInterface
class StatiInterventi extends Resource implements RetrieveInterface
{
public function retrieve($request)
{

View File

@ -3,8 +3,9 @@
namespace Modules\StatiPreventivo\API\v1;
use API\Interfaces\RetrieveInterface;
use API\Resource;
class StatiPreventivi implements RetrieveInterface
class StatiPreventivi extends Resource implements RetrieveInterface
{
public function retrieve($request)
{

View File

@ -3,10 +3,11 @@
namespace Modules\StatoServizi\API\v1;
use API\Interfaces\RetrieveInterface;
use API\Resource;
use App;
use Util\FileSystem;
class FolderSize implements RetrieveInterface
class FolderSize extends Resource implements RetrieveInterface
{
public function retrieve($request)
{

View File

@ -3,8 +3,9 @@
namespace Modules\TipiIntervento\API\v1;
use API\Interfaces\RetrieveInterface;
use API\Resource;
class TipiInterventi implements RetrieveInterface
class TipiInterventi extends Resource implements RetrieveInterface
{
public function retrieve($request)
{

View File

@ -3,10 +3,11 @@
namespace Modules\Utenti\API\v1;
use API\Interfaces\CreateInterface;
use API\Resource;
use Auth;
use Update;
class Login implements CreateInterface
class Login extends Resource implements CreateInterface
{
public function create($request)
{
@ -14,7 +15,7 @@ class Login implements CreateInterface
// Controllo sulle credenziali
if (auth()->attempt($request['username'], $request['password'])) {
$user = auth()->getUser();
$user = $this->getUser();
$token = auth()->getToken();
// Informazioni da restituire tramite l'API

View File

@ -3,13 +3,14 @@
namespace Modules\Utenti\API\v1;
use API\Interfaces\CreateInterface;
use API\Resource;
class Logout implements CreateInterface
class Logout extends Resource implements CreateInterface
{
public function create($request)
{
$database = database();
$user = auth()->getUser();
$user = $this->getUser();
if (!empty($request['token']) && !empty($user)) {
// Cancellazione della chiave

View File

@ -3,10 +3,11 @@
namespace Api\Common;
use API\Interfaces\CreateInterface;
use API\Resource;
use Modules;
use Uploads;
class Allegato implements CreateInterface
class Allegato extends Resource implements CreateInterface
{
public function create($request)
{

View File

@ -186,7 +186,9 @@ class Manager
$object = new $class();
$method = $this->type;
$object->open($request);
$response = $object->{$method}($request);
$object->close($request, $response);
return $response;
}

19
src/API/Resource.php Normal file
View File

@ -0,0 +1,19 @@
<?php
namespace API;
class Resource
{
public function open($request)
{
}
public function close($request, $response)
{
}
public function getUser()
{
return auth()->getUser();
}
}

View File

@ -111,4 +111,3 @@ INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `e
(NULL, 'v1', 'update', 'sessione_intervento', 'Modules\\Interventi\\API\\v1\\Sessioni', '1'),
(NULL, 'v1', 'retrieve', 'articoli_intervento', 'Modules\\Interventi\\API\\v1\\Articoli', '1'),
(NULL, 'v1', 'create', 'articolo_intervento', 'Modules\\Interventi\\API\\v1\\Articoli', '1');