/** * Implementatinon of getData() for encounters. * * We get all forms under the encounter, and then get all the data * from the individual form tables. * * @see \ESign\SignableIF::getData() */ public function getData() { $encStatement = "SELECT F.id, F.date, F.encounter, F.form_name, F.form_id, F.pid, F.user, F.formdir FROM forms F "; $encStatement .= "WHERE F.encounter = ? "; $data = array(); $res = sqlStatement($encStatement, array($this->_encounterId)); while ($encRow = sqlFetchArray($res)) { $formFactory = new Form_Factory($encRow['id'], $encRow['formdir'], $this->_encounterId); $signable = $formFactory->createSignable(); $data[] = $signable->getData(); } return $data; }
/** * * @return multitype:string */ public function esign_form_submit() { $message = ''; $status = self::STATUS_FAILURE; $password = $this->getRequest()->getParam('password', ''); $formId = $this->getRequest()->getParam('formId', ''); $formDir = $this->getRequest()->getParam('formDir', ''); $encounterId = $this->getRequest()->getParam('encounterId', ''); // Always lock, unless esign_lock_toggle option is enable in globals $lock = true; if ($GLOBALS['esign_lock_toggle']) { $lock = $this->getRequest()->getParam('lock', '') == 'on' ? true : false; } $amendment = $this->getRequest()->getParam('amendment', ''); if (confirm_user_password($_SESSION['authUser'], $password)) { $factory = new Form_Factory($formId, $formDir, $encounterId); $signable = $factory->createSignable(); if ($signable->sign($_SESSION['authUserID'], $lock, $amendment)) { $message = xlt("Form signed successfully"); $status = self::STATUS_SUCCESS; } else { $message = xlt("An error occured signing the form"); } } else { $message = xlt("The password you entered is invalid"); } $response = new Response($status, $message); $response->formId = $formId; $response->formDir = $formDir; $response->encounterId = $encounterId; $response->locked = $lock; $response->editButtonHtml = ""; if ($lock) { // If we're locking the form, replace the edit button with a "disabled" lock button $response->editButtonHtml = "<a href=# class='css_button_small form-edit-button-locked' id='form-edit-button-'" . attr($formDir) . "-" . attr($formId) . "><span>" . xlt('Locked') . "</span></a>"; } echo json_encode($response); exit; }