Пример #1
0
 /**
  * Function to get Instance of Faq Record Model using TroubleTicket RecordModel
  * @param  HelpDesk_Record_Model
  * @return Faq_Record_Model
  */
 public static function getInstanceFromHelpDesk($parentRecordModel)
 {
     $recordModel = Vtiger_Record_Model::getCleanInstance('Faq');
     $fieldMappingList = Faq_Record_Model::getTicketToFAQMappingFields();
     foreach ($fieldMappingList as $fieldMapping) {
         $ticketField = $fieldMapping['ticketField'];
         $faqField = $fieldMapping['faqField'];
         if (!empty($ticketField)) {
             $faqData[$faqField] = $parentRecordModel->get($ticketField);
         } else {
             $faqData[$faqField] = $fieldMapping['defaultValue'];
         }
     }
     $recordModel->setData($faqData);
     //Updating the answer of Faq
     $answer = $recordModel->get('faq_answer');
     if ($answer) {
         $answer = vtranslate('LBL_SOLUTION', 'Faq') . ":\r\n" . $answer;
     }
     $commentsList = $parentRecordModel->getCommentsList();
     if ($commentsList) {
         $answer .= "\r\n\r\n" . vtranslate('LBL_COMMENTS', 'Faq') . ":";
         foreach ($commentsList as $comment) {
             $answer .= "\r\n{$comment}";
         }
     }
     $recordModel->set('faq_answer', $answer);
     return $recordModel;
 }
Пример #2
0
 public function process(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $record = $request->get('record');
     if (!empty($record) && $request->get('isDuplicate') == true) {
         $recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
         $viewer->assign('MODE', '');
     } else {
         if (!empty($record)) {
             $recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
             $viewer->assign('RECORD_ID', $record);
             $viewer->assign('MODE', 'edit');
         } else {
             $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
             $viewer->assign('MODE', '');
             $parentId = $request->get('parentId');
             $parentModule = $request->get('parentModule');
             if ($parentId && $parentModule === 'HelpDesk') {
                 $parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $parentModule);
                 $recordModel = Faq_Record_Model::getInstanceFromHelpDesk($parentRecordModel);
             }
         }
     }
     $moduleModel = $recordModel->getModule();
     $fieldList = $moduleModel->getFields();
     $requestFieldList = array_intersect_key($request->getAll(), $fieldList);
     foreach ($requestFieldList as $fieldName => $fieldValue) {
         $fieldModel = $fieldList[$fieldName];
         if ($fieldModel->isEditable()) {
             $recordModel->set($fieldName, $fieldModel->getDBInsertValue($fieldValue));
         }
     }
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($recordModel, Vtiger_RecordStructure_Model::RECORD_STRUCTURE_MODE_EDIT);
     $viewMode = $request->get('view_mode');
     if (!empty($viewMode)) {
         $viewer->assign('VIEW_MODE', $viewMode);
     }
     $picklistDependencyDatasource = Vtiger_DependencyPicklist::getPicklistDependencyDatasource($moduleName);
     $viewer->assign('PICKIST_DEPENDENCY_DATASOURCE', Zend_Json::encode($picklistDependencyDatasource));
     $mappingRelatedField = $moduleModel->getMappingRelatedField($moduleName);
     $viewer->assign('MAPPING_RELATED_FIELD', Zend_Json::encode($mappingRelatedField));
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('RECORD', $recordModel);
     $viewer->assign('BLOCK_LIST', $moduleModel->getBlocks());
     $viewer->assign('CURRENTDATE', date('Y-n-j'));
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $isRelationOperation = $request->get('relationOperation');
     //if it is relation edit
     $viewer->assign('IS_RELATION_OPERATION', $isRelationOperation);
     if ($isRelationOperation) {
         $viewer->assign('SOURCE_MODULE', $request->get('sourceModule'));
         $viewer->assign('SOURCE_RECORD', $request->get('sourceRecord'));
     }
     $viewer->assign('MAX_UPLOAD_LIMIT_MB', Vtiger_Util_Helper::getMaxUploadSize());
     $viewer->assign('MAX_UPLOAD_LIMIT', vglobal('upload_maxsize'));
     $viewer->view('EditView.tpl', $moduleName);
 }
Пример #3
0
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $recordId = $request->get('record');
     $result = array();
     if (!empty($recordId)) {
         $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
         $faqRecordModel = Faq_Record_Model::getInstanceFromHelpDesk($recordModel);
         $answer = $faqRecordModel->get('faq_answer');
         if ($answer) {
             $faqRecordModel->save();
             header("Location: " . $faqRecordModel->getDetailViewUrl());
         } else {
             header("Location: " . $faqRecordModel->getEditViewUrl() . "&parentId={$recordId}&parentModule={$moduleName}");
         }
     }
 }