|
|
@@ -24,115 +24,66 @@ class Pages extends \OpenMind\Web\Controller
|
|
|
|
|
|
public function Pick2Light(object $f3, array $args)
|
|
|
{
|
|
|
- $stepValues = [];
|
|
|
- if ($args['step'] == 1) {
|
|
|
- $f3->clear('COOKIE.p2l');
|
|
|
- $f3->clear('COOKIE.consegna');
|
|
|
- $f3->clear('COOKIE.labelid');
|
|
|
- } else {
|
|
|
- $stepValues = array_map('strtoupper', $this->getSanitizedPostRequest());
|
|
|
- if (count($stepValues) == 0)
|
|
|
- $stepValues = json_decode($f3->get('COOKIE.p2l'), true);
|
|
|
- }
|
|
|
+ $stepValues = array_map('strtoupper', $this->getSanitizedPostRequest());
|
|
|
|
|
|
$distinta = new Distinta();
|
|
|
|
|
|
switch ($args['step']) {
|
|
|
- case 3:
|
|
|
- $distinta->CleanDistintaTable();
|
|
|
- $distinta->CopyDistinta($stepValues['consegna']);
|
|
|
-
|
|
|
- $label = new SmartESL($this->findBoxCore, [$stepValues['labelid']]);
|
|
|
- $label->BlinkSpecial(0, 1, 1000, 8, 0);
|
|
|
+ case 1:
|
|
|
+ if (count($stepValues) == 0) {
|
|
|
+ $f3->clear('INFOTEXT');
|
|
|
+ $f3->clear('SESSION.barcode_mv');
|
|
|
+ $f3->set('NEXTSTEP', 1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- $distinta->SaveProductsToFindBox('3', true, 50); // prende soltanto i primi 3 dalla tabella copia delle distinte
|
|
|
+ $commesse = $distinta->getCommesseFromProduct($stepValues['barcode_mv']);
|
|
|
+ if (count($commesse) == 0) {
|
|
|
+ $f3->set('INFOTEXT', "Nessuna commessa associata al prodotto selezionato");
|
|
|
+ $f3->set('NEXTSTEP', 1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $distinta->SendToIcamStorage($commesse);
|
|
|
|
|
|
- $f3->set('COOKIE.p2l', json_encode($stepValues));
|
|
|
- $f3->set('COOKIE.consegna', $stepValues['consegna']);
|
|
|
- $f3->set('COOKIE.labelid', $stepValues['labelid']);
|
|
|
- $f3->reroute("/pick2light/4");
|
|
|
+ $f3->set('SESSION.barcode_mv', $stepValues['barcode_mv']);
|
|
|
+ $f3->reroute("/pick2light/2");
|
|
|
return;
|
|
|
break;
|
|
|
- case 4:
|
|
|
- $distinta->SaveProductsToFindBox('3, 2000', false); // LIMIT 3,1000 perchè i primi 3 sono stati fatti nel case 3
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- $datiCommessa['consegna'] = $f3->get('COOKIE.consegna');
|
|
|
- $datiCommessa['labelid'] = $f3->get('COOKIE.labelid');
|
|
|
- $pickedBarcode = $f3->get('POST.pickedlabelid');
|
|
|
- // Decrease quantity and blink label
|
|
|
- if ($pickedBarcode != null) {
|
|
|
- // ANOMALIA
|
|
|
- if ($pickedBarcode == $f3->get('BARCODE_COMMANDS.ANOMALIACODE')) {
|
|
|
- // <Se è stato ancora passato un codice anomalia, cancella l'operazione di anomalia in corso
|
|
|
- if (isset($stepValues['anomalia']))
|
|
|
- unset($stepValues['anomalia']);
|
|
|
- else
|
|
|
- $f3->set('ANOMALIA', 'In attesa del codice anomalia');
|
|
|
- //>
|
|
|
- } else if ($stepValues['anomalia']) {
|
|
|
- if ($distinta->MarkBarcodeAsAnomalia($pickedBarcode))
|
|
|
- unset($stepValues['anomalia']);
|
|
|
- else
|
|
|
- $f3->set('ANOMALIA', 'Codice non trovato!');
|
|
|
- } else { // E' stato passato un codice
|
|
|
- $codeFromLabelId = $distinta->GetBarcodeFromLabelId($pickedBarcode);
|
|
|
- $pickedBarcode = $codeFromLabelId ?? $pickedBarcode;
|
|
|
- if ($distinta->RemoveQuantity($pickedBarcode)) {
|
|
|
- // SPEGNE LED ETICHETTA DOPO PICKING
|
|
|
- $label = new SmartESL($this->findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
|
|
|
- $label->BlinkOff();
|
|
|
- } else {
|
|
|
- $f3->set('INFOTEXT', 'Barcode non riconosciuto o non associato ad alcuna etichetta elettronica');
|
|
|
- file_put_contents('not_found.log', $pickedBarcode . "\r\n", FILE_APPEND);
|
|
|
- }
|
|
|
+ case 2:
|
|
|
+ $f3->set('NEXTSTEP', 2);
|
|
|
+ if (isset($stepValues['commessa'])) {
|
|
|
+ $ok = $distinta->isCommessaPresent($stepValues['commessa']);
|
|
|
+ if (!$ok) {
|
|
|
+ $f3->set('INFOTEXT', "Codice cesta non corretto");
|
|
|
+ } else {
|
|
|
+ $distinta->DeleteCommessa($stepValues['commessa']);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- $rowsDistinta = $distinta->getDistinta();
|
|
|
- $f3->set('PRODUCTS', $rowsDistinta);
|
|
|
- // End Picking List
|
|
|
- if (count($rowsDistinta) == 0) {
|
|
|
- //$distinta->ResetDistintaLabels($datiCommessa['consegna'], $datiCommessa['labelid']);
|
|
|
- $anomalie = $distinta->getAnomalieFromConsegne($datiCommessa['consegna']);
|
|
|
- $f3->set('LISTANOMALIE', $anomalie);
|
|
|
-
|
|
|
- //$label = new SmartESL($this->findBoxCore, [$datiCommessa['labelid']]);
|
|
|
- $distinta->SaveLabelCarrello($datiCommessa['labelid'], $datiCommessa['labelid'], $datiCommessa['consegna']);
|
|
|
-
|
|
|
- // Se non ci sono anomalie torna alla homepage
|
|
|
- if (count($anomalie) == 0) {
|
|
|
- $f3->reroute('/');
|
|
|
- return;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // Seleziona le prossime tre etichette
|
|
|
- foreach($rowsDistinta as $rowDist) {
|
|
|
- $labelId = $distinta->GetLabelIdFromBarcode($rowDist['barcode']);
|
|
|
- if ($labelId != null) {
|
|
|
- $label = new SmartESL($this->findBoxCore, [$labelId]);
|
|
|
- // Se è lo stesso barcode di quello appena pickato dall'operatore, non lo blinka di nuovo
|
|
|
- if ($distinta->GetArticleCount($rowDist['barcode']) > 0) {
|
|
|
- $label->BlinkSpecial(2, 1, 1000, 20);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ $commesse = $distinta->getCommesseFromProduct($f3->get('SESSION.barcode_mv'));
|
|
|
+ if (count($commesse) == 0) {
|
|
|
+ $f3->set('INFOTEXT', "Ventilazione terminata");
|
|
|
+ $f3->set('RESTART_VENTILAZIONE', true);
|
|
|
+ }
|
|
|
+ foreach($commesse as $commessa) {
|
|
|
+ $labelid = $distinta->GetLabelIdFromBarcode($commessa['commessa']);
|
|
|
+ $label = new SmartESL($this->findBoxCore, [$labelid]);
|
|
|
+ $eslData = array(
|
|
|
+ 'Q.ta' => $commessa['qta_prelevare'],
|
|
|
+ 'Commessa' => $commessa['commessa']
|
|
|
+ );
|
|
|
+ $err = $this->findBoxCore->SaveProducts($labelid, $commessa['descrizione'], $eslData);
|
|
|
+ $label->BlinkSpecial(0, 1, 1000, 8, 0);
|
|
|
}
|
|
|
+ $f3->set('COMMESSE', $commesse);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- $f3->set('COOKIE.p2l', json_encode($stepValues));
|
|
|
-
|
|
|
- $distinte = $distinta->getListeToBind();
|
|
|
- $f3->set('DISTINTE', $distinte);
|
|
|
- $f3->set('STEP', $args['step']);
|
|
|
- $f3->set('PAGEVALUES', $stepValues);
|
|
|
-
|
|
|
$f3->set('CONTENT', 'pick2light.tpl');
|
|
|
echo \Template::instance()->render('masterpage.tpl');
|
|
|
}
|
|
|
|
|
|
- public function Bind($f3)
|
|
|
+ public
|
|
|
+ function Bind($f3)
|
|
|
{
|
|
|
$params = $this->getSanitizedPostRequest();
|
|
|
$distinta = new Distinta();
|
|
|
@@ -145,7 +96,6 @@ class Pages extends \OpenMind\Web\Controller
|
|
|
$labelTemplateId = \F3::get("LABELS.TEMPLATES.DT31");
|
|
|
|
|
|
$err = $label->Display($labelTemplateId, $bindData['labelid']);
|
|
|
- // TODO assegnare il template corretto ed i custom field
|
|
|
$eslData = array(
|
|
|
'Q.ta' => 0,
|
|
|
'Commessa' => $bindData['commessa']
|
|
|
@@ -173,7 +123,8 @@ class Pages extends \OpenMind\Web\Controller
|
|
|
* @param $f3
|
|
|
* @param array $args
|
|
|
*/
|
|
|
- public function UnBind($f3, array $args)
|
|
|
+ public
|
|
|
+ function UnBind($f3, array $args)
|
|
|
{
|
|
|
$stepValues = array_map('strtoupper', $this->getSanitizedPostRequest());
|
|
|
if ($args['step'] == 2) {
|
|
|
@@ -191,7 +142,8 @@ class Pages extends \OpenMind\Web\Controller
|
|
|
* @deprecated for now not used
|
|
|
* @param $f3
|
|
|
*/
|
|
|
- public function ElencoDistinta($f3)
|
|
|
+ public
|
|
|
+ function ElencoDistinta($f3)
|
|
|
{
|
|
|
$distinta = new Distinta();
|
|
|
$f3->set('PRODUCTS', $distinta->getDistinte());
|