| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- /**
- * @author Open Mind
- * @date 10/04/2018
- * @time 09:43
- */
- namespace Modules;
- class Pages extends BaseController
- {
- public function Login($f3)
- {
- if (!is_null($this->userId))
- $f3->reroute('/homemenu');
- else
- $f3->set('CONTENT', 'login.tpl');
- echo \Template::instance()->render('masterpage.tpl');
- }
- public function HomeMenu($f3)
- {
- $f3->set('CONTENT', 'homemenu.tpl');
- echo \Template::instance()->render('masterpage.tpl');
- }
- public function Pick2Light(object $f3, array $args)
- {
- if ($args['step'] == 1) {
- $f3->clear('COOKIE.p2l');
- $f3->clear('COOKIE.consegna');
- $f3->clear('COOKIE.labelid');
- } else {
- $stepValues = array_map('strtoupper', $f3->get('POST'));
- if (count($stepValues) == 0)
- $stepValues = json_decode($f3->get('COOKIE.p2l'), true);
- }
- switch ($args['step']) {
- case 4:
- $f3->set('INFOTEXT', 'Quando pronto, aggancia l\'etichetta elettronica al carrello e scannerizza il barcode');
- break;
- case 5:
- $distinta = new \Distinta($f3);
- $distinta->CleanDistintaTable();
- $distinta->CopyDistinta($stepValues['consegna']);
- $distinta->SaveLabelCarrello($stepValues['labelid'], $stepValues['labelid'], $stepValues['consegna']);
- $rowsDistinta = $distinta->getDistinta();
- $CORE_SETTINGS = \F3::get('CORE.fb');
- $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
- foreach($rowsDistinta as $item) {
- $lblId = $distinta->GetLabelIdFromBarcode($item['barcode']);
- $label = new \SmartESL($findBoxCore, [$lblId]);
- $label->BlinkSpecial(0, 1, 1000, 50, 0);
- }
- $f3->set('COOKIE.p2l', json_encode($stepValues));
- $f3->set('COOKIE.consegna', $stepValues['consegna']);
- $f3->set('COOKIE.labelid', $stepValues['labelid']);
- $f3->reroute("/pick2light/6");
- return;
- break;
- case 6:
- $datiCommessa['consegna'] = $f3->get('COOKIE.consegna');
- $datiCommessa['labelid'] = $f3->get('COOKIE.labelid');
- $distinta = new \Distinta($f3);
- $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 if ($distinta->RemoveQuantity($pickedBarcode)) {
- $CORE_SETTINGS = \F3::get('CORE.fb');
- $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
- $label = new \SmartESL($findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
- $label->BlinkSpecial(0, 1, 0, 0, 0);
- } else {
- $f3->set('INFOTEXT', 'Etichetta mancante per il barcode selezionato');
- }
- }
- $rowsDistinta = $distinta->getDistinta();
- $f3->set('PRODUCTS', $rowsDistinta);
- if (count($rowsDistinta) == 0) {
- $distinta->ResetDistintaLabels($datiCommessa['consegna'], $datiCommessa['labelid']);
- $anomalie = $distinta->getAnomalieFromConsegne($datiCommessa['consegna']);
- $f3->set('LISTANOMALIE', $anomalie);
- $CORE_SETTINGS = $f3->get('CORE.fb');
- $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
- $label = new \SmartESL($findBoxCore, [$datiCommessa['labelid']]);
- $label->BlinkSpecial(0, 1, 1000, 5, 0);
- $label->Display(1017, $datiCommessa['labelid']);
- if (count($anomalie) == 0) {
- $f3->reroute('/');
- }
- } else {
- foreach($rowsDistinta as $rowDist) {
- $CORE_SETTINGS = $f3->get('CORE.fb');
- $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
- $labelId = $distinta->GetLabelIdFromBarcode($rowDist['barcode']);
- if ($labelId != null) {
- $label = new \SmartESL($findBoxCore, [$labelId]);
- $label->BlinkSpecial(0, 1, 1000, 50, 0);
- }
- }
- }
- // if ($stepValues['cartcode'] != $stepValues['confirmcartcode']) {
- // $f3->set('INFOTEXT', 'Carrello sbagliato');
- // $f3->set('REDIRECT', "/pick2light/}");
- // }
- break;
- }
- $f3->set('COOKIE.p2l', json_encode($stepValues));
- $f3->set('DISTINTE', $f3->Get('DB')->exec('SELECT DISTINCT consegna FROM distinte ORDER BY data_creazione, time_creazione'));
- $f3->set('STEP', $args['step']);
- $f3->set('PAGEVALUES', $stepValues);
- $f3->set('CONTENT', 'pick2light.tpl');
- echo \Template::instance()->render('masterpage.tpl');
- }
- public function Bind($f3, $args)
- {
- if ($args['step'] == 1)
- $f3->clear('COOKIE.bind');
- else {
- $stepValues = array_map('strtoupper', $f3->get('POST'));
- if (count($stepValues) == 0)
- $stepValues = json_decode($f3->get('COOKIE.p2l'), true);
- }
- $f3->set('COOKIE.bind', json_encode($stepValues));
- if ($args['step'] == 3) {
- $CORE_SETTINGS = $f3->get('CORE.fb');
- $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
- $findBoxCore->Bind($stepValues['labelid'], $stepValues['barcode']);
- $label = new \SmartESL($findBoxCore, [$stepValues['labelid']]);
- // Get template from field dev_type o label details
- // $details = $label->getDetails();
- // $devType = $details[$stepValues['labelid']]['status']['dev_type'];
- if ($stepValues['labelid'] == $stepValues['barcode'])
- $devType = 79;
- else
- $devType = 31;
- $labelTemplateId = \F3::get("LABELS.TEMPLATES.DT{$devType}");
- $label->Display($labelTemplateId[0], $stepValues['barcode']);
- $articles = new \DB\SQL\Mapper($this->dbHandle, 'articles');
- $articles->load("materiale='{$stepValues['barcode']}'");
- if (!$articles->dry()) {
- $dataFields = array(
- 'tipo_magazzino' => $articles['tipo_magazzino'],
- 'ubicazione' => $articles['ubicazione'],
- 'incc_intr' => $articles['incc_intr']
- );
- $err = $findBoxCore->SaveProducts($stepValues['barcode'], $articles['descrizione'], $dataFields);
- $dataFields = array_merge($dataFields, array(
- 'quantita_contenitore' => $articles['qta_contenitore'],
- 'quantita_magazzino' => $articles['qta_riordino']
- ));
- if ($devType == 31 && ($articles['qta_contenitore'] == 'NO' || $articles['qta_riordino'] == 'NO'))
- $pickTemplateId = $labelTemplateId[1];
- else
- $pickTemplateId = $labelTemplateId[2];
- $eslData = json_encode($dataFields);
- $this->dbHandle->exec("DELETE FROM label_bindings WHERE label_id='{$stepValues['labelid']}'");
- $this->dbHandle->exec("INSERT INTO label_bindings (label_id, barcode, template_id, esl_datafields) VALUES ('{$stepValues['labelid']}', '{$stepValues['barcode']}', '{$pickTemplateId}', '{$eslData}')");
- }
- }
- $f3->set('STEP', $args['step']);
- $f3->set('CONTENT', 'bind.tpl');
- $f3->set('AUTOFOCUS' . $args['step'], 'autofocus');
- echo \Template::instance()->render('masterpage.tpl');
- }
- public function ElencoDistinta($f3)
- {
- $distinta = new \Distinta($f3);
- $f3->set('PRODUCTS', $distinta->getDistinte());
- $f3->set('CONTENT', 'distinta.tpl');
- echo \Template::instance()->render('masterpage.tpl');
- }
- }
|