. */ include("./include/include.php"); require_once(FILESYSTEMROOTPATH."jc/include/classes/DefaultLayout.php"); require_once(FILESYSTEMROOTPATH."include/form/AbstractForm.php"); require_once(FILESYSTEMROOTPATH."include/classes/IModel.php"); class BarcodeModel implements IModel { private $participantId; public function getId() { return NULL; } public function getParticipantId() { return $this->participantId; } public function setParticipantId($participantId) { $participantId = substr($participantId, 0, 3) . "-" . substr($participantId, 4, 7); // print $participantId; if( strlen( $participantId )==8 AND is_numeric( substr($participantId, 0, -5) ) AND substr($participantId, 3, -4)=='-' AND is_numeric( substr($participantId, -4) ) ) { $this->participantId = $participantId; }else { throw new InvalidInputException(_("The participant Id must be of the form XXX-XXXX. 3 numbers, a dash, 4 numbers."), 1); } } } class BarcodeForm extends AbstractForm { public function save(IModel $model) { $barcodeService = $GLOBALS['ClassFactory']->getBarcodeService(); $message = $barcodeService->scan($model->getParticipantId()); $this->layout->redirect($_SERVER['PHP_SELF']."?m=".urlencode($message)); } } $layout = new DefaultLayout("JC_BARCODE"); $layout->init(); $layout->echoln(''); $layout->echoln(''); $layout->echoln(''); $layout->echoln("

Scan a Barcode

"); $form = new BarcodeForm($layout, new BarcodeModel()); $form->setName("myform"); $field = new TextField("participantId", _("Participant id of the participant")); $form->addField($field); $form->display(); if (isset($_GET['m'])){ $layout->echoln(urldecode($_GET['m'])); if(strpos($_GET['m'], 'entered') !== false){ $layout->echoln(""); }elseif(strpos($_GET['m'], 'exited') !== false){ $layout->echoln(""); }elseif (substr($_GET['m'],0,1)=='E'){ $layout->echoln(""); } } $layout->echoln( "" ); $layout->page_footer(); ?>