Pages.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. /**
  3. * @author Open Mind
  4. * @date 10/04/2018
  5. * @time 09:43
  6. */
  7. namespace Modules;
  8. class Pages extends BaseController
  9. {
  10. public function Login($f3)
  11. {
  12. if (!is_null($this->userId))
  13. $f3->reroute('/homemenu');
  14. else
  15. $f3->set('CONTENT', 'login.tpl');
  16. echo \Template::instance()->render('masterpage.tpl');
  17. }
  18. public function HomeMenu($f3)
  19. {
  20. $f3->set('CONTENT', 'homemenu.tpl');
  21. echo \Template::instance()->render('masterpage.tpl');
  22. }
  23. public function Pick2Light(object $f3, array $args)
  24. {
  25. if ($args['step'] == 1) {
  26. $f3->clear('COOKIE.p2l');
  27. $f3->clear('COOKIE.consegna');
  28. $f3->clear('COOKIE.labelid');
  29. } else {
  30. $stepValues = array_map('strtoupper', $f3->get('POST'));
  31. if (count($stepValues) == 0)
  32. $stepValues = json_decode($f3->get('COOKIE.p2l'), true);
  33. }
  34. switch ($args['step']) {
  35. case 4:
  36. $f3->set('INFOTEXT', 'Quando pronto, aggancia l\'etichetta elettronica al carrello e scannerizza il barcode');
  37. break;
  38. case 5:
  39. $distinta = new \Distinta($f3);
  40. $distinta->CleanDistintaTable();
  41. $distinta->CopyDistinta($stepValues['consegna']);
  42. $distinta->SaveLabelCarrello($stepValues['labelid'], $stepValues['labelid'], $stepValues['consegna']);
  43. $rowsDistinta = $distinta->getDistinta();
  44. $CORE_SETTINGS = \F3::get('CORE.fb');
  45. $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
  46. foreach($rowsDistinta as $item) {
  47. $lblId = $distinta->GetLabelIdFromBarcode($item['barcode']);
  48. $label = new \SmartESL($findBoxCore, [$lblId]);
  49. $label->BlinkSpecial(0, 1, 1000, 50, 0);
  50. }
  51. $f3->set('COOKIE.p2l', json_encode($stepValues));
  52. $f3->set('COOKIE.consegna', $stepValues['consegna']);
  53. $f3->set('COOKIE.labelid', $stepValues['labelid']);
  54. $f3->reroute("/pick2light/6");
  55. return;
  56. break;
  57. case 6:
  58. $datiCommessa['consegna'] = $f3->get('COOKIE.consegna');
  59. $datiCommessa['labelid'] = $f3->get('COOKIE.labelid');
  60. $distinta = new \Distinta($f3);
  61. $pickedBarcode = $f3->get('POST.pickedlabelid');
  62. // Decrease quantity and blink label
  63. if ($pickedBarcode != null) {
  64. // ANOMALIA
  65. if ($pickedBarcode == $f3->get('BARCODE_COMMANDS.ANOMALIACODE')) {
  66. // <Se è stato ancora passato un codice anomalia, cancella l'operazione di anomalia in corso
  67. if (isset($stepValues['anomalia']))
  68. unset($stepValues['anomalia']);
  69. else
  70. $f3->set('ANOMALIA', 'In attesa del codice anomalia');
  71. //>
  72. } else if ($stepValues['anomalia']) {
  73. if ($distinta->MarkBarcodeAsAnomalia($pickedBarcode))
  74. unset($stepValues['anomalia']);
  75. else
  76. $f3->set('ANOMALIA', 'Codice non trovato!');
  77. } else if ($distinta->RemoveQuantity($pickedBarcode)) {
  78. $CORE_SETTINGS = \F3::get('CORE.fb');
  79. $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
  80. $label = new \SmartESL($findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
  81. $label->BlinkSpecial(0, 1, 0, 0, 0);
  82. } else {
  83. $f3->set('INFOTEXT', 'Etichetta mancante per il barcode selezionato');
  84. }
  85. }
  86. $rowsDistinta = $distinta->getDistinta();
  87. $f3->set('PRODUCTS', $rowsDistinta);
  88. if (count($rowsDistinta) == 0) {
  89. $distinta->ResetDistintaLabels($datiCommessa['consegna'], $datiCommessa['labelid']);
  90. $anomalie = $distinta->getAnomalieFromConsegne($datiCommessa['consegna']);
  91. $f3->set('LISTANOMALIE', $anomalie);
  92. $CORE_SETTINGS = $f3->get('CORE.fb');
  93. $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
  94. $label = new \SmartESL($findBoxCore, [$datiCommessa['labelid']]);
  95. $label->BlinkSpecial(0, 1, 1000, 5, 0);
  96. $label->Display(1017, $datiCommessa['labelid']);
  97. if (count($anomalie) == 0) {
  98. $f3->reroute('/');
  99. }
  100. } else {
  101. foreach($rowsDistinta as $rowDist) {
  102. $CORE_SETTINGS = $f3->get('CORE.fb');
  103. $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
  104. $labelId = $distinta->GetLabelIdFromBarcode($rowDist['barcode']);
  105. if ($labelId != null) {
  106. $label = new \SmartESL($findBoxCore, [$labelId]);
  107. $label->BlinkSpecial(0, 1, 1000, 50, 0);
  108. }
  109. }
  110. }
  111. // if ($stepValues['cartcode'] != $stepValues['confirmcartcode']) {
  112. // $f3->set('INFOTEXT', 'Carrello sbagliato');
  113. // $f3->set('REDIRECT', "/pick2light/}");
  114. // }
  115. break;
  116. }
  117. $f3->set('COOKIE.p2l', json_encode($stepValues));
  118. $f3->set('DISTINTE', $f3->Get('DB')->exec('SELECT DISTINCT consegna FROM distinte ORDER BY data_creazione, time_creazione'));
  119. $f3->set('STEP', $args['step']);
  120. $f3->set('PAGEVALUES', $stepValues);
  121. $f3->set('CONTENT', 'pick2light.tpl');
  122. echo \Template::instance()->render('masterpage.tpl');
  123. }
  124. public function Bind($f3, $args)
  125. {
  126. if ($args['step'] == 1)
  127. $f3->clear('COOKIE.bind');
  128. else {
  129. $stepValues = array_map('strtoupper', $f3->get('POST'));
  130. if (count($stepValues) == 0)
  131. $stepValues = json_decode($f3->get('COOKIE.p2l'), true);
  132. }
  133. $f3->set('COOKIE.bind', json_encode($stepValues));
  134. if ($args['step'] == 3) {
  135. $CORE_SETTINGS = $f3->get('CORE.fb');
  136. $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
  137. $findBoxCore->Bind($stepValues['labelid'], $stepValues['barcode']);
  138. $label = new \SmartESL($findBoxCore, [$stepValues['labelid']]);
  139. // Get template from field dev_type o label details
  140. // $details = $label->getDetails();
  141. // $devType = $details[$stepValues['labelid']]['status']['dev_type'];
  142. if ($stepValues['labelid'] == $stepValues['barcode'])
  143. $devType = 79;
  144. else
  145. $devType = 31;
  146. $labelTemplateId = \F3::get("LABELS.TEMPLATES.DT{$devType}");
  147. $label->Display($labelTemplateId[0], $stepValues['barcode']);
  148. $articles = new \DB\SQL\Mapper($this->dbHandle, 'articles');
  149. $articles->load("materiale='{$stepValues['barcode']}'");
  150. if (!$articles->dry()) {
  151. $dataFields = array(
  152. 'tipo_magazzino' => $articles['tipo_magazzino'],
  153. 'ubicazione' => $articles['ubicazione'],
  154. 'incc_intr' => $articles['incc_intr']
  155. );
  156. $err = $findBoxCore->SaveProducts($stepValues['barcode'], $articles['descrizione'], $dataFields);
  157. $dataFields = array_merge($dataFields, array(
  158. 'quantita_contenitore' => $articles['qta_contenitore'],
  159. 'quantita_magazzino' => $articles['qta_riordino']
  160. ));
  161. if ($devType == 31 && ($articles['qta_contenitore'] == 'NO' || $articles['qta_riordino'] == 'NO'))
  162. $pickTemplateId = $labelTemplateId[1];
  163. else
  164. $pickTemplateId = $labelTemplateId[2];
  165. $eslData = json_encode($dataFields);
  166. $this->dbHandle->exec("DELETE FROM label_bindings WHERE label_id='{$stepValues['labelid']}'");
  167. $this->dbHandle->exec("INSERT INTO label_bindings (label_id, barcode, template_id, esl_datafields) VALUES ('{$stepValues['labelid']}', '{$stepValues['barcode']}', '{$pickTemplateId}', '{$eslData}')");
  168. }
  169. }
  170. $f3->set('STEP', $args['step']);
  171. $f3->set('CONTENT', 'bind.tpl');
  172. $f3->set('AUTOFOCUS' . $args['step'], 'autofocus');
  173. echo \Template::instance()->render('masterpage.tpl');
  174. }
  175. public function ElencoDistinta($f3)
  176. {
  177. $distinta = new \Distinta($f3);
  178. $f3->set('PRODUCTS', $distinta->getDistinte());
  179. $f3->set('CONTENT', 'distinta.tpl');
  180. echo \Template::instance()->render('masterpage.tpl');
  181. }
  182. }