Skip to content

Commit 15862bd

Browse files
committed
feat: gestione seriali articoli su app
1 parent da2d7e4 commit 15862bd

4 files changed

Lines changed: 79 additions & 2 deletions

File tree

src/API/App/v1/Articoli.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public function retrieveRecord($id)
5757
`mg_articoli`.`um`,
5858
`mg_articoli`.`idiva_vendita` AS id_iva,
5959
`categoria_lang`.`title` AS categoria,
60-
`sottocategoria_lang`.`title` AS sottocategoria
60+
`sottocategoria_lang`.`title` AS sottocategoria,
61+
`mg_articoli`.`abilita_serial`
6162
FROM
6263
`mg_articoli`
6364
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).')

src/API/App/v1/RigheInterventi.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public function retrieveRecord($id)
135135
'totale_imponibile' => $riga->totale_imponibile,
136136
'iva' => $riga->iva,
137137
'totale' => $riga->totale,
138+
'serials' => implode(',', $riga->serials),
138139
];
139140

140141
return $record;
@@ -239,5 +240,9 @@ protected function aggiornaRecord($record, $data)
239240
if (!empty($sconto)) {
240241
$record->setSconto($sconto, $data['tipo_sconto']);
241242
}
243+
244+
if($data['is_articolo']){
245+
$record->serials = explode(',', $data['serials']);
246+
}
242247
}
243248
}

src/API/App/v1/Seriali.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
/*
4+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
5+
* Copyright (C) DevCode s.r.l.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace API\App\v1;
22+
23+
use API\App\AppResource;
24+
25+
class Seriali extends AppResource
26+
{
27+
public function getCleanupData($last_sync_at)
28+
{
29+
return $this->getMissingIDs('mg_prodotti', 'id', $last_sync_at);
30+
}
31+
32+
public function getModifiedRecords($last_sync_at)
33+
{
34+
$query = 'SELECT `mg_prodotti`.`id`, `mg_prodotti`.`updated_at` FROM `mg_prodotti`';
35+
36+
// Filtro per data
37+
if ($last_sync_at) {
38+
$query .= ' WHERE mg_prodotti.updated_at > '.prepare($last_sync_at);
39+
}
40+
41+
$records = database()->fetchArray($query);
42+
43+
return $this->mapModifiedRecords($records);
44+
}
45+
46+
public function retrieveRecord($id)
47+
{
48+
// Gestione della visualizzazione dei dettagli del record
49+
$query = 'SELECT
50+
`mg_prodotti`.`id` AS id,
51+
`mg_prodotti`.`id_articolo`,
52+
`mg_prodotti`.`serial`,
53+
`mg_prodotti`.`id_riga_intervento`,
54+
`mg_prodotti`.`dir`
55+
FROM
56+
`mg_prodotti`
57+
58+
WHERE
59+
`mg_prodotti`.`id` = '.prepare($id);
60+
61+
$record = database()->fetchOne($query);
62+
63+
return $record;
64+
}
65+
}

update/2_8.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,10 @@ INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES
474474
CREATE TABLE `zz_files_categories` (`id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR(255) NOT NULL , `deleted_at` TIMESTAMP NULL , PRIMARY KEY (`id`));
475475
ALTER TABLE `zz_files` ADD `id_category` INT NULL AFTER `category`;
476476

477-
CREATE TABLE `em_files_categories_template` (`id` INT NOT NULL AUTO_INCREMENT , `id_category` INT NOT NULL , `id_template` INT NOT NULL , PRIMARY KEY (`id`))
477+
CREATE TABLE `em_files_categories_template` (`id` INT NOT NULL AUTO_INCREMENT , `id_category` INT NOT NULL , `id_template` INT NOT NULL , PRIMARY KEY (`id`));
478+
479+
-- Api seriali
480+
INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES
481+
(NULL, 'app-v1', 'retrieve', 'seriali-cleanup', 'API\\App\\v1\\Seriali', 1),
482+
(NULL, 'app-v1', 'retrieve', 'seriali', 'API\\App\\v1\\Seriali', 1),
483+
(NULL, 'app-v1', 'retrieve', 'seriale', 'API\\App\\v1\\Seriali', 1);

0 commit comments

Comments
 (0)