public function getHeaders() { $headerFields = parent::getHeaders(); //Added to support List Price $field = new Vtiger_Field_Model(); $field->set('name', 'listprice'); $field->set('column', 'listprice'); $field->set('label', 'List Price'); $headerFields['listprice'] = $field; return $headerFields; }
/** * Function to get comment fields list which are useful in tasks * @param <Vtiger_Module_Model> $moduleModel * @return <Array> list of Field models <Vtiger_Field_Model> */ public static function getCommentFieldsListForTasks($moduleModel) { $commentsFieldsInfo = array('lastComment' => 'Last Comment', 'last5Comments' => 'Last 5 Comments', 'allComments' => 'All Comments'); $commentFieldModelsList = array(); foreach ($commentsFieldsInfo as $fieldName => $fieldLabel) { $commentField = new Vtiger_Field_Model(); $commentField->setModule($moduleModel); $commentField->set('name', $fieldName); $commentField->set('label', $fieldLabel); $commentFieldModelsList[$fieldName] = $commentField; } return $commentFieldModelsList; }
public function getHeaders() { $relationModel = $this->getRelationModel(); $relatedModuleModel = $relationModel->getRelationModuleModel(); $headerFieldNames = $relatedModuleModel->getRelatedListFields(); $headerFields = array(); foreach ($headerFieldNames as $fieldName) { $headerFields[$fieldName] = $relatedModuleModel->getField($fieldName); } //Added to support List Price $field = new Vtiger_Field_Model(); $field->set('name', 'listprice'); $field->set('column', 'listprice'); $field->set('label', 'List Price'); array_push($headerFields, $field); return $headerFields; }
public function getHeaders() { $headerFields = parent::getHeaders(); if ($this->getRelationModel()->getRelationModuleModel()->getName() == 'PriceBooks') { //Added to support Unit Price $unitPriceField = new Vtiger_Field_Model(); $unitPriceField->set('name', 'unit_price'); $unitPriceField->set('column', 'unit_price'); $unitPriceField->set('label', 'Unit Price'); $headerFields['unit_price'] = $unitPriceField; //Added to support List Price $field = new Vtiger_Field_Model(); $field->set('name', 'listprice'); $field->set('column', 'listprice'); $field->set('label', 'List Price'); $headerFields['listprice'] = $field; } return $headerFields; }
public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer) { $moduleName = $this->getModule($request); $cvId = $request->get('cvid'); $pageNumber = $request->get('page'); $orderBy = $request->get('orderby'); $sortOrder = $request->get('sortorder'); $sourceModule = $request->get('src_module'); $sourceField = $request->get('src_field'); $sourceRecord = $request->get('src_record'); $searchKey = $request->get('search_key'); $searchValue = $request->get('search_value'); $currencyId = $request->get('currency_id'); //To handle special operation when selecting record from Popup $getUrl = $request->get('get_url'); //Check whether the request is in multi select mode $multiSelectMode = $request->get('multi_select'); if(empty($multiSelectMode)) { $multiSelectMode = false; } if(empty($cvId)) { $cvId = '0'; } if(empty ($pageNumber)) { $pageNumber = '1'; } $pagingModel = new Vtiger_Paging_Model(); $pagingModel->set('page', $pageNumber); $moduleModel = Vtiger_Module_Model::getInstance($moduleName); $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel); if(!empty($orderBy)) { $listViewModel->set('orderby', $orderBy); $listViewModel->set('sortorder', $sortOrder); } if(!empty($sourceModule)) { $listViewModel->set('src_module', $sourceModule); $listViewModel->set('src_field', $sourceField); $listViewModel->set('src_record', $sourceRecord); } if((!empty($searchKey)) && (!empty($searchValue))) { $listViewModel->set('search_key', $searchKey); $listViewModel->set('search_value', $searchValue); } if(!empty($currencyId)) { $listViewModel->set('currency_id', $currencyId); } if(!$this->listViewHeaders){ $this->listViewHeaders = $listViewModel->getListViewHeaders(); } //Added to support List Price $field = new Vtiger_Field_Model(); $field->set('name', 'listprice'); $field->set('column', 'listprice'); $field->set('label', 'List Price'); $this->listViewHeaders['listprice'] = $field; if(!$this->listViewEntries){ $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel); } foreach ($this->listViewEntries as $recordId => $recordModel) { $recordModel->set('listprice', $recordModel->getProductsListPrice($sourceRecord)); } $noOfEntries = count($this->listViewEntries); if(empty($sortOrder)) { $sortOrder = "ASC"; } if($sortOrder == "ASC") { $nextSortOrder = "DESC"; $sortImage = "downArrowSmall.png"; }else { $nextSortOrder = "ASC"; $sortImage = "upArrowSmall.png"; } $viewer->assign('MODULE', $moduleName); $viewer->assign('SOURCE_MODULE', $sourceModule); $viewer->assign('SOURCE_FIELD', $sourceField); $viewer->assign('SOURCE_RECORD', $sourceRecord); $viewer->assign('SEARCH_KEY', $searchKey); $viewer->assign('SEARCH_VALUE', $searchValue); $viewer->assign('ORDER_BY',$orderBy); $viewer->assign('SORT_ORDER',$sortOrder); $viewer->assign('NEXT_SORT_ORDER',$nextSortOrder); $viewer->assign('SORT_IMAGE',$sortImage); $viewer->assign('GETURL', $getUrl); $viewer->assign('CURRENCY_ID', $currencyId); $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance); $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure()); $viewer->assign('PAGING_MODEL', $pagingModel); $viewer->assign('PAGE_NUMBER',$pageNumber); $viewer->assign('LISTVIEW_ENTRIES_COUNT',$noOfEntries); $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders); $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries); if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) { if(!$this->listViewCount){ $this->listViewCount = $listViewModel->getListViewCount(); } $totalCount = $this->listViewCount; $pageLimit = $pagingModel->getPageLimit(); $pageCount = ceil((int) $totalCount / (int) $pageLimit); if($pageCount == 0){ $pageCount = 1; } $viewer->assign('PAGE_COUNT', $pageCount); $viewer->assign('LISTVIEW_COUNT', $totalCount); } $viewer->assign('MULTI_SELECT', $multiSelectMode); $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel()); }
/** * Function to get the values in stuctured format * @return <array> - values in structure array('block'=>array(fieldinfo)); */ public function getStructure() { if (!empty($this->structuredValues)) { return $this->structuredValues; } $recordModel = $this->getWorkFlowModel(); $recordId = $recordModel->getId(); $values = array(); $baseModuleModel = $moduleModel = $this->getModule(); $blockModelList = $moduleModel->getBlocks(); //SalesPlatform.ru add Direct link field to Detail view of entity $additionalFieldModel = new Vtiger_Field_Model(); $additionalFieldModel->set('workflow_columnname', 'spDetailViewLink')->set('workflow_columnlabel', vtranslate('LBL_DETAIL_VIEW_LINK', $moduleModel->getName())); $values['SP_LINKS_BLOCK'] = array(); $values['SP_LINKS_BLOCK'][] = $additionalFieldModel; //SalesPlatform.ru end foreach ($blockModelList as $blockLabel => $blockModel) { $fieldModelList = $blockModel->getFields(); if (!empty($fieldModelList)) { $values[$blockLabel] = array(); foreach ($fieldModelList as $fieldName => $fieldModel) { if ($fieldModel->isViewable()) { if ($moduleModel->getName() == "Documents" && $fieldName == "filename") { continue; } if (in_array($moduleModel->getName(), array('Calendar', 'Events')) && $fieldModel->getDisplayType() == 3) { /* Restricting the following fields(Event module fields) for "Calendar" module * time_start, time_end, eventstatus, activitytype, visibility, duration_hours, * duration_minutes, reminder_time, recurringtype, notime */ continue; } if (!empty($recordId)) { //Set the fieldModel with the valuetype for the client side. $fieldValueType = $recordModel->getFieldFilterValueType($fieldName); $fieldInfo = $fieldModel->getFieldInfo(); $fieldInfo['workflow_valuetype'] = $fieldValueType; $fieldModel->setFieldInfo($fieldInfo); } switch ($fieldModel->getFieldDataType()) { case 'date': if ($moduleName === 'Events' && in_array($fieldName, array('date_start', 'due_date')) || $moduleName === 'Calendar' && $fieldName === 'date_start') { $fieldName = $fieldName . ' ($(general : (__VtigerMeta__) usertimezone))'; } else { $fieldName = $fieldName . ' ($_DATE_FORMAT_)'; } break; case 'datetime': $fieldName = $fieldName . ' ($(general : (__VtigerMeta__) usertimezone))'; break; default: $fieldName; } // This will be used during editing task like email, sms etc $fieldModel->set('workflow_columnname', $fieldName)->set('workflow_columnlabel', vtranslate($fieldModel->get('label'), $moduleModel->getName())); // This is used to identify the field belongs to source module of workflow $fieldModel->set('workflow_sourcemodule_field', true); $values[$blockLabel][$fieldName] = clone $fieldModel; } } } } if ($moduleModel->isCommentEnabled()) { $commentFieldModelsList = Settings_Workflows_Field_Model::getCommentFieldsListForTasks($moduleModel); $labelName = vtranslate($moduleModel->getSingularLabelKey(), $moduleModel->getName()) . ' ' . vtranslate('LBL_COMMENTS', $moduleModel->getName()); foreach ($commentFieldModelsList as $commentFieldName => $commentFieldModel) { switch ($commentFieldModel->getFieldDataType()) { case 'date': $commentFieldName = $commentFieldName . ' ($_DATE_FORMAT_)'; break; case 'datetime': $commentFieldName = $commentFieldName . ' ($(general : (__VtigerMeta__) usertimezone)_)'; break; default: $commentFieldName; } $commentFieldModel->set('workflow_columnname', $commentFieldName)->set('workflow_columnlabel', vtranslate($commentFieldModel->get('label'), $moduleModel->getName()))->set('workflow_sourcemodule_field', true); $values[$labelName][$commentFieldName] = $commentFieldModel; } } //All the reference fields should also be sent $fields = $moduleModel->getFieldsByType(array('reference', 'owner', 'multireference')); foreach ($fields as $parentFieldName => $field) { $type = $field->getFieldDataType(); $referenceModules = $field->getReferenceList(); if ($type == 'owner') { $referenceModules = array('Users'); } foreach ($referenceModules as $refModule) { $moduleModel = Vtiger_Module_Model::getInstance($refModule); $blockModelList = $moduleModel->getBlocks(); foreach ($blockModelList as $blockLabel => $blockModel) { $fieldModelList = $blockModel->getFields(); if (!empty($fieldModelList)) { foreach ($fieldModelList as $fieldName => $fieldModel) { if ($fieldModel->isViewable()) { $name = "({$parentFieldName} : ({$refModule}) {$fieldName})"; $label = vtranslate($field->get('label'), $baseModuleModel->getName()) . ' : (' . vtranslate($refModule, $refModule) . ') ' . vtranslate($fieldModel->get('label'), $refModule); switch ($fieldModel->getFieldDataType()) { case 'date': if ($moduleName === 'Events' && in_array($fieldName, array('date_start', 'due_date')) || $moduleName === 'Calendar' && $fieldName === 'date_start') { $workflowColumnName = $name . ' ($(general : (__VtigerMeta__) usertimezone))'; } else { $workflowColumnName = $name . ' ($_DATE_FORMAT_)'; } break; case 'datetime': $workflowColumnName = $name . ' ($(general : (__VtigerMeta__) usertimezone))'; break; default: $workflowColumnName = $name; } $fieldModel->set('workflow_columnname', $workflowColumnName)->set('workflow_columnlabel', $label); if (!empty($recordId)) { $fieldValueType = $recordModel->getFieldFilterValueType($name); $fieldInfo = $fieldModel->getFieldInfo(); $fieldInfo['workflow_valuetype'] = $fieldValueType; $fieldModel->setFieldInfo($fieldInfo); } $values[$field->get('label')][$name] = clone $fieldModel; } } } } $commentFieldModelsList = array(); if ($moduleModel->isCommentEnabled()) { $labelName = vtranslate($moduleModel->getSingularLabelKey(), $moduleModel->getName()) . ' ' . vtranslate('LBL_COMMENTS', $moduleModel->getName()); $commentFieldModelsList = Settings_Workflows_Field_Model::getCommentFieldsListForTasks($moduleModel); foreach ($commentFieldModelsList as $commentFieldName => $commentFieldModel) { $name = "({$parentFieldName} : ({$refModule}) {$commentFieldName})"; $label = vtranslate($field->get('label'), $baseModuleModel->getName()) . ' : (' . vtranslate($refModule, $refModule) . ') ' . vtranslate($commentFieldModel->get('label'), $refModule); $commentFieldModel->set('workflow_columnname', $name)->set('workflow_columnlabel', $label); $values[$labelName][$name] = $commentFieldModel; } } } } $this->structuredValues = $values; return $values; }