예제 #1
0
 public function getWidgetTimeControl($user, $time)
 {
     if (!$time) {
         return array();
     }
     $db = PearDatabase::getInstance();
     $param = array('OSSTimeControl', $user, $time['start'], $time['end']);
     $sql = "SELECT SUM(sum_time) AS daytime, due_date FROM vtiger_osstimecontrol\n\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_osstimecontrol.osstimecontrolid = vtiger_crmentity.crmid\n\t\t\t\t\tWHERE vtiger_crmentity.setype = ? AND vtiger_crmentity.smownerid = ? ";
     $sql .= "AND (vtiger_osstimecontrol.date_start >= ? AND vtiger_osstimecontrol.due_date <= ?) GROUP BY due_date";
     $result = $db->pquery($sql, $param);
     $data = array();
     $countDays = 0;
     $average = 0;
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $due_date = $db->query_result_raw($result, $i, 'due_date');
         $daytime = $db->query_result_raw($result, $i, 'daytime');
         $due_date = DateTimeField::convertToUserFormat($due_date);
         $data[] = array($daytime, $due_date);
         $countDays++;
         $average = $average + $daytime;
     }
     if ($average > 0) {
         $average = $average / $countDays;
     }
     return array('data' => $data, 'countDays' => $countDays, 'average' => number_format($average, 2, '.', ' '));
 }
예제 #2
0
 public static function assignMessages($crmid, $viewer)
 {
     $chwmfkvuq = "current_user";
     $dpddjpchus = "row";
     ${"GLOBALS"}["pvcpgoobkx"] = "sql";
     ${"GLOBALS"}["dbjyloqr"] = "cu_model";
     ${$chwmfkvuq} = ${${"GLOBALS"}["dbjyloqr"]} = \Users_Record_Model::getCurrentUserModel();
     ${${"GLOBALS"}["gmbukkbbs"]} = \PearDatabase::getInstance();
     $twasrbuxi = "result";
     ${${"GLOBALS"}["uxfpyp"]} = "SELECT * FROM vtiger_wf_messages WHERE\n        (\n                (crmid = " . ${${"GLOBALS"}["podklxc"]} . " AND target = \"record\") OR\n                (crmid = " . $current_user->id . " AND target = \"user\")\n            )\n        AND (show_until =  \"0000-00-00 00:00:00\" OR show_until >= NOW())";
     ${${"GLOBALS"}["ciokylfx"]} = $adb->query(${${"GLOBALS"}["pvcpgoobkx"]});
     ${"GLOBALS"}["esusgmf"] = "sql";
     ${${"GLOBALS"}["hbelbc"]} = array();
     while (${$dpddjpchus} = $adb->fetchByAssoc(${$twasrbuxi})) {
         $wyoevilr = "row";
         ${"GLOBALS"}["wtiuxgl"] = "messages";
         ${"GLOBALS"}["txeedjxevu"] = "row";
         if (${$wyoevilr}["show_until"] != "0000-00-00 00:00:00") {
             $ticepvccqsn = "row";
             ${"GLOBALS"}["kemkeniiqmz"] = "row";
             ${${"GLOBALS"}["kemkeniiqmz"]}["show_until"] = getTranslatedString("LBL_VISIBLE_UNTIL", "Workflow2") . ": " . \DateTimeField::convertToUserFormat(${$ticepvccqsn}["show_until"]);
         } else {
             ${${"GLOBALS"}["wiurqquqjut"]}["show_until"] = "";
         }
         ${${"GLOBALS"}["wtiuxgl"]}[] = ${${"GLOBALS"}["txeedjxevu"]};
     }
     $viewer->assign("messages", ${${"GLOBALS"}["hbelbc"]});
     ${${"GLOBALS"}["esusgmf"]} = "DELETE FROM vtiger_wf_messages WHERE\n            (\n                (crmid = " . intval($_REQUEST["record"]) . " AND target = 'record') OR\n                (crmid = " . intval($current_user->id) . " AND target = 'user')\n            ) AND\n            (show_once = '1' OR (show_until != '0000-00-00 00:00:00' AND show_until < NOW()))";
     $adb->query(${${"GLOBALS"}["uxfpyp"]});
 }
예제 #3
0
 function preProcess(Vtiger_Request $request)
 {
     parent::preProcess($request);
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $recordId = $request->get('record');
     $page = $request->get('page');
     $detailViewModel = Reports_DetailView_Model::getInstance($moduleName, $recordId);
     $reportModel = $detailViewModel->getRecord();
     $reportModel->setModule('Reports');
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $page);
     $pagingModel->set('limit', self::REPORT_LIMIT);
     $this->reportData = $reportModel->getReportData($pagingModel);
     $this->calculationFields = $reportModel->getReportCalulationData();
     $primaryModule = $reportModel->getPrimaryModule();
     $secondaryModules = $reportModel->getSecondaryModules();
     $primaryModuleModel = Vtiger_Module_Model::getInstance($primaryModule);
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $userPrivilegesModel = Users_Privileges_Model::getInstanceById($currentUser->getId());
     $permission = $userPrivilegesModel->hasModulePermission($primaryModuleModel->getId());
     if (!$permission) {
         $viewer->assign('MODULE', $primaryModule);
         $viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED');
         $viewer->view('OperationNotPermitted.tpl', $primaryModule);
         exit;
     }
     $detailViewLinks = $detailViewModel->getDetailViewLinks();
     // Advanced filter conditions
     $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter());
     $viewer->assign('PRIMARY_MODULE', $primaryModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel);
     $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure();
     $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure();
     $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure);
     $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures);
     $secondaryModuleIsCalendar = strpos($secondaryModules, 'Calendar');
     if ($primaryModule == 'Calendar' || $secondaryModuleIsCalendar !== FALSE) {
         $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType();
     } else {
         $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType();
     }
     $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions());
     $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType);
     $dateFilters = Vtiger_Field_Model::getDateFilterTypes();
     foreach ($dateFilters as $comparatorKey => $comparatorInfo) {
         $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
         $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
         $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module);
         $dateFilters[$comparatorKey] = $comparatorInfo;
     }
     $viewer->assign('DATE_FILTERS', $dateFilters);
     $viewer->assign('LINEITEM_FIELD_IN_CALCULATION', $reportModel->showLineItemFieldsInFilter(false));
     $viewer->assign('DETAILVIEW_LINKS', $detailViewLinks);
     $viewer->assign('REPORT_MODEL', $reportModel);
     $viewer->assign('RECORD_ID', $recordId);
     $viewer->assign('COUNT', count($this->reportData));
     $viewer->assign('MODULE', $moduleName);
     $viewer->view('ReportHeader.tpl', $moduleName);
 }
예제 #4
0
 public function process($module, $id, Vtiger_PDF_Model $pdf)
 {
     $db = PearDatabase::getInstance();
     $query = 'SELECT `createdtime` FROM `vtiger_crmentity` WHERE `crmid` = ? LIMIT 1;';
     $result = $db->pquery($query, [$id]);
     $createdTime = $db->getSingleValue($result);
     return DateTimeField::convertToUserFormat($createdTime);
 }
예제 #5
0
 function preProcess(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $recordId = $request->get('record');
     $this->record = $detailViewModel = Reports_DetailView_Model::getInstance($moduleName, $recordId);
     parent::preProcess($request);
     $reportModel = $detailViewModel->getRecord();
     $reportModel->setModule('Reports');
     $primaryModule = $reportModel->getPrimaryModule();
     $secondaryModules = $reportModel->getSecondaryModules();
     $primaryModuleModel = Vtiger_Module_Model::getInstance($primaryModule);
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $userPrivilegesModel = Users_Privileges_Model::getInstanceById($currentUser->getId());
     $permission = $userPrivilegesModel->hasModulePermission($primaryModuleModel->getId());
     if (!$permission) {
         $viewer->assign('MODULE', $primaryModule);
         $viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED');
         $viewer->view('OperationNotPermitted.tpl', $primaryModule);
         exit;
     }
     $isAdmin = $currentUser->isAdminUser();
     $viewer->assign('isAdmin', $isAdmin);
     // Advanced filter conditions
     $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter());
     $viewer->assign('PRIMARY_MODULE', $primaryModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel);
     $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure();
     $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure();
     $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure);
     $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures);
     $secondaryModuleIsCalendar = strpos($secondaryModules, 'Calendar');
     if ($primaryModule == 'Calendar' || $secondaryModuleIsCalendar !== FALSE) {
         $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType();
     } else {
         $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType();
     }
     $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions());
     $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType);
     $dateFilters = Vtiger_Field_Model::getDateFilterTypes();
     foreach ($dateFilters as $comparatorKey => $comparatorInfo) {
         $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
         $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
         $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $moduleName);
         $dateFilters[$comparatorKey] = $comparatorInfo;
     }
     $reportChartModel = Reports_Chart_Model::getInstanceById($reportModel);
     $viewer->assign('PRIMARY_MODULE_FIELDS', $reportModel->getPrimaryModuleFieldsForAdvancedReporting());
     $viewer->assign('SECONDARY_MODULE_FIELDS', $reportModel->getSecondaryModuleFieldsForAdvancedReporting());
     $viewer->assign('CALCULATION_FIELDS', $reportModel->getModuleCalculationFieldsForReport());
     $viewer->assign('DATE_FILTERS', $dateFilters);
     $viewer->assign('REPORT_MODEL', $reportModel);
     $viewer->assign('RECORD', $recordId);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('CHART_MODEL', $reportChartModel);
     $viewer->view('ChartReportHeader.tpl', $moduleName);
 }
 public function renderFrontend($data, $context)
 {
     if (!empty($data['config']['default'])) {
         $data['config']['default'] = \Workflow\VTTemplate::parse($data['config']['default'], $context);
     }
     $html = '';
     $script = '';
     switch ($data['type']) {
         case 'file':
             $field = '<input type="file" id="reqfield_' . $data['name'] . '" data-filestoreid="' . $data['config']['default'] . '" style="width:400px;" name="' . $data['name'] . '" value="' . $data['config']["default"] . '">';
             break;
         case 'checkbox':
             $field = '<input type="checkbox" name="' . $data['name'] . '" ' . ($data["config"]["default"] == 'On' ? "checked='checked'" : "") . ' value="on">';
             break;
         case 'textarea':
             $field = '<textarea id="reqfield_' . $data['name'] . '" style="width:400px;height:100px;" name="' . $data['name'] . '">' . $data['config']["default"] . '</textarea>';
             break;
         case 'picklist':
             $options = explode("\n", $data['config']['default']);
             $field = '<select style="width:410px;" name="' . $data['name'] . '" class="select2">';
             foreach ($options as $option) {
                 $option = trim($option);
                 if (strpos($option, '#~#') !== false) {
                     $parts = explode('#~#', $option);
                     $fieldValue = $parts[1];
                     $fieldLabel = $parts[0];
                 } else {
                     $fieldValue = $option;
                     $fieldLabel = $option;
                 }
                 $field .= '<option value="' . $fieldValue . '">' . $fieldLabel . '</option>';
             }
             $field .= '</select>';
             break;
         case 'date':
             $current_user = \Users_Record_Model::getCurrentUserModel();
             $field = '<div class="input-append pull-right" style="width:410px;">';
             if (!empty($data['config']["default"])) {
                 $preset = \DateTimeField::convertToUserFormat($data['config']["default"]);
             } else {
                 $preset = '';
             }
             $field .= '<input type="text" class="dateField span2" data-date-format="' . $current_user->date_format . '"id="reqfield_' . $data['name'] . '"name="' . $data['name'] . '" value="' . $preset . '">';
             $field .= '<span class="add-on"><i class="icon-calendar"></i></span>';
             $field .= '</div>';
             break;
         case 'text':
         default:
             $field = '<input type="text" id="reqfield_' . $data['name'] . '" style="width:400px;" name="' . $data['name'] . '" value="' . $data['config']["default"] . '">';
             break;
     }
     $html = "<label><div style='min-height:26px;padding:2px 0;'><div style=''><strong>" . $data['label'] . "</strong></div><div style='text-align:right;'>" . $field . "</div></div></label>";
     return array('html' => $html, 'javascript' => $script);
 }
예제 #7
0
 public static function getDateFilter($moduleName)
 {
     $dateFilters = Vtiger_Field_Model::getDateFilterTypes();
     foreach ($dateFilters as $comparatorKey => $comparatorInfo) {
         $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
         $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
         $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $moduleName);
         $dateFilters[$comparatorKey] = $comparatorInfo;
     }
     return $dateFilters;
 }
예제 #8
0
 /**
  * Function to get Edit view display value
  * @param <String> Data base value
  * @return <String> value
  */
 public function getEditViewDisplayValue($value)
 {
     $fieldName = $this->getName();
     //Set the start date and end date
     if (empty($value)) {
         if ($fieldName === 'date_start') {
             return DateTimeField::convertToUserFormat(date('Y-m-d'));
         } elseif ($fieldName === 'due_date') {
             //$currentUser = Users_Record_Model::getCurrentUserModel();
             $minutes = 15;
             return DateTimeField::convertToUserFormat(date('Y-m-d', strtotime("+{$minutes} minutes")));
         }
     }
     return parent::getEditViewDisplayValue($value);
 }
예제 #9
0
 /**
  * Function to display the UI for advance search on any of the module
  * @param Vtiger_Request $request
  */
 function showAdvancedSearch(Vtiger_Request $request)
 {
     //Modules for which search is excluded
     $excludedModuleForSearch = array('Vtiger', 'Reports');
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     if ($request->get('source_module')) {
         $moduleName = $request->get('source_module');
     }
     $saveFilterPermitted = true;
     $saveFilterexcludedModules = array('ModComments', 'RSS', 'Portal', 'Integration', 'PBXManager', 'DashBoard');
     if (in_array($moduleName, $saveFilterexcludedModules)) {
         $saveFilterPermitted = false;
     }
     //See if it is an excluded module, If so search in home module
     if (in_array($moduleName, $excludedModuleForSearch)) {
         $moduleName = 'Home';
     }
     $module = $request->getModule();
     $customViewModel = new CustomView_Record_Model();
     $customViewModel->setModule($moduleName);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     $viewer->assign('SEARCHABLE_MODULES', Vtiger_Module_Model::getSearchableModules());
     $viewer->assign('CUSTOMVIEW_MODEL', $customViewModel);
     if ($moduleName == 'Calendar') {
         $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType();
     } else {
         $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType();
     }
     $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions());
     $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType);
     $dateFilters = Vtiger_Field_Model::getDateFilterTypes();
     foreach ($dateFilters as $comparatorKey => $comparatorInfo) {
         $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
         $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
         $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module);
         $dateFilters[$comparatorKey] = $comparatorInfo;
     }
     $viewer->assign('DATE_FILTERS', $dateFilters);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('SOURCE_MODULE', $moduleName);
     $viewer->assign('SOURCE_MODULE_MODEL', $moduleModel);
     $viewer->assign('MODULE', $module);
     $viewer->assign('SAVE_FILTER_PERMITTED', $saveFilterPermitted);
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     echo $viewer->view('AdvanceSearch.tpl', $moduleName, true);
 }
예제 #10
0
 public function process(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $moduleName = $request->get('source_module');
     $module = $request->getModule();
     $record = $request->get('record');
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     if (!empty($record)) {
         $customViewModel = CustomView_Record_Model::getInstanceById($record);
         $viewer->assign('MODE', 'edit');
     } else {
         $customViewModel = new CustomView_Record_Model();
         $customViewModel->setModule($moduleName);
         $viewer->assign('MODE', '');
     }
     $viewer->assign('ADVANCE_CRITERIA', $customViewModel->transformToNewAdvancedFilter());
     $viewer->assign('CURRENTDATE', date('Y-n-j'));
     $viewer->assign('DATE_FILTERS', Vtiger_Field_Model::getDateFilterTypes());
     if ($moduleName == 'Calendar') {
         $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType();
     } else {
         $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType();
     }
     $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions());
     $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType);
     $dateFilters = Vtiger_Field_Model::getDateFilterTypes();
     foreach ($dateFilters as $comparatorKey => $comparatorInfo) {
         $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
         $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
         $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module);
         $dateFilters[$comparatorKey] = $comparatorInfo;
     }
     $viewer->assign('DATE_FILTERS', $dateFilters);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('CUSTOMVIEW_MODEL', $customViewModel);
     $viewer->assign('RECORD_ID', $record);
     $viewer->assign('MODULE', $module);
     $viewer->assign('SOURCE_MODULE', $moduleName);
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('CV_PRIVATE_VALUE', CustomView_Record_Model::CV_STATUS_PRIVATE);
     $viewer->assign('CV_PENDING_VALUE', CustomView_Record_Model::CV_STATUS_PENDING);
     $viewer->assign('CV_PUBLIC_VALUE', CustomView_Record_Model::CV_STATUS_PUBLIC);
     $viewer->assign('MODULE_MODEL', $moduleModel);
     echo $viewer->view('EditView.tpl', $module, true);
 }
예제 #11
0
 public function process(Vtiger_Request $request)
 {
     $primaryModule = $request->get('primodule');
     $secondaryModules = $request->get('secmodule');
     $record = $request->get('record');
     $reportModel = Reports_Record_Model::getCleanInstance($record);
     /*if (!empty($record)) {
               $viewer->assign('SELECTED_STANDARD_FILTER_FIELDS', $reportModel->getSelectedStandardFilter());
               $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter());
       }*/
     $reportModel->setPrimaryModule($primaryModule);
     if (!empty($secondaryModules)) {
         $reportModel->setSecondaryModule($secondaryModules);
     }
     $viewer = $this->getViewer($request);
     $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter());
     $viewer->assign('PRIMARY_MODULE', $primaryModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel);
     $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure();
     $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure();
     $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure);
     $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures);
     //$viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $reportModel->getPrimaryModuleRecordStructure());
     //$viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $reportModel->getSecondaryModuleRecordStructure());
     $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions());
     $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', Vtiger_Field_Model::getAdvancedFilterOpsByFieldType());
     $dateFilters = Vtiger_Field_Model::getDateFilterTypes();
     foreach ($dateFilters as $comparatorKey => $comparatorInfo) {
         $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
         $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
         $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module);
         $dateFilters[$comparatorKey] = $comparatorInfo;
     }
     $viewer->assign('DATE_FILTERS', $dateFilters);
     echo $viewer->view('BlockFilters.tpl', 'PDFMaker', true);
     /*
     $content = $viewer->view('BlockFilters.tpl', 'PDFMaker',true);
     echo "aaaaaaaaa"; 
     
     /*
     $response = new Vtiger_Response();
     $response->setResult($content);
     $response->emit();
     */
 }
예제 #12
0
 function process(Mobile_API_Request $request)
 {
     $current_user = $this->getActiveUser();
     //$module = $request->get('module');
     $module = $this->detectModuleName($request->get('record'));
     $record = $this->processRetrieve($request);
     $this->resolveRecordValues($record, $current_user);
     $response = new Mobile_API_Response();
     $ret_arr = array('record' => $record);
     if ($request->get('module')) {
         $module = $request->get('module');
         $moduleWSFieldNames = Mobile_WS_Utils::getEntityFieldnames($module);
         foreach ($moduleWSFieldNames as $key => $value) {
             $relatedlistcontent[$key] = $record[$value];
         }
         $relatedlistcontent['id'] = $record['id'];
         $ret_arr['relatedlistcontent'] = $relatedlistcontent;
     } elseif (vtlib_isModuleActive('ModComments') and $module != 'HelpDesk') {
         include_once 'include/Webservices/Query.php';
         $comments = vtws_query("SELECT * FROM ModComments WHERE related_to = '" . $record['id'] . "' ORDER BY createdtime DESC LIMIT 5;", $current_user);
         if (count($comments) > 0) {
             foreach ($comments as &$comment) {
                 $comment['assigned_user_id'] = vtws_getName($comment['assigned_user_id'], $current_user);
                 $comment['createdtime'] = DateTimeField::convertToUserFormat($comment['createdtime']);
             }
             $ret_arr['comments'] = $comments;
         } else {
             $ret_arr['comments'] = array();
         }
     } elseif ($module == 'HelpDesk') {
         //there is currently no vtws service for ticket comments
         $comments = Mobile_WS_Utils::getTicketComments($record);
         if (!empty($comments)) {
             foreach ($comments as &$comment) {
                 $comment['assigned_user_id'] = vtws_getName($comment['assigned_user_id'], $current_user);
                 $comment['createdtime'] = DateTimeField::convertToUserFormat($comment['createdtime']);
             }
             $ret_arr['comments'] = $comments;
         } else {
             $ret_arr['comments'] = array();
         }
     }
     $response->setResult($ret_arr);
     return $response;
 }
예제 #13
0
 public function process($ModuleName, $ID, $record_form, $config)
 {
     $projectmilestoneid = $record_form['projectmilestoneid'];
     if (!isset($projectmilestoneid) || $projectmilestoneid == 0 || $projectmilestoneid == '') {
         return array('save_record' => true);
     }
     $moduleModel = Vtiger_Record_Model::getInstanceById($projectmilestoneid, 'ProjectMilestone');
     $projectMilestoneDate = $moduleModel->get('projectmilestonedate');
     if (!isset($projectMilestoneDate) || $projectMilestoneDate == 0 || $projectMilestoneDate == '') {
         return array('save_record' => true);
     }
     $dateField = new DateTimeField($projectMilestoneDate);
     $projectMilestoneDateUserFormat = $dateField->convertToUserFormat($projectMilestoneDate);
     $dateField = new DateTimeField($record_form['targetenddate']);
     $targetEndDateUserFormat = $dateField->convertToDBFormat($record_form['targetenddate']);
     if (strtotime($targetEndDateUserFormat) > strtotime($projectMilestoneDate)) {
         return array('save_record' => false, 'type' => 0, 'info' => array('text' => vtranslate('Date can not be greater', 'DataAccess') . ' ( ' . $record_form['targetenddate'] . ' < ' . $projectMilestoneDateUserFormat . ')', 'type' => 'error'));
     } else {
         return array('save_record' => true);
     }
 }
예제 #14
0
 function getContent(Mobile_API_Request $request)
 {
     $comment = $request->get('comment');
     $parentid = $request->get('parentid');
     if (isset($comment) && !empty($comment)) {
         $parentmodule = Mobile_WS_Utils::detectModulenameFromRecordId($parentid);
         if ($parentmodule != 'HelpDesk') {
             include_once 'include/Webservices/Create.php';
             $current_user = $this->getActiveUser();
             $userid = Mobile_WS_Utils::getEntityModuleWSId('Users') . "x" . $current_user->id;
             $arr_comment = array('commentcontent' => $comment, 'related_to' => $parentid, 'creator' => $userid, 'assigned_user_id' => $userid);
             $ele = vtws_create('ModComments', $arr_comment, $current_user);
         } else {
             $parentrecordid = vtws_getIdComponents($parentid);
             $parentrecordid = $parentrecordid[1];
             //there is currently no vtws service available for ticket comments
             $current_user = $this->getActiveUser();
             $current_user_id = $current_user->id;
             $userrecordid = vtws_getIdComponents($current_user_id);
             $userrecordid = $userrecordid[1];
             $arr_comment = array('commentcontent' => $comment, 'related_to' => $parentrecordid, 'creator' => $current_user_id);
             //$ele = vtws_create('ModComments', $arr_comment, $current_user);
             $saverecord = Mobile_WS_Utils::createTicketComment($arr_comment);
             if ($saverecord == true) {
                 $userid = Mobile_WS_Utils::getEntityModuleWSId('Users') . "x" . $current_user_id;
                 $ele['commentcontent'] = $arr_comment['commentcontent'];
                 $ele['creator'] = $userid;
                 $ele['assigned_user_id'] = $userid;
                 $ele['related_to'] = $parentid;
                 $ele['id'] = '';
                 $ele['createdtime'] = DateTimeField::convertToUserFormat(date('Y-m-d H:i:s'));
             }
         }
     }
     $response = new Mobile_API_Response();
     $ele['assigned_user_id'] = vtws_getName($ele['creator'], $current_user);
     $response->setResult(array('comment' => $ele));
     return $response;
 }
예제 #15
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["dpplygv"] = "module";
     $gdtleqjpkdsh = "crmid";
     ${"GLOBALS"}["auyafnnce"] = "waitingRST";
     $haauhnidlo = "sql";
     $ltqivoyu = "adb";
     $tislpkpngsol = "request";
     $itkrgfcibt = "waiting";
     $brgjuxus = "crmid";
     $ihjgddsfo = "cu_model";
     ${${"GLOBALS"}["pxuwujbkkm"]} = ${$ihjgddsfo} = Users_Record_Model::getCurrentUserModel();
     ${"GLOBALS"}["yemuhpxpdnq"] = "viewer";
     ${${"GLOBALS"}["kaqzwjtnc"]} = Vtiger_Language_Handler::getLanguage();
     ${$ltqivoyu} = PearDatabase::getInstance();
     ${${"GLOBALS"}["yemuhpxpdnq"]} = $this->getViewer(${$tislpkpngsol});
     ${${"GLOBALS"}["dpplygv"]} = $request->get("source_module");
     ${${"GLOBALS"}["nfzomvg"]} = (int) $request->get("crmid");
     $lpkmsdfy = "row";
     ${$haauhnidlo} = "SELECT\n                    *\n                FROM\n                    vtiger_wf_entityddata\n                WHERE\n                    vtiger_wf_entityddata.crmid = " . ${$gdtleqjpkdsh} . "";
     $jvcckdhwm = "waitingRST";
     ${${"GLOBALS"}["auyafnnce"]} = $adb->query(${${"GLOBALS"}["csoiribry"]}, true);
     ${$itkrgfcibt} = array();
     while (${$lpkmsdfy} = $adb->fetchByAssoc(${$jvcckdhwm})) {
         $qhlgfswqh = "row";
         $nhzoipi = "row";
         $kgtwmjpd = "row";
         ${"GLOBALS"}["zxbipozhknd"] = "row";
         ${$nhzoipi}["modified"] = DateTimeField::convertToUserFormat(${${"GLOBALS"}["zxbipozhknd"]}["modified"]);
         ${${"GLOBALS"}["llcomooxgjot"]}["value"] = @unserialize(html_entity_decode(${$qhlgfswqh}["value"]));
         ${${"GLOBALS"}["jyvlypyp"]}[] = ${$kgtwmjpd};
     }
     $viewer->assign("crmid", ${$brgjuxus});
     $viewer->assign("entityData", ${${"GLOBALS"}["jyvlypyp"]});
     $viewer->view("EntityData.tpl", "Workflow2");
 }
예제 #16
0
function updateAdvancedCriteria($reportid, $advft_criteria, $advft_criteria_groups)
{
    global $adb, $log;
    $idelrelcriteriasql = "delete from vtiger_relcriteria where queryid=?";
    $idelrelcriteriasqlresult = $adb->pquery($idelrelcriteriasql, array($reportid));
    $idelrelcriteriagroupsql = "delete from vtiger_relcriteria_grouping where queryid=?";
    $idelrelcriteriagroupsqlresult = $adb->pquery($idelrelcriteriagroupsql, array($reportid));
    if (empty($advft_criteria)) {
        return;
    }
    foreach ($advft_criteria as $column_index => $column_condition) {
        if (empty($column_condition)) {
            continue;
        }
        $adv_filter_column = $column_condition["columnname"];
        $adv_filter_comparator = $column_condition["comparator"];
        $adv_filter_value = $column_condition["value"];
        $adv_filter_column_condition = $column_condition["columncondition"];
        $adv_filter_groupid = $column_condition["groupid"];
        $column_info = explode(":", $adv_filter_column);
        $moduleFieldLabel = $column_info[2];
        $fieldName = $column_info[3];
        list($module, $fieldLabel) = explode('__', $moduleFieldLabel, 2);
        $fieldInfo = getFieldByReportLabel($module, $fieldLabel);
        $fieldType = null;
        if (!empty($fieldInfo)) {
            $field = WebserviceField::fromArray($adb, $fieldInfo);
            $fieldType = $field->getFieldDataType();
        }
        if ($fieldType == 'currency') {
            // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
            if ($field->getUIType() == '72') {
                $adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value, null, true);
            } else {
                $adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value);
            }
        }
        $temp_val = explode(",", $adv_filter_value);
        if (($column_info[4] == 'D' || $column_info[4] == 'T' && $column_info[1] != 'time_start' && $column_info[1] != 'time_end' || $column_info[4] == 'DT') && ($column_info[4] != '' && $adv_filter_value != '')) {
            $val = array();
            for ($x = 0; $x < count($temp_val); $x++) {
                if (trim($temp_val[$x]) != '') {
                    $date = new DateTimeField(trim($temp_val[$x]));
                    if ($column_info[4] == 'D') {
                        $val[$x] = DateTimeField::convertToUserFormat(trim($temp_val[$x]));
                    } elseif ($column_info[4] == 'DT') {
                        $val[$x] = $date->getDBInsertDateTimeValue();
                    } else {
                        $val[$x] = $date->getDBInsertTimeValue();
                    }
                }
            }
            $adv_filter_value = implode(",", $val);
        }
        $irelcriteriasql = "insert into vtiger_relcriteria(QUERYID,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE,GROUPID,COLUMN_CONDITION) values (?,?,?,?,?,?,?)";
        $irelcriteriaresult = $adb->pquery($irelcriteriasql, array($reportid, $column_index, $adv_filter_column, $adv_filter_comparator, $adv_filter_value, $adv_filter_groupid, $adv_filter_column_condition));
        // Update the condition expression for the group to which the condition column belongs
        $groupConditionExpression = '';
        if (!empty($advft_criteria_groups[$adv_filter_groupid]["conditionexpression"])) {
            $groupConditionExpression = $advft_criteria_groups[$adv_filter_groupid]["conditionexpression"];
        }
        $groupConditionExpression = $groupConditionExpression . ' ' . $column_index . ' ' . $adv_filter_column_condition;
        $advft_criteria_groups[$adv_filter_groupid]["conditionexpression"] = $groupConditionExpression;
    }
    foreach ($advft_criteria_groups as $group_index => $group_condition_info) {
        if (empty($group_condition_info)) {
            continue;
        }
        if (empty($group_condition_info["conditionexpression"])) {
            continue;
        }
        // Case when the group doesn't have any column criteria
        $irelcriteriagroupsql = "insert into vtiger_relcriteria_grouping(GROUPID,QUERYID,GROUP_CONDITION,CONDITION_EXPRESSION) values (?,?,?,?)";
        $irelcriteriagroupresult = $adb->pquery($irelcriteriagroupsql, array($group_index, $reportid, $group_condition_info["groupcondition"], $group_condition_info["conditionexpression"]));
    }
}
예제 #17
0
/** This function returns a HTML output of associated vtiger_products for a given entity (Quotes,Invoice,Sales order or Purchase order)
 * Param $module - module name
 * Param $focus - module object
 * Return type string
 */
function getDetailAssociatedProducts($module, $focus)
{
    global $log;
    $log->debug("Entering getDetailAssociatedProducts(" . $module . "," . get_class($focus) . ") method ...");
    global $adb;
    global $mod_strings;
    global $theme;
    global $log;
    global $app_strings, $current_user;
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    if (vtlib_isModuleActive("Products")) {
        $hide_stock = 'no';
    } else {
        $hide_stock = 'yes';
    }
    if ($module != 'PurchaseOrder') {
        if (GlobalVariable::getVariable('B2B', '1') == '1') {
            $acvid = $focus->column_fields['account_id'];
        } else {
            $acvid = $focus->column_fields['contact_id'];
        }
        if ($hide_stock == 'no') {
            $colspan = '2';
        } else {
            $colspan = '1';
        }
    } else {
        $acvid = $focus->column_fields['vendor_id'];
        $colspan = '1';
    }
    //Get the taxtype of this entity
    $taxtype = getInventoryTaxType($module, $focus->id);
    $currencytype = getInventoryCurrencyInfo($module, $focus->id);
    $output = '';
    //Header Rows
    $output .= '

	<table width="100%"  border="0" align="center" cellpadding="5" cellspacing="0" class="crmTable" id="proTab">
	   <tr valign="top">
	   	<td colspan="' . $colspan . '" class="dvInnerHeader"><b>' . $app_strings['LBL_ITEM_DETAILS'] . '</b></td>
		<td class="dvInnerHeader" align="center" colspan="2"><b>' . $app_strings['LBL_CURRENCY'] . ' : </b>' . getTranslatedCurrencyString($currencytype['currency_name']) . ' (' . $currencytype['currency_symbol'] . ')
		</td>
		<td class="dvInnerHeader" align="center" colspan="2"><b>' . $app_strings['LBL_TAX_MODE'] . ' : </b>' . $app_strings[$taxtype] . '
		</td>
	   </tr>
	   <tr valign="top">
		<td width=40% class="lvtCol"><font color="red">*</font>
			<b>' . $app_strings['LBL_ITEM_NAME'] . '</b>
		</td>';
    //Add Quantity in Stock column for SO, Quotes and Invoice
    if (($module == 'Quotes' || $module == 'SalesOrder' || $module == 'Invoice') && $hide_stock == 'no') {
        $output .= '<td width=10% class="lvtCol"><b>' . $app_strings['LBL_QTY_IN_STOCK'] . '</b></td>';
    }
    $output .= '

		<td width=10% class="lvtCol"><b>' . $app_strings['LBL_QTY'] . '</b></td>
		<td width=10% class="lvtCol" align="right"><b>' . $app_strings['LBL_LIST_PRICE'] . '</b></td>
		<td width=12% nowrap class="lvtCol" align="right"><b>' . $app_strings['LBL_TOTAL'] . '</b></td>
		<td width=13% valign="top" class="lvtCol" align="right"><b>' . $app_strings['LBL_NET_PRICE'] . '</b></td>
	   </tr>
	   	';
    // DG 15 Aug 2006
    // Add "ORDER BY sequence_no" to retain add order on all inventoryproductrel items
    if ($module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Invoice') {
        $query = "select case when vtiger_products.productid != '' then vtiger_products.productname else vtiger_service.servicename end as productname," . " case when vtiger_products.productid != '' then 'Products' else 'Services' end as entitytype," . " case when vtiger_products.productid != '' then vtiger_products.unit_price else vtiger_service.unit_price end as unit_price," . " case when vtiger_products.productid != '' then vtiger_products.qtyinstock else 'NA' end as qtyinstock, vtiger_inventoryproductrel.* " . " from vtiger_inventoryproductrel" . " left join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid " . " left join vtiger_service on vtiger_service.serviceid=vtiger_inventoryproductrel.productid " . " where id=? ORDER BY sequence_no";
    }
    $result = $adb->pquery($query, array($focus->id));
    $num_rows = $adb->num_rows($result);
    $netTotal = '0.00';
    for ($i = 1; $i <= $num_rows; $i++) {
        $sub_prod_query = $adb->pquery("SELECT productid from vtiger_inventorysubproductrel WHERE id=? AND sequence_no=?", array($focus->id, $i));
        $subprodname_str = '';
        if ($adb->num_rows($sub_prod_query) > 0) {
            for ($j = 0; $j < $adb->num_rows($sub_prod_query); $j++) {
                $sprod_id = $adb->query_result($sub_prod_query, $j, 'productid');
                $sprod_name = getProductName($sprod_id);
                $str_sep = "";
                if ($j > 0) {
                    $str_sep = ":";
                }
                $subprodname_str .= $str_sep . " - " . $sprod_name;
            }
        }
        $subprodname_str = str_replace(":", "<br>", $subprodname_str);
        $productid = $adb->query_result($result, $i - 1, 'productid');
        $entitytype = $adb->query_result($result, $i - 1, 'entitytype');
        $productname = $adb->query_result($result, $i - 1, 'productname');
        $productname = '<a href="index.php?action=DetailView&record=' . $productid . '&module=' . $entitytype . '">' . $productname . '</a>';
        if ($subprodname_str != '') {
            $productname .= "<br/><span style='color:#C0C0C0;font-style:italic;'>" . $subprodname_str . "</span>";
        }
        $comment = $adb->query_result($result, $i - 1, 'comment');
        $qtyinstock = $adb->query_result($result, $i - 1, 'qtyinstock');
        $qty = $adb->query_result($result, $i - 1, 'quantity');
        $qty = number_format($qty, 2, '.', '');
        //Convert to 2 decimals
        $unitprice = $adb->query_result($result, $i - 1, 'unit_price');
        $listprice = $adb->query_result($result, $i - 1, 'listprice');
        $total = $qty * $listprice;
        $listprice = number_format($listprice, 2, '.', '');
        //Convert to 2 decimals
        //Product wise Discount calculation - starts
        $discount_percent = $adb->query_result($result, $i - 1, 'discount_percent');
        $discount_amount = $adb->query_result($result, $i - 1, 'discount_amount');
        $totalAfterDiscount = $total;
        $productDiscount = '0.00';
        if ($discount_percent != 'NULL' && $discount_percent != '') {
            $productDiscount = $total * $discount_percent / 100;
            $productDiscount = number_format($productDiscount, 2, '.', '');
            $totalAfterDiscount = $total - $productDiscount;
            //if discount is percent then show the percentage
            $discount_info_message = "{$discount_percent} % of " . CurrencyField::convertToUserFormat($total, null, true) . " = " . CurrencyField::convertToUserFormat($productDiscount, null, true);
        } elseif ($discount_amount != 'NULL' && $discount_amount != '') {
            $productDiscount = $discount_amount;
            $productDiscount = number_format($productDiscount, 2, '.', '');
            $totalAfterDiscount = $total - $productDiscount;
            $discount_info_message = $app_strings['LBL_DIRECT_AMOUNT_DISCOUNT'] . " = " . CurrencyField::convertToUserFormat($productDiscount, null, true);
        } else {
            $discount_info_message = $app_strings['LBL_NO_DISCOUNT_FOR_THIS_LINE_ITEM'];
        }
        //Product wise Discount calculation - ends
        $totalAfterDiscount = number_format($totalAfterDiscount, 2, '.', '');
        //Convert to 2 decimals
        $netprice = $totalAfterDiscount;
        //Calculate the individual tax if taxtype is individual
        if ($taxtype == 'individual') {
            $taxtotal = '0.00';
            $tax_info_message = $app_strings['LBL_TOTAL_AFTER_DISCOUNT'] . " = " . CurrencyField::convertToUserFormat($totalAfterDiscount, null, true) . " \\n";
            $tax_details = getTaxDetailsForProduct($productid, 'all', $acvid);
            for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
                $tax_name = $tax_details[$tax_count]['taxname'];
                $tax_label = $tax_details[$tax_count]['taxlabel'];
                $tax_value = getInventoryProductTaxValue($focus->id, $productid, $tax_name);
                $individual_taxamount = $totalAfterDiscount * $tax_value / 100;
                $individual_taxamount = number_format($individual_taxamount, 2, '.', '');
                //Convert to 2 decimals
                $taxtotal = $taxtotal + $individual_taxamount;
                $taxtotal = number_format($taxtotal, 2, '.', '');
                //Convert to 2 decimals
                $tax_info_message .= "{$tax_label} : {$tax_value} % = " . CurrencyField::convertToUserFormat($individual_taxamount, null, true) . " \\n";
            }
            $tax_info_message .= "\\n " . $app_strings['LBL_TOTAL_TAX_AMOUNT'] . " = " . CurrencyField::convertToUserFormat($taxtotal, null, true);
            $netprice = $netprice + $taxtotal;
            $netprice = number_format($netprice, 2, '.', '');
            //Convert to 2 decimals
        }
        $sc_image_tag = '';
        if ($module == 'Invoice') {
            switch ($entitytype) {
                case 'Services':
                    if (vtlib_isModuleActive('ServiceContracts')) {
                        $sc_image_tag = '<a href="index.php?module=ServiceContracts&action=EditView&service_id=' . $productid . '&sc_related_to=' . $focus->column_fields['account_id'] . '&start_date=' . DateTimeField::convertToUserFormat($focus->column_fields['invoicedate']) . '&return_module=' . $module . '&return_id=' . $focus->id . '">' . '<img border="0" src="' . vtiger_imageurl('handshake.gif', $theme) . '" title="' . getTranslatedString('LBL_ADD_NEW', $module) . " " . getTranslatedString('ServiceContracts', 'ServiceContracts') . '" style="cursor: pointer;" align="absmiddle" />' . '</a>';
                    }
                    break;
                case 'Products':
                    if (vtlib_isModuleActive('Assets')) {
                        $sc_image_tag = '<a href="index.php?module=Assets&action=EditView&invoiceid=' . $focus->id . '&product=' . $productid . '&account=' . $focus->column_fields['account_id'] . '&datesold=' . DateTimeField::convertToUserFormat($focus->column_fields['invoicedate']) . '&return_module=' . $module . '&return_id=' . $focus->id . '" onmouseout="vtlib_listview.trigger(\'invoiceasset.onmouseout\', $(this))" onmouseover="vtlib_listview.trigger(\'cell.onmouseover\', $(this))">' . '<img border="0" src="' . vtiger_imageurl('barcode.png', $theme) . '" title="' . getTranslatedString('LBL_ADD_NEW', $module) . " " . getTranslatedString('Assets', 'Assets') . '" style="cursor: pointer;" align="absmiddle" />' . '<span style="display:none;" vtmodule="Assets" vtfieldname="invoice_product" vtrecordid="' . $focus->id . '::' . $productid . '::' . $i . '" type="vtlib_metainfo"></span>' . '</a>';
                    }
                    break;
                default:
                    $sc_image_tag = '';
            }
        }
        //For Product Name
        $output .= '
			   <tr valign="top">
				<td class="crmTableRow small lineOnTop">
					' . $productname . '&nbsp;' . $sc_image_tag . '
					<br>' . $comment . '
				</td>';
        //Upto this added to display the Product name and comment
        if ($module != 'PurchaseOrder' && $hide_stock == 'no') {
            $output .= '<td class="crmTableRow small lineOnTop">' . $qtyinstock . '</td>';
        }
        $output .= '<td class="crmTableRow small lineOnTop">' . $qty . '</td>';
        $output .= '
			<td class="crmTableRow small lineOnTop" align="right">
				<table width="100%" border="0" cellpadding="5" cellspacing="0">
				   <tr>
				   	<td align="right">' . CurrencyField::convertToUserFormat($listprice, null, true) . '</td>
				   </tr>
				   <tr>
					   <td align="right">(-)&nbsp;<b><a href="javascript:;" onclick="alert(\'' . $discount_info_message . '\'); ">' . $app_strings['LBL_DISCOUNT'] . ' : </a></b></td>
				   </tr>
				   <tr>
				   	<td align="right" nowrap>' . $app_strings['LBL_TOTAL_AFTER_DISCOUNT'] . ' : </td>
				   </tr>';
        if ($taxtype == 'individual') {
            $output .= '
				   <tr>
					   <td align="right" nowrap>(+)&nbsp;<b><a href="javascript:;" onclick="alert(\'' . $tax_info_message . '\');">' . $app_strings['LBL_TAX'] . ' : </a></b></td>
				   </tr>';
        }
        $output .= '
				</table>
			</td>';
        $output .= '
			<td class="crmTableRow small lineOnTop" align="right">
				<table width="100%" border="0" cellpadding="5" cellspacing="0">
				   <tr><td align="right">' . CurrencyField::convertToUserFormat($total, null, true) . '</td></tr>
				   <tr><td align="right">' . CurrencyField::convertToUserFormat($productDiscount, null, true) . '</td></tr>
				   <tr><td align="right" nowrap>' . CurrencyField::convertToUserFormat($totalAfterDiscount, null, true) . '</td></tr>';
        if ($taxtype == 'individual') {
            $output .= '<tr><td align="right" nowrap>' . CurrencyField::convertToUserFormat($taxtotal, null, true) . '</td></tr>';
        }
        $output .= '
				</table>
			</td>';
        $output .= '<td class="crmTableRow small lineOnTop" valign="bottom" align="right">' . CurrencyField::convertToUserFormat($netprice, null, true) . '</td>';
        $output .= '</tr>';
        $netTotal = $netTotal + $netprice;
    }
    $output .= '</table>';
    //$netTotal should be equal to $focus->column_fields['hdnSubTotal']
    $netTotal = $focus->column_fields['hdnSubTotal'];
    $netTotal = number_format($netTotal, 2, '.', '');
    //Convert to 2 decimals
    //Display the total, adjustment, S&H details
    $output .= '<table width="100%" border="0" cellspacing="0" cellpadding="5" class="crmTable">';
    $output .= '<tr>';
    $output .= '<td width="88%" class="crmTableRow small" align="right"><b>' . $app_strings['LBL_NET_TOTAL'] . '</td>';
    $output .= '<td width="12%" class="crmTableRow small" align="right"><b>' . CurrencyField::convertToUserFormat($netTotal, null, true) . '</b></td>';
    $output .= '</tr>';
    //Decide discount
    $finalDiscount = '0.00';
    $final_discount_info = '0';
    //if($focus->column_fields['hdnDiscountPercent'] != '') - previously (before changing to prepared statement) the selected option (either percent or amount) will have value and the other remains empty. So we can find the non selected item by empty check. But now with prepared statement, the non selected option stored as 0
    if ($focus->column_fields['hdnDiscountPercent'] != '0') {
        $finalDiscount = $netTotal * $focus->column_fields['hdnDiscountPercent'] / 100;
        $finalDiscount = number_format($finalDiscount, 2, '.', '');
        $final_discount_info = $focus->column_fields['hdnDiscountPercent'] . " % of " . CurrencyField::convertToUserFormat($netTotal, null, true) . " = " . CurrencyField::convertToUserFormat($finalDiscount, null, true);
    } elseif ($focus->column_fields['hdnDiscountAmount'] != '0') {
        $finalDiscount = $focus->column_fields['hdnDiscountAmount'];
        $finalDiscount = number_format($finalDiscount, 2, '.', '');
        $final_discount_info = CurrencyField::convertToUserFormat($finalDiscount, null, true);
    }
    //Alert the Final Discount amount even it is zero
    $final_discount_info = $app_strings['LBL_FINAL_DISCOUNT_AMOUNT'] . " = {$final_discount_info}";
    $final_discount_info = 'onclick="alert(\'' . $final_discount_info . '\');"';
    $output .= '<tr>';
    $output .= '<td align="right" class="crmTableRow small lineOnTop">(-)&nbsp;<b><a href="javascript:;" ' . $final_discount_info . '>' . $app_strings['LBL_DISCOUNT'] . '</a></b></td>';
    $output .= '<td align="right" class="crmTableRow small lineOnTop">' . CurrencyField::convertToUserFormat($finalDiscount, null, true) . '</td>';
    $output .= '</tr>';
    if ($taxtype == 'group') {
        $taxtotal = '0.00';
        $final_totalAfterDiscount = $netTotal - $finalDiscount;
        $tax_info_message = $app_strings['LBL_TOTAL_AFTER_DISCOUNT'] . " = " . CurrencyField::convertToUserFormat($final_totalAfterDiscount, null, true) . " \\n";
        //First we should get all available taxes and then retrieve the corresponding tax values
        $tax_details = getAllTaxes('available', '', 'edit', $focus->id);
        $ipr_cols = $adb->getColumnNames('vtiger_inventoryproductrel');
        //if taxtype is group then the tax should be same for all products in vtiger_inventoryproductrel table
        for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
            $tax_name = $tax_details[$tax_count]['taxname'];
            $tax_label = $tax_details[$tax_count]['taxlabel'];
            if (in_array($tax_name, $ipr_cols)) {
                $tax_value = $adb->query_result($result, 0, $tax_name);
            } else {
                $tax_value = $tax_details[$tax_count]['percentage'];
            }
            if ($tax_value == '' || $tax_value == 'NULL') {
                $tax_value = '0.00';
            }
            $taxamount = ($netTotal - $finalDiscount) * $tax_value / 100;
            $taxtotal = $taxtotal + $taxamount;
            $tax_info_message .= "{$tax_label} : {$tax_value} % = " . CurrencyField::convertToUserFormat($taxtotal, null, true) . " \\n";
        }
        $tax_info_message .= "\\n " . $app_strings['LBL_TOTAL_TAX_AMOUNT'] . " = " . CurrencyField::convertToUserFormat($taxtotal, null, true);
        $output .= '<tr>';
        $output .= '<td align="right" class="crmTableRow small">(+)&nbsp;<b><a href="javascript:;" onclick="alert(\'' . $tax_info_message . '\');">' . $app_strings['LBL_TAX'] . '</a></b></td>';
        $output .= '<td align="right" class="crmTableRow small">' . CurrencyField::convertToUserFormat($taxtotal, null, true) . '</td>';
        $output .= '</tr>';
    }
    $shAmount = $focus->column_fields['hdnS_H_Amount'] != '' ? $focus->column_fields['hdnS_H_Amount'] : '0.00';
    $shAmount = number_format($shAmount, 2, '.', '');
    //Convert to 2 decimals
    $output .= '<tr>';
    $output .= '<td align="right" class="crmTableRow small">(+)&nbsp;<b>' . $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'] . '</b></td>';
    $output .= '<td align="right" class="crmTableRow small">' . CurrencyField::convertToUserFormat($shAmount, null, true) . '</td>';
    $output .= '</tr>';
    //calculate S&H tax
    $shtaxtotal = '0.00';
    //First we should get all available taxes and then retrieve the corresponding tax values
    $shtax_details = getAllTaxes('available', 'sh', 'edit', $focus->id);
    //if taxtype is group then the tax should be same for all products in vtiger_inventoryproductrel table
    $shtax_info_message = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGE'] . " = " . CurrencyField::convertToUserFormat($shAmount, null, true) . "\\n";
    for ($shtax_count = 0; $shtax_count < count($shtax_details); $shtax_count++) {
        $shtax_name = $shtax_details[$shtax_count]['taxname'];
        $shtax_label = $shtax_details[$shtax_count]['taxlabel'];
        $shtax_percent = getInventorySHTaxPercent($focus->id, $shtax_name);
        $shtaxamount = $shAmount * $shtax_percent / 100;
        $shtaxamount = number_format($shtaxamount, 2, '.', '');
        $shtaxtotal = $shtaxtotal + $shtaxamount;
        $shtax_info_message .= "{$shtax_label} : {$shtax_percent} % = " . CurrencyField::convertToUserFormat($shtaxamount, null, true) . " \\n";
    }
    $shtax_info_message .= "\\n " . $app_strings['LBL_TOTAL_TAX_AMOUNT'] . " = " . CurrencyField::convertToUserFormat($shtaxtotal, null, true);
    $output .= '<tr>';
    $output .= '<td align="right" class="crmTableRow small">(+)&nbsp;<b><a href="javascript:;" onclick="alert(\'' . $shtax_info_message . '\')">' . $app_strings['LBL_TAX_FOR_SHIPPING_AND_HANDLING'] . '</a></b></td>';
    $output .= '<td align="right" class="crmTableRow small">' . CurrencyField::convertToUserFormat($shtaxtotal, null, true) . '</td>';
    $output .= '</tr>';
    $adjustment = $focus->column_fields['txtAdjustment'] != '' ? $focus->column_fields['txtAdjustment'] : '0.00';
    $adjustment = number_format($adjustment, 2, '.', '');
    //Convert to 2 decimals
    $output .= '<tr>';
    $output .= '<td align="right" class="crmTableRow small">&nbsp;<b>' . $app_strings['LBL_ADJUSTMENT'] . '</b></td>';
    $output .= '<td align="right" class="crmTableRow small">' . CurrencyField::convertToUserFormat($adjustment, null, true) . '</td>';
    $output .= '</tr>';
    $grandTotal = $focus->column_fields['hdnGrandTotal'] != '' ? $focus->column_fields['hdnGrandTotal'] : '0.00';
    $grandTotal = number_format($grandTotal, 2, '.', '');
    //Convert to 2 decimals
    $output .= '<tr>';
    $output .= '<td align="right" class="crmTableRow small lineOnTop"><b>' . $app_strings['LBL_GRAND_TOTAL'] . '</b></td>';
    $output .= '<td align="right" class="crmTableRow small lineOnTop">' . CurrencyField::convertToUserFormat($grandTotal, null, true) . '</td>';
    $output .= '</tr>';
    $output .= '</table>';
    $log->debug("Exiting getDetailAssociatedProducts method ...");
    return $output;
}
예제 #18
0
 /**
  * this function takes in an array of values for an user and sanitizes it for export
  * @param array $arr - the array of values
  */
 function sanitizeValues($arr)
 {
     $db = PearDatabase::getInstance();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $roleid = $currentUser->get('roleid');
     if (empty($this->fieldArray)) {
         $this->fieldArray = $this->moduleFieldInstances;
         foreach ($this->fieldArray as $fieldName => $fieldObj) {
             //In database we have same column name in two tables. - inventory modules only
             if ($fieldObj->get('table') == 'vtiger_inventoryproductrel' && ($fieldName == 'discount_amount' || $fieldName == 'discount_percent')) {
                 $fieldName = 'item_' . $fieldName;
                 $this->fieldArray[$fieldName] = $fieldObj;
             } else {
                 $columnName = $fieldObj->get('column');
                 $this->fieldArray[$columnName] = $fieldObj;
             }
         }
     }
     $moduleName = $this->moduleInstance->getName();
     foreach ($arr as $fieldName => &$value) {
         if (isset($this->fieldArray[$fieldName])) {
             $fieldInfo = $this->fieldArray[$fieldName];
         } else {
             unset($arr[$fieldName]);
             continue;
         }
         $value = trim(decode_html($value), "\"");
         $uitype = $fieldInfo->get('uitype');
         $fieldname = $fieldInfo->get('name');
         if (!$this->fieldDataTypeCache[$fieldName]) {
             $this->fieldDataTypeCache[$fieldName] = $fieldInfo->getFieldDataType();
         }
         $type = $this->fieldDataTypeCache[$fieldName];
         if ($fieldname != 'hdnTaxType' && ($uitype == 15 || $uitype == 16 || $uitype == 33)) {
             if (empty($this->picklistValues[$fieldname])) {
                 $this->picklistValues[$fieldname] = $this->fieldArray[$fieldname]->getPicklistValues();
             }
             // If the value being exported is accessible to current user
             // or the picklist is multiselect type.
             if ($uitype == 33 || $uitype == 16 || array_key_exists($value, $this->picklistValues[$fieldname])) {
                 // NOTE: multipicklist (uitype=33) values will be concatenated with |# delim
                 $value = trim($value);
             } else {
                 $value = '';
             }
         } elseif ($uitype == 52 || $type == 'owner') {
             $value = Vtiger_Util_Helper::getOwnerName($value);
         } elseif ($type == 'reference') {
             $value = trim($value);
             if (!empty($value)) {
                 $parent_module = getSalesEntityType($value);
                 $displayValueArray = getEntityName($parent_module, $value);
                 if (!empty($displayValueArray)) {
                     foreach ($displayValueArray as $k => $v) {
                         $displayValue = $v;
                     }
                 }
                 if (!empty($parent_module) && !empty($displayValue)) {
                     $value = $parent_module . "::::" . $displayValue;
                 } else {
                     $value = "";
                 }
             } else {
                 $value = '';
             }
         } elseif ($uitype == 72 || $uitype == 71) {
             $value = CurrencyField::convertToUserFormat($value, null, true, true);
         } elseif ($uitype == 7 && $fieldInfo->get('typeofdata') == 'N~O' || $uitype == 9) {
             $value = decimalFormat($value);
         } else {
             if ($type == 'date' || $type == 'datetime') {
                 $value = DateTimeField::convertToUserFormat($value);
             }
         }
         if ($moduleName == 'Documents' && $fieldname == 'description') {
             $value = strip_tags($value);
             $value = str_replace('&nbsp;', '', $value);
             array_push($new_arr, $value);
         }
     }
     return $arr;
 }
예제 #19
0
 public function getPDFMakerFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName)
 {
     global $current_user, $default_charset;
     $db = PearDatabase::getInstance();
     $value = $valueArray[$fieldName];
     $fld_type = $dbField->type;
     list($module, $fieldLabel) = explode('_', $dbField->name, 2);
     $fieldInfo = $this->getFieldByPDFMakerLabel($module, $fieldLabel);
     $fieldType = null;
     $fieldvalue = $value;
     if (!empty($fieldInfo)) {
         $field = WebserviceField::fromArray($db, $fieldInfo);
         $fieldType = $field->getFieldDataType();
     }
     if ($fieldType == 'currency' && $value != '') {
         // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
         if ($field->getUIType() == '72') {
             $curid_value = explode("::", $value);
             $currency_id = $curid_value[0];
             $currency_value = $curid_value[1];
             $cur_sym_rate = getCurrencySymbolandCRate($currency_id);
             if ($value != '') {
                 if ($dbField->name == 'Products_Unit_Price') {
                     // need to do this only for Products Unit Price
                     if ($currency_id != 1) {
                         $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value;
                     }
                 }
                 $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true);
                 $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']);
             }
         } else {
             $currencyField = new CurrencyField($value);
             $fieldvalue = $currencyField->getDisplayValue();
         }
     } elseif ($dbField->name == "PurchaseOrder_Currency" || $dbField->name == "SalesOrder_Currency" || $dbField->name == "Invoice_Currency" || $dbField->name == "Quotes_Currency" || $dbField->name == "PriceBooks_Currency") {
         if ($value != '') {
             $fieldvalue = getTranslatedCurrencyString($value);
         }
     } elseif (in_array($dbField->name, $this->ui101_fields) && !empty($value)) {
         $entityNames = getEntityName('Users', $value);
         $fieldvalue = $entityNames[$value];
     } elseif ($fieldType == 'date' && !empty($value)) {
         if ($module == 'Calendar' && $field->getFieldName() == 'due_date') {
             $endTime = $valueArray['calendar_end_time'];
             if (empty($endTime)) {
                 $recordId = $valueArray['calendar_id'];
                 $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId);
             }
             $date = new DateTimeField($value . ' ' . $endTime);
             $fieldvalue = $date->getDisplayDate();
         } else {
             $fieldvalue = DateTimeField::convertToUserFormat($value);
         }
     } elseif ($fieldType == "datetime" && !empty($value)) {
         $date = new DateTimeField($value);
         $fieldvalue = $date->getDisplayDateTimeValue();
     } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') {
         if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") {
             $date = new DateTimeField($value);
             $fieldvalue = $date->getDisplayTime();
         } else {
             $fieldvalue = $value;
         }
     } elseif ($fieldType == "picklist" && !empty($value)) {
         if (is_array($picklistArray)) {
             if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) {
                 $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE'];
             } else {
                 $fieldvalue = $this->getTranslatedString($value, $module);
             }
         } else {
             $fieldvalue = $this->getTranslatedString($value, $module);
         }
     } elseif ($fieldType == "multipicklist" && !empty($value)) {
         if (is_array($picklistArray[1])) {
             $valueList = explode(' |##| ', $value);
             $translatedValueList = array();
             foreach ($valueList as $value) {
                 if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) {
                     $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE'];
                 } else {
                     $translatedValueList[] = $this->getTranslatedString($value, $module);
                 }
             }
         }
         if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) {
             $fieldvalue = str_replace(' |##| ', ', ', $value);
         } else {
             implode(', ', $translatedValueList);
         }
     } elseif ($fieldType == 'double') {
         if ($current_user->truncate_trailing_zeros == true) {
             $fieldvalue = decimalFormat($fieldvalue);
         }
     }
     if ($fieldvalue == "") {
         return "-";
     }
     $fieldvalue = str_replace("<", "&lt;", $fieldvalue);
     $fieldvalue = str_replace(">", "&gt;", $fieldvalue);
     $fieldvalue = decode_html($fieldvalue);
     if (stristr($fieldvalue, "|##|") && empty($fieldType)) {
         $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue);
     } elseif ($fld_type == "date" && empty($fieldType)) {
         $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue);
     } elseif ($fld_type == "datetime" && empty($fieldType)) {
         $date = new DateTimeField($fieldvalue);
         $fieldvalue = $date->getDisplayDateTimeValue();
     }
     // Added to render html tag for description fields
     if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) {
         return $fieldvalue;
     }
     return htmlentities($fieldvalue, ENT_QUOTES, $default_charset);
 }
예제 #20
0
     if ($start_time_lenght == 10) {
         $is_full_day_event = true;
     } else {
         $is_full_day_event = false;
     }
     $startdatetime = new DateTime($When[0]->getStartTime());
     $startdatetime->setTimeZone($c_time_zone);
     $user_date_start = DateTimeField::convertToUserFormat($startdatetime->format('Y-m-d'));
     if (!$is_full_day_event) {
         $user_time_start = $startdatetime->format('H:i');
     } else {
         $user_time_start = "00:00";
     }
     $enddatetime = new DateTime($When[0]->getEndTime());
     $enddatetime->setTimeZone($c_time_zone);
     $user_date_end = DateTimeField::convertToUserFormat($enddatetime->format('Y-m-d'));
     if (!$is_full_day_event) {
         $user_time_end = $enddatetime->format('H:i');
     } else {
         $user_time_end = "00:00";
     }
 }
 $time_arr = getaddEventPopupTime($user_time_start, $user_time_end, $format);
 if ($typeid == 'task') {
     $typename = 'todo';
 } else {
     $typename = getActTypeForCalendar($typeid, false);
 }
 if ($add_into_vtiger) {
     echo "<span style='font-size:12px'>" . $app_strings['LBL_ACTION'] . ": ";
     echo "<a href=\"javascript:insertIntoCRM('" . $userid . "','" . $eventid . "','" . $typename . "','" . $event->id->text . "','" . $user_date_start . "','" . $user_date_end . "','" . $time_arr['starthour'] . "','" . $time_arr['startmin'] . "','" . $time_arr['startfmt'] . "','" . $time_arr['endhour'] . "','" . $time_arr['endmin'] . "','" . $time_arr['endfmt'] . "')\">" . $mod_strings["LBL_INSERT_INTO_CRM"] . "</a>";
예제 #21
0
 /**
  * Function to get Edit view display value
  * @param <String> Data base value
  * @return <String> value
  */
 public function getEditViewDisplayValue($value, $record = false)
 {
     $fieldName = $this->getName();
     if ($fieldName == 'time_start' || $fieldName == 'time_end') {
         return $this->getUITypeModel()->getDisplayTimeDifferenceValue($fieldName, $value);
     }
     //Set the start date and end date
     if (empty($value)) {
         if ($fieldName === 'date_start') {
             return DateTimeField::convertToUserFormat(date('Y-m-d'));
         } elseif ($fieldName === 'due_date') {
             $currentUser = Users_Record_Model::getCurrentUserModel();
             $minutes = $currentUser->get('callduration');
             return DateTimeField::convertToUserFormat(date('Y-m-d', strtotime("+{$minutes} minutes")));
         }
     }
     return parent::getEditViewDisplayValue($value, $record);
 }
예제 #22
0
function vtWorkflowEdit($adb, $request, $requestUrl, $current_language, $app_strings)
{
    global $theme, $current_user;
    $util = new VTWorkflowUtils();
    $image_path = "themes/{$theme}/images/";
    $module = new VTWorkflowApplication("editworkflow");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    if ($request['source'] == 'from_template') {
        $tm = new VTWorkflowTemplateManager($adb);
        $template = $tm->retrieveTemplate($request['template_id']);
        $workflow = $tm->createWorkflow($template);
    } else {
        $wfs = new VTWorkflowManager($adb);
        if (isset($request["workflow_id"])) {
            $workflow = $wfs->retrieve($request["workflow_id"]);
        } else {
            $moduleName = $request["module_name"];
            $workflow = $wfs->newWorkflow($moduleName);
        }
        $smarty->assign('ScheduledWorkflowsCount', $wfs->getScheduledWorkflowsCount());
        $smarty->assign('MaxAllowedScheduledWorkflows', $wfs->getMaxAllowedScheduledWorkflows());
        $smarty->assign('schdtime_12h', date('h:ia', strtotime(substr($workflow->schtime, 0, strrpos($workflow->schtime, ':')))));
        $schannualdates = json_decode($workflow->schannualdates);
        if (count($schannualdates) > 0) {
            $schannualdates = DateTimeField::convertToUserFormat($schannualdates[0]);
        } else {
            $schannualdates = '';
        }
        $smarty->assign('schdate', $schannualdates);
        $smarty->assign('selected_days1_31', json_decode($workflow->schdayofmonth));
        $smarty->assign('dayOfWeek', json_decode($workflow->schdayofweek));
    }
    if ($workflow == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']);
        return;
    }
    $workflow->test = addslashes($workflow->test);
    $tm = new VTTaskManager($adb);
    $tasks = $tm->getTasksForWorkflow($workflow->id);
    $smarty->assign("tasks", $tasks);
    $taskTypes = $tm->getTaskTypes($workflow->moduleName);
    $smarty->assign("taskTypes", $taskTypes);
    $smarty->assign("newTaskReturnUrl", vtlib_purify($requestUrl));
    $dayrange = array();
    for ($d = 1; $d <= 31; $d++) {
        $dayrange[$d] = $d;
    }
    $smarty->assign('days1_31', $dayrange);
    $smarty->assign('wfnexttrigger_time', DateTimeField::convertToUserFormat($workflow->nexttrigger_time));
    $smarty->assign("dateFormat", parse_calendardate($current_user->date_format));
    $smarty->assign("returnUrl", vtlib_purify($request["return_url"]));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, $module->name)));
    $smarty->assign("THEME", $theme);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", $mod['LBL_EDIT_WORKFLOW']);
    $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_WORKFLOW_TITLE']);
    $smarty->assign("workflow", $workflow);
    $smarty->assign("saveType", isset($workflow->id) ? "edit" : "new");
    $smarty->assign("module", $module);
    $smarty->assign("WORKFLOW_TRIGGER_TYPES_HELP_LINK", WORKFLOW_TRIGGER_TYPES);
    $smarty->display("{$module->name}/EditWorkflow.tpl");
}
    function content_5685e54d8fd7c($_smarty_tpl)
    {
        ?>
<div class="reportContents"><form class="form-horizontal recordEditView" id="report_step1" method="post" action="index.php"><input type="hidden" name="module" value="<?php 
        echo $_smarty_tpl->tpl_vars['MODULE']->value;
        ?>
" /><input type="hidden" name="view" value="<?php 
        echo $_smarty_tpl->tpl_vars['VIEW']->value;
        ?>
" /><input type="hidden" name="mode" value="step2" /><input type="hidden" class="step" value="1" /><input type="hidden" name="isDuplicate" value="<?php 
        echo $_smarty_tpl->tpl_vars['IS_DUPLICATE']->value;
        ?>
" /><input type="hidden" name="record" value="<?php 
        echo $_smarty_tpl->tpl_vars['RECORD_ID']->value;
        ?>
" /><input type=hidden id="relatedModules" data-value='<?php 
        echo ZEND_JSON::encode($_smarty_tpl->tpl_vars['RELATED_MODULES']->value);
        ?>
' /><div class="well contentsBackground"><div class="row-fluid padding1per"><span class="span3"><?php 
        echo vtranslate('LBL_REPORT_NAME', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
<span class="redColor">*</span></span><span class="span7 row-fluid"><input class="span6" data-validation-engine='validate[required]' type="text" name="reportname" value="<?php 
        echo $_smarty_tpl->tpl_vars['REPORT_MODEL']->value->get('reportname');
        ?>
"/></span></div><div class="row-fluid padding1per"><span class="span3"><?php 
        echo vtranslate('LBL_REPORT_FOLDER', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
<span class="redColor">*</span></span><span class="span7 row-fluid"><select class="chzn-select span6" name="folderid"><optgroup><?php 
        $_smarty_tpl->tpl_vars['REPORT_FOLDER'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['REPORT_FOLDER']->_loop = false;
        $_from = $_smarty_tpl->tpl_vars['REPORT_FOLDERS']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['REPORT_FOLDER']->key => $_smarty_tpl->tpl_vars['REPORT_FOLDER']->value) {
            $_smarty_tpl->tpl_vars['REPORT_FOLDER']->_loop = true;
            ?>
<option value="<?php 
            echo $_smarty_tpl->tpl_vars['REPORT_FOLDER']->value->getId();
            ?>
"<?php 
            if ($_smarty_tpl->tpl_vars['REPORT_FOLDER']->value->getId() == $_smarty_tpl->tpl_vars['REPORT_MODEL']->value->get('folderid')) {
                ?>
selected=""<?php 
            }
            ?>
><?php 
            echo vtranslate($_smarty_tpl->tpl_vars['REPORT_FOLDER']->value->getName(), $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
</option><?php 
        }
        ?>
</optgroup></select></span></div><div class="row-fluid padding1per"><span class="span3"><?php 
        echo vtranslate('PRIMARY_MODULE', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
<span class="redColor">*</span></span><span class="span7 row-fluid"><select class="span6 chzn-select" id="primary_module" name="primary_module"><optgroup><?php 
        $_smarty_tpl->tpl_vars['RELATED_MODULE'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['RELATED_MODULE']->_loop = false;
        $_smarty_tpl->tpl_vars['RELATED_MODULE_KEY'] = new Smarty_Variable();
        $_from = $_smarty_tpl->tpl_vars['MODULELIST']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['RELATED_MODULE']->key => $_smarty_tpl->tpl_vars['RELATED_MODULE']->value) {
            $_smarty_tpl->tpl_vars['RELATED_MODULE']->_loop = true;
            $_smarty_tpl->tpl_vars['RELATED_MODULE_KEY']->value = $_smarty_tpl->tpl_vars['RELATED_MODULE']->key;
            ?>
<option value="<?php 
            echo $_smarty_tpl->tpl_vars['RELATED_MODULE_KEY']->value;
            ?>
" <?php 
            if ($_smarty_tpl->tpl_vars['REPORT_MODEL']->value->getPrimaryModule() == $_smarty_tpl->tpl_vars['RELATED_MODULE_KEY']->value) {
                ?>
 selected="selected" <?php 
            }
            ?>
><?php 
            echo vtranslate($_smarty_tpl->tpl_vars['RELATED_MODULE_KEY']->value, $_smarty_tpl->tpl_vars['RELATED_MODULE_KEY']->value);
            ?>
</option><?php 
        }
        ?>
</optgroup></select></span></div><div class="row-fluid padding1per"><span class="span3"><div><?php 
        echo vtranslate('LBL_SELECT_RELATED_MODULES', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</div><div>(<?php 
        echo vtranslate('LBL_MAX', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
&nbsp;2)</div></span><span class="span7 row-fluid"><?php 
        $_smarty_tpl->tpl_vars['SECONDARY_MODULES_ARR'] = new Smarty_variable(explode(':', $_smarty_tpl->tpl_vars['REPORT_MODEL']->value->getSecondaryModules()), null, 0);
        $_smarty_tpl->tpl_vars['PRIMARY_MODULE'] = new Smarty_variable($_smarty_tpl->tpl_vars['REPORT_MODEL']->value->getPrimaryModule(), null, 0);
        if ($_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == '') {
            $_smarty_tpl->tpl_vars['RELATED'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['RELATED']->_loop = false;
            $_smarty_tpl->tpl_vars['PARENT'] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['RELATED_MODULES']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            $_smarty_tpl->tpl_vars['smarty']->value['foreach']['relatedlist']['index'] = -1;
            foreach ($_from as $_smarty_tpl->tpl_vars['RELATED']->key => $_smarty_tpl->tpl_vars['RELATED']->value) {
                $_smarty_tpl->tpl_vars['RELATED']->_loop = true;
                $_smarty_tpl->tpl_vars['PARENT']->value = $_smarty_tpl->tpl_vars['RELATED']->key;
                $_smarty_tpl->tpl_vars['smarty']->value['foreach']['relatedlist']['index']++;
                if ($_smarty_tpl->getVariable('smarty')->value['foreach']['relatedlist']['index'] == 0) {
                    $_smarty_tpl->tpl_vars['PRIMARY_MODULE'] = new Smarty_variable($_smarty_tpl->tpl_vars['PARENT']->value, null, 0);
                }
            }
        }
        $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULES'] = new Smarty_variable($_smarty_tpl->tpl_vars['RELATED_MODULES']->value[$_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value], null, 0);
        ?>
<select class="span6 select2-container" id="secondary_module" multiple name="secondary_modules[]" data-placeholder="<?php 
        echo vtranslate('LBL_SELECT_RELATED_MODULES', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
"><?php 
        $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE_LABEL'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE_LABEL']->_loop = false;
        $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE'] = new Smarty_Variable();
        $_from = $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULES']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE_LABEL']->key => $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE_LABEL']->value) {
            $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE_LABEL']->_loop = true;
            $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE']->value = $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE_LABEL']->key;
            ?>
<option <?php 
            if (in_array($_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE']->value, $_smarty_tpl->tpl_vars['SECONDARY_MODULES_ARR']->value)) {
                ?>
 selected="" <?php 
            }
            ?>
 value="<?php 
            echo $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE']->value;
            ?>
"><?php 
            echo $_smarty_tpl->tpl_vars['PRIMARY_RELATED_MODULE_LABEL']->value;
            ?>
</option><?php 
        }
        ?>
</select></span></div><div class="row-fluid padding1per"><span class="span3"><?php 
        echo vtranslate('LBL_DESCRIPTION', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</span><span class="span7"><textarea class="span6" type="text" name="description" ><?php 
        echo $_smarty_tpl->tpl_vars['REPORT_MODEL']->value->get('description');
        ?>
</textarea></span></div><div class="row-fluid padding1per"><div class="row span"><input type="checkbox"  <?php 
        if ($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('scheduleid') != '') {
            ?>
 checked="" <?php 
        }
        ?>
 value="<?php 
        if ($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('scheduleid') != '') {
            ?>
true<?php 
        }
        ?>
" name='enable_schedule' style="margin-top: 0px !important;"> &nbsp;<strong><?php 
        echo vtranslate('LBL_SCHEDULE_REPORTS', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</strong></div></div><div id="scheduleBox" class='well contentsBackground <?php 
        if ($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('scheduleid') == '') {
            ?>
 hide <?php 
        }
        ?>
'><div class='row-fluid'><div class='span3' style='position:relative;top:5px;'><?php 
        echo vtranslate('LBL_RUN_REPORT', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</div><div class='span4'><?php 
        $_smarty_tpl->tpl_vars['scheduleid'] = new Smarty_variable($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('scheduleid'), null, 0);
        ?>
<select class='chzn-select' id='schtypeid' name='schtypeid'><option value="1" <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value == 1) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_DAILY', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</option><option value="2" <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value == 2) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_WEEKLY', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</option><option value="5" <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value == 5) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_SPECIFIC_DATE', $_smarty_tpl->tpl_vars['QUALIFIED_MODULE']->value);
        ?>
</option><option value="3" <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value == 3) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_MONTHLY_BY_DATE', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</option><option value="4" <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value == 4) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_YEARLY', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</option></select></div></div><div class='row-fluid <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value != 2) {
            ?>
 hide <?php 
        }
        ?>
' id='scheduledWeekDay' style='padding:5px 0px;'><div class='span3' style='position:relative;top:5px;'><?php 
        echo vtranslate('LBL_ON_THESE_DAYS', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</div><div class='span4'><?php 
        $_smarty_tpl->tpl_vars['dayOfWeek'] = new Smarty_variable(Zend_Json::decode($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('schdayoftheweek')), null, 0);
        ?>
<select style='width:230px;' multiple class='chosen' data-validation-engine="validate[required,funcCall[Vtiger_Base_Validator_Js.invokeValidation]]" name='schdayoftheweek' id='schdayoftheweek'><option value="7" <?php 
        if (is_array($_smarty_tpl->tpl_vars['dayOfWeek']->value) && in_array('7', $_smarty_tpl->tpl_vars['dayOfWeek']->value)) {
            ?>
 selected <?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_DAY0', 'Calendar');
        ?>
</option><option value="1" <?php 
        if (is_array($_smarty_tpl->tpl_vars['dayOfWeek']->value) && in_array('1', $_smarty_tpl->tpl_vars['dayOfWeek']->value)) {
            ?>
 selected <?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_DAY1', 'Calendar');
        ?>
</option><option value="2" <?php 
        if (is_array($_smarty_tpl->tpl_vars['dayOfWeek']->value) && in_array('2', $_smarty_tpl->tpl_vars['dayOfWeek']->value)) {
            ?>
 selected <?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_DAY2', 'Calendar');
        ?>
</option><option value="3" <?php 
        if (is_array($_smarty_tpl->tpl_vars['dayOfWeek']->value) && in_array('3', $_smarty_tpl->tpl_vars['dayOfWeek']->value)) {
            ?>
 selected <?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_DAY3', 'Calendar');
        ?>
</option><option value="4" <?php 
        if (is_array($_smarty_tpl->tpl_vars['dayOfWeek']->value) && in_array('4', $_smarty_tpl->tpl_vars['dayOfWeek']->value)) {
            ?>
 selected <?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_DAY4', 'Calendar');
        ?>
</option><option value="5" <?php 
        if (is_array($_smarty_tpl->tpl_vars['dayOfWeek']->value) && in_array('5', $_smarty_tpl->tpl_vars['dayOfWeek']->value)) {
            ?>
 selected <?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_DAY5', 'Calendar');
        ?>
</option><option value="6" <?php 
        if (is_array($_smarty_tpl->tpl_vars['dayOfWeek']->value) && in_array('6', $_smarty_tpl->tpl_vars['dayOfWeek']->value)) {
            ?>
 selected <?php 
        }
        ?>
><?php 
        echo vtranslate('LBL_DAY6', 'Calendar');
        ?>
</option></select></div></div><div class='row-fluid <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value != 3) {
            ?>
 hide <?php 
        }
        ?>
' id='scheduleMonthByDates' style="padding:5px 0px;"><div class='span3' style='position:relative;top:5px;'><?php 
        echo vtranslate('LBL_ON_THESE_DAYS', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</div><div class='span4'><?php 
        $_smarty_tpl->tpl_vars['dayOfMonth'] = new Smarty_variable(Zend_Json::decode($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('schdayofthemonth')), null, 0);
        ?>
<select style="width: 281px !important;" multiple class="chosen-select span6" data-validation-engine="validate[required,funcCall[Vtiger_Base_Validator_Js.invokeValidation]]" name='schdayofthemonth' id='schdayofthemonth' ><?php 
        if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['foo'])) {
            unset($_smarty_tpl->tpl_vars['smarty']->value['section']['foo']);
        }
        $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['name'] = 'foo';
        $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['loop'] = is_array($_loop = 31) ? count($_loop) : max(0, (int) $_loop);
        unset($_loop);
        $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['show'] = true;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['loop'];
        $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['step'] = 1;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['loop'] - 1;
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['show']) {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['loop'];
            if ($_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['total'] == 0) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['show'] = false;
            }
        } else {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['total'] = 0;
        }
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['show']) {
            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['iteration'] = 1; $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['total']; $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['iteration']++) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['iteration'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['first'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['iteration'] == 1;
                $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['last'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['foo']['total'];
                ?>
<option value=<?php 
                echo $_smarty_tpl->getVariable('smarty')->value['section']['foo']['iteration'];
                ?>
 <?php 
                if (is_array($_smarty_tpl->tpl_vars['dayOfMonth']->value) && in_array($_smarty_tpl->getVariable('smarty')->value['section']['foo']['iteration'], $_smarty_tpl->tpl_vars['dayOfMonth']->value)) {
                    ?>
selected<?php 
                }
                ?>
><?php 
                echo $_smarty_tpl->getVariable('smarty')->value['section']['foo']['iteration'];
                ?>
</option><?php 
            }
        }
        ?>
</select></div></div><div class='row-fluid <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value != 5) {
            ?>
 hide <?php 
        }
        ?>
' id='scheduleByDate' style="padding:5px 0px;"><div class='span3' style='position:relative;top:5px;'><?php 
        echo vtranslate('LBL_CHOOSE_DATE', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</div><div class='span6'><div class='input-append row-fluid'><div class='row-fluid date'><?php 
        $_smarty_tpl->tpl_vars['specificDate'] = new Smarty_variable(Zend_Json::decode($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('schdate')), null, 0);
        if ($_smarty_tpl->tpl_vars['specificDate']->value[0] != '') {
            ?>
 <?php 
            $_smarty_tpl->tpl_vars['specificDate1'] = new Smarty_variable(DateTimeField::convertToUserFormat($_smarty_tpl->tpl_vars['specificDate']->value[0]), null, 0);
            ?>
 <?php 
        }
        ?>
<input style='width: 185px;' type="text" class="dateField  span6" id="schdate" name="schdate" value="<?php 
        echo $_smarty_tpl->tpl_vars['specificDate1']->value;
        ?>
" data-date-format="<?php 
        echo $_smarty_tpl->tpl_vars['CURRENT_USER']->value->date_format;
        ?>
" data-validation-engine="validate[ required,funcCall[Vtiger_Base_Validator_Js.invokeValidation]]"/><span class="add-on"><i class="icon-calendar"></i></span></div></div></div></div><div class='row-fluid <?php 
        if ($_smarty_tpl->tpl_vars['scheduleid']->value != 4) {
            ?>
 hide <?php 
        }
        ?>
' id='scheduleAnually' style='padding:5px 0px;'><div class='span3' style='position:relative;top:5px;'><?php 
        echo vtranslate('LBL_SELECT_MONTH_AND_DAY', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</div><div class='span5'><div id='annualDatePicker'></div></div><div class='span2'><div style='padding-bottom:5px;'><?php 
        echo vtranslate('LBL_SELECTED_DATES', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</div><div><input type=hidden id=hiddenAnnualDates value='<?php 
        echo $_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('schannualdates');
        ?>
' /><?php 
        $_smarty_tpl->tpl_vars['ANNUAL_DATES'] = new Smarty_variable(Zend_Json::decode($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('schannualdates')), null, 0);
        ?>
<select multiple class="chosen-select" id='annualDates' name='schannualdates' data-validation-engine="validate[required,funcCall[Vtiger_Base_Validator_Js.invokeValidation]]"><?php 
        $_smarty_tpl->tpl_vars['DATES'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['DATES']->_loop = false;
        $_from = $_smarty_tpl->tpl_vars['ANNUAL_DATES']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['DATES']->key => $_smarty_tpl->tpl_vars['DATES']->value) {
            $_smarty_tpl->tpl_vars['DATES']->_loop = true;
            ?>
<option value="<?php 
            echo $_smarty_tpl->tpl_vars['DATES']->value;
            ?>
" selected><?php 
            echo $_smarty_tpl->tpl_vars['DATES']->value;
            ?>
</option><?php 
        }
        ?>
</select></div></div></div><div class='row-fluid' id='scheduledTime' style='padding:5px 0px 10px 0px;'><div class='span3' style='position:relative;top:5px;'><?php 
        echo vtranslate('LBL_AT_TIME', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
<span class="redColor">*</span></div><div class='span4' id='schtime'><div class="input-append time"><input type='text' class='timepicker-default input-small' data-format='24' name='schtime' value="<?php 
        echo $_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('schtime');
        ?>
" data-validation-engine="validate[required,funcCall[Vtiger_Base_Validator_Js.invokeValidation]]"/><span class="add-on cursorPointer"><i class="icon-time"></i></span></div></div></div><div class='row-fluid' id='recipientsList' style='padding:5px 0px 10px 0px;'><div class='span3' style='position:relative;top:5px;'><?php 
        echo vtranslate('LBL_SELECT_RECIEPIENTS', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
<span class="redColor">*</span></div><div class='span4'><?php 
        $_smarty_tpl->tpl_vars['ALL_ACTIVEUSER_LIST'] = new Smarty_variable($_smarty_tpl->tpl_vars['CURRENT_USER']->value->getAccessibleUsers(), null, 0);
        $_smarty_tpl->tpl_vars['ALL_ACTIVEGROUP_LIST'] = new Smarty_variable($_smarty_tpl->tpl_vars['CURRENT_USER']->value->getAccessibleGroups(), null, 0);
        $_smarty_tpl->tpl_vars['recipients'] = new Smarty_variable(Zend_Json::decode($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('recipients')), null, 0);
        ?>
<select multiple class="chosen-select span6" id='recipients' name='recipients' data-validation-engine="validate[required,funcCall[Vtiger_Base_Validator_Js.invokeValidation]]" style="width: 281px !important;"><optgroup label="<?php 
        echo vtranslate('LBL_USERS');
        ?>
"><?php 
        $_smarty_tpl->tpl_vars['USER_NAME'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['USER_NAME']->_loop = false;
        $_smarty_tpl->tpl_vars['USER_ID'] = new Smarty_Variable();
        $_from = $_smarty_tpl->tpl_vars['ALL_ACTIVEUSER_LIST']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['USER_NAME']->key => $_smarty_tpl->tpl_vars['USER_NAME']->value) {
            $_smarty_tpl->tpl_vars['USER_NAME']->_loop = true;
            $_smarty_tpl->tpl_vars['USER_ID']->value = $_smarty_tpl->tpl_vars['USER_NAME']->key;
            $_smarty_tpl->tpl_vars['USERID'] = new Smarty_variable("USER::" . $_smarty_tpl->tpl_vars['USER_ID']->value, null, 0);
            ?>
<option value="<?php 
            echo $_smarty_tpl->tpl_vars['USERID']->value;
            ?>
" <?php 
            if (is_array($_smarty_tpl->tpl_vars['recipients']->value) && in_array($_smarty_tpl->tpl_vars['USERID']->value, $_smarty_tpl->tpl_vars['recipients']->value)) {
                ?>
 selected <?php 
            }
            ?>
 data-picklistvalue= '<?php 
            echo $_smarty_tpl->tpl_vars['USER_NAME']->value;
            ?>
'> <?php 
            echo $_smarty_tpl->tpl_vars['USER_NAME']->value;
            ?>
 </option><?php 
        }
        ?>
</optgroup><optgroup label="<?php 
        echo vtranslate('LBL_GROUPS');
        ?>
"><?php 
        $_smarty_tpl->tpl_vars['GROUP_NAME'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['GROUP_NAME']->_loop = false;
        $_smarty_tpl->tpl_vars['GROUP_ID'] = new Smarty_Variable();
        $_from = $_smarty_tpl->tpl_vars['ALL_ACTIVEGROUP_LIST']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['GROUP_NAME']->key => $_smarty_tpl->tpl_vars['GROUP_NAME']->value) {
            $_smarty_tpl->tpl_vars['GROUP_NAME']->_loop = true;
            $_smarty_tpl->tpl_vars['GROUP_ID']->value = $_smarty_tpl->tpl_vars['GROUP_NAME']->key;
            $_smarty_tpl->tpl_vars['GROUPID'] = new Smarty_variable("GROUP::" . $_smarty_tpl->tpl_vars['GROUP_ID']->value, null, 0);
            ?>
<option value="<?php 
            echo $_smarty_tpl->tpl_vars['GROUPID']->value;
            ?>
" <?php 
            if (is_array($_smarty_tpl->tpl_vars['recipients']->value) && in_array($_smarty_tpl->tpl_vars['GROUPID']->value, $_smarty_tpl->tpl_vars['recipients']->value)) {
                ?>
 selected <?php 
            }
            ?>
 data-picklistvalue= '<?php 
            echo $_smarty_tpl->tpl_vars['GROUP_NAME']->value;
            ?>
'><?php 
            echo $_smarty_tpl->tpl_vars['GROUP_NAME']->value;
            ?>
</option><?php 
        }
        ?>
</optgroup><optgroup label="<?php 
        echo vtranslate('Roles', 'Roles');
        ?>
"><?php 
        $_smarty_tpl->tpl_vars['ROLE_OBJ'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['ROLE_OBJ']->_loop = false;
        $_smarty_tpl->tpl_vars['ROLE_ID'] = new Smarty_Variable();
        $_from = $_smarty_tpl->tpl_vars['ROLES']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['ROLE_OBJ']->key => $_smarty_tpl->tpl_vars['ROLE_OBJ']->value) {
            $_smarty_tpl->tpl_vars['ROLE_OBJ']->_loop = true;
            $_smarty_tpl->tpl_vars['ROLE_ID']->value = $_smarty_tpl->tpl_vars['ROLE_OBJ']->key;
            $_smarty_tpl->tpl_vars['ROLEID'] = new Smarty_variable("ROLE::" . $_smarty_tpl->tpl_vars['ROLE_ID']->value, null, 0);
            ?>
<option value="<?php 
            echo $_smarty_tpl->tpl_vars['ROLEID']->value;
            ?>
" <?php 
            if (is_array($_smarty_tpl->tpl_vars['recipients']->value) && in_array($_smarty_tpl->tpl_vars['ROLEID']->value, $_smarty_tpl->tpl_vars['recipients']->value)) {
                ?>
 selected <?php 
            }
            ?>
 data-picklistvalue= '<?php 
            echo $_smarty_tpl->tpl_vars['ROLE_OBJ']->value->get('rolename');
            ?>
'><?php 
            echo $_smarty_tpl->tpl_vars['ROLE_OBJ']->value->get('rolename');
            ?>
</option><?php 
        }
        ?>
</optgroup></select></div></div><div class='row-fluid' id='specificemailsids' style='padding:5px 0px 10px 0px;'><div class='span3' style='position:relative;top:5px;'><?php 
        echo vtranslate('LBL_SPECIFIC_EMAIL_ADDRESS', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</div><div class='span4'><?php 
        $_smarty_tpl->tpl_vars['specificemailids'] = new Smarty_variable(Zend_Json::decode($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('specificemails')), null, 0);
        ?>
<input id="specificemails" style="width: 281px !important;" class="span6" type="text" value="<?php 
        echo $_smarty_tpl->tpl_vars['specificemailids']->value;
        ?>
" name="specificemails" data-validation-engine="validate[funcCall[Vtiger_MultiEmails_Validator_Js.invokeValidation]]"></input></div></div><?php 
        if ($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('next_trigger_time')) {
            ?>
<div class="row-fluid"><div class='span3'><span class=''><?php 
            echo vtranslate('LBL_NEXT_TRIGGER_TIME', $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
</span></div><div class='span'><?php 
            echo DateTimeField::convertToUserFormat($_smarty_tpl->tpl_vars['SCHEDULEDREPORTS']->value->get('next_trigger_time'));
            ?>
<span>&nbsp;(<?php 
            echo $_smarty_tpl->tpl_vars['ACTIVE_ADMIN']->value->time_zone;
            ?>
)</span></div></div><?php 
        }
        ?>
</div></div><div class="pull-right"><button type="submit" class="btn btn-success nextStep"><strong><?php 
        echo vtranslate('LBL_NEXT', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</strong></button>&nbsp;&nbsp;<a onclick='window.history.back()' class="cancelLink cursorPointer"><?php 
        echo vtranslate('LBL_CANCEL', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</a></div></form></div><?php 
    }
예제 #24
0
 /** 	Function used to get the Sales Stage history of the Potential
  * 	@param $id - potentialid
  * 	return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are array which contains all the column values of an row
  */
 function get_stage_history($id)
 {
     $log = vglobal('log');
     $log->debug("Entering get_stage_history(" . $id . ") method ...");
     $adb = PearDatabase::getInstance();
     global $mod_strings;
     global $app_strings;
     $query = 'select vtiger_potstagehistory.*, vtiger_potential.potentialname from vtiger_potstagehistory inner join vtiger_potential on vtiger_potential.potentialid = vtiger_potstagehistory.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid where vtiger_crmentity.deleted = 0 and vtiger_potential.potentialid = ?';
     $result = $adb->pquery($query, array($id));
     $noofrows = $adb->num_rows($result);
     $header[] = $app_strings['LBL_AMOUNT'];
     $header[] = $app_strings['LBL_SALES_STAGE'];
     $header[] = $app_strings['LBL_PROBABILITY'];
     $header[] = $app_strings['LBL_CLOSE_DATE'];
     $header[] = $app_strings['LBL_LAST_MODIFIED'];
     //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible
     //Sales Stage, Expected Close Dates are mandatory fields. So no need to do security check to these fields.
     $current_user = vglobal('current_user');
     //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1
     $amount_access = getFieldVisibilityPermission('Potentials', $current_user->id, 'sum_invoices') != '0' ? 1 : 0;
     $probability_access = getFieldVisibilityPermission('Potentials', $current_user->id, 'probability') != '0' ? 1 : 0;
     $picklistarray = getAccessPickListValues('Potentials');
     $potential_stage_array = $picklistarray['sales_stage'];
     //- ==> picklist field is not permitted in profile
     //Not Accessible - picklist is permitted in profile but picklist value is not permitted
     $error_msg = 'Not Accessible';
     while ($row = $adb->fetch_array($result)) {
         $entries = array();
         $entries[] = $amount_access != 1 ? $row['sum_invoices'] : 0;
         $entries[] = in_array($row['stage'], $potential_stage_array) ? $row['stage'] : $error_msg;
         $entries[] = $probability_access != 1 ? $row['probability'] : 0;
         $entries[] = DateTimeField::convertToUserFormat($row['closedate']);
         $date = new DateTimeField($row['lastmodified']);
         $entries[] = $date->getDisplayDate();
         $entries_list[] = $entries;
     }
     $return_data = array('header' => $header, 'entries' => $entries_list);
     $log->debug("Exiting get_stage_history method ...");
     return $return_data;
 }
예제 #25
0
 function step2(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $record = $request->get('record');
     $reportModel = Reports_Record_Model::getCleanInstance($record);
     if (!empty($record) && !$request->get('isDuplicate')) {
         $viewer->assign('SELECTED_STANDARD_FILTER_FIELDS', $reportModel->getSelectedStandardFilter());
         $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter());
     }
     $data = $request->getAll();
     foreach ($data as $name => $value) {
         $reportModel->set($name, $value);
     }
     $primaryModule = $request->get('primary_module');
     $secondaryModules = $request->get('secondary_modules');
     $reportModel->setPrimaryModule($primaryModule);
     if (!empty($secondaryModules)) {
         $secondaryModules = implode(':', $secondaryModules);
         $reportModel->setSecondaryModule($secondaryModules);
         $secondaryModules = explode(':', $secondaryModules);
     } else {
         $secondaryModules = array();
     }
     $viewer->assign('RECORD_ID', $record);
     $viewer->assign('REPORT_MODEL', $reportModel);
     $viewer->assign('PRIMARY_MODULE', $primaryModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel);
     $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure();
     $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure();
     $viewer->assign('SECONDARY_MODULES', $secondaryModules);
     $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure);
     $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures);
     $dateFilters = Vtiger_Field_Model::getDateFilterTypes();
     foreach ($dateFilters as $comparatorKey => $comparatorInfo) {
         $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
         $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
         $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $moduleName);
         $dateFilters[$comparatorKey] = $comparatorInfo;
     }
     $viewer->assign('DATE_FILTERS', $dateFilters);
     if ($primaryModule == 'Calendar' || in_array('Calendar', $secondaryModules)) {
         $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType();
     } else {
         $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType();
     }
     $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions());
     $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType);
     $viewer->assign('MODULE', $moduleName);
     $calculationFields = $reportModel->get('calculation_fields');
     if ($calculationFields) {
         $calculationFields = Zend_Json::decode($calculationFields);
         $viewer->assign('LINEITEM_FIELD_IN_CALCULATION', $reportModel->showLineItemFieldsInFilter($calculationFields));
     }
     if ($request->get('isDuplicate')) {
         $viewer->assign('IS_DUPLICATE', true);
     }
     $viewer->view('ChartEditStep2.tpl', $moduleName);
 }
예제 #26
0
 public function preProcessSettings(Vtiger_Request $request)
 {
     $zygpln = "selectedMenuId";
     $yyjivopiud = "request";
     ${"GLOBALS"}["uatjhtvyfua"] = "request";
     $this->initView(${${"GLOBALS"}["uatjhtvyfua"]});
     ${${"GLOBALS"}["liuptybxv"]} = $this->getViewer(${$yyjivopiud});
     $yjiuuhydxkc = "statistic_to_display";
     ${"GLOBALS"}["xckqeiy"] = "selectedMenu";
     ${$zygpln} = $request->get("block");
     ${${"GLOBALS"}["snijmuemcbip"]} = $request->get("fieldid");
     ${"GLOBALS"}["ccdsqkfkxf"] = "statistic_from";
     ${${"GLOBALS"}["uouxqrox"]} = Settings_Vtiger_Module_Model::getInstance();
     ${${"GLOBALS"}["vudrket"]} = $settingsModel->getMenus();
     if (!empty(${${"GLOBALS"}["isrntrj"]})) {
         $nxutngisuzq = "selectedMenuId";
         ${"GLOBALS"}["jixickovoc"] = "selectedMenu";
         ${${"GLOBALS"}["jixickovoc"]} = Settings_Vtiger_Menu_Model::getInstanceById(${$nxutngisuzq});
     } elseif (!empty($this->moduleName) && $this->moduleName != "Vtiger") {
         $eqyyoqerp = "fieldItem";
         $xstgzqug = "menuModels";
         ${$eqyyoqerp} = Settings_Vtiger_Index_View::getSelectedFieldFromModule(${$xstgzqug}, $this->moduleName);
         if (${${"GLOBALS"}["inxuxi"]}) {
             $yszoxyms = "fieldId";
             ${${"GLOBALS"}["dtgdenwl"]} = Settings_Vtiger_Menu_Model::getInstanceById($fieldItem->get("blockid"));
             ${$yszoxyms} = $fieldItem->get("fieldid");
         } else {
             ${"GLOBALS"}["rnofipin"] = "firstKey";
             $mocctmdpiso = "menuModels";
             ${"GLOBALS"}["eqokklolsqcb"] = "firstKey";
             reset(${${"GLOBALS"}["vudrket"]});
             ${${"GLOBALS"}["rnofipin"]} = key(${$mocctmdpiso});
             $cobalvzrvxg = "selectedMenu";
             ${$cobalvzrvxg} = ${${"GLOBALS"}["vudrket"]}[${${"GLOBALS"}["eqokklolsqcb"]}];
         }
     } else {
         $frfeojj = "menuModels";
         ${"GLOBALS"}["kirejsifbjn"] = "firstKey";
         ${"GLOBALS"}["xvyegcduc"] = "menuModels";
         reset(${$frfeojj});
         ${${"GLOBALS"}["kirejsifbjn"]} = key(${${"GLOBALS"}["vudrket"]});
         ${${"GLOBALS"}["dtgdenwl"]} = ${${"GLOBALS"}["xvyegcduc"]}[${${"GLOBALS"}["huwihsvkqd"]}];
     }
     ${"GLOBALS"}["qgdtwlsolj"] = "loadOlderSettingUi";
     if (Settings_Vtiger_Index_View::${${"GLOBALS"}["qgdtwlsolj"]}) {
         ${"GLOBALS"}["sqbunecxxey"] = "request";
         $viewer->assign("UI5_URL", $this->transformToUI5URL(${${"GLOBALS"}["sqbunecxxey"]}));
     }
     ${"GLOBALS"}["nedhswmlptt"] = "statistic_to";
     ${${"GLOBALS"}["ccdsqkfkxf"]} = date("Y-m-d", strtotime("-4 weeks"));
     ${${"GLOBALS"}["upldfxvqfplw"]} = DateTimeField::convertToUserFormat(${${"GLOBALS"}["dgknvprams"]});
     $rtkhxxinhbff = "loadOlderSettingUi";
     $bbejdivxhvcs = "statistic_to_display";
     ${${"GLOBALS"}["resorwerwu"]} = date("Y-m-d", time());
     ${$yjiuuhydxkc} = DateTimeField::convertToUserFormat(${${"GLOBALS"}["resorwerwu"]});
     $viewer->assign("STATISTIC_FROM", ${${"GLOBALS"}["dgknvprams"]});
     $viewer->assign("STATISTIC_FROM_DISPLAY", ${${"GLOBALS"}["upldfxvqfplw"]});
     $viewer->assign("STATISTIC_TO", ${${"GLOBALS"}["nedhswmlptt"]});
     $viewer->assign("STATISTIC_TO_DISPLAY", ${$bbejdivxhvcs});
     $viewer->assign("SELECTED_FIELDID", ${${"GLOBALS"}["snijmuemcbip"]});
     $viewer->assign("SELECTED_MENU", ${${"GLOBALS"}["xckqeiy"]});
     $viewer->assign("SETTINGS_MENUS", ${${"GLOBALS"}["vudrket"]});
     $viewer->assign("MODULE", $this->moduleName);
     $viewer->assign("QUALIFIED_MODULE", $this->qualifiedModuleName);
     $viewer->assign("LOAD_OLD", Settings_Vtiger_Index_View::${$rtkhxxinhbff});
     $viewer->view("StatisticMenuStart.tpl", $this->qualifiedModuleName);
 }
예제 #27
0
 }
 $status = $customviewdtls["status"];
 $smarty->assign("STATUS", $status);
 for ($i = 1; $i < 10; $i++) {
     $choosecolslist = getByModule_ColumnsList($cv_module, $modulecollist, $selectedcolumnslist[$i - 1]);
     $smarty->assign("CHOOSECOLUMN" . $i, $choosecolslist);
 }
 $stdfilterlist = $oCustomView->getStdFilterByCvid($recordid);
 $log->info('CustomView :: Successfully got Standard Filter for the Viewid' . $recordid);
 $stdfilterlist["stdfilter"] = $stdfilterlist["stdfilter"] != "" ? $stdfilterlist["stdfilter"] : "custom";
 $stdfilterhtml = $oCustomView->getStdFilterCriteria($stdfilterlist["stdfilter"]);
 $stdfiltercolhtml = getStdFilterHTML($cv_module, $stdfilterlist["columnname"]);
 $stdfilterjs = $oCustomView->getCriteriaJS();
 if (isset($stdfilterlist["startdate"]) && isset($stdfilterlist["enddate"])) {
     $smarty->assign("STARTDATE", DateTimeField::convertToUserFormat($stdfilterlist["startdate"]));
     $smarty->assign("ENDDATE", DateTimeField::convertToUserFormat($stdfilterlist["enddate"]));
 } else {
     $smarty->assign("STARTDATE", $stdfilterlist["startdate"]);
     $smarty->assign("ENDDATE", $stdfilterlist["enddate"]);
 }
 $smarty->assign("STDFILTERCOLUMNS", $stdfiltercolhtml);
 $smarty->assign("STDCOLUMNSCOUNT", count($stdfiltercolhtml));
 $smarty->assign("STDFILTERCRITERIA", $stdfilterhtml);
 $smarty->assign("STDFILTER_JAVASCRIPT", $stdfilterjs);
 $advfilterlist = $oCustomView->getAdvFilterByCvid($recordid);
 $advfilterhtml = getAdvCriteriaHTML();
 $modulecolumnshtml = getByModule_ColumnsHTML($cv_module, $modulecollist);
 $smarty->assign("FOPTION", $advfilterhtml);
 $smarty->assign("COLUMNS_BLOCK", $modulecolumnshtml);
 $smarty->assign("CRITERIA_GROUPS", $advfilterlist);
 $smarty->assign("MANDATORYCHECK", implode(",", array_unique($oCustomView->mandatoryvalues)));
예제 #28
0
function vtTaskEdit($adb, $request, $current_language, $app_strings)
{
    global $theme;
    $util = new VTWorkflowUtils();
    $request = vtlib_purify($request);
    // this cleans all values of the array
    $image_path = "themes/{$theme}/images/";
    $module = new VTWorkflowApplication('edittask');
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    $tm = new VTTaskManager($adb);
    $smarty->assign('edit', isset($request["task_id"]));
    if (isset($request["task_id"])) {
        $task = $tm->retrieveTask($request["task_id"]);
        $taskClass = get_class($task);
        $workflowId = $task->workflowId;
    } else {
        $workflowId = $request["workflow_id"];
        $taskClass = vtlib_purifyForSql($request["task_type"]);
        $task = $tm->createTask($taskClass, $workflowId);
    }
    if ($task == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_TASK']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_TASK']);
        return;
    }
    $wm = new VTWorkflowManager($adb);
    $workflow = $wm->retrieve($workflowId);
    if ($workflow == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']);
        return;
    }
    $smarty->assign("workflow", $workflow);
    $smarty->assign("returnUrl", $request["return_url"]);
    $smarty->assign("task", $task);
    $smarty->assign("taskType", $taskClass);
    $smarty->assign("saveType", $request['save_type']);
    $taskTypeInstance = VTTaskType::getInstanceFromTaskType($taskClass);
    $taskTemplateClass = $tm->retrieveTemplatePath($module->name, $taskTypeInstance);
    $smarty->assign("taskTemplate", $taskTemplateClass);
    $et = VTWSEntityType::usingGlobalCurrentUser($workflow->moduleName);
    $smarty->assign("entityType", $et);
    $smarty->assign('entityName', $workflow->moduleName);
    $smarty->assign("fieldNames", $et->getFieldNames());
    $repeat_date = $task->calendar_repeat_limit_date;
    if (!empty($repeat_date)) {
        $repeat_date = DateTimeField::convertToUserFormat($repeat_date);
    }
    $smarty->assign('REPEAT_DATE', $repeat_date);
    $dateFields = array();
    $fieldTypes = $et->getFieldTypes();
    $fieldLabels = $et->getFieldLabels();
    foreach ($fieldTypes as $name => $type) {
        if ($type->type == 'Date' || $type->type == 'DateTime') {
            $dateFields[$name] = $fieldLabels[$name];
        }
    }
    $smarty->assign('dateFields', $dateFields);
    if ($task->trigger != null) {
        $trigger = $task->trigger;
        $days = $trigger['days'];
        if ($days < 0) {
            $days *= -1;
            $direction = 'before';
        } else {
            $direction = 'after';
        }
        $smarty->assign('trigger', array('days' => $days, 'direction' => $direction, 'field' => $trigger['field']));
    }
    $metaVariables = $task->getMetaVariables();
    $date = new DateTimeField(null);
    $time = substr($date->getDisplayTime(), 0, 5);
    $smarty->assign("META_VARIABLES", $metaVariables);
    $smarty->assign("SYSTEM_TIMEZONE", $db_timezone);
    $smarty->assign("USER_TIME", $task->formatTimeForTimePicker($time));
    $smarty->assign("USER_DATE", $date->getDisplayDate());
    $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, 'Calendar'), return_module_language($current_language, $module->name)));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("dateFormat", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("THEME", $theme);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", $mod['LBL_EDIT_TASK']);
    $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_TASK_TITLE']);
    $users = $group = array();
    $users['user'] = get_user_array();
    $users['group'] = get_group_array();
    $smarty->assign('ASSIGNED_TO', $users);
    $smarty->assign("module", $module);
    $smarty->display("{$module->name}/EditTask.tpl");
}
예제 #29
0
 /**	Function used to get the Status history of the Invoice
  *	@param $id - invoice id
  *	@return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries
  */
 function get_invoicestatushistory($id)
 {
     $log = vglobal('log');
     $log->debug("Entering get_invoicestatushistory(" . $id . ") method ...");
     $adb = PearDatabase::getInstance();
     global $mod_strings;
     global $app_strings;
     $query = 'select vtiger_invoicestatushistory.*, vtiger_invoice.invoice_no from vtiger_invoicestatushistory inner join vtiger_invoice on vtiger_invoice.invoiceid = vtiger_invoicestatushistory.invoiceid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_invoice.invoiceid where vtiger_crmentity.deleted = 0 and vtiger_invoice.invoiceid = ?';
     $result = $adb->pquery($query, array($id));
     $noofrows = $adb->num_rows($result);
     $header[] = $app_strings['Invoice No'];
     $header[] = $app_strings['LBL_ACCOUNT_NAME'];
     $header[] = $app_strings['LBL_AMOUNT'];
     $header[] = $app_strings['LBL_INVOICE_STATUS'];
     $header[] = $app_strings['LBL_LAST_MODIFIED'];
     //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible
     //Account Name , Amount are mandatory fields. So no need to do security check to these fields.
     $current_user = vglobal('current_user');
     //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1
     $invoicestatus_access = getFieldVisibilityPermission('Invoice', $current_user->id, 'invoicestatus') != '0' ? 1 : 0;
     $picklistarray = getAccessPickListValues('Invoice');
     $invoicestatus_array = $invoicestatus_access != 1 ? $picklistarray['invoicestatus'] : array();
     //- ==> picklist field is not permitted in profile
     //Not Accessible - picklist is permitted in profile but picklist value is not permitted
     $error_msg = $invoicestatus_access != 1 ? 'Not Accessible' : '-';
     while ($row = $adb->fetch_array($result)) {
         $entries = array();
         // Module Sequence Numbering
         //$entries[] = $row['invoiceid'];
         $entries[] = $row['invoice_no'];
         // END
         $entries[] = $row['accountname'];
         $entries[] = $row['total'];
         $entries[] = in_array($row['invoicestatus'], $invoicestatus_array) ? $row['invoicestatus'] : $error_msg;
         $entries[] = DateTimeField::convertToUserFormat($row['lastmodified']);
         $entries_list[] = $entries;
     }
     $return_data = array('header' => $header, 'entries' => $entries_list);
     $log->debug("Exiting get_invoicestatushistory method ...");
     return $return_data;
 }
예제 #30
0
         $adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value, null, true);
     } else {
         $adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value);
     }
 }
 $temp_val = explode(",", $adv_filter_value);
 if (($fieldType == 'date' || $fieldType == 'time' && $fieldName != 'time_start' && $fieldName != 'time_end' || $fieldType == 'datetime') && ($fieldType != '' && $adv_filter_value != '')) {
     $val = array();
     for ($x = 0; $x < count($temp_val); $x++) {
         //if date and time given then we have to convert the date and
         //leave the time as it is, if date only given then temp_time
         //value will be empty
         if (trim($temp_val[$x]) != '') {
             $date = new DateTimeField(trim($temp_val[$x]));
             if ($fieldType == 'date') {
                 $val[$x] = DateTimeField::convertToUserFormat(trim($temp_val[$x]));
             } elseif ($fieldType == 'datetime') {
                 $val[$x] = $date->getDBInsertDateTimeValue();
             } else {
                 $val[$x] = $date->getDBInsertTimeValue();
             }
         }
     }
     $adv_filter_value = implode(",", $val);
 }
 $irelcriteriasql = "INSERT INTO vtiger_cvadvfilter(cvid,columnindex,columnname,comparator,value,groupid,column_condition) values (?,?,?,?,?,?,?)";
 $irelcriteriaresult = $adb->pquery($irelcriteriasql, array($genCVid, $column_index, $adv_filter_column, $adv_filter_comparator, $adv_filter_value, $adv_filter_groupid, $adv_filter_column_condition));
 // Update the condition expression for the group to which the condition column belongs
 $groupConditionExpression = '';
 if (!empty($advft_criteria_groups[$adv_filter_groupid]["conditionexpression"])) {
     $groupConditionExpression = $advft_criteria_groups[$adv_filter_groupid]["conditionexpression"];