2020-08-25 17:38:10 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2020-08-25 17:38:10 +02:00
|
|
|
|
2021-07-27 18:11:54 +02:00
|
|
|
namespace Plugins\ListinoFornitori;
|
2020-08-25 17:38:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Formato: https://www.metel.it/wp-content/uploads/2020/04/536_L001_1r18_listino_021.pdf.
|
|
|
|
*
|
|
|
|
* @since 2.4.18
|
|
|
|
*/
|
|
|
|
class METEL
|
|
|
|
{
|
2021-07-27 18:11:54 +02:00
|
|
|
const HEADER = [
|
2020-08-25 17:38:10 +02:00
|
|
|
1 => 'Identificazione tracciato',
|
|
|
|
21 => 'Sigla Azienda',
|
|
|
|
24 => 'Partita IVA',
|
|
|
|
35 => 'Numero listino prezzi',
|
|
|
|
41 => 'Decorrenza listino prezzi',
|
|
|
|
49 => 'Data ultima variazione/immissione',
|
|
|
|
57 => 'Descrizione listino prezzi',
|
|
|
|
87 => 'Filler (spazi)',
|
|
|
|
126 => 'Versione tracciato listino prezzi',
|
|
|
|
129 => 'Data decorrenza listino grossista',
|
|
|
|
137 => 'Isopartita',
|
|
|
|
153 => 'Filler (spazi)',
|
|
|
|
];
|
|
|
|
|
2021-07-07 07:57:10 +02:00
|
|
|
public const ROW = [
|
2020-08-25 17:38:10 +02:00
|
|
|
1 => 'Sigla Marchio',
|
|
|
|
4 => 'Codice Prodotto Azienda',
|
|
|
|
20 => 'Codice EAN',
|
|
|
|
33 => 'Descrizione prodotto',
|
|
|
|
76 => 'Quantità cartone',
|
|
|
|
81 => 'Quantità multipla ordinazione',
|
|
|
|
86 => 'Quantità minima ordinazione',
|
|
|
|
91 => 'Quantità massima ordinazione',
|
|
|
|
97 => 'Lead Time',
|
|
|
|
98 => 'Prezzo al rivenditore',
|
|
|
|
109 => 'Prezzo al Pubblico',
|
|
|
|
120 => 'Moltiplicatore prezzo',
|
|
|
|
126 => 'Codice Valuta',
|
|
|
|
129 => 'Unità di misura',
|
|
|
|
132 => 'Prodotto Composto',
|
|
|
|
133 => 'Stato del prodotto',
|
|
|
|
134 => 'Data ultima variazione',
|
|
|
|
142 => 'Famiglia di sconto',
|
|
|
|
160 => 'Famiglia statistica',
|
|
|
|
178 => 'Codice Electrocod',
|
|
|
|
188 => 'Codice Etim',
|
|
|
|
198 => 'Codice Barcode',
|
|
|
|
233 => 'Qualificatore Codice Barcode',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function parse($string, $fields)
|
|
|
|
{
|
|
|
|
$fields_number = count($fields);
|
|
|
|
$keys = array_keys($fields);
|
|
|
|
|
|
|
|
$results = [];
|
|
|
|
for ($i = 0; $i < $fields_number; ++$i) {
|
|
|
|
$key = $keys[$i];
|
|
|
|
$start = $key - 1;
|
|
|
|
|
|
|
|
if ($fields_number - 1 == $i) {
|
|
|
|
$end = strlen($string);
|
|
|
|
} else {
|
|
|
|
$end = $keys[$i + 1] - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$length = $end - $start;
|
|
|
|
|
|
|
|
$piece = substr($string, $start, $length);
|
|
|
|
$results[$fields[$key]] = trim($piece);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function parseHeader($content)
|
|
|
|
{
|
|
|
|
return $this->parse($content, static::HEADER);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function parseRow($content)
|
|
|
|
{
|
|
|
|
return $this->parse($content, static::ROW);
|
|
|
|
}
|
|
|
|
}
|