Exemplo n.º 1
0
 public function process(Vtiger_Request $request)
 {
     $recordId = $request->get('record');
     $step = $request->get('step');
     $moduleName = $request->get('module_name');
     if ($recordId) {
         $pdfModel = Vtiger_PDF_Model::getInstanceById($recordId, $moduleName);
     } else {
         $pdfModel = Settings_PDF_Record_Model::getCleanInstance($moduleName);
     }
     $stepFields = Settings_PDF_Module_Model::getFieldsByStep($step);
     foreach ($stepFields as $field) {
         $value = $request->get($field);
         if (is_array($value)) {
             $value = implode(',', $value);
         }
         if ($field === 'module_name' && $pdfModel->get('module_name') != $value) {
             // change of main module, overwrite existing conditions
             $pdfModel->deleteConditions();
         }
         $pdfModel->set($field, $value);
     }
     $pdfModel->set('conditions', $request->get('conditions'));
     Settings_PDF_Record_Model::transformAdvanceFilterToWorkFlowFilter($pdfModel);
     Settings_PDF_Record_Model::save($pdfModel, $step);
     $response = new Vtiger_Response();
     $response->setResult(['id' => $pdfModel->get('pdfid')]);
     $response->emit();
 }
Exemplo n.º 2
0
 function process(Vtiger_Request $request)
 {
     $forModule = $request->get('for_module');
     $output = Settings_PDF_Module_Model::getMainModuleFields($forModule);
     $response = new Vtiger_Response();
     $response->setResult($output);
     $response->emit();
 }
Exemplo n.º 3
0
 public function preProcess(Vtiger_Request $request, $display = true)
 {
     $viewer = $this->getViewer($request);
     $viewer->assign('SUPPORTED_MODULE_MODELS', Settings_PDF_Module_Model::getSupportedModules());
     parent::preProcess($request, $display);
 }
Exemplo n.º 4
0
	public function step($step, Vtiger_Request $request)
	{
		$viewer = $this->getViewer($request);
		$moduleName = $request->getModule();
		$qualifiedModuleName = $request->getModule(false);

		$recordId = $request->get('record');
		if ($recordId) {
			$pdfModel = Vtiger_PDF_Model::getInstanceById($recordId);
			$viewer->assign('RECORDID', $recordId);
			$viewer->assign('MODE', 'edit');
			$selectedModuleName = $pdfModel->get('module_name');
		} else {
			$selectedModuleName = $request->get('source_module');
			$pdfModel = Settings_PDF_Record_Model::getCleanInstance();
		}
		$viewer->assign('SELECTED_MODULE', $selectedModuleName);
		$viewer->assign('PDF_MODEL', $pdfModel);
		$allModules = Settings_PDF_Module_Model::getSupportedModules();
		$viewer->assign('ALL_MODULES', $allModules);
		$viewer->assign('MODULE', $moduleName);
		$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
		$viewer->assign('SOURCE_MODULE', $selectedModuleName);

		switch ($step) {
			case 'step8':
				$viewer->view('Step8.tpl', $qualifiedModuleName);
				break;

			case 'step7':
				$viewer->view('Step7.tpl', $qualifiedModuleName);
				break;

			case 'step6':
				$moduleModel = Vtiger_Module_Model::getInstance($pdfModel->get('module_name'));
				$recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
				$viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
				$viewer->assign('ADVANCE_CRITERIA', Vtiger_AdvancedFilter_Helper::transformToAdvancedFilterCondition($pdfModel->get('conditions')));
				$viewer->view('Step6.tpl', $qualifiedModuleName);
				break;

			case 'step5':
				$relatedModules = Settings_PDF_Module_Model::getRelatedModules($pdfModel->get('module_name'));
				if (count($relatedModules) > 0) {
					$relatedFields = Settings_PDF_Module_Model::getMainModuleFields(reset($relatedModules));
				} else {
					$relatedFields = [];
				}
				$specialFunctions = Vtiger_PDF_Model::getSpecialFunctions($allModules[key($allModules)]->getName());

				$viewer->assign('RELATED_MODULES', $relatedModules);
				$viewer->assign('RELATED_FIELDS', $relatedFields);
				$viewer->assign('SPECIAL_FUNCTIONS', $specialFunctions);
				$viewer->view('Step5.tpl', $qualifiedModuleName);
				break;

			case 'step4':
				$relatedModules = Settings_PDF_Module_Model::getRelatedModules($pdfModel->get('module_name'));
				if (count($relatedModules) > 0) {
					$relatedFields = Settings_PDF_Module_Model::getMainModuleFields(reset($relatedModules));
				} else {
					$relatedFields = [];
				}
				$specialFunctions = Vtiger_PDF_Model::getSpecialFunctions($allModules[key($allModules)]->getName());

				$viewer->assign('RELATED_MODULES', $relatedModules);
				$viewer->assign('RELATED_FIELDS', $relatedFields);
				$viewer->assign('SPECIAL_FUNCTIONS', $specialFunctions);
				$viewer->view('Step4.tpl', $qualifiedModuleName);
				break;

			case 'step3':
				$relatedModules = Settings_PDF_Module_Model::getRelatedModules($pdfModel->get('module_name'));
				if (count($relatedModules) > 0) {
					$relatedFields = Settings_PDF_Module_Model::getMainModuleFields(reset($relatedModules));
				} else {
					$relatedFields = [];
				}
				$specialFunctions = Vtiger_PDF_Model::getSpecialFunctions($allModules[key($allModules)]->getName());

				$viewer->assign('RELATED_MODULES', $relatedModules);
				$viewer->assign('RELATED_FIELDS', $relatedFields);
				$viewer->assign('SPECIAL_FUNCTIONS', $specialFunctions);
				$viewer->view('Step3.tpl', $qualifiedModuleName);
				break;

			case 'step2':
				$viewer->view('Step2.tpl', $qualifiedModuleName);
				break;

			case 'step1':
			default:
				$viewer->view('Step1.tpl', $qualifiedModuleName);
				break;
		}
	}
Exemplo n.º 5
0
 public static function save(Vtiger_PDF_Model $pdfModel, $step = 1)
 {
     $db = PearDatabase::getInstance();
     switch ($step) {
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
         case 8:
             $stepFields = Settings_PDF_Module_Model::getFieldsByStep($step);
             $params = [];
             $fields = [];
             foreach ($stepFields as $field) {
                 if ($field === 'conditions') {
                     $params[] = json_encode($pdfModel->get($field));
                 } else {
                     $params[] = $pdfModel->get($field);
                 }
                 $fields[] = "`{$field}` = ?";
             }
             $params[] = $pdfModel->getId();
             $query = 'UPDATE `a_yf_pdf` SET ' . implode(',', $fields) . ' WHERE `pdfid` = ? LIMIT 1;';
             $result = $db->pquery($query, $params);
             return $pdfModel->get('pdfid');
         case 1:
             $stepFields = Settings_PDF_Module_Model::getFieldsByStep($step);
             if (!$pdfModel->getId()) {
                 $params = [];
                 foreach ($stepFields as $field) {
                     $params[$field] = $pdfModel->get($field);
                 }
                 $db->insert('a_yf_pdf', $params);
                 $pdfModel->set('pdfid', $db->getLastInsertID());
             } else {
                 $params = [];
                 $fields = [];
                 foreach ($stepFields as $field) {
                     $params[] = $pdfModel->get($field);
                     $fields[] = "`{$field}` = ?";
                 }
                 $params[] = $pdfModel->getId();
                 $query = 'UPDATE `a_yf_pdf` SET ' . implode(',', $fields) . ' WHERE `pdfid` = ? LIMIT 1;';
                 $result = $db->pquery($query, $params);
             }
             return $pdfModel->get('pdfid');
         case 'import':
             $allFields = Settings_PDF_Module_Model::$allFields;
             $params = [];
             foreach ($allFields as $field) {
                 if ($field === 'conditions') {
                     $params[$field] = json_encode($pdfModel->get($field));
                 } else {
                     $params[$field] = $pdfModel->get($field);
                 }
             }
             $db->insert('a_yf_pdf', $params);
             $pdfModel->set('pdfid', $db->getLastInsertID());
             return $pdfModel->get('pdfid');
     }
 }