Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^10|^11"
"phpunit/phpunit": "^12.4.4"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 3 additions & 2 deletions modules/articoli/src/Articolo.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,15 @@ public function registra($qta, $descrizone = null, $data = null, $manuale = fals
// Movimento il magazzino solo se l'articolo non è un servizio
if (empty($this->servizio)) {
// Registrazione della movimentazione
database()->insert('mg_movimenti', array_merge($array, [
// I valori in $array hanno priorità (es. idutente passato dall'API)
database()->insert('mg_movimenti', array_merge([
'idarticolo' => $this->id,
'qta' => $qta,
'movimento' => $descrizone,
'data' => $data,
'manuale' => $manuale,
'idutente' => $user->id,
]));
], $array));
}
$id = database()->lastInsertedID();

Expand Down
8 changes: 2 additions & 6 deletions modules/interventi/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,7 @@
// Salvataggio firma
$data = explode(',', post('firma_base64'));
$img = getImageManager()->read(base64_decode($data[1]));
$img->resize(680, 202, function ($constraint) {
$constraint->aspectRatio();
});
$img->scaleDown(680, 202);

if (setting('Sistema di firma') == 'Tavoletta Wacom') {
$img->brightness((float) setting('Luminosità firma Wacom'));
Expand Down Expand Up @@ -1068,9 +1066,7 @@
// Salvataggio firma
$data = explode(',', post('firma_base64'));
$img = getImageManager()->read(base64_decode($data[1]));
$img->resize(680, 202, function ($constraint) {
$constraint->aspectRatio();
});
$img->scaleDown(680, 202);
$encoded_image = $img->toJpeg();
$file_content = $encoded_image->toString();

Expand Down
9 changes: 1 addition & 8 deletions src/API/App/v1/Interventi.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,7 @@ protected function salvaFirma($firma_base64, $id_intervento)
{
$data = explode(',', (string) $firma_base64);
$img = getImageManager()->read(base64_decode($data[1]));
$img->resize(680, 202, function ($constraint) {
$constraint->aspectRatio();
});

if (setting('Sistema di firma') == 'Tavoletta Wacom') {
$img->brightness((float) setting('Luminosità firma Wacom'));
$img->contrast((float) setting('Contrasto firma Wacom'));
}
$img->scaleDown(680, 202);
$encoded_image = $img->toJpeg();
$file_content = $encoded_image->toString();

Expand Down
66 changes: 62 additions & 4 deletions src/API/App/v1/MovimentiManuali.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,86 @@ class MovimentiManuali extends AppResource
{
public function getCleanupData($last_sync_at)
{
return [];
// Recupera l'ID utente loggato
$user = auth_osm()->getUser();
$id_utente = $user->id;

// Restituisce i movimenti eliminati o non più appartenenti all'utente
$query = 'SELECT `mg_movimenti`.`id`
FROM `mg_movimenti`
WHERE `mg_movimenti`.`idutente` = '.prepare($id_utente);

if ($last_sync_at) {
$query .= ' AND `mg_movimenti`.`updated_at` > '.prepare($last_sync_at);
}

$records = database()->fetchArray($query);
$ids = array_column($records, 'id');

return $this->getMissingIDs('mg_movimenti', 'id', $last_sync_at, $ids);
}

public function getModifiedRecords($last_sync_at)
{
return [];
// Recupera l'ID utente loggato
$user = auth_osm()->getUser();
$id_utente = $user->id;

// Calcola le date dell'ultimo giorno (00:00 - 23:59)
$oggi = Carbon::now();
$inizio_giorno = $oggi->copy()->startOfDay()->format('Y-m-d H:i:s');
$fine_giorno = $oggi->copy()->endOfDay()->format('Y-m-d H:i:s');

// Query per recuperare i movimenti dell'utente loggato nell'ultimo giorno
$query = 'SELECT `mg_movimenti`.`id`, `mg_movimenti`.`updated_at`
FROM `mg_movimenti`
WHERE `mg_movimenti`.`idutente` = '.prepare($id_utente).'
AND `mg_movimenti`.`data` BETWEEN '.prepare($inizio_giorno).' AND '.prepare($fine_giorno);

$records = database()->fetchArray($query);

return $this->mapModifiedRecords($records);
}

public function retrieveRecord($id)
{
return [];
// Recupera l'ID utente loggato per sicurezza
$user = auth_osm()->getUser();
$id_utente = $user->id;

// Query per recuperare il dettaglio del movimento
$query = 'SELECT
`mg_movimenti`.`id`,
`mg_movimenti`.`idarticolo` AS id_articolo,
`mg_movimenti`.`qta`,
`mg_movimenti`.`movimento` AS descrizione,
`mg_movimenti`.`data`,
`mg_movimenti`.`idsede` AS id_sede_azienda,
`mg_movimenti`.`idutente` AS id_utente,
`mg_movimenti`.`manuale`
FROM
`mg_movimenti`
LEFT JOIN `mg_articoli` ON `mg_movimenti`.`idarticolo` = `mg_articoli`.`id`
LEFT JOIN `mg_articoli_lang` ON (`mg_articoli`.`id` = `mg_articoli_lang`.`id_record` AND `mg_articoli_lang`.`id_lang` = '.prepare(\Models\Locale::getDefault()->id).')
WHERE
`mg_movimenti`.`id` = '.prepare($id).'
AND `mg_movimenti`.`idutente` = '.prepare($id_utente);

$record = database()->fetchOne($query);

return $record;
}

public function createRecord($data)
{
$articolo = Articolo::find($data['id_articolo']);
$data_movimento = new Carbon($data['created_at']);
$data_movimento = new Carbon($data['data']);

$id_sede = isset($data['id_sede_azienda']) && $data['id_sede_azienda'] !== null ? $data['id_sede_azienda'] : 0;

$id_movimento = $articolo->movimenta($data['qta'], $data['descrizione'], $data_movimento, true, [
'idsede' => $id_sede,
'idutente' => auth_osm()->getUser()->id,
]);

return [
Expand Down
4 changes: 1 addition & 3 deletions src/Models/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,7 @@ protected static function generateThumbnails($upload)

$img = getImageManager()->read($filepath);

$img->resize(600, null, function ($constraint) {
$constraint->aspectRatio();
});
$img->scaleDown(600, null);
$img->save(slashes($directory.'/'.$info['filename'].'_thumb600.'.$info['extension']));

$img->scale(250, null);
Expand Down
4 changes: 1 addition & 3 deletions src/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ public function setPhotoAttribute($value)
$file = base_dir().'/files/temp_photo.'.$info['extension'];

// Ridimensionamento
$img = getImageManager()->read($filepath)->resize(100, 100, function ($constraint) {
$constraint->aspectRatio();
});
$img = getImageManager()->read($filepath)->scaleDown(100, 100);
$img->save(slashes($file));

// Aggiunta nuova foto
Expand Down
5 changes: 4 additions & 1 deletion update/2_10.sql
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,7 @@ ALTER TABLE `zz_modules` DROP COLUMN `use_notes`;
ALTER TABLE `zz_modules` DROP COLUMN `use_checklists`;

-- Aggiunta colonna session_token per gestione sessione singola
ALTER TABLE `zz_users` ADD `session_token` VARCHAR(64) NULL DEFAULT NULL AFTER `password`;
ALTER TABLE `zz_users` ADD `session_token` VARCHAR(64) NULL DEFAULT NULL AFTER `password`;

-- Aggiunta risorsa API per la gestione dei movimenti manuali
INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`, `created_at`, `updated_at`) VALUES (NULL, 'app-v1', 'retrieve', 'movimento-manuale', 'API\\App\\v1\\MovimentiManuali', '1', NULL, NULL)
Loading