コード例 #1
0
 /**
  * (non-PHPdoc)
  * @see \Base\Controller\BaseController::saveAction()
  * @return array
  */
 public function saveAction()
 {
     $userId = $this->_message->auth->userId;
     $tabId = $this->params('tabId', false);
     $windowId = $this->params('windowId', false);
     $browserTabId = $this->params('id', false);
     $formXml = 'templates/lead/forms/edit.xml';
     $handler = 'MoveIn4Person\\Model\\Person';
     $formCollection = array('person', 'email', 'phoneNumber', 'instantMessaging', 'socialMediaProfile', 'address', 'lead', 'opportunity', 'group', 'nationality', 'identityDocument');
     // extract email form data before checking for duplicate
     $result = $_POST['data'];
     $form = file_get_contents('public/' . $formXml);
     $resultObject = new Result($result, $form);
     $fc = $resultObject->getData();
     $emails = array();
     foreach ($fc['email'] as $emailobj) {
         $emails[] = (string) $emailobj['email'];
     }
     // Check for duplicates before saving
     $filter = array('emails' => $emails, 'fields' => array('id', 'firstName'));
     $dupeId = $this->_message->addAction($this->defaultQueue, 'checkDuplicates', $filter, $this->_handler);
     // on duplicate register error handler
     $data = array('channel' => array('tab_' . $browserTabId), 'message' => array('windowId' => $windowId, 'data_attr' => array('xpath' => '//fault/action[@id="' . $dupeId . '"]/fault')), 'jsFunction' => 'checkDuplicateLead', 'jsClass' => 'baseView');
     $this->_message->addErrorhandler('response', 'send', $data, 'SocketResponse', array('parentId' => $dupeId, 'errorCode' => 'duplicateFound'));
     $this->saveHelper($formXml, $handler, $formCollection);
     return $this->setresponse();
 }
コード例 #2
0
 /**
  * this method saves person-details activities
  * @param string $formXml forms xml
  * @param string $handler Model name
  * @param string $formCollection CollectionName
  * @param string $pushToQueue pushToQueue
  * @author Sheraz Saleem
  * @return string
  */
 public function saveHelper($formXml, $handler, $formCollection, $pushToQueue = true)
 {
     $jsCallback = $this->params('jsCallback', 'moveInViewModel.personDetails.communicationStream.saveUpdateForm');
     $result = $_POST['data'];
     $form = file_get_contents('public/' . $formXml);
     $resultObject = new Result($result, $form);
     $data = $resultObject->getData();
     $data['lockedRecord'] = false;
     $message = array('jsData' => ['message' => 'label_successfully_saved'], 'phpMethod' => 'edit', 'phpData' => $data, 'jsCallback' => $jsCallback, 'windowId' => $this->params('windowId', false), 'browserTabId' => $this->params('id', false));
     $this->_queueMessage($message);
     return $this->_disableViewAndLayout();
 }
コード例 #3
0
 /**
  * this method saves formConfig data
  * @param string $formXml forms xml
  * @param string $handler Model name
  * @param string $formCollection CollectionName
  * @param string $queue pushToQueue
  * @author Sheraz Saleem
  * @return string
  */
 protected function saveHelper($formXml, $handler, $formCollection, $queue = true)
 {
     $userId = $this->_message->auth->userId;
     $tabId = $this->params('tabId', false);
     $windowId = $this->params('windowId', false);
     $browserTabId = $this->params('id', false);
     $triggerType = $this->params()->fromPost('trigger_type', 'save');
     $newData = $this->params()->fromPost('id', '');
     $result = $_POST['data'];
     $form = file_get_contents('public/' . $formXml);
     $resultObject = new Result($result, $form);
     $forRes = $resultObject->getData();
     // create Xml files for definition and translation on bases of formTemplate selected only when no xml defination has been set
     if ($forRes['xmlDefinition'][0]['fileName'] == '' || isset($forRes['xmlDefinition'][0]['delete'])) {
         $filesData = $this->createXmlFiles($result);
         $forRes = array_merge($forRes, $filesData);
     }
     $editId = $this->_message->addAction($this->defaultQueue, 'edit', $forRes, $handler);
     $data = array('channel' => array('tab_' . $browserTabId), 'message' => array('windowId' => $windowId, 'data' => $resultObject->getData(), 'rowId_attr' => array('xpath' => '//response/action[@id="' . $editId . '"]/data/id'), 'newDoc_attr' => array('xpath' => '//response/action[@id="' . $editId . '"]/data/newSubDocuments'), 'message' => 'label_successfully_saved'), 'jsFunction' => empty($_POST['jsFunction']) ? 'singleViewMessage' : $_POST['jsFunction'], 'jsClass' => 'baseView');
     $this->_message->addAction('response', 'send', $data, 'SocketResponse');
     $this->queue($this->_message);
     return $editId;
 }
コード例 #4
0
 /**
  * merge document tempaltes
  * @return void
  */
 public function generateSystemTemplateDocumentAction()
 {
     $windowId = $this->params('windowId', false);
     $jsCallback = $this->params('jsCallback', 'moveInViewModel.personDetails.communicationStream.getActivityMessages');
     $browserTabId = $this->params('id', false);
     $session = new Container();
     $this->_formXml = 'templates/activity/forms/template.xml';
     $form = file_get_contents('public/' . $this->_formXml);
     $result = new Result($this->params()->fromPost('data', false), $form);
     $data = $result->getData();
     //save the system document temaplte document
     //lock the record
     $data['lockedRecord'] = true;
     $data['generatedOn'] = date('d/m/Y h:i:A');
     $editId = $this->_message->addAction($this->defaultQueue, 'edit', $data, 'MoveIn4Activity\\Model\\ActivitySystemTemplate');
     //refresh stream
     $responseData = ['channel' => ['tab_' . $browserTabId], 'message' => ['windowId' => $windowId, 'pagerId' => $this->params()->fromPost('pagerId', false), 'data_attr' => ['xpath' => '//response/action[@id="' . $editId . '"]/data']], 'jsFunction' => $this->params('jsCallback', 'moveInViewModel.personDetails.communicationStreamDocumentTemplate.hideDocumentTemplateForm')];
     $this->_message->addAction('response', 'send', $responseData, 'SocketResponse');
     //get the system activiy document
     $activityData = array('id_attr' => array('xpath' => '//response/action[@id="' . $editId . '"]/data/id'), 'fields' => array('area', 'message', 'owner', 'templatename', 'templatedoc', 'template', 'lockedRecord', 'watcher', 'generatedOn'));
     $activityId = $this->_message->addAction($this->defaultQueue, 'getSystemTemplateDocumentForNewTemplateDocument', $activityData, 'MoveIn4Activity\\Model\\ActivitySystemTemplate');
     //close form
     //Save activity before attachement of pdf, pdf take time so it will be attached when ready.
     $editSimpleDocumentId = array();
     foreach ($data['recipient'] as $recipIndex => $recipient) {
         //create the document activity for this person with the attached file
         $editSimpleDocumentData = array('recipient' => $recipient, 'fields_attr' => array('xpath' => '//response/action[@id="' . $activityId . '"]/data/fields'));
         $editSimpleDocumentId[$recipIndex] = $this->_message->addAction($this->defaultQueue, 'edit', $editSimpleDocumentData, 'MoveIn4Activity\\Model\\ActivityTemplate');
     }
     //refresh stream
     $refreshData = ['channel' => ['tab_' . $browserTabId], 'message' => ['windowId' => $windowId, 'pagerId' => $this->params()->fromPost('pagerId', false), 'data_attr' => ['xpath' => '//response/action[@id="' . $editId . '"]/data']], 'jsFunction' => $jsCallback];
     $this->_message->addAction('response', 'send', $refreshData, 'SocketResponse');
     //get the document template
     $template = $data['template'];
     $templateData = array('id' => $template, 'fields' => array('fileName.fileName', 'fileName.fileStorageId', 'name'));
     $templateId = $this->_message->addAction($this->defaultQueue, 'getOne', $templateData, 'MoveIn4DocumentTemplate\\Model\\DocumentTemplate');
     //get the file as a file resource
     $fileData = array('id_attr' => array('xpath' => '//response/action[@id="' . $templateId . '"]/data/fields/fileName/fileStorageId'));
     $fileId = $this->_message->addAction('filestorage', 'getFileAsResource', $fileData, 'FileStorage');
     //get the merge fields for the document
     $docmergeFieldsData = array('options' => array('inputFormat' => 'docx'), 'template_attr' => array('xpath' => '//response/action[@id="' . $fileId . '"]/data/file'));
     $docmergeFieldsId = $this->_message->addAction('docmerge', 'getFieldNames', $docmergeFieldsData, 'DocMerge');
     //foreach recipient
     $pdfToMerge = array();
     foreach ($data['recipient'] as $recipIndex => $recipient) {
         //get the applicant merge data
         $recipientData = array();
         $recipientData['fields_attr'] = array('xpath' => '//response/action[@id="' . $docmergeFieldsId . '"]/data/fieldNames');
         $recipientData['entities'] = array('person' => (string) $recipient['person'][0], 'currentuser' => $session->userId);
         $recipientData['subDocumentsIds']['lead'] = $recipient['documentId'];
         $recipientDataId = $this->_message->addAction($this->defaultQueue, 'getMergeData', $recipientData, 'MoveIn4ServiceHelper\\Model\\MailMergeData');
         //merge the document as pdf
         $docmergeData = array('options' => array('inputFormat_attr' => array('xpath' => '//response/action[@id="' . $fileId . '"]/data/attributes/extension'), 'tags_attr' => array('xpath' => '//response/action[@id="' . $recipientDataId . '"]/data/mergeData')), 'template_attr' => array('xpath' => '//response/action[@id="' . $fileId . '"]/data/file'));
         $docmergeId = $this->_message->addAction('docmerge', 'merge', $docmergeData, 'DocMerge');
         $pdfToMerge[] = $docmergeId;
         //save the pdf (add pdf file to an array of files
         $mergeFileData = array('id' => null, 'file_attr' => array('xpath' => '//response/action[@id="' . $docmergeId . '"]/data/doc'), 'options' => array('filename_attr' => array('xpath' => '//response/action[@id="' . $activityId . '"]/data/fields/templatename'), 'extension' => 'pdf', 'pathPrepend' => array(getenv('APPLICATION_ENV'), getenv('APPLICATION_INSTANCE'))));
         $fileStorage = $this->_message->addAction('filestorage', 'saveFile', $mergeFileData, 'FileStorage');
         //update the template document with the file
         $editDocumentTemplateData = array('id_attr' => array('xpath' => '//response/action[@id="' . $editSimpleDocumentId[$recipIndex] . '"]/data/id'), 'attachment' => array('fileStorageId_attr' => array('xpath' => '//response/action[@id="' . $fileStorage . '"]/data/docId'), 'fileName_attr' => array('xpath' => '//response/action[@id="' . $activityId . '"]/data/fields/templatename'), 'extension' => 'pdf'));
         $editTemplateDocumentId = $this->_message->addAction($this->defaultQueue, 'edit', $editDocumentTemplateData, 'MoveIn4Activity\\Model\\ActivityTemplate');
     }
     //combine all merged pdf files
     foreach ($pdfToMerge as $k => $v) {
         $pdfToMerge[$k] = array('fileRef_attr' => array('xpath' => '//response/action[@id="' . $v . '"]/data/doc'));
     }
     $pdfCombineData = array('file' => $pdfToMerge);
     $pdfCombineId = $this->_message->addAction('pdfcombine', 'combine', $pdfCombineData, 'PdfCombine');
     //save the merged pdf file
     $mergeFileData = array('id' => null, 'file_attr' => array('xpath' => '//response/action[@id="' . $pdfCombineId . '"]/data/doc'), 'options' => array('filename_attr' => array('xpath' => '//response/action[@id="' . $activityId . '"]/data/fields/templatename'), 'extension' => 'pdf', 'pathPrepend' => array(getenv('APPLICATION_ENV'), getenv('APPLICATION_INSTANCE'))));
     $fileStorage = $this->_message->addAction('filestorage', 'saveFile', $mergeFileData, 'FileStorage');
     //update the system template document with the file
     $editSystemTemplateDocumentData = array('id_attr' => array('xpath' => '//response/action[@id="' . $editId . '"]/data/id'), 'attachment' => array('fileStorageId_attr' => array('xpath' => '//response/action[@id="' . $fileStorage . '"]/data/docId'), 'filename_attr' => array('xpath' => '//response/action[@id="' . $activityId . '"]/data/fields/templatename'), 'extension' => 'pdf'));
     $editSystemTemplateDocumentId = $this->_message->addAction($this->defaultQueue, 'edit', $editSystemTemplateDocumentData, 'MoveIn4Activity\\Model\\ActivitySystemTemplate');
     // on second time refresh do not hide form just refresh activity messages. because in pdf creation time if you want to create another then it will hide form after pdf creation.
     if (!strpos($refreshData['jsFunction'], 'closeForm')) {
         $refreshData['jsFunction'] = 'moveInViewModel.personDetails.communicationStream.getActivityMessages()';
     }
     $this->_message->addAction('response', 'send', $refreshData, 'SocketResponse');
     //         header("Content-type: text/xml");
     //          echo $this->_message->asXml();
     $this->queue($this->_message);
     return $this->setresponse();
 }
コード例 #5
0
 /**
  * Update and add new email document on send mail
  * @author Mudassar Ali
  * @param string $mergeFieldId the merge field action id
  * @return string
  */
 private function _saveMergedEmail($mergeFieldId)
 {
     // Now create new email document for each to addresses
     $result = $_POST['data'];
     $windowId = $this->params('windowId', false);
     $browserTabId = $this->params('id', false);
     $jsCallback = $this->params('jsCallback', 'moveInViewModel.personDetails.communicationStream.getActivityMessages');
     $form = file_get_contents('public/' . $this->_formXml);
     $resultObject = new Result($result, $form);
     $data = $resultObject->getData();
     $data['lockedRecord'] = true;
     $data['sent'] = date('d/m/Y h:i:A');
     $editId = $this->_message->addAction($this->defaultQueue, 'edit', $data, 'MoveIn4Activity\\Model\\ActivitySystemEmail');
     // delete system email if there is no merge field and only one person in to
     if (count($data['to']) == 1) {
         $this->_deleteSystemEmailIfNoMergeFields($editId, $mergeFieldId);
     }
     $tos = $data['to'];
     $i = 0;
     foreach ($this->personEmailMessageQueueIds as $personActionId => $mergeMessageActionId) {
         unset($data['id']);
         unset($data['to']);
         $data['to'] = [$tos[$i]];
         $dataTmp = $data;
         $dataTmp['message_attr'] = array('xpath' => '//response/action[@id="' . $mergeMessageActionId . '"]/data/result');
         unset($dataTmp['template']);
         $editId = $this->_message->addAction($this->defaultQueue, 'edit', $dataTmp, 'MoveIn4Activity\\Model\\ActivityEmail');
         $i++;
     }
     $data = ['channel' => ['tab_' . $browserTabId], 'message' => ['windowId' => $windowId, 'pagerId' => $this->params()->fromPost('pagerId', false), 'data_attr' => ['xpath' => '//response/action[@id="' . $editId . '"]/data']], 'jsFunction' => $jsCallback];
     $this->_message->addAction('response', 'send', $data, 'SocketResponse');
 }