Esempio n. 1
0
 /**
  * 
  * @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;
 }
Esempio n. 2
0
 /**
  * 
  * @return multitype:string
  */
 public function esign_form_submit()
 {
     $message = '';
     $status = self::STATUS_FAILURE;
     $password = $this->getRequest()->getParam('password', '');
     $encounterId = $this->getRequest()->getParam('encounterId', '');
     // Lock if 'Lock e-signed encounters and their forms' option is set,
     // unless esign_lock_toggle option is enable in globals, then check the request param
     $lock = false;
     if ($GLOBALS['lock_esign_all']) {
         $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)) {
         $signable = new Encounter_Signable($encounterId);
         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->encounterId = $encounterId;
     $response->locked = $lock;
     if ($lock) {
         $response->editButtonHtml = "<a href=# class='css_button_small form-edit-button-locked'><span>" . xlt('Locked') . "</span></a>";
     }
     echo json_encode($response);
     exit;
 }