Example #1
0
 public function getBreadcrumbTitle(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     if ($request->has('isDuplicate')) {
         $pageTitle = vtranslate('LBL_VIEW_DUPLICATE', $moduleName);
     } elseif ($request->has('record')) {
         $pageTitle = vtranslate('LBL_VIEW_EDIT', $moduleName);
     } else {
         $pageTitle = vtranslate('LBL_VIEW_CREATE', $moduleName);
     }
     return $pageTitle;
 }
Example #2
0
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $srecord = $request->get('srecord');
     $smodule = $request->get('smodule');
     $type = $request->get('type');
     $mode = $request->get('mode');
     $record = $request->get('record');
     $mailFilter = $request->get('mailFilter');
     $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
     $recordModel_OSSMailScanner = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
     $config = $recordModel_OSSMailScanner->getConfig('email_list');
     if ($request->has('limit')) {
         $config['widget_limit'] = $request->get('limit');
     }
     $viewer = $this->getViewer($request);
     $viewer->assign('RECOLDLIST', $recordModel->{$mode}($srecord, $smodule, $config, $type, $mailFilter));
     $viewer->assign('SENDURLDDATA', $urldata);
     $viewer->assign('MODULENAME', $moduleName);
     $viewer->assign('SMODULENAME', $smodule);
     $viewer->assign('RECORD', $record);
     $viewer->assign('SRECORD', $srecord);
     $viewer->assign('TYPE', $type);
     $viewer->assign('POPUP', $config['popup']);
     $viewer->view('widgets.tpl', 'OSSMailView');
 }
Example #3
0
 function process(Vtiger_Request $request)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $moduleName = $request->getModule();
     $componentName = $request->get('name');
     $linkId = $request->get('linkid');
     if (!empty($componentName)) {
         $className = Vtiger_Loader::getComponentClassName('Dashboard', $componentName, $moduleName);
         if (!empty($className)) {
             $widget = NULL;
             if (!empty($linkId)) {
                 $widget = new Vtiger_Widget_Model();
                 $widget->set('linkid', $linkId);
                 $widget->set('userid', $currentUser->getId());
                 $widget->set('filterid', $request->get('filterid', NULL));
                 if ($request->has('data')) {
                     $widget->set('data', $request->get('data'));
                 }
                 $widget->add();
             }
             $classInstance = new $className();
             $classInstance->process($request, $widget);
             return;
         }
     }
     $response = new Vtiger_Response();
     $response->setResult(array('success' => false, 'message' => vtranslate('NO_DATA')));
     $response->emit();
 }
Example #4
0
 public function save(Vtiger_Request $request)
 {
     $fieldId = $request->get('fieldid');
     $fieldInstance = Vtiger_Field_Model::getInstance($fieldId);
     $fields = ['presence', 'quickcreate', 'summaryfield', 'helpinfo', 'generatedtype', 'masseditable', 'displaytype'];
     foreach ($request->getAll() as $key => $value) {
         if ($key == 'mandatory') {
             $fieldInstance->updateTypeofDataFromMandatory($value);
         }
         if (in_array($key, $fields)) {
             $fieldInstance->set($key, $value);
         }
     }
     $defaultValue = $request->get('fieldDefaultValue');
     if ($fieldInstance->getFieldDataType() == 'date') {
         $dateInstance = new Vtiger_Date_UIType();
         $defaultValue = $dateInstance->getDBInsertedValue($defaultValue);
     }
     if ($request->has('fieldMask')) {
         $fieldInstance->set('fieldparams', $request->get('fieldMask'));
     }
     if (is_array($defaultValue)) {
         $defaultValue = implode(' |##| ', $defaultValue);
     }
     $fieldInstance->set('defaultvalue', $defaultValue);
     $response = new Vtiger_Response();
     try {
         $fieldInstance->save();
         $response->setResult(array('success' => true, 'presence' => $request->get('presence'), 'mandatory' => $fieldInstance->isMandatory(), 'label' => vtranslate($fieldInstance->get('label'), $request->get('sourceModule'))));
     } catch (Exception $e) {
         $response->setError($e->getCode(), $e->getMessage());
     }
     $response->emit();
 }
 public function process(Vtiger_Request $request)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $moduleName = $request->getModule();
     $page = $request->get('page');
     $linkId = $request->get('linkid');
     $widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
     if (!$request->has('owner')) {
         $owner = Settings_WidgetsManagement_Module_Model::getDefaultUserId($widget);
     } else {
         $owner = $request->get('owner');
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $page);
     $pagingModel->set('limit', (int) $widget->get('limit'));
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $overDueActivities = $owner === false ? array() : $moduleModel->getCalendarActivities('overdue', $pagingModel, $owner);
     $viewer = $this->getViewer($request);
     $viewer->assign('WIDGET', $widget);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('ACTIVITIES', $overDueActivities);
     $viewer->assign('PAGING', $pagingModel);
     $viewer->assign('CURRENTUSER', $currentUser);
     $title_max_length = vglobal('title_max_length');
     $href_max_length = vglobal('href_max_length');
     $viewer->assign('NAMELENGHT', $title_max_length);
     $viewer->assign('HREFNAMELENGHT', $href_max_length);
     $viewer->assign('NODATAMSGLABLE', 'LBL_NO_OVERDUE_ACTIVITIES');
     $content = $request->get('content');
     if (!empty($content)) {
         $viewer->view('dashboards/CalendarActivitiesContents.tpl', $moduleName);
     } else {
         $viewer->view('dashboards/CalendarActivities.tpl', $moduleName);
     }
 }
Example #6
0
 public function process(Vtiger_Request $request)
 {
     PDFMaker_Debugger_Model::GetInstance()->Init();
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     if ($PDFMaker->CheckPermissions("DELETE") == false) {
         $PDFMaker->DieDuePermission();
     }
     $adb = PearDatabase::getInstance();
     $id_array = array();
     if ($request->has('templateid') && !$request->isEmpty('templateid')) {
         $templateid = $request->get('templateid');
         $checkSql = "select module from vtiger_pdfmaker where templateid=?";
         $checkRes = $adb->pquery($checkSql, array($templateid));
         $checkRow = $adb->fetchByAssoc($checkRes);
         //if we are trying to delete template that is not allowed for current user then die because user should not be able to see the template
         //$PDFMaker->CheckTemplatePermissions($checkRow["module"], $templateid);
         $Template_Permissions_Data = $PDFMaker->returnTemplatePermissionsData($checkRow["module"], $templateid);
         if ($Template_Permissions_Data["delete"] === false) {
             $this->DieDuePermission();
         }
         $sql = "delete from vtiger_pdfmaker where templateid=?";
         $adb->pquery($sql, array($templateid));
         $sql = "delete from vtiger_pdfmaker_settings where templateid=?";
         $adb->pquery($sql, array($templateid));
     } else {
         $idlist = $request->get('idlist');
         $id_array = explode(';', $idlist);
         $checkSql = "select templateid, module from vtiger_pdfmaker where templateid IN (" . generateQuestionMarks($id_array) . ")";
         $checkRes = $adb->pquery($checkSql, $id_array);
         $checkArr = array();
         while ($checkRow = $adb->fetchByAssoc($checkRes)) {
             $checkArr[$checkRow["templateid"]] = $checkRow["module"];
         }
         for ($i = 0; $i < count($id_array) - 1; $i++) {
             //if we are trying to delete template that is not allowed for current user then die because user should not be able to see the template
             //$PDFMaker->CheckTemplatePermissions($checkArr[$id_array[$i]], $id_array[$i]);
             $Template_Permissions_Data = $PDFMaker->returnTemplatePermissionsData($checkArr[$id_array[$i]], $id_array[$i]);
             if ($Template_Permissions_Data["delete"] === false) {
                 $this->DieDuePermission();
             }
             $sql = "delete from vtiger_pdfmaker where templateid=?";
             $adb->pquery($sql, array($id_array[$i]));
             $sql = "delete from vtiger_pdfmaker_settings where templateid=?";
             $adb->pquery($sql, array($id_array[$i]));
         }
     }
     $ajaxDelete = $request->get('ajaxDelete');
     $listViewUrl = "index.php?module=PDFMaker&view=List";
     if ($ajaxDelete) {
         $response = new Vtiger_Response();
         $response->setResult($listViewUrl);
         return $response;
     } else {
         header("Location: {$listViewUrl}");
     }
 }
Example #7
0
 /**
  * Function to get the record model based on the request parameters
  * @param Vtiger_Request $request
  * @return Vtiger_Record_Model or Module specific Record Model instance
  */
 protected function getRecordModelFromRequest(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $recordId = $request->get('record');
     if (!empty($recordId)) {
         $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
         $modelData = $recordModel->getData();
         $recordModel->set('id', $recordId);
         $sharedType = $request->get('sharedtype');
         if (!empty($sharedType)) {
             $recordModel->set('calendarsharedtype', $request->get('sharedtype'));
         }
         $recordModel->set('mode', 'edit');
     } else {
         $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
         $modelData = $recordModel->getData();
         $recordModel->set('mode', '');
     }
     foreach ($modelData as $fieldName => $value) {
         $requestFieldExists = $request->has($fieldName);
         if (!$requestFieldExists) {
             continue;
         }
         $fieldValue = $request->get($fieldName, null);
         if ($fieldName === 'is_admin' && !$fieldValue) {
             $fieldValue = 'off';
         }
         if ($fieldValue !== null) {
             if (!is_array($fieldValue)) {
                 $fieldValue = trim($fieldValue);
             }
             $recordModel->set($fieldName, $fieldValue);
         }
     }
     $homePageComponents = $recordModel->getHomePageComponents();
     $selectedHomePageComponents = $request->get('homepage_components', array());
     foreach ($homePageComponents as $key => $value) {
         if (in_array($key, $selectedHomePageComponents)) {
             $request->setGlobal($key, $key);
         } else {
             $request->setGlobal($key, '');
         }
     }
     // Tag cloud save
     $tagCloud = $request->get('tagcloudview');
     if ($tagCloud == "on") {
         $recordModel->set('tagcloud', 0);
     } else {
         $recordModel->set('tagcloud', 1);
     }
     return $recordModel;
 }
Example #8
0
 /**
  * Function to get the record model based on the request parameters
  * @param Vtiger_Request $request
  * @return Vtiger_Record_Model or Module specific Record Model instance
  */
 public function getRecordModelFromRequest(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $recordId = $request->get('record');
     if (!empty($recordId)) {
         $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
         $recordModel->set('id', $recordId);
         $recordModel->set('mode', 'edit');
         $fieldModelList = $recordModel->getModule()->getFields();
         foreach ($fieldModelList as $fieldName => $fieldModel) {
             $fieldValue = $fieldModel->getUITypeModel()->getUserRequestValue($recordModel->get($fieldName));
             if ($fieldName === $request->get('field')) {
                 $fieldValue = $request->get('value');
             }
             $fieldDataType = $fieldModel->getFieldDataType();
             if ($fieldDataType == 'time') {
                 $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
             }
             if ($fieldValue !== null) {
                 if (!is_array($fieldValue)) {
                     $fieldValue = trim($fieldValue);
                 }
                 $recordModel->set($fieldName, $fieldValue);
             }
             $recordModel->set($fieldName, $fieldValue);
         }
     } else {
         $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
         $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
         $recordModel->set('mode', '');
         $fieldModelList = $moduleModel->getFields();
         foreach ($fieldModelList as $fieldName => $fieldModel) {
             if ($request->has($fieldName)) {
                 $fieldValue = $request->get($fieldName, null);
             } else {
                 $fieldValue = $fieldModel->getDefaultFieldValue();
             }
             $fieldDataType = $fieldModel->getFieldDataType();
             if ($fieldDataType == 'time') {
                 $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
             }
             if ($fieldValue !== null) {
                 if (!is_array($fieldValue)) {
                     $fieldValue = trim($fieldValue);
                 }
                 $recordModel->set($fieldName, $fieldValue);
             }
         }
     }
     return $recordModel;
 }
 public function process(Vtiger_Request $request)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $moduleName = $request->getModule();
     $page = $request->get('page');
     $linkId = $request->get('linkid');
     $sortOrder = $request->get('sortorder');
     $orderBy = $request->get('orderby');
     $data = $request->getAll();
     $params = ['activitesType' => 'upcoming'];
     if ($request->get('activitesType')) {
         $params = ['activitesType' => $request->get('activitesType')];
     } else {
         $data['activitesType'] = 'upcoming';
         $params = ['activitesType' => 'upcoming'];
     }
     $widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
     if (!$request->has('owner')) {
         $owner = Settings_WidgetsManagement_Module_Model::getDefaultUserId($widget);
     } else {
         $owner = $request->get('owner');
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $page);
     $pagingModel->set('limit', (int) $widget->get('limit'));
     $pagingModel->set('orderby', $orderBy);
     $pagingModel->set('sortorder', $sortOrder);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $overDueActivities = $owner === false ? array() : $moduleModel->getCalendarActivities('createdByMeButNotMine', $pagingModel, $owner, false, $params);
     $viewer = $this->getViewer($request);
     $viewer->assign('WIDGET', $widget);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('ACTIVITIES', $overDueActivities);
     $viewer->assign('PAGING', $pagingModel);
     $viewer->assign('CURRENTUSER', $currentUser);
     $title_max_length = vglobal('title_max_length');
     $href_max_length = vglobal('href_max_length');
     $viewer->assign('NAMELENGHT', $title_max_length);
     $viewer->assign('HREFNAMELENGHT', $href_max_length);
     $viewer->assign('NODATAMSGLABLE', 'LBL_NO_RECORDS_MATCHED_THIS_CRITERIA');
     $viewer->assign('OWNER', $owner);
     $viewer->assign('DATA', $data);
     $content = $request->get('content');
     if (!empty($content)) {
         $viewer->view('dashboards/CalendarActivitiesContents.tpl', $moduleName);
     } else {
         $viewer->view('dashboards/CreatedNotMineActivities.tpl', $moduleName);
     }
 }
 public function process(Vtiger_Request $request)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $linkId = $request->get('linkid');
     $response = new Vtiger_Response();
     if ($request->has('widgetid')) {
         $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->get('widgetid'), $currentUser->getId());
     } else {
         $widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
     }
     if (!$widget->isDefault()) {
         $widget->remove();
         $response->setResult(array('linkid' => $linkId, 'name' => $widget->getName(), 'url' => $widget->getUrl(), 'title' => vtranslate($widget->getTitle(), $request->getModule())));
     } else {
         $response->setError(vtranslate('LBL_CAN_NOT_REMOVE_DEFAULT_WIDGET', $moduleName));
     }
     $response->emit();
 }
Example #11
0
 protected function transformToUI5URL(Vtiger_Request $request)
 {
     $params = 'module=Settings&action=index';
     if ($request->has('item')) {
         switch ($request->get('item')) {
             case 'LayoutEditor':
                 $params = 'module=Settings&action=LayoutBlockList&parenttab=Settings&formodule=' . $request->get('source_module');
                 break;
             case 'EditWorkflows':
                 $params = 'module=com_vtiger_workflow&action=workflowlist&list_module=' . $request->get('source_module');
                 break;
             case 'PicklistEditor':
                 $params = 'module=PickList&action=PickList&parenttab=Settings&moduleName=' . $request->get('source_module');
                 break;
             case 'SMSServerConfig':
                 $params = 'module=' . $request->get('source_module') . '&action=SMSConfigServer&parenttab=Settings&formodule=' . $request->get('source_module');
                 break;
             case 'CustomFieldList':
                 $params = 'module=Settings&action=CustomFieldList&parenttab=Settings&formodule=' . $request->get('source_module');
                 break;
             case 'GroupDetailView':
                 $params = 'module=Settings&action=GroupDetailView&groupId=' . $request->get('groupId');
                 break;
             case 'ModuleManager':
                 $params = 'module=Settings&action=ModuleManager&parenttab=Settings';
                 break;
             case 'MailScanner':
                 $params = 'module=Settings&action=MailScanner&parenttab=Settings';
                 break;
             case 'WebForms':
                 $params = 'module=Webforms&action=index&parenttab=Settings';
                 break;
             case 'CustomFields':
                 $params = 'module=Settings&action=CustomFieldList&parenttab=Settings&formodule=' . $request->get('source_module');
                 break;
         }
     }
     return '../index.php?' . $params;
 }
Example #12
0
 function process(Vtiger_Request $request)
 {
     if (!$request->has('_operation')) {
         return $this->processRoot($request);
     }
     $operation = $request->getOperation();
     $controllerInfo = self::$controllers[$operation];
     // TODO Handle case when controller information is not available
     //$controllerFile = dirname(__FILE__) . '/' . $controllerInfo['file'];
     //checkFileAccessForInclusion($controllerFile);
     //include_once $controllerFile;
     $controller = new $controllerInfo['class']();
     // Making sure to close the open connection
     if ($controller) {
         $controller->closeConnector();
     }
     $response = $controller->process($request);
     if ($response) {
         $response->emit();
     }
     unset($request);
     unset($response);
 }
Example #13
0
 public function process(Vtiger_Request $request)
 {
     $record = $request->get('record');
     if (empty($record)) {
         //get instance from currency name, Aleady deleted and adding again same currency case
         $recordModel = Settings_Currency_Record_Model::getInstance($request->get('currency_name'));
         if (empty($recordModel)) {
             $recordModel = new Settings_Currency_Record_Model();
         }
     } else {
         $recordModel = Settings_Currency_Record_Model::getInstance($record);
     }
     $fieldList = array('currency_name', 'conversion_rate', 'currency_status', 'currency_code', 'currency_symbol');
     foreach ($fieldList as $fieldName) {
         if ($request->has($fieldName)) {
             $recordModel->set($fieldName, $request->get($fieldName));
         }
     }
     //To make sure we are saving record as non deleted. This is useful if we are adding deleted currency
     $recordModel->set('deleted', 0);
     $response = new Vtiger_Response();
     try {
         if ($request->get('currency_status') == 'Inactive' && !empty($record)) {
             $transforCurrencyToId = $request->get('transform_to_id');
             if (empty($transforCurrencyToId)) {
                 throw new Exception('Transfer currency id cannot be empty');
             }
             Settings_Currency_Module_Model::tranformCurrency($record, $transforCurrencyToId);
         }
         $id = $recordModel->save();
         $recordModel = Settings_Currency_Record_Model::getInstance($id);
         $response->setResult(array_merge($recordModel->getData(), array('record' => $recordModel->getId())));
     } catch (Exception $e) {
         $response->setError($e->getCode(), $e->getMessage());
     }
     $response->emit();
 }
Example #14
0
 /**
  * Get the value to save
  * @param Vtiger_Request $request
  * @param string $field Field name
  * @param int $i Sequence number
  * @return string
  */
 public function getValueForSave($request, $field, $i)
 {
     $value = '';
     if ($request->has($field . $i)) {
         $value = $request->get($field . $i);
     } else {
         if ($request->has($field)) {
             $value = $request->get($field);
         }
     }
     if (in_array($field, $this->jsonFields) && $value != '') {
         $value = json_encode($value);
     }
     if (in_array($field, ['price', 'gross', 'net', 'discount', 'purchase', 'margin', 'marginp', 'tax', 'total'])) {
         $value = CurrencyField::convertToDBFormat($value, null, true);
     }
     return $value;
 }
Example #15
0
 /**
  * Function to get the record model based on the request parameters
  * @param Vtiger_Request $request
  * @return Vtiger_Record_Model or Module specific Record Model instance
  */
 public function getRecordModelFromRequest(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $recordId = $request->get('record');
     if ($request->get('field') == 'enable_recurring') {
         $enableRecurrence = true;
     }
     if (!empty($recordId)) {
         $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
         $recordModel->set('id', $recordId);
         $recordModel->set('mode', 'edit');
         $fieldModelList = $recordModel->getModule()->getFields();
         foreach ($fieldModelList as $fieldName => $fieldModel) {
             //For not converting createdtime and modified time to user format
             $uiType = $fieldModel->get('uitype');
             if ($uiType == 70) {
                 $fieldValue = $recordModel->get($fieldName);
             } else {
                 $fieldValue = $fieldModel->getUITypeModel()->getUserRequestValue($recordModel->get($fieldName));
             }
             if ($fieldName === $request->get('field')) {
                 $fieldValue = $request->get('value');
             }
             /**
              * If field is enable recurrence then we need to pass related fields of
              * recurrence to save,because untill enable recurrence is checked,the 
              * related field values wont get saved
              */
             if ($enableRecurrence) {
                 $requestFieldValue = $request->get($fieldName);
                 if ($requestFieldValue != '') {
                     $fieldValue = $request->get($fieldName);
                 }
             }
             $fieldDataType = $fieldModel->getFieldDataType();
             if ($fieldDataType == 'time') {
                 $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
             }
             if ($fieldValue !== null) {
                 if (!is_array($fieldValue)) {
                     $fieldValue = trim($fieldValue);
                 }
                 $recordModel->set($fieldName, $fieldValue);
             }
             $recordModel->set($fieldName, $fieldValue);
         }
     } else {
         $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
         $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
         $recordModel->set('mode', '');
         $fieldModelList = $moduleModel->getFields();
         foreach ($fieldModelList as $fieldName => $fieldModel) {
             if ($request->has($fieldName)) {
                 $fieldValue = $request->get($fieldName, null);
             } else {
                 $fieldValue = $fieldModel->getDefaultFieldValue();
             }
             $fieldDataType = $fieldModel->getFieldDataType();
             if ($fieldDataType == 'time') {
                 $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
             }
             if ($fieldValue !== null) {
                 if (!is_array($fieldValue)) {
                     $fieldValue = trim($fieldValue);
                 }
                 $recordModel->set($fieldName, $fieldValue);
             }
         }
     }
     return $recordModel;
 }
Example #16
0
 /**
  * Function to get the field details
  * @return <Array> - array of field values
  */
 public function getFieldInfo()
 {
     parent::getFieldInfo();
     //Change the default search operator
     if ($this->get('name') == 'date_start') {
         $request = new Vtiger_Request($_REQUEST, $_REQUEST);
         if ($request->has('search_params')) {
             $searchParams = $request->get('search_params');
             if (!empty($searchParams)) {
                 foreach ($searchParams[0] as $value) {
                     if ($value[0] == 'date_start') {
                         $this->fieldInfo['searchOperator'] = $value[1];
                     }
                 }
             }
         }
     }
     return $this->fieldInfo;
 }
Example #17
0
 public static function ReportGraphs(Vtiger_Request $request, $viewer)
 {
     $moduleName = $request->getModule();
     $record = $request->get('record');
     $R_Data = $request->getAll();
     $viewer->assign("MODULE", $moduleName);
     $LBL_INFORMATIONS_4YOU = vtranslate("LBL_STEP12_INFO", $moduleName);
     $viewer->assign("LBL_INFORMATIONS_4YOU", $LBL_INFORMATIONS_4YOU);
     // ITS4YOU-END 10. 9. 2013 16:13:50
     $reportModel = ITS4YouReports_Record_Model::getCleanInstance($record);
     $Report_Informations = $reportModel->getReportInformations();
     if (!empty($Report_Informations["charts"])) {
         $charts_array = $Report_Informations["charts"];
     }
     if (isset($R_Data["chartType1"])) {
         for ($chi = 1; $chi < 4; $chi++) {
             if (isset($R_Data["chartType{$chi}"])) {
                 $charts_array[$chi]['charttype'] = $R_Data["chartType{$chi}"];
                 $charts_array[$chi]['dataseries'] = $R_Data["data_series{$chi}"];
             }
         }
     }
     if (isset($R_Data["chart_type"]) && $R_Data["chart_type"] != "" && $R_Data["chart_type"] != "none") {
         $selected_chart_type = $R_Data["chart_type"];
     } else {
         $selected_chart_type = $Report_Informations["charts"]["charttype"];
     }
     $viewer->assign("IMAGE_PATH", $chart_type);
     if (isset($R_Data["data_series"]) && $R_Data["data_series"] != "") {
         $selected_data_series = $R_Data["data_series"];
     } else {
         $selected_data_series = $Report_Informations["charts"];
     }
     if (isset($R_Data["charttitle"]) && $R_Data["charttitle"] != "") {
         $selected_charttitle = $R_Data["charttitle"];
     } else {
         $selected_charttitle = $Report_Informations["charts"][1]["charttitle"];
     }
     $viewer->assign("charttitle", $selected_charttitle);
     $chart_type["horizontal"] = array("value" => vtranslate("LBL_CHART_horizontal", $moduleName), "selected" => $selected_chart_type == "horizontal" ? "selected" : "");
     $chart_type["vertical"] = array("value" => vtranslate("LBL_CHART_vertical", $moduleName), "selected" => $selected_chart_type == "vertical" ? "selected" : "");
     $chart_type["linechart"] = array("value" => vtranslate("LBL_CHART_linechart", $moduleName), "selected" => $selected_chart_type == "linechart" ? "selected" : "");
     $chart_type["pie"] = array("value" => vtranslate("LBL_CHART_pie", $moduleName), "selected" => $selected_chart_type == "pie" ? "selected" : "");
     //$chart_type["pie3d"]=array("value"=>vtranslate("LBL_CHART_pie3D",$moduleName),"selected"=>($selected_chart_type=="pie3d"?"selected":""));
     $chart_type["funnel"] = array("value" => vtranslate("LBL_CHART_funnel", $moduleName), "selected" => $selected_chart_type == "funnel" ? "selected" : "");
     $viewer->assign("CHART_TYPE", $chart_type);
     // column
     // bar
     // line
     // pie
     // funnel
     // selected labels from url
     if (isset($R_Data["lblurl"])) {
         $lbl_url_string = html_entity_decode($R_Data["lblurl"]);
     }
     $lbl_url_string = str_replace("@AMPKO@", "&", $lbl_url_string);
     if ($lbl_url_string != "") {
         $lbl_url_arr = explode('$_@_$', $lbl_url_string);
         foreach ($lbl_url_arr as $key => $lbl_value) {
             if (strpos($lbl_value, 'hidden_') === false) {
                 if (strpos($lbl_value, '_SC_lLbLl_') !== false) {
                     $temp = explode('_SC_lLbLl_', $lbl_value);
                     $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                     $lbl_key = $temp_lbls[0];
                     $lbl_value = $temp_lbls[1];
                     $lbl_url_selected["SC"][$lbl_key] = $lbl_value;
                 }
                 if (strpos($lbl_value, '_SM_lLbLl_') !== false) {
                     $temp = explode('_SM_lLbLl_', $lbl_value);
                     $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                     $lbl_key = $temp_lbls[0];
                     $lbl_value = $temp_lbls[1];
                     $lbl_url_selected["SM"][$lbl_key] = $lbl_value;
                 }
                 if (strpos($lbl_value, '_CT_lLbLl_') !== false) {
                     $temp = explode('_CT_lLbLl_', $lbl_value);
                     $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                     $lbl_key = $temp_lbls[0];
                     $lbl_value = $temp_lbls[1];
                     $lbl_url_selected["CT"][$lbl_key] = $lbl_value;
                 }
             }
         }
     }
     /*
                 global $current_language;
                 $group_string = "";
                 if(isset($R_Data["selectedSummariesString"])!=""){
                     $selectedSummariesArray = explode(";", trim($R_Data["selectedSummariesString"],";"));
                     
                     if(!empty($selectedSummariesArray)){
                         foreach($selectedSummariesArray as $column_str){
                             if($column_str!=""){
                                 $column_str = str_replace("@AMPKO@", "&", $column_str);
                                 $column_lbl = $reportModel->report->getColumnStr_Label($column_str,"SM");
                                 $data_series[$column_str] = array("value"=>$column_lbl,"selected"=>($column_str==$selected_data_series?"selected":""));
                             }
                             /*if($column_str!=""){
                                 if(isset($lbl_url_selected["SM"][$column_str]) && $lbl_url_selected["SM"][$column_str]!=""){
                                     $column_lbl = $lbl_url_selected["SM"][$column_str];
                                 }else{
                                     $column_str_arr = explode(":", $column_str);
                                     $translate_arr = explode("_", $column_str_arr[2]);
                                     $translate_module = $translate_arr[0];
                                     unset($translate_arr[0]);
                                     $translate_str = implode("_", $translate_arr);
                                     $translate_mod_str = return_module_language($current_language, $translate_module);
                                     if(isset($translate_mod_str[$translate_str])){
                                         $column_lbl = $translate_mod_str[$translate_str];
                                     }else{
                                         $column_lbl = str_replace("_", " ", $translate_str);
                                     }
                                 }
                                 $data_series[$column_str] = array("value"=>$column_lbl,"selected"=>($column_str==$selected_data_series?"selected":""));
                             }* /
                         }
                     }
                 }
     */
     /*
                 if(empty($data_series) && $selected_data_series!="" && in_array($selected_data_series, $selectedSummariesArray)){
                     $column_lbl = $reportModel->getColumnStr_Label($selected_data_series,"SM");
                     $data_series[$selected_data_series] = array("value"=>$column_lbl,"selected"=>"selected");
                 }*/
     //            $viewer->assign("DATA_SERIES",$data_series);
     // NEW WAY
     $viewer->assign("CHARTS_ARRAY", $charts_array);
     if ($request->has("selectedSummariesString")) {
         $selectedSummariesString = $request->get("selectedSummariesString");
         $selectedSummariesString = str_replace("@AMPKO@", "&", $selectedSummariesString);
         $r_selectedSummariesArr = explode(";", $selectedSummariesString);
         foreach ($r_selectedSummariesArr as $key => $summaries_col_str) {
             if ($summaries_col_str != "") {
                 $selectedSummariesArr[] = array("value" => $summaries_col_str, "label" => $reportModel->report->getColumnStr_Label($summaries_col_str, "SM"));
             }
         }
     } else {
         if (!empty($Report_Informations["summaries_columns"])) {
             foreach ($Report_Informations["summaries_columns"] as $key => $summaries_columns_arr) {
                 $selectedSummariesArr[] = array("value" => $summaries_columns_arr["columnname"], "label" => $reportModel->report->getColumnStr_Label($summaries_columns_arr["columnname"], "SM"));
             }
         }
     }
     if (empty($selectedSummariesArr)) {
         $primarymodule = $reportModel->report->primarymodule;
         $crmid_count_str = "vtiger_crmentity:crmid:" . $primarymodule . "_COUNT Records:" . $primarymodule . "_count:V";
         $selectedSummariesArr[] = array("value" => $crmid_count_str, "label" => $reportModel->getColumnStr_Label($crmid_count_str, "SM"));
     }
     $viewer->assign("selected_summaries", $selectedSummariesArr);
     $group_string = "";
     if (isset($R_Data["group1"])) {
         for ($gi = 1; $gi < 3; $gi++) {
             if (isset($R_Data["group" . $gi]) && $R_Data["group" . $gi] != "none") {
                 if ($group_string != "") {
                     $group_string .= " - ";
                 }
                 $group_string .= $reportModel->getColumnStr_Label($R_Data["group" . $gi]);
                 $x_group["group" . $gi]['value'] = $group_string;
                 if ("group" . $gi == $R_Data["x_group"]) {
                     $x_group["group" . $gi]['selected'] = " selected='selected' ";
                 }
             }
         }
     } else {
         for ($gi = 1; $gi < 3; $gi++) {
             if (isset($Report_Informations["Group" . $gi]) && $Report_Informations["Group" . $gi] != "none") {
                 if ($group_string != "") {
                     $group_string .= " - ";
                 }
                 $group_string .= $reportModel->getColumnStr_Label($Report_Informations["Group" . $gi]);
                 // $x_group[$Report_Informations["Group".$gi]]['value'] = $group_string;
                 $x_group["group" . $gi]['value'] = $group_string;
                 if ("group" . $gi == $Report_Informations["charts"][1]["x_group"]) {
                     $x_group["group" . $gi]['selected'] = " selected='selected' ";
                 }
             }
         }
     }
     $viewer->assign("X_GROUP", $x_group);
     $viewer->assign("X_GROUP_COUNT", count($x_group));
     return $viewer->view("ReportGraphs.tpl", $moduleName, true);
 }
Example #18
0
 function getPrimaryModules()
 {
     $request = new Vtiger_Request($_REQUEST, $_REQUEST);
     if ($request->has("primarymodule") && $request->get('primarymodule') !== "") {
         $this->primarymoduleid = $request->get("primarymodule");
     }
     $p_key = 0;
     if (!isset($this->module_list) || empty($this->module_list)) {
         $this->initListOfModules();
     }
     foreach ($this->module_list as $modulename => $moduleblocks) {
         $moduleid = getTabid($modulename);
         $m_return = array();
         $m_return['id'] = $moduleid;
         /* if (in_array($modulename, array("Calendar", "PBXManager"))) {
            $module_lbl = vtranslate($modulename, $modulename);
            } else {
            $module_lbl = vtranslate("SINGLE_$modulename", $modulename);
            } */
         $module_lbl = vtranslate($modulename, $modulename);
         $m_return['module'] = $module_lbl;
         $m_return['selected'] = $this->primarymoduleid == $moduleid ? 'selected' : '';
         $t_return[$module_lbl] = $m_return;
         $p_key++;
     }
     ksort($t_return);
     $return = array();
     $t_i = 0;
     foreach ($t_return as $m_arr) {
         $return[$t_i] = $m_arr;
         $t_i++;
     }
     if ($this->primarymoduleid == "") {
         $return[0]['selected'] = "selected";
     }
     return $return;
 }
Example #19
0
 /**
  * Save the inventory data
  */
 public function saveInventoryData()
 {
     //Event triggering code
     require_once "include/events/include.inc";
     $db = PearDatabase::getInstance();
     $log = vglobal('log');
     $log->debug('Entering ' . __CLASS__ . '::' . __METHOD__);
     $moduleName = $this->getModuleName();
     $inventory = Vtiger_InventoryField_Model::getInstance($moduleName);
     $fields = $inventory->getColumns();
     $table = $inventory->getTableName('data');
     $summaryFields = $inventory->getSummaryFields();
     $insertDataTemp = $summary = [];
     $request = new Vtiger_Request($_REQUEST, $_REQUEST);
     $numRow = $request->get('inventoryItemsNo');
     //In Bulk mode stop triggering events
     if (!CRMEntity::isBulkSaveMode()) {
         $em = new VTEventsManager($adb);
         // Initialize Event trigger cache
         $em->initTriggerCache();
         $em->triggerEvent('entity.inventory.beforesave', [$this, $inventory]);
     }
     $db->pquery("delete from {$table} where id = ?", [$this->getId()]);
     for ($i = 1; $i <= $numRow; $i++) {
         if (!$request->has(reset($fields)) && !$request->has(reset($fields) . $i)) {
             continue;
         }
         $insertData = ['id' => $this->getId(), 'seq' => $request->get('seq' . $i)];
         foreach ($fields as $field) {
             $value = $insertData[$field] = $inventory->getValueForSave($request, $field, $i);
             if (in_array($field, $summaryFields)) {
                 $summary[$field] += $value;
             }
         }
         $db->insert($table, $insertData);
         $insertDataTemp[] = $insertData;
     }
     foreach ($summary as $fieldName => $fieldValue) {
         if ($this->has($fieldName)) {
             $this->set($fieldName, CurrencyField::convertToUserFormat($fieldValue, null, true));
         }
     }
     if ($em) {
         //Event triggering code
         $em->triggerEvent('entity.inventory.aftersave', [$this, $inventory, $insertDataTemp, $summary]);
     }
     $log->debug('Exiting ' . __CLASS__ . '::' . __METHOD__);
 }
Example #20
0
 public function getRecordModelFromRequest(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $recordId = $request->get('record');
     if (!empty($recordId)) {
         $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
         $recordModel->set('id', $recordId);
         $recordModel->set('mode', 'edit');
         $fieldModelList = $recordModel->getModule()->getFields();
         foreach ($fieldModelList as $fieldName => $fieldModel) {
             //For not converting craetedtime and modified time to user format
             $uiType = $fieldModel->get('uitype');
             if ($uiType == 70) {
                 $fieldValue = $recordModel->get($fieldName);
             } else {
                 $fieldValue = $fieldModel->getUITypeModel()->getUserRequestValue($recordModel->get($fieldName));
             }
             if ($fieldName === $request->get('field')) {
                 $fieldValue = $request->get('value');
             }
             $fieldDataType = $fieldModel->getFieldDataType();
             if ($fieldDataType == 'time') {
                 $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
             }
             if ($fieldValue !== null) {
                 if (!is_array($fieldValue)) {
                     $fieldValue = trim($fieldValue);
                 }
                 $recordModel->set($fieldName, $fieldValue);
             }
             $recordModel->set($fieldName, $fieldValue);
         }
     } else {
         $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
         $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
         $recordModel->set('mode', '');
         $fieldModelList = $moduleModel->getFields();
         foreach ($fieldModelList as $fieldName => $fieldModel) {
             if ($request->has($fieldName)) {
                 $fieldValue = $request->get($fieldName, null);
             } else {
                 $fieldValue = $fieldModel->getDefaultFieldValue();
                 // to update the  support_end_date and support_start_date in Quick create
                 if ($fieldName == 'support_end_date') {
                     $fieldValue = DateTimeField::convertToUserFormat(date('Y-m-d', strtotime("+1 year")));
                 } else {
                     if ($fieldName == 'support_start_date') {
                         $fieldValue = DateTimeField::convertToUserFormat(date('Y-m-d'));
                     }
                 }
             }
             $fieldDataType = $fieldModel->getFieldDataType();
             if ($fieldDataType == 'time') {
                 $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
             }
             if ($fieldValue !== null) {
                 if (!is_array($fieldValue)) {
                     $fieldValue = trim($fieldValue);
                 }
                 $recordModel->set($fieldName, $fieldValue);
             }
         }
     }
     return $recordModel;
 }
Example #21
0
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $requestAll = $request->getAll();
     $record = $requestAll["record"];
     if ($record != "") {
         $mode = "edit";
     } else {
         $mode = "create";
     }
     global $default_charset;
     $reportModel = new ITS4YouReports_Record_Model();
     $reportModel->setModule("ITS4YouReports");
     if (!empty($record) && !$request->get('isDuplicate')) {
         $reportModel->setId($record);
     }
     //$reporttype = $request->get('reporttype');
     //if(empty($reporttype)) $reporttype='tabular';
     $reportModel->set('reportname', $requestAll['reportname']);
     $reportModel->set('folderid', $requestAll['reportfolder']);
     $reportModel->set('description', $requestAll['reports_description']);
     //$reportModel->set('reporttype', $reporttype);
     $reportModel->setPrimaryModule($requestAll['primarymodule']);
     $reportModel->set('template_owner', $requestAll['template_owner']);
     $reportModel->set('sharing', $requestAll['sharing']);
     //$secondaryModules = $request->get('secondary_modules');
     //$secondaryModules = implode(':', $secondaryModules);
     //$reportModel->setSecondaryModule($secondaryModules);
     $saveselectedcolumns = explode(";", trim($requestAll['selectedColumnsString'], ";"));
     $reportModel->set('selectedFields', $saveselectedcolumns);
     $selectedSummaries_array = explode(";", trim($requestAll['selectedSummariesString'], ";"));
     $reportModel->set('selectedSummaries', $selectedSummaries_array);
     $reportModel->set('summaries_orderby', $requestAll['summaries_orderby_columnString']);
     $reportModel->set('summaries_orderby_type', $requestAll['summaries_orderby_type']);
     $lbl_array = array();
     $lbl_url_string = $requestAll['labels_to_go'];
     $lbl_url_string = urldecode($lbl_url_string);
     $lbl_url_string = html_entity_decode($lbl_url_string, ENT_QUOTES, $default_charset);
     // $lbl_url_string = str_replace("@AMPKO@", "&", $lbl_url_string);
     if ($lbl_url_string != "") {
         $lbl_url_arr = explode('$_@_$', $lbl_url_string);
         foreach ($lbl_url_arr as $key => $lbl_value) {
             if (strpos($lbl_value, '_SC_lLbLl_') !== false) {
                 $temp = explode('_SC_lLbLl_', $lbl_value);
                 $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                 $lbl_key = $temp_lbls[0];
                 $lbl_value = $temp_lbls[1];
                 $lbl_array["SC"][$lbl_key] = $lbl_value;
             }
             if (strpos($lbl_value, '_SM_lLbLl_') !== false) {
                 $temp = explode('_SM_lLbLl_', $lbl_value);
                 $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                 $lbl_key = $temp_lbls[0];
                 $lbl_value = $temp_lbls[1];
                 $lbl_array["SM"][$lbl_key] = $lbl_value;
             }
             if (strpos($lbl_value, '_CT_lLbLl_') !== false) {
                 $temp = explode('_CT_lLbLl_', $lbl_value);
                 $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                 $lbl_key = $temp_lbls[0];
                 $lbl_value = $temp_lbls[1];
                 $lbl_array["CT"][$lbl_key] = $lbl_value;
             }
         }
     }
     $reportModel->set('lbl_array', $lbl_array);
     for ($gi = 1; $gi < 4; $gi++) {
         $reportModel->set('sort_by' . $gi, $requestAll['Group' . $gi]);
         $reportModel->set('sort_order' . $gi, $requestAll['Sort' . $gi]);
     }
     $reportModel->set('timeline_type2', $requestAll['timeline_type2']);
     $reportModel->set('timeline_type3', $requestAll['timeline_type3']);
     for ($tgi = 1; $tgi < 4; $tgi++) {
         if ($request->has('TimeLineColumn_Group' . $tgi) && !$request->isEmpty('TimeLineColumn_Group' . $tgi) && $requestAll['Group' . $tgi] != "none") {
             $TimeLineColumn_Group = $requestAll['TimeLineColumn_Group' . $tgi];
             $TimeLineColumn_Group_arr = explode("@vlv@", $TimeLineColumn_Group);
             $TimeLineColumn_str = $TimeLineColumn_Group_arr[0];
             $TimeLineColumn_frequency = $TimeLineColumn_Group_arr[1];
             $reportModel->set('TimeLineColumn_str' . $tgi, $TimeLineColumn_str);
             $reportModel->set('TimeLineColumn_frequency' . $tgi, $TimeLineColumn_frequency);
         }
     }
     $reportModel->set('SortByColumn', $requestAll['SortByColumn']);
     $reportModel->set('SortOrderColumn', $requestAll['SortOrderColumn']);
     $pmodule = $requestAll['primarymodule'];
     $reportModel->set('pmodule', $pmodule);
     $smodule = trim($requestAll['secondarymodule'], ":");
     $reportModel->set('smodule', $smodule);
     $reportModel->set('sharetype', $requestAll['sharing']);
     $reportModel->set('shared_entities', $requestAll['sharingSelectedColumnsString']);
     $columnstototal = explode('$_@_$', $requestAll["curl_to_go"]);
     $reportModel->set('columnstototal', $columnstototal);
     $json = new Zend_Json();
     //$std_filter_columns = $ITS4YouReports->getStdFilterColumns();
     $advft_criteria = $requestAll['advft_criteria'];
     $advft_criteria = $json->decode($advft_criteria);
     $reportModel->set('advft_criteria', $advft_criteria);
     $advft_criteria_groups = $requestAll['advft_criteria_groups'];
     $advft_criteria_groups = $json->decode($advft_criteria_groups);
     $reportModel->set('advft_criteria_groups', $advft_criteria_groups);
     $groupft_criteria = $requestAll['groupft_criteria'];
     $groupft_criteria = $json->decode($groupft_criteria);
     $reportModel->set('groupft_criteria', $groupft_criteria);
     $reportModel->set('limit', $requestAll['limit']);
     $reportModel->set('summaries_limit', $requestAll['summaries_limit']);
     $reportModel->set('isReportScheduled', $requestAll['isReportScheduled']);
     $reportModel->set('selectedRecipientsString', $requestAll['selectedRecipientsString']);
     $reportModel->set('scheduledReportFormat', $requestAll['scheduledReportFormat']);
     $reportModel->set('scheduledIntervalString', $requestAll['scheduledIntervalString']);
     $chartType = $requestAll["chartType"];
     $reportModel->set('chartType', $chartType);
     if ($chartType != "" && $chartType != "none") {
         $data_series = $requestAll["data_series"];
         $reportModel->set('data_series', $data_series);
         $charttitle = $requestAll["charttitle"];
         $reportModel->set('charttitle', $charttitle);
     }
     $reportModel->save();
     //Scheduled Reports
     /*
     $scheduleReportModel = new Reports_ScheduleReports_Model();
     $scheduleReportModel->set('scheduleid', $request->get('schtypeid'));
     $scheduleReportModel->set('schtime', $request->get('schtime'));
     $scheduleReportModel->set('schdate', $request->get('schdate'));
     $scheduleReportModel->set('schdayoftheweek', $request->get('schdayoftheweek'));
     $scheduleReportModel->set('schdayofthemonth', $request->get('schdayofthemonth'));
     $scheduleReportModel->set('schannualdates', $request->get('schannualdates'));
     $scheduleReportModel->set('reportid', $reportModel->getId());
     $scheduleReportModel->set('recipients', $request->get('recipients'));
     $scheduleReportModel->set('isReportScheduled', $request->get('enable_schedule'));
     $scheduleReportModel->set('specificemails', $request->get('specificemails'));
     $scheduleReportModel->saveScheduleReport();
     */
     //END
     if ($requestAll["SaveType"] == "Save") {
         $loadUrl = $reportModel->getListViewUrl();
     } else {
         $loadUrl = $reportModel->getDetailViewUrl();
     }
     header("Location: {$loadUrl}");
 }
Example #22
0
 /**
  * Function saves a Report
  */
 function save()
 {
     $adb = PearDatabase::getInstance();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $export_sql = false;
     //$export_sql = true;
     $export_to_file = false;
     //$export_to_file = true;
     $debug_save = false;
     //$debug_save = true;
     $request = new Vtiger_Request($_REQUEST, $_REQUEST);
     $request_data = $request->getAll();
     if ($export_sql) {
         ITS4YouReports::sshow($_REQUEST);
         //exit;
     }
     $reportid = $this->getId();
     $r4u_sesstion_name = ITS4YouReports::getITS4YouReportStoreName();
     $r4u_sesstion_unset = ITS4YouReports::unsetITS4YouReportsSerialize($r4u_sesstion_name);
     if ($debug_save) {
         echo "<pre>UNSET Session: ";
         print_r($r4u_sesstion_unset);
         echo "</pre>";
     }
     $ITS4YouReports = ITS4YouReports::getStoredITS4YouReport();
     $std_filter_columns = $ITS4YouReports->getStdFilterColumns();
     //<<<<<<<report>>>>>>>>>
     global $default_charset;
     $reportname = $request->get('reportname');
     $reportname = html_entity_decode($reportname, ENT_QUOTES, $default_charset);
     $reportdescription = $request->get("reportdesc");
     $reportdescription = html_entity_decode($reportdescription, ENT_QUOTES, $default_charset);
     $reporttype = $request->get("reporttype");
     $folderid = $request->get("reportfolder");
     $isDuplicate = $request->get("isDuplicate");
     //<<<<<<<report>>>>>>>>>
     //<<<<<<<selectcolumn>>>>>>>>>
     $selectedcolumnstring = $request->get("selectedColumnsString");
     $selectedcolumnstring = str_replace("@AMPKO@", "&", $selectedcolumnstring);
     $saveselectedcolumns = explode(";", trim($selectedcolumnstring, ";"));
     $selectedcolumns = array();
     foreach ($saveselectedcolumns as $sc) {
         $selectedcolumns[] = $sc;
     }
     //<<<<<<<selectcolumn>>>>>>>>>
     //<<<<<<<selectedSummaries>>>>>>>>>
     $selectedSummariesString = $request->get("selectedSummariesString");
     $selectedSummariesString = str_replace("@AMPKO@", "&", $selectedSummariesString);
     $selectedSummaries_array = explode(";", trim($selectedSummariesString, ";"));
     $selectedSummaries = array();
     foreach ($selectedSummaries_array as $sm) {
         $selectedSummaries[] = $sm;
     }
     //<<<<<<<selectedSummaries>>>>>>>>>
     //<<<<<<<SummariesOrderBy>>>>>>>>>
     $summaries_orderby = $request->get("summaries_orderby_columnString");
     $summaries_orderby_type = $request->get("summaries_orderby_type");
     //<<<<<<<SummariesOrderBy>>>>>>>>>
     // ITS4YOU-CR SlOl 13. 3. 2014 10:17:31
     $lbl_array = array();
     $lbl_url_string = $request->get("labels_to_go");
     $lbl_url_string = str_replace("@AMPKO@", "&", $lbl_url_string);
     $lbl_url_string = urldecode($lbl_url_string);
     $lbl_url_string = html_entity_decode($lbl_url_string, ENT_QUOTES, $default_charset);
     if ($lbl_url_string != "") {
         $lbl_url_arr = explode('$_@_$', $lbl_url_string);
         foreach ($lbl_url_arr as $key => $lbl_value) {
             if (strpos($lbl_value, '_SC_lLbLl_') !== false) {
                 $temp = explode('_SC_lLbLl_', $lbl_value);
                 $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                 $lbl_key = $temp_lbls[0];
                 $lbl_value = $temp_lbls[1];
                 $lbl_array["SC"][$lbl_key] = $lbl_value;
             }
             if (strpos($lbl_value, '_SM_lLbLl_') !== false) {
                 $temp = explode('_SM_lLbLl_', $lbl_value);
                 $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                 $lbl_key = $temp_lbls[0];
                 $lbl_value = $temp_lbls[1];
                 $lbl_array["SM"][$lbl_key] = $lbl_value;
             }
             if (strpos($lbl_value, '_CT_lLbLl_') !== false) {
                 $temp = explode('_CT_lLbLl_', $lbl_value);
                 $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                 $lbl_key = $temp_lbls[0];
                 $lbl_value = $temp_lbls[1];
                 $lbl_array["CT"][$lbl_key] = $lbl_value;
             }
         }
     }
     // ITS4YOU-END 13. 3. 2014 10:17:32
     //<<<<<<<reportsortcol>>>>>>>>>
     $sort_by1 = decode_html($request->get("Group1"));
     $sort_order1 = $request->get("Sort1");
     $sort_by2 = decode_html($request->get("Group2"));
     $sort_order2 = $request->get("Sort2");
     $sort_by3 = decode_html($request->get("Group3"));
     $sort_order3 = $request->get("Sort3");
     $timeline_type2 = $request->get("timeline_type2");
     $timeline_type3 = $request->get("timeline_type3");
     if ($request->has("TimeLineColumn_Group1") && !$request->isEmpty("TimeLineColumn_Group1") && $sort_by1 != "none") {
         $TimeLineColumn_Group1 = $request->get("TimeLineColumn_Group1");
         $TimeLineColumn_Group1_arr = explode("@vlv@", $TimeLineColumn_Group1);
         $TimeLineColumn_str1 = $TimeLineColumn_Group1_arr[0];
         $TimeLineColumn_frequency1 = $TimeLineColumn_Group1_arr[1];
     }
     if ($request->has("TimeLineColumn_Group2") && !$request->isEmpty("TimeLineColumn_Group2") && $sort_by2 != "none") {
         $TimeLineColumn_Group2 = $request->get("TimeLineColumn_Group2");
         $TimeLineColumn_Group2_arr = explode("@vlv@", $TimeLineColumn_Group2);
         $TimeLineColumn_str2 = $TimeLineColumn_Group2_arr[0];
         $TimeLineColumn_frequency2 = $TimeLineColumn_Group2_arr[1];
     }
     if ($request->has("TimeLineColumn_Group3") && !$request->isEmpty("TimeLineColumn_Group3") && $sort_by3 != "none") {
         $TimeLineColumn_Group3 = $request->get("TimeLineColumn_Group3");
         $TimeLineColumn_Group3_arr = explode("@vlv@", $TimeLineColumn_Group3);
         $TimeLineColumn_str3 = $TimeLineColumn_Group3_arr[0];
         $TimeLineColumn_frequency3 = $TimeLineColumn_Group3_arr[1];
     }
     $sort_by_column = decode_html($request->get("SortByColumn"));
     $sort_order_column = $request->get("SortOrderColumn");
     //<<<<<<<reportsortcol>>>>>>>>>
     //<<<<<<<reportmodules>>>>>>>>>
     $pmodule = $request->get("primarymodule");
     $smodule = trim($request->get("secondarymodule"), ":");
     //<<<<<<<reportmodules>>>>>>>>>
     //<<<<<<<shared entities>>>>>>>>>
     $sharetype = $request->get("sharing");
     $shared_entities = $request->get("sharingSelectedColumnsString");
     //<<<<<<<shared entities>>>>>>>>>
     //<<<<<<<columnstototal>>>>>>>>>>
     if ($request->has("curl_to_go") && !$request->isEmpty("curl_to_go")) {
         $columnstototal = explode('$_@_$', $request->get("curl_to_go"));
     }
     //<<<<<<<columnstototal>>>>>>>>>
     //<<<<<<<advancedfilter>>>>>>>>check
     $json = new Zend_Json();
     $std_filter_columns = $ITS4YouReports->getStdFilterColumns();
     $advft_criteria_groups = $request->get('advft_criteria_groups');
     $new_criteria_groups = $gi_change = array();
     if (!empty($advft_criteria_groups)) {
         $new_gi = 1;
         foreach ($advft_criteria_groups as $advftg_i => $advftg_array) {
             if (!empty($advftg_array)) {
                 $gi_change[$advftg_i] = $new_gi;
                 $new_criteria_groups[$new_gi] = $advftg_array;
                 $new_gi++;
             }
         }
     }
     $advft_criteria_groups = $new_criteria_groups;
     //advft_criteria_groups = $json->decode($advft_criteria_groups);
     $new_advft_criteria = array();
     $advft_criteria = $request->get('advft_criteria');
     if (!empty($advft_criteria)) {
         $new_i = 0;
         foreach ($advft_criteria as $advft_i => $advft_array) {
             if (!empty($advft_array)) {
                 $advft_array["groupid"] = $gi_change[$advft_array["groupid"]];
                 $new_advft_criteria[$new_i] = $advft_array;
                 $new_i++;
             }
         }
     }
     $advft_criteria = $new_advft_criteria;
     //$advft_criteria = $json->decode($advft_criteria);
     //<<<<<<<advancedfilter>>>>>>>>
     //<<<<<<<groupconditioncolumn>>>>>>>>
     $groupft_criteria = $request->get('groupft_criteria');
     //$groupft_criteria = $json->decode($groupft_criteria);
     //<<<<<<<groupconditioncolumn>>>>>>>>
     //<<<<<<<limit>>>>>>>>
     $limit = $summaries_limit = 0;
     if ($request->has("columns_limit") && !$request->isEmpty("columns_limit")) {
         $limit = $request->get("columns_limit");
     }
     if ($request->has("summaries_limit") && !$request->isEmpty("summaries_limit")) {
         $summaries_limit = $request->get("summaries_limit");
     }
     //<<<<<<<limit>>>>>>>>
     //<<<<<<<scheduled report>>>>>>>>
     $isReportScheduled = $request->get('isReportScheduled');
     $scheduledFormat = "";
     $r_key_arr = array();
     if ($isReportScheduled == 'on' || $isReportScheduled == '1') {
         foreach ($request_data as $r_key => $r_val) {
             if (strpos($r_key, "scheduledReportFormat_") !== false) {
                 $r_key_arr[] = substr($r_key, 22);
             }
         }
     }
     if (!empty($r_key_arr)) {
         $scheduledFormat = implode(";", $r_key_arr);
     }
     $selectedRecipients = $request->get('selectedRecipientsString');
     $selectedRecipients = Zend_JSON::encode($selectedRecipients);
     //$scheduledFormat = $request->get('scheduledReportFormat');
     $scheduledInterval = $request->get('scheduledIntervalString');
     $scheduledInterval = Zend_JSON::encode($scheduledInterval);
     //<<<<<<<scheduled report>>>>>>>>
     // ITS4YOU-CR SlOl 20. 3. 2014 12:02:47
     for ($tg_i = 1; $tg_i < 4; $tg_i++) {
         if ($request->has("TimeLineColumn_Group{$tg_i}") && !$request->isEmpty("TimeLineColumn_Group{$tg_i}") && $request->get("TimeLineColumn_Group{$tg_i}") != "none") {
             $tg_col_str = $request->get("TimeLineColumn_Group{$tg_i}");
             $tg_col_arr = explode("@vlv@", $tg_col_str);
             $timelinecols_arr[$tg_i] = $tg_col_str;
             $timelinecols_frequency[$tg_i] = $tg_col_arr[1];
         }
     }
     // ITS4YOU-END 20. 3. 2014 12:02:48
     // ITS4YOU-CR SlOl | 2.7.2014 15:18
     //
     // chartType1 data_series1
     if ($request->has("chartType1") && !$request->isEmpty("chartType1")) {
         $charttitle = $request->get("charttitle");
         $x_group = $request->get("x_group");
         $charts = array();
         for ($chi = 1; $chi < 4; $chi++) {
             // charttype 	dataseries 	charttitle 	chart_seq 	x_group
             if ($request->has("chartType{$chi}") && !$request->isEmpty("chartType{$chi}")) {
                 $charttype = $request->get("chartType{$chi}");
                 if ($charttype != "none") {
                     $ch_params = array("charttype" => $charttype, "dataseries" => $request->get("data_series{$chi}"), "charttitle" => $charttitle, "chart_seq" => $chi, "x_group" => $x_group);
                     $charts[$chi] = $ch_params;
                 } else {
                     break;
                 }
             } else {
                 break;
             }
         }
     }
     /*
      if ($request->has("chartType") && !$request->isEmpty("chartType")) {
      $chartType = $request->get("chartType");
      if ($chartType != "" && $chartType != "none") {
      $data_series = $request->get("data_series");
      $charttitle = $request->get("charttitle");
      }
      }
     */
     // ITS4YOU-END 2.7.2014 15:18
     // ITS4YOU-CR SlOl | 20.8.2015 11:30
     if ($reporttype == "custom_report") {
         $customSql = ITS4YouReports::validateCustomSql($request->get("reportcustomsql"));
     }
     // ITS4YOU-END 20.8.2015 11:30
     if ($reportid != "" && $isDuplicate != "true") {
         $d_selectedcolumns = "DELETE FROM its4you_reports4you_selectcolumn WHERE its4you_reports4you_selectcolumn.queryid = ?";
         $d_columnsqlresult = $adb->pquery($d_selectedcolumns, array($reportid));
         if (!empty($selectedcolumns)) {
             for ($i = 0; $i < count($selectedcolumns); $i++) {
                 if (!empty($selectedcolumns[$i])) {
                     $icolumnsql = "INSERT INTO its4you_reports4you_selectcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) VALUES (?,?,?)";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($reportid, $i, decode_html($selectedcolumns[$i]));
                     $params_tofile = array("@reportid", $i, decode_html($selectedcolumns[$i]));
                     $report_array['its4you_reports4you_selectcolumn'][] = $params_tofile;
                     $icolumnsqlresult = $adb->pquery($icolumnsql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                 }
             }
         }
         // ITS4YOU-CR SlOl 7. 3. 2014 11:24:46 Summaries Save
         $d_selectedSummaries = "DELETE FROM its4you_reports4you_summaries WHERE reportsummaryid = ?";
         $d_Summariessqlqfresult = $adb->pquery($d_selectedSummaries, array($reportid));
         if (!empty($selectedSummaries)) {
             for ($i = 0; $i < count($selectedSummaries); $i++) {
                 if (!empty($selectedSummaries[$i])) {
                     $iSmmariessql = "INSERT INTO its4you_reports4you_summaries (reportsummaryid,summarytype,columnname) VALUES (?,?,?)";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($reportid, $i, decode_html($selectedSummaries[$i]));
                     $params_tofile = array("@reportid", $i, decode_html($selectedSummaries[$i]));
                     $report_array['its4you_reports4you_summaries'][] = $params_tofile;
                     $iSummariessqlresult = $adb->pquery($iSmmariessql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                 }
             }
         }
         // ITS4YOU-END 7. 3. 2014 11:24:48
         // ITS4YOU-CR SlOl 24. 3. 2014 8:52:40
         $d_selected_s_orderby = "DELETE FROM its4you_reports4you_summaries_orderby WHERE reportid = ?";
         $d_selected_s_orderbyresult = $adb->pquery($d_selected_s_orderby, array($reportid));
         if ($summaries_orderby != "" && $summaries_orderby_type != "") {
             $d_selected_s_orderby_sql = "INSERT INTO  its4you_reports4you_summaries_orderby (reportid,columnindex,summaries_orderby,summaries_orderby_type) VALUES (?,?,?,?)";
             $export_sql === true ? $adb->setDebug(true) : "";
             $params = array($reportid, 0, $summaries_orderby, $summaries_orderby_type);
             $params_tofile = array("@reportid", 0, $summaries_orderby, $summaries_orderby_type);
             $report_array['its4you_reports4you_summaries_orderby'] = $params_tofile;
             $d_selected_s_orderby_result = $adb->pquery($d_selected_s_orderby_sql, $params);
             $export_sql === true ? $adb->setDebug(false) : "";
         }
         // ITS4YOU-END 24. 3. 2014 8:52:42
         // ITS4YOU-CR SlOl 13. 3. 2014 11:34:24
         $d_selectedLabels = "DELETE FROM its4you_reports4you_labels WHERE reportid = ?";
         $d_Labelssqlqfresult = $adb->pquery($d_selectedLabels, array($reportid));
         if (!empty($lbl_array)) {
             foreach ($lbl_array as $type => $type_array) {
                 foreach ($type_array as $column_str => $column_lbl) {
                     $iLabelssql = "INSERT INTO its4you_reports4you_labels (reportid,type,columnname,columnlabel) VALUES (?,?,?,?)";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($reportid, $type, $column_str, $column_lbl);
                     $params_tofile = array("@reportid", $type, $column_str, $column_lbl);
                     $report_array['its4you_reports4you_labels'][] = $params_tofile;
                     $iLabelssqlresult = $adb->pquery($iLabelssql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                 }
             }
         }
         $d_selectedqfcolumns = "DELETE FROM its4you_reports4you_selectqfcolumn WHERE queryid = ?";
         $d_columnsqlqfresult = $adb->pquery($d_selectedqfcolumns, array($reportid));
         if (!empty($selectedqfcolumns)) {
             for ($i = 0; $i < count($selectedqfcolumns); $i++) {
                 if (!empty($selectedqfcolumns[$i])) {
                     $icolumnsql = "INSERT INTO its4you_reports4you_selectqfcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) VALUES (?,?,?)";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($reportid, $i, decode_html($selectedqfcolumns[$i]));
                     $params_tofile = array("@reportid", $i, decode_html($selectedqfcolumns[$i]));
                     $report_array['its4you_reports4you_selectqfcolumn'][] = $params_tofile;
                     $icolumnsqlresult = $adb->pquery($icolumnsql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                 }
             }
         }
         $d_shared = "DELETE FROM its4you_reports4you_sharing WHERE reports4youid = ?";
         $d_sharedresult = $adb->pquery($d_shared, array($reportid));
         if ($shared_entities != "") {
             if ($sharetype == "share") {
                 $selectedsharecolumn = explode("|", $shared_entities);
                 for ($i = 0; $i < count($selectedsharecolumn) - 1; $i++) {
                     $temp = split("::", $selectedsharecolumn[$i]);
                     $icolumnsql = "INSERT INTO its4you_reports4you_sharing (reports4youid,shareid,setype) VALUES (?,?,?)";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($reportid, $temp[1], $temp[0]);
                     $params_tofile = array("@reportid", $temp[1], $temp[0]);
                     $report_array['its4you_reports4you_sharing'][] = $params_tofile;
                     $icolumnsqlresult = $adb->pquery($icolumnsql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                 }
             }
         }
         if ($reportid != "") {
             $ireportsql = "UPDATE its4you_reports4you SET reports4youname=?, description=?, folderid=?, reporttype=?, columns_limit=?, summaries_limit=? WHERE reports4youid=?";
             $ireportparams = array($reportname, $reportdescription, $folderid, $reporttype, $limit, $summaries_limit, $reportid);
             $params_tofile = array("@reportid", $reportname, $reportdescription, $folderid, $reporttype, 0, $limit, $summaries_limit);
             // ITS4YOU-END
             $export_sql === true ? $adb->setDebug(true) : "";
             $report_array['its4you_reports4you'] = $params_tofile;
             $ireportresult = $adb->pquery($ireportsql, $ireportparams);
             $export_sql === true ? $adb->setDebug(false) : "";
             if ($ireportresult != false) {
                 if ($reporttype != "custom_report") {
                     //<<<<reportmodules>>>>>>>
                     $d_modules = "DELETE FROM its4you_reports4you_modules WHERE reportmodulesid = ?";
                     $d_modulesresult = $adb->pquery($d_modules, array($reportid));
                     $ireportmodulesql = "INSERT INTO its4you_reports4you_modules (REPORTMODULESID,PRIMARYMODULE,SECONDARYMODULES) VALUES (?,?,?)";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($reportid, $pmodule, $smodule);
                     $params_tofile = array("@reportid", $pmodule, $smodule);
                     $report_array['its4you_reports4you_modules'] = $params_tofile;
                     $ireportmoduleresult = $adb->pquery($ireportmodulesql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                     //<<<<reportmodules>>>>>>>
                     //<<<<step3 its4you_reports4you_sortcol>>>>>>>
                     $d_sortcol1 = "DELETE FROM its4you_reports4you_sortcol WHERE reportid = ? AND sortcolid=?";
                     $d_sortcol1_result = $adb->pquery($d_sortcol1, array($reportid, 1));
                     if ($sort_by1 != "") {
                         $sort_by1sql = "INSERT INTO its4you_reports4you_sortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER,timeline_columnstr,timeline_columnfreq) VALUES (?,?,?,?,?,?)";
                         $export_sql === true ? $adb->setDebug(true) : "";
                         $params = array(1, $reportid, $sort_by1, $sort_order1, $TimeLineColumn_str1, $TimeLineColumn_frequency1);
                         $params_tofile = array(1, "@reportid", $sort_by1, $sort_order1, "rows", $TimeLineColumn_str1, $TimeLineColumn_frequency1);
                         $report_array['its4you_reports4you_sortcol'][] = $params_tofile;
                         $sort_by1result = $adb->pquery($sort_by1sql, $params);
                         $export_sql === true ? $adb->setDebug(false) : "";
                     }
                     $d_sortcol2 = "DELETE FROM its4you_reports4you_sortcol WHERE reportid = ? AND sortcolid=?";
                     $d_sortcol2_result = $adb->pquery($d_sortcol2, array($reportid, 2));
                     if ($sort_by2 != "") {
                         $sort_by2sql = "INSERT INTO its4you_reports4you_sortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER,timeline_type,timeline_columnstr,timeline_columnfreq) VALUES (?,?,?,?,?,?,?)";
                         $export_sql === true ? $adb->setDebug(true) : "";
                         $params = array(2, $reportid, $sort_by2, $sort_order2, $timeline_type2, $TimeLineColumn_str2, $TimeLineColumn_frequency2);
                         $params_tofile = array(2, "@reportid", $sort_by2, $sort_order2, $timeline_type2, $TimeLineColumn_str2, $TimeLineColumn_frequency2);
                         $report_array['its4you_reports4you_sortcol'][] = $params_tofile;
                         $sort_by2result = $adb->pquery($sort_by2sql, $params);
                         $export_sql === true ? $adb->setDebug(false) : "";
                     }
                     $d_sortcol3 = "DELETE FROM its4you_reports4you_sortcol WHERE reportid = ? AND sortcolid=?";
                     $d_sortcol3_result = $adb->pquery($d_sortcol3, array($reportid, 3));
                     if ($sort_by3 != "") {
                         $sort_by3sql = "INSERT INTO its4you_reports4you_sortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER,timeline_type,timeline_columnstr,timeline_columnfreq) VALUES (?,?,?,?,?,?,?)";
                         $export_sql === true ? $adb->setDebug(true) : "";
                         $params = array(3, $reportid, $sort_by3, $sort_order3, $timeline_type3, $TimeLineColumn_str3, $TimeLineColumn_frequency3);
                         $params_tofile = array(3, "@reportid", $sort_by3, $sort_order3, $timeline_type3, $TimeLineColumn_str3, $TimeLineColumn_frequency3);
                         $report_array['its4you_reports4you_sortcol'][] = $params_tofile;
                         $sort_by3result = $adb->pquery($sort_by3sql, $params);
                         $export_sql === true ? $adb->setDebug(false) : "";
                     }
                     $d_sortcol4 = "DELETE FROM its4you_reports4you_sortcol WHERE reportid = ? AND sortcolid=?";
                     $d_sortcol4_result = $adb->pquery($d_sortcol4, array($reportid, 4));
                     if ($sort_by_column != "") {
                         $sort_by_columnsql = "INSERT INTO its4you_reports4you_sortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) VALUES (?,?,?,?)";
                         $export_sql === true ? $adb->setDebug(true) : "";
                         $params = array(4, $reportid, $sort_by_column, $sort_order_column);
                         $params_tofile = array(4, "@reportid", $sort_by_column, $sort_order_column, "", "", "");
                         $report_array['its4you_reports4you_sortcol'][] = $params_tofile;
                         ${$sort_by_columnresult} = $adb->pquery($sort_by_columnsql, $params);
                         $export_sql === true ? $adb->setDebug(false) : "";
                     }
                     //<<<<step3 its4you_reports4you_sortcol>>>>>>>
                     //<<<<step5 standarfilder>>>>>>>
                     $d_datefilter = "DELETE FROM its4you_reports4you_datefilter WHERE datefilterid = ?";
                     $d_datefilter_result = $adb->pquery($d_datefilter, array($reportid));
                     $ireportmodulesql = "INSERT INTO its4you_reports4you_datefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) VALUES (?,?,?,?,?)";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($reportid, $stdDateFilterField, $stdDateFilter, $startdate, $enddate);
                     $params_tofile = array("@reportid", $stdDateFilterField, $stdDateFilter, $startdate, $enddate);
                     $report_array['its4you_reports4you_datefilter'] = $params_tofile;
                     $ireportmoduleresult = $adb->pquery($ireportmodulesql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                     //<<<<step5 standarfilder>>>>>>>
                     //<<<<step4 columnstototal>>>>>>>
                     $d_summary = "DELETE FROM its4you_reports4you_summary WHERE reportsummaryid = ?";
                     $d_summary_result = $adb->pquery($d_summary, array($reportid));
                     for ($i = 0; $i < count($columnstototal); $i++) {
                         $ireportsummarysql = "INSERT INTO its4you_reports4you_summary (REPORTSUMMARYID,SUMMARYTYPE,COLUMNNAME) VALUES (?,?,?)";
                         $export_sql === true ? $adb->setDebug(true) : "";
                         $params = array($reportid, $i, $columnstototal[$i]);
                         $params_tofile = array("@reportid", $i, $columnstototal[$i]);
                         $report_array['its4you_reports4you_summary'][] = $params_tofile;
                         $ireportsummaryresult = $adb->pquery($ireportsummarysql, $params);
                         $export_sql === true ? $adb->setDebug(false) : "";
                     }
                     //<<<<step4 columnstototal>>>>>>>
                     //<<<<step5 advancedfilter>>>>>>>
                     $default_charset = vglobal("default_charset");
                     $this->saveAdvancedFilters($advft_criteria, $advft_criteria_groups, $std_filter_columns, $export_sql);
                     $d_adv_criteria = "DELETE FROM its4you_reports4you_relcriteria_summaries WHERE reportid = ?";
                     $d_adv_criteria_result = $adb->pquery($d_adv_criteria, array($reportid));
                     foreach ($groupft_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["column_condition"];
                         $adv_filter_groupid = $column_condition["groupid"];
                         $column_info = explode(":", $adv_filter_column);
                         $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::convertToDBFormat(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 its4you_reports4you_relcriteria_summaries(reportid,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE,GROUPID,COLUMN_CONDITION) VALUES (?,?,?,?,?,?,?)";
                         $export_sql === true ? $adb->setDebug(true) : "";
                         $params = array($reportid, $column_index, $adv_filter_column, $adv_filter_comparator, $adv_filter_value, $adv_filter_groupid, $adv_filter_column_condition);
                         $params_tofile = array("@reportid", $column_index, $adv_filter_column, $adv_filter_comparator, $adv_filter_value, $adv_filter_groupid, $adv_filter_column_condition);
                         $report_array['its4you_reports4you_relcriteria_summaries'][] = $params_tofile;
                         $irelcriteriaresult = $adb->pquery($irelcriteriasql, $params);
                         $export_sql === true ? $adb->setDebug(false) : "";
                         // 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;
                     }
                     //<<<<step5 advancedfilter>>>>>>>
                 }
                 $owner = vtlib_purify($_REQUEST["template_owner"]);
                 $sharingtype = vtlib_purify($_REQUEST["sharing"]);
                 if ($owner != "" && $owner != "") {
                     $limitsql = "UPDATE its4you_reports4you_settings SET owner=?, sharingtype=? WHERE reportid=?";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($owner, $sharingtype, $reportid);
                     $params_tofile = array("@reportid", $owner, $sharingtype);
                     $report_array['its4you_reports4you_settings'] = $params_tofile;
                     $limitresult = $adb->pquery($limitsql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                 }
                 //<<<<step7 scheduledReport>>>>>>>
                 if ($isReportScheduled == 'off' || $isReportScheduled == '0' || $isReportScheduled == '') {
                     $deleteScheduledReportSql = "DELETE FROM its4you_reports4you_scheduled_reports WHERE reportid=?";
                     $adb->pquery($deleteScheduledReportSql, array($reportid));
                 } else {
                     $checkScheduledResult = $adb->pquery('SELECT 1 FROM its4you_reports4you_scheduled_reports WHERE reportid=?', array($reportid));
                     if ($adb->num_rows($checkScheduledResult) > 0) {
                         $scheduledReportSql = 'UPDATE its4you_reports4you_scheduled_reports SET recipients=?,schedule=?,format=? WHERE reportid=?';
                         $export_sql === true ? $adb->setDebug(true) : "";
                         $params = array($selectedRecipients, $scheduledInterval, $scheduledFormat, $reportid);
                         $params_tofile = array("@reportid", $selectedRecipients, $scheduledInterval, $scheduledFormat, date("Y-m-d H:i:s"));
                         $report_array['its4you_reports4you_scheduled_reports'] = $params_tofile;
                         $adb->pquery($scheduledReportSql, $params);
                         $export_sql === true ? $adb->setDebug(false) : "";
                     } else {
                         $scheduleReportSql = 'INSERT INTO its4you_reports4you_scheduled_reports (reportid,recipients,schedule,format,next_trigger_time) VALUES (?,?,?,?,?)';
                         $export_sql === true ? $adb->setDebug(true) : "";
                         $params = array($reportid, $selectedRecipients, $scheduledInterval, $scheduledFormat, date("Y-m-d H:i:s"));
                         $params_tofile = array("@reportid", $selectedRecipients, $scheduledInterval, $scheduledFormat, date("Y-m-d H:i:s"));
                         $report_array['its4you_reports4you_scheduled_reports'] = $params_tofile;
                         $adb->pquery($scheduleReportSql, $params);
                         $export_sql === true ? $adb->setDebug(false) : "";
                     }
                 }
                 //<<<<step7 scheduledReport>>>>>>>
                 if ($reporttype != "custom_report") {
                     //<<<<step12 Report Charts >>>>>>>
                     $deleteChartsSql = "DELETE FROM its4you_reports4you_charts WHERE reports4youid=?";
                     $adb->pquery($deleteChartsSql, array($reportid));
                     if (!empty($charts)) {
                         foreach ($charts as $chi => $ch_params) {
                             $ChartsSql = 'INSERT INTO its4you_reports4you_charts (reports4youid,charttype,dataseries,charttitle,chart_seq,x_group) VALUES (?,?,?,?,?,?)';
                             $ch_params_tofile = array_merge(array("reports4youid" => "@reportid"), $ch_params);
                             $ch_params = array_merge(array($reportid), $ch_params);
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $report_array['its4you_reports4you_charts'][] = $ch_params_tofile;
                             $adb->pquery($ChartsSql, array($ch_params));
                             $export_sql === true ? $adb->setDebug(false) : "";
                         }
                     }
                     /*
                      if ($chartType != "" && $chartType != "none") {
                      $ChartsSql = 'INSERT INTO its4you_reports4you_charts (reports4youid,charttype,dataseries,charttitle) VALUES (?,?,?,?)';
                      $export_sql === true ? $adb->setDebug(true) : "";
                      $adb->pquery($ChartsSql, array($reportid, $chartType, $data_series, $charttitle));
                      $export_sql === true ? $adb->setDebug(false) : "";
                      }
                     */
                     //<<<<step12 Report Charts >>>>>>>
                 }
                 //<<<<step13 Custom Report SQL >>>>>>>
                 if ($reporttype == "custom_report") {
                     $deleteCustomSql = "DELETE FROM its4you_reports4you_customsql WHERE reports4youid=?";
                     $adb->pquery($deleteCustomSql, array($reportid));
                     $CustomSqlQry = 'INSERT INTO its4you_reports4you_customsql (reports4youid,custom_sql) VALUES (?,?)';
                     $params = array($reportid, $customSql);
                     $params_tofile = array("@reportid", $customSql);
                     $report_array['its4you_reports4you_customsql'] = $params_tofile;
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $adb->pquery($CustomSqlQry, array($params));
                     $export_sql === true ? $adb->setDebug(false) : "";
                 }
                 //<<<<step13 Custom Report SQL >>>>>>>
             } else {
                 $errormessage = "<font color='red'><B>Error Message<ul>\n                                            <li><font color='red'>Error while inserting the record</font>\n                                            </ul></B></font> <br>";
                 echo $errormessage;
                 die;
             }
         }
         if ($export_sql === true) {
             ITS4YouReports::sshow("EDIT");
         }
     } else {
         $genQueryId = $adb->getUniqueID("its4you_reports4you_selectquery");
         if ($genQueryId < 1) {
             $adb->pquery("DELETE FROM its4you_reports4you_selectquery_seq ", array());
             $adb->pquery("SELECT @max_reportid:=max(reports4youid)+1 FROM `its4you_reports4you`;", array());
             $adb->pquery("INSERT INTO its4you_reports4you_selectquery_seq (id) VALUES (@max_reportid); ", array());
             $genQueryId = $adb->getUniqueID("its4you_reports4you_selectquery");
         }
         $reportid = $genQueryId;
         $this->setId($reportid);
         if ($genQueryId != "") {
             $iquerysql = "insert into its4you_reports4you_selectquery (QUERYID,STARTINDEX,NUMOFOBJECTS) values (?,?,?)";
             $export_sql === true ? $adb->setDebug(true) : "";
             $params = array($genQueryId, 0, 0);
             $params_tofile = array("@reportid", 0, 0);
             $report_array['its4you_reports4you_selectquery'] = $params_tofile;
             $iquerysqlresult = $adb->pquery($iquerysql, $params);
             $export_sql === true ? $adb->setDebug(false) : "";
             if ($iquerysqlresult != false) {
                 //<<<<step2 vtiger_rep4u_selectcolumn>>>>>>>>
                 if (!empty($selectedcolumns)) {
                     for ($i = 0; $i < count($selectedcolumns); $i++) {
                         if (!empty($selectedcolumns[$i])) {
                             $icolumnsql = "insert into its4you_reports4you_selectcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) values (?,?,?)";
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $params = array($genQueryId, $i, decode_html($selectedcolumns[$i]));
                             $params_tofile = array("@reportid", $i, decode_html($selectedcolumns[$i]));
                             $report_array['its4you_reports4you_selectcolumn'][] = $params_tofile;
                             $icolumnsqlresult = $adb->pquery($icolumnsql, $params);
                             $export_sql === true ? $adb->setDebug(false) : "";
                         }
                     }
                 }
                 //<<<< its4you_reports4you_summaries>>>>>>>>
                 if (!empty($selectedSummaries)) {
                     for ($i = 0; $i < count($selectedSummaries); $i++) {
                         if (!empty($selectedSummaries[$i])) {
                             $iSmmariessql = "INSERT INTO its4you_reports4you_summaries (reportsummaryid,summarytype,columnname) VALUES (?,?,?)";
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $params = array($genQueryId, $i, decode_html($selectedSummaries[$i]));
                             $params_tofile = array("@reportid", $i, decode_html($selectedSummaries[$i]));
                             $report_array['its4you_reports4you_summaries'][] = $params_tofile;
                             $iSummariessqlresult = $adb->pquery($iSmmariessql, $params);
                             $export_sql === true ? $adb->setDebug(false) : "";
                         }
                     }
                 }
                 if ($summaries_orderby != "" && $summaries_orderby_type != "") {
                     $d_selected_s_orderby_sql = "INSERT INTO  its4you_reports4you_summaries_orderby (reportid,columnindex,summaries_orderby,summaries_orderby_type) VALUES (?,?,?,?)";
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $params = array($genQueryId, 0, $summaries_orderby, $summaries_orderby_type);
                     $params_tofile = array("@reportid", 0, $summaries_orderby, $summaries_orderby_type);
                     $report_array['its4you_reports4you_summaries_orderby'] = $params_tofile;
                     $d_selected_s_orderby_result = $adb->pquery($d_selected_s_orderby_sql, $params);
                     $export_sql === true ? $adb->setDebug(false) : "";
                 }
                 if (!empty($lbl_array)) {
                     foreach ($lbl_array as $type => $type_array) {
                         foreach ($type_array as $column_str => $column_lbl) {
                             $iLabelssql = "INSERT INTO its4you_reports4you_labels (reportid,type,columnname,columnlabel) VALUES (?,?,?,?)";
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $params = array($genQueryId, $type, $column_str, $column_lbl);
                             $params_tofile = array("@reportid", $type, $column_str, $column_lbl);
                             $report_array['its4you_reports4you_labels'][] = $params_tofile;
                             $iLabelssqlresult = $adb->pquery($iLabelssql, $params);
                             $export_sql === true ? $adb->setDebug(false) : "";
                         }
                     }
                 }
                 if (!empty($selectedqfcolumns)) {
                     for ($i = 0; $i < count($selectedqfcolumns); $i++) {
                         if (!empty($selectedqfcolumns[$i])) {
                             $icolumnsql = "insert into its4you_reports4you_selectqfcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) values (?,?,?)";
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $params = array($genQueryId, $i, decode_html($selectedqfcolumns[$i]));
                             $params_tofile = array("@reportid", $i, decode_html($selectedqfcolumns[$i]));
                             $report_array['its4you_reports4you_selectqfcolumn'][] = $params_tofile;
                             $icolumnsqlresult = $adb->pquery($icolumnsql, $params);
                             $export_sql === true ? $adb->setDebug(false) : "";
                         }
                     }
                 }
                 if ($shared_entities != "") {
                     if ($sharetype == "share") {
                         $selectedsharecolumn = explode("|", $shared_entities);
                         for ($i = 0; $i < count($selectedsharecolumn) - 1; $i++) {
                             $temp = split("::", $selectedsharecolumn[$i]);
                             $icolumnsql = "INSERT INTO its4you_reports4you_sharing (reports4youid,shareid,setype) VALUES (?,?,?)";
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $params = array($reportid, $temp[1], $temp[0]);
                             $params_tofile = array("@reportid", $temp[1], $temp[0]);
                             $report_array['its4you_reports4you_sharing'][] = $params_tofile;
                             $icolumnsqlresult = $adb->pquery($icolumnsql, $params);
                             $export_sql === true ? $adb->setDebug(false) : "";
                         }
                     }
                 }
                 if ($genQueryId != "") {
                     $ireportsql = "insert into its4you_reports4you (reports4youid,reports4youname,description,folderid,reporttype,columns_limit,summaries_limit) values (?,?,?,?,?,?,?)";
                     $ireportparams = array($genQueryId, $reportname, $reportdescription, $folderid, $reporttype, $limit, $summaries_limit);
                     $params_tofile = array("@reportid", $reportname, $reportdescription, $folderid, $reporttype, 0, $limit, $summaries_limit);
                     // ITS4YOU-END
                     $export_sql === true ? $adb->setDebug(true) : "";
                     $report_array['its4you_reports4you'] = $params_tofile;
                     $ireportresult = $adb->pquery($ireportsql, $ireportparams);
                     $export_sql === true ? $adb->setDebug(false) : "";
                     if ($ireportresult != false) {
                         if ($reporttype != "custom_report") {
                             //<<<<reportmodules>>>>>>>
                             $ireportmodulesql = "insert into its4you_reports4you_modules (REPORTMODULESID,PRIMARYMODULE,SECONDARYMODULES) values (?,?,?)";
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $params = array($genQueryId, $pmodule, $smodule);
                             $params_tofile = array("@reportid", $pmodule, $smodule);
                             $report_array['its4you_reports4you_modules'] = $params_tofile;
                             $ireportmoduleresult = $adb->pquery($ireportmodulesql, $params);
                             $export_sql === true ? $adb->setDebug(false) : "";
                             //<<<<reportmodules>>>>>>>
                             //<<<<step3 its4you_reports4you_sortcol>>>>>>>
                             if ($sort_by1 != "") {
                                 $sort_by1sql = "insert into its4you_reports4you_sortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER,timeline_columnstr,timeline_columnfreq) values (?,?,?,?,?,?)";
                                 $export_sql === true ? $adb->setDebug(true) : "";
                                 $params = array(1, $genQueryId, $sort_by1, $sort_order1, $TimeLineColumn_str1, $TimeLineColumn_frequency1);
                                 $params_tofile = array(1, "@reportid", $sort_by1, $sort_order1, "rows", $TimeLineColumn_str1, $TimeLineColumn_frequency1);
                                 $report_array['its4you_reports4you_sortcol'][] = $params_tofile;
                                 $sort_by1result = $adb->pquery($sort_by1sql, $params);
                                 $export_sql === true ? $adb->setDebug(false) : "";
                             }
                             if ($sort_by2 != "") {
                                 $sort_by2sql = "insert into its4you_reports4you_sortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER,timeline_type,timeline_columnstr,timeline_columnfreq) values (?,?,?,?,?,?,?)";
                                 $export_sql === true ? $adb->setDebug(true) : "";
                                 $params = array(2, $genQueryId, $sort_by2, $sort_order2, $timeline_type2, $TimeLineColumn_str2, $TimeLineColumn_frequency2);
                                 $params_tofile = array(2, "@reportid", $sort_by2, $sort_order2, $timeline_type2, $TimeLineColumn_str2, $TimeLineColumn_frequency2);
                                 $report_array['its4you_reports4you_sortcol'][] = $params_tofile;
                                 $sort_by2result = $adb->pquery($sort_by2sql, $params);
                                 $export_sql === true ? $adb->setDebug(false) : "";
                             }
                             if ($sort_by3 != "") {
                                 $sort_by3sql = "insert into its4you_reports4you_sortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER,timeline_type,timeline_columnstr,timeline_columnfreq) values (?,?,?,?,?,?,?)";
                                 $export_sql === true ? $adb->setDebug(true) : "";
                                 $params = array(3, $genQueryId, $sort_by3, $sort_order3, $timeline_type3, $TimeLineColumn_str3, $TimeLineColumn_frequency3);
                                 $params_tofile = array(3, "@reportid", $sort_by3, $sort_order3, $timeline_type3, $TimeLineColumn_str3, $TimeLineColumn_frequency3);
                                 $report_array['its4you_reports4you_sortcol'][] = $params_tofile;
                                 $sort_by3result = $adb->pquery($sort_by3sql, $params);
                                 $export_sql === true ? $adb->setDebug(false) : "";
                             }
                             if ($sort_by_column != "") {
                                 $sort_by_columnsql = "insert into its4you_reports4you_sortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (?,?,?,?)";
                                 $export_sql === true ? $adb->setDebug(true) : "";
                                 $params = array(4, $genQueryId, $sort_by_column, $sort_order_column);
                                 $params_tofile = array(4, "@reportid", $sort_by_column, $sort_order_column, "", "", "");
                                 $report_array['its4you_reports4you_sortcol'][] = $params_tofile;
                                 $sort_by_columnresult = $adb->pquery($sort_by_columnsql, $params);
                                 $export_sql === true ? $adb->setDebug(false) : "";
                             }
                             //<<<<step3 its4you_reports4you_sortcol>>>>>>>
                             //<<<<step5 standarfilder>>>>>>>
                             $ireportmodulesql = "insert into its4you_reports4you_datefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (?,?,?,?,?)";
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $params = array($genQueryId, $stdDateFilterField, $stdDateFilter, $startdate, $enddate);
                             $params_tofile = array("@reportid", $stdDateFilterField, $stdDateFilter, $startdate, $enddate);
                             $report_array['its4you_reports4you_datefilter'] = $params_tofile;
                             $ireportmoduleresult = $adb->pquery($ireportmodulesql, $params);
                             $export_sql === true ? $adb->setDebug(false) : "";
                             //<<<<step5 standarfilder>>>>>>>
                             //<<<<step4 columnstototal>>>>>>>
                             for ($i = 0; $i < count($columnstototal); $i++) {
                                 $ireportsummarysql = "insert into its4you_reports4you_summary (REPORTSUMMARYID,SUMMARYTYPE,COLUMNNAME) values (?,?,?)";
                                 $export_sql === true ? $adb->setDebug(true) : "";
                                 $params = array($genQueryId, $i, $columnstototal[$i]);
                                 $params_tofile = array("@reportid", $i, $columnstototal[$i]);
                                 $report_array['its4you_reports4you_summary'][] = $params_tofile;
                                 $ireportsummaryresult = $adb->pquery($ireportsummarysql, $params);
                                 $export_sql === true ? $adb->setDebug(false) : "";
                             }
                             //<<<<step4 columnstototal>>>>>>>
                             //<<<<step5 advancedfilter>>>>>>>
                             // DOKONC SAVE TO FILE OLDO
                             $this->saveAdvancedFilters($advft_criteria, $advft_criteria_groups, $std_filter_columns, $export_sql);
                             foreach ($groupft_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["column_condition"];
                                 $adv_filter_groupid = $column_condition["groupid"];
                                 $column_info = explode(":", $adv_filter_column);
                                 $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::convertToDBFormat(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 its4you_reports4you_relcriteria_summaries(reportid,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE,GROUPID,COLUMN_CONDITION) VALUES (?,?,?,?,?,?,?)";
                                 $export_sql === true ? $adb->setDebug(true) : "";
                                 $params = array($reportid, $column_index, $adv_filter_column, $adv_filter_comparator, $adv_filter_value, $adv_filter_groupid, $adv_filter_column_condition);
                                 $params_tofile = array("@reportid", $column_index, $adv_filter_column, $adv_filter_comparator, $adv_filter_value, $adv_filter_groupid, $adv_filter_column_condition);
                                 $report_array['its4you_reports4you_relcriteria_summaries'][] = $params_tofile;
                                 $irelcriteriaresult = $adb->pquery($irelcriteriasql, $params);
                                 $export_sql === true ? $adb->setDebug(false) : "";
                                 // 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;
                             }
                             //<<<<step5 advancedfilter>>>>>>>
                         }
                         //<<<<step6 sharing >>>>>>>
                         $owner = vtlib_purify($_REQUEST["template_owner"]);
                         $sharingtype = vtlib_purify($_REQUEST["sharing"]);
                         if ($owner != "" && $owner != "") {
                             $limitsql = "insert into its4you_reports4you_settings (reportid,owner,sharingtype) VALUES (?,?,?)";
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $params = array($genQueryId, $owner, $sharingtype);
                             $params_tofile = array("@reportid", $owner, $sharingtype);
                             $report_array['its4you_reports4you_settings'] = $params_tofile;
                             $limitresult = $adb->pquery($limitsql, $params);
                             $export_sql === true ? $adb->setDebug(false) : "";
                         }
                         //<<<<step6 sharing >>>>>>>
                         //<<<<step7 scheduledReport>>>>>>>
                         if ($isReportScheduled == 'off' || $isReportScheduled == '0' || $isReportScheduled == '') {
                             $deleteScheduledReportSql = "DELETE FROM its4you_reports4you_scheduled_reports WHERE reportid=?";
                             $adb->pquery($deleteScheduledReportSql, array($reportid));
                         } else {
                             $checkScheduledResult = $adb->pquery('SELECT 1 FROM its4you_reports4you_scheduled_reports WHERE reportid=?', array($reportid));
                             if ($adb->num_rows($checkScheduledResult) > 0) {
                                 $scheduledReportSql = 'UPDATE its4you_reports4you_scheduled_reports SET recipients=?,schedule=?,format=? WHERE reportid=?';
                                 $export_sql === true ? $adb->setDebug(true) : "";
                                 $params = array($selectedRecipients, $scheduledInterval, $scheduledFormat, $reportid);
                                 $params_tofile = array("@reportid", $selectedRecipients, $scheduledInterval, $scheduledFormat, date("Y-m-d H:i:s"));
                                 $report_array['its4you_reports4you_scheduled_reports'] = $params_tofile;
                                 $adb->pquery($scheduledReportSql, $params);
                                 $export_sql === true ? $adb->setDebug(false) : "";
                             } else {
                                 $scheduleReportSql = 'INSERT INTO its4you_reports4you_scheduled_reports (reportid,recipients,schedule,format,next_trigger_time) VALUES (?,?,?,?,?)';
                                 $export_sql === true ? $adb->setDebug(true) : "";
                                 $params = array($reportid, $selectedRecipients, $scheduledInterval, $scheduledFormat, date("Y-m-d H:i:s"));
                                 $params_tofile = array("@reportid", $selectedRecipients, $scheduledInterval, $scheduledFormat, date("Y-m-d H:i:s"));
                                 $report_array['its4you_reports4you_scheduled_reports'] = $params_tofile;
                                 $adb->pquery($scheduleReportSql, $params);
                                 $export_sql === true ? $adb->setDebug(false) : "";
                             }
                         }
                         if ($reporttype != "custom_report") {
                             //<<<<step12 Report Charts >>>>>>>
                             $deleteChartsSql = "DELETE FROM its4you_reports4you_charts WHERE reports4youid=?";
                             $adb->pquery($deleteChartsSql, array($reportid));
                             /*
                              if ($chartType != "" && $chartType != "none") {
                              $ChartsSql = 'INSERT INTO its4you_reports4you_charts (reports4youid,charttype,dataseries,charttitle) VALUES (?,?,?,?)';
                              $export_sql === true ? $adb->setDebug(true) : "";
                              $adb->pquery($ChartsSql, array($reportid, $chartType, $data_series, $charttitle));
                              $export_sql === true ? $adb->setDebug(false) : "";
                              }
                             */
                             if (!empty($charts)) {
                                 foreach ($charts as $chi => $ch_params) {
                                     $ChartsSql = 'INSERT INTO its4you_reports4you_charts (reports4youid,charttype,dataseries,charttitle,chart_seq,x_group) VALUES (?,?,?,?,?,?)';
                                     $ch_params = array_merge(array($reportid), $ch_params);
                                     $ch_params_tofile = array_merge(array("@reportid"), $ch_params);
                                     $export_sql === true ? $adb->setDebug(true) : "";
                                     $params = array($ch_params);
                                     $report_array['its4you_reports4you_charts'][] = array($ch_params_tofile);
                                     $adb->pquery($ChartsSql, $params);
                                     $export_sql === true ? $adb->setDebug(false) : "";
                                 }
                             }
                             //<<<<step12 Report Charts >>>>>>>
                         }
                         //<<<<step13 Custom Report SQL >>>>>>>
                         if ($reporttype == "custom_report") {
                             $CustomSqlQry = 'INSERT INTO its4you_reports4you_customsql (reports4youid,custom_sql) VALUES (?,?)';
                             $params = array($reportid, $customSql);
                             $params_tofile = array("@reportid", $customSql);
                             $report_array['its4you_reports4you_customsql'] = $params_tofile;
                             $export_sql === true ? $adb->setDebug(true) : "";
                             $adb->pquery($CustomSqlQry, array($params));
                             $export_sql === true ? $adb->setDebug(false) : "";
                         }
                         //<<<<step13 Custom Report SQL >>>>>>>
                     } else {
                         $errormessage = "<font color='red'><B>Error Message<ul>\n                                                            <li><font color='red'>Error while inserting the record</font>\n                                                            </ul></B></font> <br>";
                         echo $errormessage;
                         die;
                     }
                 }
             } else {
                 $errormessage = "<font color='red'><B>Error Message<ul>\n                                            <li><font color='red'>Error while inserting the record (QUERYID)</font>\n                                            </ul></B></font> <br>";
                 echo $errormessage;
                 die;
             }
         }
         if ($export_sql === true && $isDuplicate != "true") {
             ITS4YouReports::sshow("EDIT");
         } elseif ($export_sql === true) {
             ITS4YouReports::sshow("DUPLICATE");
         }
     }
     if ($export_to_file === true) {
         $report_array_json = Zend_JSON::encode($report_array);
         //			ITS4YouReports::sshow($report_array['its4you_reports4you_charts']);
         //			ITS4YouReports::sshow($report_array_json);
         $fileReportContent = "<?php " . '$report_array_json = ' . "'" . $report_array_json . "'; ";
         $file_path = "test/ITS4YouReports/ITS4YouReports_" . $this->getId() . ".php";
         $exportOfReport = fopen($file_path, 'w');
         fwrite($exportOfReport, $fileReportContent);
         fclose($exportOfReport);
         echo "DONE {$file_path}";
         exit;
     }
     if ($export_sql === true) {
         exit;
     }
     return true;
     // ini_set("display_errors", 1);error_reporting(63);
 }
Example #23
0
 /**
  * Save the inventory data
  */
 public function saveInventoryData()
 {
     $db = PearDatabase::getInstance();
     $log = vglobal('log');
     $log->debug('Entering ' . __CLASS__ . '::' . __METHOD__);
     $moduleName = $this->getModuleName();
     $inventory = Vtiger_InventoryField_Model::getInstance($moduleName);
     $fields = $inventory->getColumns();
     $table = $inventory->getTableName('data');
     $request = new Vtiger_Request($_REQUEST, $_REQUEST);
     $numRow = $request->get('inventoryItemsNo');
     $db->pquery("delete from {$table} where id = ?", [$this->getId()]);
     for ($i = 1; $i <= $numRow; $i++) {
         if (!$request->has(reset($fields)) && !$request->has(reset($fields) . $i)) {
             continue;
         }
         $insertData = ['id' => $this->getId(), 'seq' => $request->get('seq' . $i)];
         foreach ($fields as $field) {
             $insertData[$field] = $inventory->getValueForSave($request, $field, $i);
         }
         $db->insert($table, $insertData);
     }
     $log->debug('Exiting ' . __CLASS__ . '::' . __METHOD__);
 }
Example #24
0
 /**
  * Save the inventory data
  */
 public function initInventoryData()
 {
     $log = vglobal('log');
     $log->debug('Entering ' . __CLASS__ . '::' . __METHOD__);
     $moduleName = $this->getModuleName();
     $inventory = Vtiger_InventoryField_Model::getInstance($moduleName);
     $fields = $inventory->getColumns();
     $table = $inventory->getTableName('data');
     $summaryFields = $inventory->getSummaryFields();
     $inventoryData = $summary = [];
     if ($this->has('inventoryData')) {
         $request = $this->get('inventoryData');
     } else {
         $request = new Vtiger_Request($_REQUEST, $_REQUEST);
     }
     if ($request->has('inventoryItemsNo')) {
         $numRow = $request->get('inventoryItemsNo');
         for ($i = 1; $i <= $numRow; $i++) {
             if (!$request->has(reset($fields)) && !$request->has(reset($fields) . $i)) {
                 continue;
             }
             $insertData = ['seq' => $request->get('seq' . $i)];
             foreach ($fields as $field) {
                 $value = $insertData[$field] = $inventory->getValueForSave($request, $field, $i);
                 if (in_array($field, $summaryFields)) {
                     $summary[$field] += $value;
                 }
             }
             $inventoryData[] = $insertData;
         }
         foreach ($summary as $fieldName => $fieldValue) {
             if ($this->has($fieldName)) {
                 $this->set($fieldName, CurrencyField::convertToUserFormat($fieldValue, null, true));
             }
         }
     }
     $this->inventoryData = $inventoryData;
     $log->debug('Exiting ' . __CLASS__ . '::' . __METHOD__);
 }
Example #25
0
 public function process(Vtiger_Request $request)
 {
     $qlbhckksnimn = "taskFormMessage";
     ${"GLOBALS"}["ondjqerxav"] = "result";
     ${"GLOBALS"}["dmqhyvmbkuu"] = "qualifiedModuleName";
     global $adb, $current_user;
     ob_end_flush();
     ${"GLOBALS"}["wjqjuxci"] = "taskObj";
     $uysndayj = "requestValues";
     ob_end_flush();
     $adb->dieOnError = false;
     global $current_user;
     $ttjbib = "configArray";
     ${"GLOBALS"}["lafbuiijg"] = "useBuiltinEncoderDecoder";
     global $root_directory;
     ${${"GLOBALS"}["cnblwvhg"]} = PearDatabase::getInstance();
     ${"GLOBALS"}["upiqdw"] = "configArray";
     ${${"GLOBALS"}["axxhajyp"]} = $request->getModule();
     $xfrtukowsxy = "taskObj";
     ${${"GLOBALS"}["ttrtah"]} = $request->getModule(false);
     ${${"GLOBALS"}["ixtqommhm"]} = $this->getViewer(${${"GLOBALS"}["hrxvefnlrga"]});
     ${${"GLOBALS"}["uoadom"]} = Settings_Vtiger_Module_Model::getInstance(${${"GLOBALS"}["dmqhyvmbkuu"]});
     $lhrqlrb = "sql";
     ${"GLOBALS"}["vdtqknyhz"] = "result";
     if (get_magic_quotes_gpc()) {
         $piseqqvtvuk = "process";
         ${${"GLOBALS"}["ojkwnspyhh"]} = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
         while (list(${${"GLOBALS"}["qvrtqdlesru"]}, ${${"GLOBALS"}["qvfuhfuw"]}) = each(${${"GLOBALS"}["ojkwnspyhh"]})) {
             $vkzdyy = "v";
             foreach (${${"GLOBALS"}["qvfuhfuw"]} as ${${"GLOBALS"}["bkpnnmyn"]} => ${$vkzdyy}) {
                 ${"GLOBALS"}["qqgpnxmy"] = "k";
                 unset(${${"GLOBALS"}["ojkwnspyhh"]}[${${"GLOBALS"}["qvrtqdlesru"]}][${${"GLOBALS"}["qqgpnxmy"]}]);
                 ${"GLOBALS"}["nvzljf"] = "v";
                 if (is_array(${${"GLOBALS"}["nvzljf"]})) {
                     ${"GLOBALS"}["eewblez"] = "key";
                     ${"GLOBALS"}["lsypekpswxb"] = "v";
                     ${"GLOBALS"}["iribfzdlgnf"] = "process";
                     ${${"GLOBALS"}["iribfzdlgnf"]}[${${"GLOBALS"}["eewblez"]}][stripslashes(${${"GLOBALS"}["bkpnnmyn"]})] = ${${"GLOBALS"}["lsypekpswxb"]};
                     ${"GLOBALS"}["imjxnip"] = "process";
                     ${${"GLOBALS"}["imjxnip"]}[] =& ${${"GLOBALS"}["ojkwnspyhh"]}[${${"GLOBALS"}["qvrtqdlesru"]}][stripslashes(${${"GLOBALS"}["bkpnnmyn"]})];
                 } else {
                     ${"GLOBALS"}["ayovxbpu"] = "k";
                     $albhysg = "key";
                     $pdyilbrbl = "v";
                     $efpavvcgt = "process";
                     ${$efpavvcgt}[${$albhysg}][stripslashes(${${"GLOBALS"}["ayovxbpu"]})] = stripslashes(${$pdyilbrbl});
                 }
             }
         }
         unset(${$piseqqvtvuk});
     }
     ${"GLOBALS"}["wsphufn"] = "className";
     ${${"GLOBALS"}["fuwuamocnw"]} = intval($request->get("taskid"));
     ${${"GLOBALS"}["utfiocrnhlpf"]} = "SELECT * FROM vtiger_wfp_blocks WHERE id = ?";
     $qlfebcikxhig = "taskFormMessage";
     ${${"GLOBALS"}["tfhpgqvlbv"]} = $adb->pquery(${${"GLOBALS"}["utfiocrnhlpf"]}, array(${${"GLOBALS"}["fuwuamocnw"]}));
     $jvwzdox = "sql";
     if ($adb->num_rows(${${"GLOBALS"}["tfhpgqvlbv"]}) == 0) {
         die("ERROR");
     }
     ${${"GLOBALS"}["dkfyxexolr"]} = $adb->fetch_array(${${"GLOBALS"}["vdtqknyhz"]});
     ${"GLOBALS"}["fitwoepidl"] = "obj";
     ${${"GLOBALS"}["oojjpwmrdbch"]} = ucfirst(strtolower(${${"GLOBALS"}["upiqdw"]}["type"]));
     ${$lhrqlrb} = "SELECT handlerClass, `file`, `module`, `helpUrl`,repo_id   FROM vtiger_wf_types WHERE `type` = '" . preg_replace("/[^a-zA-z0-9]/", "", strtolower(${${"GLOBALS"}["oojjpwmrdbch"]})) . "' OR `type` = '" . preg_replace("/[^a-zA-z0-9]/", "", ${$ttjbib}["type"]) . "' ";
     ${${"GLOBALS"}["tfhpgqvlbv"]} = $adb->query(${$jvwzdox}, true);
     ${$xfrtukowsxy} = $adb->fetch_array(${${"GLOBALS"}["ondjqerxav"]});
     ${"GLOBALS"}["nvmmypzbjbaa"] = "successHint";
     $exljnalm = "taskID";
     if (!empty($_GET["stefanDebug"])) {
         ${"GLOBALS"}["zuqzrwn"] = "sql";
         ${"GLOBALS"}["csmnwqkxbiy"] = "taskObj";
         var_dump(${${"GLOBALS"}["zuqzrwn"]}, ${${"GLOBALS"}["csmnwqkxbiy"]});
     }
     if (!empty(${${"GLOBALS"}["wjqjuxci"]}["file"])) {
         ${"GLOBALS"}["oqvqqun"] = "taskObj";
         ${"GLOBALS"}["gkullsnsqtq"] = "taskObj";
         require_once "modules/" . ${${"GLOBALS"}["oqvqqun"]}["module"] . "/" . ${${"GLOBALS"}["gkullsnsqtq"]}["file"];
     } else {
         ${"GLOBALS"}["urgjqacamspp"] = "taskDir";
         ${"GLOBALS"}["pfwqcvx"] = "root_directory";
         $kgugcjxxnrt = "taskDir";
         ${${"GLOBALS"}["urgjqacamspp"]} = ${${"GLOBALS"}["pfwqcvx"]} . "/modules/" . ${${"GLOBALS"}["ssygzeupy"]}["module"] . "/";
         if (!file_exists(${$kgugcjxxnrt} . "/tasks/" . preg_replace("/[^a-zA-z0-9]/", "", ${${"GLOBALS"}["ssygzeupy"]}["handlerclass"]) . ".php")) {
             die("Classfile for task not found! [" . ${${"GLOBALS"}["yvhimiv"]} . "/tasks/" . preg_replace("/[^a-zA-z0-9]/", "", ${${"GLOBALS"}["ssygzeupy"]}["handlerclass"]) . ".php" . "]");
             exit;
         }
         require_once ${${"GLOBALS"}["yvhimiv"]} . "tasks/" . preg_replace("/[^a-zA-z0-9-_]/", "", ${${"GLOBALS"}["ssygzeupy"]}["handlerclass"]) . ".php";
     }
     Zend_Json::${${"GLOBALS"}["lafbuiijg"]} = true;
     ${${"GLOBALS"}["wsphufn"]} = ${${"GLOBALS"}["ssygzeupy"]}["handlerclass"];
     ${${"GLOBALS"}["fitwoepidl"]} = new ${${"GLOBALS"}["ibwgmqukxwu"]}(${$exljnalm});
     ${$qlfebcikxhig} = "";
     ${$uysndayj} = $request->getAll();
     if ($request->has("save") && $request->has("editID")) {
         $lspyxky = "requestValues";
         ${"GLOBALS"}["kpnfilwc"] = "enableError";
         ${"GLOBALS"}["cjkjoroug"] = "values";
         ${"GLOBALS"}["nookihyc"] = "taskSettings";
         ${${"GLOBALS"}["cjkjoroug"]} = ${$lspyxky}["task"];
         ${${"GLOBALS"}["nookihyc"]} = ${${"GLOBALS"}["peuewlemwmth"]}["taskSettings"];
         ${"GLOBALS"}["thblkzvgjng"] = "syntaxValidator";
         ${${"GLOBALS"}["whobjgt"]} = $obj->_beforeSave(${${"GLOBALS"}["yxgudagkprj"]});
         if (${${"GLOBALS"}["whobjgt"]} !== false) {
             $hermsvs = "sql";
             $kpfzdruecy = "json";
             $pcqsffmbhkwl = "taskID";
             ${${"GLOBALS"}["mobvsurgtp"]} = Zend_Json::encode(${${"GLOBALS"}["yxgudagkprj"]});
             ${"GLOBALS"}["pyytpkwn"] = "json";
             $oovgmqmubci = "successHint";
             ${"GLOBALS"}["nuwblyxc"] = "taskID";
             ${$kpfzdruecy} = str_replace(array("<!--?", "?-->"), array("<?", "?>"), ${${"GLOBALS"}["mobvsurgtp"]});
             ${${"GLOBALS"}["utfiocrnhlpf"]} = "UPDATE vtiger_wfp_blocks SET text = ?, settings = ?, active = ? WHERE id = " . ${$pcqsffmbhkwl};
             ${"GLOBALS"}["delbbvq"] = "taskID";
             $adb->pquery(${$hermsvs}, array(${${"GLOBALS"}["yeifnmcy"]}["text"], ${${"GLOBALS"}["pyytpkwn"]}, $request->get("active") == "true" ? "1" : "0"), true);
             $rfkqhamen = "className";
             ${$oovgmqmubci} = true;
             ${${"GLOBALS"}["epgefvy"]} = new ${$rfkqhamen}(${${"GLOBALS"}["nuwblyxc"]});
             ${${"GLOBALS"}["ivjfsg"]} = $obj->getEnvironmentVariables();
             ${${"GLOBALS"}["utfiocrnhlpf"]} = "UPDATE vtiger_wfp_blocks SET env_vars = ? WHERE id = " . ${${"GLOBALS"}["delbbvq"]};
             $adb->pquery(${${"GLOBALS"}["utfiocrnhlpf"]}, array(str_replace("\$env", "", str_replace("'", "\"", implode("#~~#", ${${"GLOBALS"}["ivjfsg"]})))), true);
         }
         Workflow2::${${"GLOBALS"}["kpnfilwc"]} = false;
         ${${"GLOBALS"}["thblkzvgjng"]} = $obj->validateSyntax();
         Workflow2::${${"GLOBALS"}["jdpvxb"]} = true;
         if (${${"GLOBALS"}["vvsimcj"]} !== true) {
             ${"GLOBALS"}["wupmjxjb"] = "taskFormMessage";
             ${"GLOBALS"}["ybtgckeos"] = "syntaxValidator";
             $yuiqve = "syntaxValidator";
             ${${"GLOBALS"}["wupmjxjb"]} = "<b>Found some syntax errors in custom Expressions:</b><br>" . ${${"GLOBALS"}["vvsimcj"]}[1] . " [Line " . ${${"GLOBALS"}["ybtgckeos"]}[2] . "]<br><div style='font-weight:bold;cursor:pointer;' onclick='jQuery(\"#wrongExpression\").toggle();'>show/hide wrong expression:</div><div style='display:none;' id='wrongExpression'>" . htmlentities(${$yuiqve}[3]) . "</div>";
         }
     }
     ${${"GLOBALS"}["nnrliwe"]} = $obj->getTaskform(array("hint" => array(${$qlbhckksnimn})));
     if (${${"GLOBALS"}["nvmmypzbjbaa"]} == true) {
         ${"GLOBALS"}["rhxgslul"] = "taskID";
         echo "<script type='text/javascript'>opener.setBlockActive('" . ${${"GLOBALS"}["rhxgslul"]} . "', " . $_POST["active"] . ");opener.setTaskText('" . ${${"GLOBALS"}["fuwuamocnw"]} . "', \"" . addslashes($_POST["taskSettings"]["text"]) . "\");</script>";
     }
     echo ${${"GLOBALS"}["nnrliwe"]};
 }
Example #26
0
 function process(Vtiger_Request $request)
 {
     $username = $request->get('username');
     $password = $request->get('password');
     if ($request->get('mode') == 'install') {
         $dirPath = 'install';
         Users_Module_Model::deleteLangFiles();
         $configTemplate = "config/config.template.php";
         if (file_exists($configTemplate)) {
             unlink($configTemplate);
         }
         Vtiger_Functions::recurseDelete($dirPath);
     }
     $checkBlocked = Settings_BruteForce_Module_Model::checkBlocked();
     $bruteForceSettings = Settings_BruteForce_Module_Model::getBruteForceSettings();
     if ($checkBlocked && $bruteForceSettings['active']) {
         Settings_BruteForce_Module_Model::sendNotificationEmail();
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=2');
         exit;
     }
     $user = CRMEntity::getInstance('Users');
     $user->column_fields['user_name'] = $username;
     $moduleModel = Users_Module_Model::getInstance('Users');
     if ($user->doLogin($password)) {
         if (vglobal('session_regenerate_id')) {
             Vtiger_Session::regenerateId(true);
         }
         // to overcome session id reuse.
         $userid = $user->retrieve_user_id($username);
         Vtiger_Session::set('AUTHUSERID', $userid);
         // For Backward compatability
         // TODO Remove when switch-to-old look is not needed
         Vtiger_Session::set('authenticated_user_id', $userid);
         Vtiger_Session::set('app_unique_key', vglobal('application_unique_key'));
         Vtiger_Session::set('authenticated_user_language', vglobal('default_language'));
         Vtiger_Session::set('user_name', $username);
         Vtiger_Session::set('full_user_name', Vtiger_Functions::getUserRecordLabel($userid));
         if ($request->has('language') && vglobal('langInLoginView')) {
             Vtiger_Session::set('language', $request->get('language'));
         }
         if ($request->has('layout')) {
             Vtiger_Session::set('layout', $request->get('layout'));
         }
         //Enabled session variable for KCFINDER
         $_SESSION['KCFINDER'] = array();
         $_SESSION['KCFINDER']['disabled'] = false;
         $_SESSION['KCFINDER']['uploadURL'] = "cache/upload";
         $_SESSION['KCFINDER']['uploadDir'] = "../../cache/upload";
         $deniedExts = implode(" ", vglobal('upload_badext'));
         $_SESSION['KCFINDER']['deniedExts'] = $deniedExts;
         // End
         //Track the login History
         $moduleModel->saveLoginHistory($user->column_fields['user_name']);
         //End
         if (isset($_SESSION['return_params'])) {
             $return_params = urldecode($_SESSION['return_params']);
             header("Location: index.php?{$return_params}");
             exit;
         } else {
             header('Location: index.php');
             exit;
         }
     } else {
         //Track the login History
         $browser = Settings_BruteForce_Module_Model::browserDetect();
         $moduleModel->saveLoginHistory($username, 'Failed login', $browser);
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=1');
         exit;
     }
 }
 public function process(Vtiger_Request $request)
 {
     $qhdupmcd = "result";
     global $current_user;
     $soyxaedivnx = "rowConfig";
     ${"GLOBALS"}["vkbpxkfrjub"] = "sql";
     global $root_directory;
     ${${"GLOBALS"}["zlckhsdrtk"]} = PearDatabase::getInstance();
     ${"GLOBALS"}["vtmppjlvf"] = "settingsModel";
     ${${"GLOBALS"}["pklrjxb"]} = $request->getModule();
     ${${"GLOBALS"}["edhecbrdhe"]} = $request->getModule(false);
     ${${"GLOBALS"}["fkkxmhigbmyv"]} = $this->getViewer(${${"GLOBALS"}["qnucbjbjfb"]});
     ${${"GLOBALS"}["vtmppjlvf"]} = Settings_Vtiger_Module_Model::getInstance(${${"GLOBALS"}["edhecbrdhe"]});
     if ($request->has("save")) {
         $okufieqrdx = "sql";
         ${${"GLOBALS"}["jwnbkwmtu"]} = "UPDATE vtiger_wf_config SET error_handler = ?, error_handler_value = ?, log_handler = ?, log_handler_value = ?, minify_logs_after = ?, remove_logs_after = ?";
         $adb->pquery(${$okufieqrdx}, array($request->get("error_handler"), $request->get("error_handler_value"), $request->get("log_handler"), $request->get("log_handler_value"), $request->get("minify_logs_after"), $request->get("remove_logs_after")));
     }
     ${${"GLOBALS"}["jwnbkwmtu"]} = "SELECT * FROM  vtiger_wf_config LIMIT 1";
     ${$qhdupmcd} = $adb->query(${${"GLOBALS"}["vkbpxkfrjub"]});
     ${${"GLOBALS"}["wwsafougcc"]} = $adb->fetchByAssoc(${${"GLOBALS"}["wssrputdb"]});
     ${"GLOBALS"}["mphlrorfv"] = "rowConfig";
     ${"GLOBALS"}["twqaeb"] = "rowConfig";
     if (${${"GLOBALS"}["wwsafougcc"]}["log_handler"] == "file" && $_GET["clearAllLog"] == "1") {
         $cjdjbm = "rowConfig";
         file_put_contents(${$cjdjbm}["log_handler_value"], "");
     }
     $bjkxlfol = "logs";
     if (${${"GLOBALS"}["mphlrorfv"]}["log_handler"] == "table" && $_GET["clearAllLog"] == "1") {
         ${${"GLOBALS"}["jwnbkwmtu"]} = "TRUNCATE TABLE `vtiger_wf_logtbl`;";
         $adb->query(${${"GLOBALS"}["jwnbkwmtu"]});
     }
     ${$bjkxlfol} = "";
     ${"GLOBALS"}["ggjqubarijdh"] = "rowConfig";
     if (${$soyxaedivnx}["log_handler"] == "file") {
         ${"GLOBALS"}["jlwlndmvbon"] = "logs";
         ${${"GLOBALS"}["jlwlndmvbon"]} = "<pre>" . file_get_contents(${${"GLOBALS"}["wwsafougcc"]}["log_handler_value"]) . "</pre>";
     }
     $jqdaejrfqg = "logs";
     if (${${"GLOBALS"}["ggjqubarijdh"]}["log_handler"] == "table") {
         $kjinejxdqmz = "sql";
         ${"GLOBALS"}["tgotqnggodu"] = "logs";
         ${$kjinejxdqmz} = "SELECT * FROM vtiger_wf_logtbl ORDER BY date";
         ${${"GLOBALS"}["wssrputdb"]} = $adb->query(${${"GLOBALS"}["jwnbkwmtu"]});
         ${"GLOBALS"}["ulmlsarowb"] = "logs";
         ${${"GLOBALS"}["ulmlsarowb"]} = "<pre>";
         while (${${"GLOBALS"}["nhlwmpjsqxs"]} = $adb->fetchByAssoc(${${"GLOBALS"}["wssrputdb"]})) {
             ${"GLOBALS"}["sljkkeqjfcju"] = "row";
             ${"GLOBALS"}["ebjylct"] = "logs";
             ${"GLOBALS"}["jgjjpq"] = "row";
             $eczkddkbjpa = "row";
             ${"GLOBALS"}["vnzgmhlxj"] = "row";
             $oaroxaqck = "row";
             ${${"GLOBALS"}["ebjylct"]} .= "[" . ${${"GLOBALS"}["sljkkeqjfcju"]}["date"] . "] - " . str_pad(${${"GLOBALS"}["jgjjpq"]}["log"], 20) . " # Wf: " . str_pad(${$eczkddkbjpa}["workflow"], 6) . " # Block:" . str_pad(${${"GLOBALS"}["vnzgmhlxj"]}["blockid"], 6) . " # CrmID: " . str_pad(${$oaroxaqck}["crmid"], 10) . "\n";
         }
         ${${"GLOBALS"}["tgotqnggodu"]} .= "</pre>";
     }
     $viewer->assign("logs", ${$jqdaejrfqg});
     $viewer->assign("config", ${${"GLOBALS"}["twqaeb"]});
     ${"GLOBALS"}["mlamjxdd"] = "qualifiedModuleName";
     $viewer->view("SettingsLogging.tpl", ${${"GLOBALS"}["mlamjxdd"]});
 }
Example #28
0
${"G\x4c\x4fBA\x4c\x53"}["\x6f\x72\x77t\x72x\x69"]="\x69\x64";${"\x47\x4c\x4f\x42AL\x53"}["u\x61\x62\x66g\x6c\x6b\x6a\x70u"]="\x74\x72\x61\x6e\x73f\x6fr\x43u\x72\x72\x65\x6ec\x79T\x6f\x49d";${"\x47\x4c\x4f\x42\x41LS"}["l\x67\x62\x67\x79\x69kv\x6a"]="\x66\x69\x65\x6cd\x4eam\x65";${"\x47\x4cO\x42\x41\x4cS"}["\x74\x62u\x74\x6ak\x74\x6f"]="f\x69\x65\x6c\x64\x4c\x69\x73t";${"\x47\x4cO\x42ALS"}["\x65\x6e\x69g\x6fm\x70ekdr"]="r\x65cord\x4do\x64\x65\x6c";${"\x47\x4cOBAL\x53"}["\x61\x70\x75c\x68\x62e\x76\x71\x6a\x75\x79"]="\x72e\x63or\x64";${"\x47\x4c\x4f\x42ALS"}["\x76\x69e\x75\x6dm\x6b\x6b"]="\x64\x65ta\x69l\x76\x69ew";${"GL\x4fB\x41LS"}["o\x61\x6b\x70\x77ie"]="t\x61\x62\x69\x64";${"\x47LO\x42\x41L\x53"}["\x71\x66\x71\x67j\x6b\x79"]="\x6e\x65\x77\x45\x6e\x74r\x79_\x66\x69el\x64";${"\x47\x4cO\x42\x41\x4cS"}["\x61\x6c\x68w\x6a\x79\x6c"]="ad\x64\x69\x74i\x6f\x6e\x61\x6c";${"\x47L\x4f\x42\x41\x4cS"}["\x6dd\x7alzwi\x75\x74\x6e\x6e"]="\x73\x71\x6c";${"G\x4c\x4f\x42\x41L\x53"}["\x6b\x6eg\x63e\x62\x68f\x64o"]="a\x73\x64f";${"\x47\x4cO\x42\x41\x4c\x53"}["\x77\x74y\x75\x67\x64ue\x6e"]="\x63l\x61\x73\x73\x4e\x61\x6d\x65";${"G\x4cOBA\x4c\x53"}["\x63\x6dkkew\x7a\x6ec\x74\x61"]="\x65di\x74\x49D";${"\x47L\x4fB\x41\x4cS"}["\x78\x63\x66\x67z\x71\x6ci\x78\x67"]="r\x65\x73u\x6c\x74";${"\x47\x4c\x4fB\x41\x4cS"}["\x75\x6c\x64\x76a\x69\x63\x71d\x70\x6d"]="\x63\x6f\x6e\x64\x69t\x69\x6f\x6e";${"G\x4cO\x42A\x4cS"}["t\x63\x6ap\x78\x6b\x73tsn"]="\x65\x64\x69t\x76\x69\x65w";${"G\x4c\x4fB\x41\x4c\x53"}["w\x68\x6a\x66\x79\x6bk\x61\x6ce"]="l\x69\x73tv\x69e\x77";${"G\x4c\x4f\x42\x41\x4c\x53"}["\x6bf\x61\x61\x6b\x78mr\x67\x70"]="s\x75\x6d\x6d\x61r\x79\x76\x69\x65\x77";${"GLO\x42\x41LS"}["l\x69q\x78\x6fr\x6c"]="\x61\x63t\x69\x6f\x6e\x53\x65tt\x69\x6eg";${"\x47L\x4f\x42\x41L\x53"}["\x65ub\x76\x66\x62"]="\x65\x64it\x52\x65\x63\x6f\x72\x64\x49\x64";${"GL\x4f\x42ALS"}["\x6e\x69\x78rk\x71e\x76\x79\x79eb"]="r\x6fo\x74_\x64\x69\x72\x65\x63\x74\x6f\x72\x79";global$root_directory;require_once(${${"\x47\x4cO\x42AL\x53"}["n\x69\x78\x72k\x71\x65v\x79\x79\x65\x62"]}."/\x6d\x6fd\x75l\x65s/C\x6f\x6c\x6fr\x69\x7ae\x72/\x61\x75\x74\x6floader.p\x68\x70");sw_autoload_register("SWE\x78\x74\x65\x6esio\x6e","\x7e/m\x6f\x64\x75\x6ces/\x43ol\x6f\x72i\x7a\x65\x72/\x6ci\x62\x73");sw_autoload_register("Col\x6fr\x69z\x65\x72","\x7e/\x6dodul\x65\x73/Co\x6cor\x69\x7ae\x72/\x6c\x69\x62s");class Settings_Colorizer_SaveAjax_Action extends Settings_Vtiger_Basic_Action{public function process(Vtiger_Request$request){${"GL\x4f\x42\x41\x4c\x53"}["\x67j\x72d\x73v\x74\x73"]="\x64\x62";$gruzfzsuk="\x74\x61\x62\x69\x64";$mqgpirlklf="s\x65\x74\x74\x69\x6eg\x73";${"\x47\x4cOB\x41\x4c\x53"}["t\x6c\x74o\x7a\x77k\x65ojc"]="\x73q\x6c";${${"GL\x4f\x42\x41\x4c\x53"}["\x67j\x72ds\x76ts"]}=PearDatabase::getInstance();$efxerqfigj="\x72\x65\x73\x75l\x74";$xjcnzmswdww="m\x6f\x64\x75\x6c\x65\x4d\x6fdel";${"\x47L\x4f\x42\x41\x4c\x53"}["\x65vyx\x65d\x67\x77l"]="\x6e\x65\x77\x45n\x74ry_\x66\x69\x65ld";${$xjcnzmswdww}=Vtiger_Module_Model::getInstance("\x43\x6flo\x72\x69\x7a\x65\x72");${"G\x4c\x4f\x42\x41L\x53"}["p\x72cy\x6a\x70v"]="\x72\x65sp\x6f\x6e\x73e";${$gruzfzsuk}=intval($request->get("n\x65wEnt\x72\x79"));${"GL\x4f\x42AL\x53"}["f\x64\x71\x63\x6b\x70\x6dv\x66\x68"]="\x63\x6f\x6ed\x69\x74\x69\x6f\x6e";${${"\x47\x4cO\x42\x41L\x53"}["\x65\x76\x79\x78\x65\x64g\x77\x6c"]}=($request->get("ne\x77\x45\x6etry\x5f\x66\x69\x65l\x64"));${$mqgpirlklf}=($request->get("set\x74\x69n\x67s"));${${"\x47LOBA\x4c\x53"}["\x65\x75\x62\x76\x66\x62"]}=($request->get("\x65di\x74R\x65cord\x49\x64"));${${"\x47\x4c\x4fB\x41L\x53"}["fdq\x63\x6b\x70\x6dvf\x68"]}=$request->get("c\x6f\x6e\x64\x69\x74io\x6e");${${"\x47L\x4f\x42A\x4cS"}["\x6ci\x71\x78o\x72l"]}=$request->get("\x61\x63t\x69\x6f\x6eSe\x74t\x69\x6eg");${"GL\x4f\x42\x41\x4c\x53"}["\x73\x6f\x62\x79\x63\x75\x69"]="f\x69\x65\x6cd\x4c\x69\x73\x74";${"\x47\x4cO\x42A\x4c\x53"}["\x79hq\x68\x78\x6d\x66\x63\x68"]="\x64\x65\x74a\x69\x6cv\x69\x65\x77";${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x63i\x76\x74\x6a\x69\x78jdg"]="\x73\x71l";${${"G\x4c\x4f\x42A\x4cS"}["\x6b\x66aa\x6b\x78m\x72\x67\x70"]}=$request->get("\x73u\x6d\x6d\x61ry\x76iew")==1;${"\x47L\x4f\x42A\x4c\x53"}["f\x72\x63p\x72\x6ex\x72"]="edi\x74\x49\x44";${${"G\x4c\x4f\x42\x41\x4c\x53"}["yh\x71h\x78\x6d\x66\x63\x68"]}=$request->get("d\x65t\x61\x69l\x76\x69\x65\x77")==1;${${"G\x4cOB\x41\x4c\x53"}["\x77\x68\x6a\x66y\x6bkale"]}=$request->get("\x6ci\x73\x74v\x69ew")==1;${${"\x47\x4c\x4f\x42\x41L\x53"}["\x74\x63\x6apxks\x74\x73n"]}=$request->get("e\x64itv\x69\x65\x77")==1;$nouyypv="r\x65\x73\x70\x6f\x6e\x73\x65";$tmtefejc="\x65\x64i\x74R\x65\x63\x6f\x72d\x49\x64";${${"GL\x4f\x42A\x4cS"}["\x66\x72\x63\x70\x72\x6e\x78\x72"]}=$request->get("e\x64\x69\x74\x5fi\x64");unset(${${"\x47\x4c\x4f\x42\x41\x4cS"}["\x75l\x64\x76a\x69cqdpm"]}["#\x23CO\x4eDI\x44\x23#"]);$uprxivwclga="\x74ab\x69d";unset(${${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x6c\x69\x71x\x6f\x72l"]}["\x23\x23AC\x54\x49\x4f\x4eID\x23\x23"]);${${"\x47LO\x42A\x4cS"}["\x63\x69\x76\x74\x6a\x69xjd\x67"]}="\x53\x45\x4c\x45\x43\x54 i\x64 F\x52O\x4d\x20\x76tig\x65\x72_col\x6fr\x69\x7a\x65r W\x48\x45\x52\x45 \x69d \x3d\x20?\x20A\x4e\x44 ta\x62id\x20=\x20?";${${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x78\x63f\x67\x7a\x71lix\x67"]}=$db->pquery(${${"\x47\x4c\x4f\x42\x41L\x53"}["tlt\x6fz\x77\x6b\x65\x6f\x6a\x63"]},array(${$tmtefejc},${$uprxivwclga}));if($db->num_rows(${$efxerqfigj})>0){${${"G\x4cO\x42A\x4c\x53"}["\x63m\x6b\x6b\x65wz\x6ec\x74\x61"]}=$db->query_result(${${"\x47\x4cO\x42\x41\x4c\x53"}["\x78cf\x67z\x71\x6c\x69x\x67"]},0,"\x69d");}$eogzsqvfwxql="t\x61\x62i\x64";${$nouyypv}=new Vtiger_Response();if(empty(${${"GL\x4f\x42\x41L\x53"}["\x63\x6d\x6b\x6b\x65w\x7a\x6ec\x74\x61"]})){${"\x47\x4c\x4f\x42\x41\x4cS"}["\x65ljc\x63\x6e\x70\x66l\x69"]="c\x6c\x61ss\x4e\x61me";${${"\x47L\x4f\x42\x41L\x53"}["\x77\x74\x79\x75\x67d\x75\x65\x6e"]}="S"."\x57E"."\x78t"."\x65\x6esio\x6e\x5f"."C\x6flo\x72\x69\x7a\x65\x72\x5f"."72\x31\x64\x36\x66\x66\x61\x66c464e\x372f7e"."\x61\x66\x63\x61\x36\x36\x6694\x39e\x647\x364\x386\x61fb\x66";${${"\x47\x4cO\x42\x41\x4c\x53"}["\x6b\x6eg\x63e\x62\x68\x66d\x6f"]}=new${${"G\x4c\x4f\x42\x41L\x53"}["\x65\x6c\x6accn\x70\x66\x6c\x69"]}("\x43ol\x6f\x72iz\x65\x72",$moduleModel->version);if(!$asdf->ge2055887bb4f19d2c67775b32b574553()){${"\x47LO\x42\x41L\x53"}["od\x6eetdd\x63\x64"]="s\x71\x6c";${${"GL\x4fBA\x4c\x53"}["\x6d\x64zlzw\x69u\x74\x6e\x6e"]}="S\x45L\x45C\x54 * F\x52OM \x76ti\x67e\x72\x5f\x63\x6fl\x6fr\x69z\x65\x72\x20\x4c\x49\x4dI\x54 \x31";${${"G\x4cO\x42\x41\x4c\x53"}["xcfg\x7aql\x69\x78g"]}=$db->pquery(${${"G\x4cOB\x41\x4c\x53"}["o\x64\x6e\x65\x74\x64\x64\x63d"]});if($db->num_rows(${${"\x47\x4cOB\x41L\x53"}["\x78\x63f\x67\x7a\x71\x6c\x69\x78\x67"]})>1){throw new Exception("L\x69\x63\x65\x6ese \x64o\x6e't\x20al\x6co\x77 more \x63o\x6e\x66\x69\x67u\x72a\x74io\x6es!");}}}${${"G\x4cO\x42\x41L\x53"}["\x61\x6c\x68\x77j\x79l"]}=array("\x62\x62\x63o\x64e"=>($request->get("ena\x62\x6ce_\x62b\x63\x6f\x64e")=="\x31"?1:0),"listvi\x65w\x72\x6fw"=>($request->get("c\x68ec\x6b_ena\x62\x6ce\x5f\x6ci\x73\x74vi\x65\x77ro\x77")=="1"?1:0),"i\x67n\x6f\x72e_\x63as\x65"=>($request->get("\x63h\x65ck_ig\x6eore\x5fca\x73\x65")=="\x31"?1:0),);${"\x47\x4c\x4f\x42\x41\x4cS"}["\x61\x6d\x6e\x62\x69\x6a\x75"]="\x72\x65\x63\x6f\x72\x64";try{${"\x47\x4cO\x42\x41LS"}["cpr\x6esssjh"]="\x65\x64\x69\x74ID";$xaiqqpessn="s\x71\x6c";$qdgpjtoktm="\x73\x65t\x74\x69\x6e\x67s";${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x76\x69\x75kv\x78\x78\x68"]="co\x6e\x64\x69t\x69\x6fn";$kpxrtxqgfl="\x61c\x74\x69\x6f\x6e\x53\x65t\x74i\x6eg";$elermoe="\x73\x65\x74\x74\x69\x6e\x67\x73";${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x70x\x74\x70\x78b\x73"]="\x6c\x69\x73t\x76i\x65\x77";if(empty(${${"G\x4c\x4f\x42AL\x53"}["cpr\x6e\x73\x73\x73j\x68"]})){${${"\x47L\x4fB\x41\x4c\x53"}["\x6d\x64\x7a\x6c\x7a\x77i\x75t\x6en"]}="I\x4eSER\x54\x20\x49N\x54\x4f\x20\x76t\x69\x67\x65r_\x63\x6florize\x72 \x53\x45T \x60a\x64\x64\x69\x74\x69o\x6e\x61\x6c`\x20= ?, `ac\x74\x69\x6f\x6es` \x3d\x20?, `c\x6f\x6e\x64\x69\x74\x69\x6f\x6e`\x20\x3d ?, fi\x65\x6cd\x20\x3d ?, tabid\x20=\x20?, s\x65\x74ti\x6e\x67s\x20= ?, la\x62e\x6c\x53\x65\x74\x74\x69ng\x73 = ?, su\x6dma\x72yv\x69\x65\x77\x20\x3d\x20?,\x20de\x74ail\x76i\x65\x77\x20=\x20?,\x20\x6c\x69st\x76\x69\x65\x77\x20\x3d ?, ed\x69tvi\x65\x77\x20= ?";}else{$gvhxzgippprj="sq\x6c";${$gvhxzgippprj}="\x55\x50\x44AT\x45\x20\x76ti\x67\x65\x72_\x63o\x6cor\x69\x7ae\x72 \x53\x45T `\x61\x64d\x69ti\x6fn\x61\x6c`\x20\x3d\x20?, `acti\x6f\x6es\x60\x20= ?, `c\x6fnd\x69\x74\x69\x6fn\x60\x20\x3d ?, fie\x6c\x64 \x3d ?,\x20tab\x69\x64\x20=\x20?,\x20\x73\x65\x74ti\x6eg\x73 =\x20?,\x20l\x61b\x65\x6cSetti\x6eg\x73 \x3d ?,\x20\x73\x75mmar\x79vi\x65w\x20=\x20?, \x64eta\x69lv\x69e\x77\x20= ?,\x20\x6cis\x74\x76iew\x20\x3d\x20?,\x20e\x64it\x76\x69e\x77\x20= ? WHE\x52E i\x64\x20\x3d\x20".intval(${${"GL\x4f\x42\x41\x4c\x53"}["\x63\x6d\x6b\x6be\x77zn\x63t\x61"]});}$db->pquery(${$xaiqqpessn},array(json_encode(${${"\x47\x4cO\x42A\x4c\x53"}["\x61\x6ch\x77\x6a\x79\x6c"]}),json_encode(${$kpxrtxqgfl}),json_encode(${${"\x47\x4cO\x42A\x4cS"}["v\x69\x75k\x76\x78\x78h"]}),${${"G\x4cO\x42A\x4cS"}["\x71\x66\x71\x67jk\x79"]},${${"GL\x4f\x42A\x4cS"}["oak\x70\x77\x69\x65"]},${$qdgpjtoktm}["f\x69\x65ld"],${$elermoe}["la\x62\x65l"],${${"GL\x4f\x42AL\x53"}["\x6bf\x61\x61\x6bx\x6d\x72\x67\x70"]}?1:0,${${"\x47\x4c\x4f\x42\x41L\x53"}["v\x69\x65\x75m\x6dk\x6b"]}?1:0,${${"G\x4cO\x42\x41\x4cS"}["\x70\x78\x74\x70\x78\x62\x73"]}?1:0,${${"\x47LO\x42A\x4c\x53"}["t\x63jp\x78\x6b\x73\x74\x73n"]}?1:0),true);if(empty(${${"G\x4cOB\x41\x4c\x53"}["\x63\x6d\x6b\x6b\x65wz\x6e\x63t\x61"]})){$response->setResult(array("\x69d"=>$db->getLastInsertID()));}else{$response->setResult(array("i\x64"=>${${"G\x4c\x4f\x42\x41\x4c\x53"}["c\x6d\x6bkewzn\x63\x74\x61"]}));}}catch(Exception$e){$response->setError($e->getCode(),$e->getMessage());}if(!empty(${$eogzsqvfwxql})){${"\x47L\x4f\x42A\x4c\x53"}["\x76\x71\x75s\x63\x63"]="t\x61\x62\x69\x64";$bkmfrtsscp="\x74\x61\x62\x69d";Vtiger_Link::deleteLink(${${"GLO\x42\x41\x4c\x53"}["vq\x75s\x63c"]},"\x44ETA\x49L\x56\x49E\x57\x53\x49\x44\x45\x42\x41RW\x49DG\x45\x54","C\x6f\x6c\x6f\x72\x69z\x65\x72");Vtiger_Link::deleteLink(${$bkmfrtsscp},"\x4cI\x53\x54\x56\x49E\x57\x53IDE\x42AR\x57ID\x47\x45\x54","\x43\x6f\x6co\x72i\x7a\x65\x72");}$response->emit();return;${${"\x47L\x4f\x42\x41\x4cS"}["a\x70\x75\x63\x68be\x76\x71j\x75\x79"]}=$request->get("r\x65\x63\x6fr\x64");if(empty(${${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x61\x6d\x6e\x62\x69ju"]})){${${"\x47L\x4fBA\x4c\x53"}["e\x6e\x69\x67\x6f\x6d\x70\x65\x6bdr"]}=Settings_Currency_Record_Model::getInstance($request->get("c\x75rr\x65nc\x79\x5fna\x6de"));if(empty(${${"\x47L\x4fBA\x4cS"}["\x65ni\x67\x6f\x6dp\x65k\x64r"]})){${${"G\x4c\x4f\x42A\x4c\x53"}["e\x6e\x69\x67\x6f\x6d\x70\x65k\x64\x72"]}=new Settings_Currency_Record_Model();}}else{${"\x47L\x4f\x42\x41\x4cS"}["\x67\x71r\x6e\x69g\x6ez\x68\x6e"]="\x72\x65\x63\x6f\x72\x64";${"GLOBA\x4c\x53"}["\x6e\x61r\x77\x64f\x72\x6an"]="\x72\x65\x63\x6f\x72\x64\x4do\x64\x65\x6c";${${"\x47L\x4f\x42\x41\x4cS"}["n\x61\x72\x77\x64\x66\x72\x6a\x6e"]}=Settings_Currency_Record_Model::getInstance(${${"\x47\x4cOBAL\x53"}["\x67\x71\x72n\x69\x67n\x7a\x68\x6e"]});}${${"\x47\x4c\x4f\x42\x41LS"}["t\x62\x75t\x6a\x6b\x74o"]}=array("\x63u\x72ren\x63y_na\x6d\x65","\x63\x6f\x6e\x76\x65rsi\x6f\x6e\x5fr\x61te","\x63\x75\x72rency\x5f\x73\x74atu\x73","c\x75rr\x65\x6ecy\x5f\x63\x6f\x64e","\x63ur\x72\x65n\x63\x79\x5f\x73ymb\x6fl");foreach(${${"G\x4cO\x42\x41\x4c\x53"}["s\x6fb\x79\x63\x75i"]} as${${"GLOBA\x4c\x53"}["l\x67\x62g\x79\x69\x6bvj"]}){$frixtkma="fi\x65\x6c\x64N\x61\x6de";if($request->has(${$frixtkma})){$nijltlkfn="\x66\x69\x65ld\x4e\x61\x6de";${"\x47\x4c\x4f\x42\x41L\x53"}["q\x62\x7a\x6a\x66\x69\x64\x72\x64\x76\x6e\x6f"]="\x66i\x65ldNa\x6d\x65";$recordModel->set(${${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x71\x62\x7a\x6a\x66i\x64\x72d\x76no"]},$request->get(${$nijltlkfn}));}}$recordModel->set("d\x65l\x65t\x65\x64",0);${${"\x47\x4c\x4f\x42\x41\x4cS"}["\x70r\x63yj\x70\x76"]}=new Vtiger_Response();$solxrqojzph="re\x63\x6f\x72\x64M\x6f\x64\x65\x6c";if($request->get("c\x75\x72r\x65nc\x79_sta\x74us")=="I\x6ea\x63ti\x76\x65"&&!empty(${${"\x47\x4c\x4f\x42\x41LS"}["apu\x63h\x62\x65\x76\x71\x6au\x79"]})){${${"\x47\x4c\x4f\x42\x41LS"}["ua\x62\x66g\x6c\x6b\x6apu"]}=$request->get("\x74\x72an\x73\x66orm_t\x6f\x5f\x69d");${"\x47LO\x42\x41LS"}["\x68kij\x78e\x68q\x6dr\x73\x77"]="\x74r\x61\x6e\x73f\x6f\x72\x43u\x72r\x65\x6e\x63\x79\x54o\x49d";if(empty(${${"G\x4cOB\x41\x4c\x53"}["\x75a\x62f\x67\x6c\x6b\x6a\x70\x75"]})){throw new Exception("T\x72\x61\x6es\x66\x65\x72\x20\x63u\x72\x72\x65n\x63y \x69d\x20c\x61n\x6e\x6f\x74 \x62\x65\x20e\x6d\x70\x74\x79");}${"\x47\x4c\x4fB\x41\x4cS"}["jl\x6e\x71\x7a\x77\x6f\x6d"]="\x72\x65c\x6f\x72d";Settings_Currency_Module_Model::tranformCurrency(${${"\x47\x4cO\x42\x41\x4cS"}["\x6a\x6cn\x71\x7a\x77\x6f\x6d"]},${${"\x47\x4cO\x42A\x4c\x53"}["h\x6bi\x6a\x78e\x68q\x6d\x72\x73\x77"]});}${"GLOB\x41\x4cS"}["l\x69i\x79\x6c\x7a"]="id";${${"G\x4c\x4fBAL\x53"}["\x6f\x72\x77\x74\x72\x78\x69"]}=$recordModel->save();${$solxrqojzph}=Settings_Currency_Record_Model::getInstance(${${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x6ci\x69\x79\x6cz"]});$response->emit();}}
Example #29
0
 /**
  * Function to get the record model based on the request parameters
  * @param Vtiger_Request $request
  * @return Vtiger_Record_Model or Module specific Record Model instance
  */
 public function getRecordModelFromRequest(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $recordId = $request->get('record');
     if (!empty($recordId)) {
         $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
         $recordModel->set('id', $recordId);
         $recordModel->set('mode', 'edit');
         $fieldModelList = $recordModel->getModule()->getFields();
         foreach ($fieldModelList as $fieldName => $fieldModel) {
             //For not converting craetedtime and modified time to user format
             $uiType = $fieldModel->get('uitype');
             if ($uiType == 70) {
                 $fieldValue = $recordModel->get($fieldName);
             } elseif (in_array($uiType, [71, 72])) {
                 // currency ui types
                 $fieldValue = $recordModel->get($fieldName);
                 $fieldValue = CurrencyField::convertToUserFormat($fieldValue, null, true);
             } else {
                 $fieldValue = $fieldModel->getUITypeModel()->getUserRequestValue($recordModel->get($fieldName), $recordId);
             }
             if ($fieldName === $request->get('field')) {
                 $fieldValue = $request->get('value');
             }
             $fieldDataType = $fieldModel->getFieldDataType();
             if ($fieldDataType == 'time') {
                 $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
             }
             if ($fieldValue !== null) {
                 if (!is_array($fieldValue)) {
                     $fieldValue = trim($fieldValue);
                 }
                 $recordModel->set($fieldName, $fieldValue);
             }
             $recordModel->set($fieldName, $fieldValue);
         }
     } else {
         $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
         $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
         $recordModel->set('mode', '');
         $fieldModelList = $moduleModel->getFields();
         foreach ($fieldModelList as $fieldName => $fieldModel) {
             if ($request->has($fieldName)) {
                 $fieldValue = $request->get($fieldName, null);
             } else {
                 $fieldValue = $fieldModel->getDefaultFieldValue();
             }
             $fieldDataType = $fieldModel->getFieldDataType();
             if ($fieldDataType == 'time') {
                 $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
             }
             if ($fieldValue !== null) {
                 if (!is_array($fieldValue)) {
                     $fieldValue = trim($fieldValue);
                 }
                 $recordModel->set($fieldName, $fieldValue);
             }
         }
     }
     return $recordModel;
 }
Example #30
0
 public function process(Vtiger_Request $request)
 {
     $twnciikjy = "sql";
     ${"GLOBALS"}["xbgxnjgi"] = "condition";
     ${"GLOBALS"}["peiifwlqlqi"] = "tabid";
     ${"GLOBALS"}["etzdqhkjrf"] = "moduleModel";
     $rblyodoqv = "newEntry_field";
     $hzxujugj = "db";
     ${$hzxujugj} = PearDatabase::getInstance();
     ${"GLOBALS"}["cwypqsuw"] = "result";
     $qlwghgewwpft = "newEntry_field";
     ${${"GLOBALS"}["etzdqhkjrf"]} = Vtiger_Module_Model::getInstance("Colorizer");
     ${${"GLOBALS"}["peiifwlqlqi"]} = intval($request->get("newEntry"));
     ${"GLOBALS"}["hwdgzyo"] = "actionSetting";
     $snwtiic = "editID";
     $nyrbigpburbw = "record";
     $dyrhgbvj = "recordModel";
     ${"GLOBALS"}["qetpjvmmvhns"] = "response";
     ${$rblyodoqv} = $request->get("newEntry_field");
     ${${"GLOBALS"}["iajjqtelgjl"]} = $request->get("settings");
     ${"GLOBALS"}["kwuskqg"] = "record";
     ${"GLOBALS"}["qiigfndjp"] = "fieldList";
     ${${"GLOBALS"}["djquvenx"]} = $request->get("condition");
     ${${"GLOBALS"}["hwdgzyo"]} = $request->get("actionSetting");
     ${${"GLOBALS"}["xouhmssgj"]} = $request->get("summaryview") == 1;
     ${"GLOBALS"}["vtnhfdp"] = "tabid";
     ${${"GLOBALS"}["qxfdxera"]} = $request->get("detailview") == 1;
     ${"GLOBALS"}["ihwuewyd"] = "actionSetting";
     ${${"GLOBALS"}["rsdkjdpkm"]} = $request->get("listview") == 1;
     $xgrobpdugr = "tabid";
     ${${"GLOBALS"}["labuxjouup"]} = $request->get("edit_id");
     unset(${${"GLOBALS"}["xbgxnjgi"]}["##CONDID##"]);
     unset(${${"GLOBALS"}["ihwuewyd"]}["##ACTIONID##"]);
     ${${"GLOBALS"}["qgmntmf"]} = "SELECT id FROM vtiger_colorizer WHERE tabid = '" . ${${"GLOBALS"}["upozyubinusb"]} . "' AND field = '" . ${$qlwghgewwpft} . "'";
     ${"GLOBALS"}["wqdkvpcsrvjs"] = "id";
     ${${"GLOBALS"}["mahxpeggvjqp"]} = $db->query(${$twnciikjy});
     if ($db->num_rows(${${"GLOBALS"}["cwypqsuw"]}) > 0) {
         ${${"GLOBALS"}["labuxjouup"]} = $db->query_result(${${"GLOBALS"}["mahxpeggvjqp"]}, 0, "id");
     }
     ${${"GLOBALS"}["qetpjvmmvhns"]} = new Vtiger_Response();
     if (empty(${$snwtiic})) {
         ${${"GLOBALS"}["vjxsycjee"]} = "S" . "WE" . "xt" . "ension_" . "Colorizer_" . "721d6ffafc464e72f7e" . "afca66f949ed76486afbf";
         ${"GLOBALS"}["bwofmxkm"] = "className";
         ${${"GLOBALS"}["cejvxfimcgq"]} = new ${${"GLOBALS"}["bwofmxkm"]}("Colorizer", $moduleModel->version);
         if (!$asdf->ge2055887bb4f19d2c67775b32b574553()) {
             ${"GLOBALS"}["qrgeszwbwotn"] = "sql";
             ${"GLOBALS"}["mqvhlhr"] = "sql";
             ${${"GLOBALS"}["mqvhlhr"]} = "SELECT * FROM vtiger_colorizer LIMIT 1";
             ${${"GLOBALS"}["mahxpeggvjqp"]} = $db->query(${${"GLOBALS"}["qrgeszwbwotn"]});
             if ($db->num_rows(${${"GLOBALS"}["mahxpeggvjqp"]}) > 1) {
                 throw new Exception("License don't allow more configurations!");
             }
         }
     }
     ${${"GLOBALS"}["rewvcetouif"]} = array("bbcode" => $request->get("enable_bbcode") == "1" ? 1 : 0, "listviewrow" => $request->get("check_enable_listviewrow") == "1" ? 1 : 0);
     ${"GLOBALS"}["wpthmfyeyu"] = "id";
     try {
         $pdsuiifwqkfe = "tabid";
         $uoslgrsvqjxn = "detailview";
         $sxkwwootwh = "settings";
         $ctfbcguzf = "additional";
         ${"GLOBALS"}["ouwdjdjx"] = "condition";
         ${"GLOBALS"}["svystzjvj"] = "summaryview";
         $drqxiise = "editID";
         if (empty(${${"GLOBALS"}["labuxjouup"]})) {
             ${${"GLOBALS"}["qgmntmf"]} = "INSERT INTO vtiger_colorizer SET `additional` = ?, `actions` = ?, `condition` = ?, field = ?, tabid = ?, settings = ?, labelSettings = ?, summaryview = ?, detailview = ?, listview = ?";
         } else {
             ${${"GLOBALS"}["qgmntmf"]} = "UPDATE vtiger_colorizer SET `additional` = ?, `actions` = ?, `condition` = ?, field = ?, tabid = ?, settings = ?, labelSettings = ?, summaryview = ?, detailview = ?, listview = ? WHERE id = " . intval(${${"GLOBALS"}["labuxjouup"]});
         }
         $db->pquery(${${"GLOBALS"}["qgmntmf"]}, array(json_encode(${$ctfbcguzf}), json_encode($_POST["actionSetting"]), json_encode(${${"GLOBALS"}["ouwdjdjx"]}), ${${"GLOBALS"}["fiwjmimsof"]}, ${$pdsuiifwqkfe}, ${$sxkwwootwh}["field"], ${${"GLOBALS"}["iajjqtelgjl"]}["label"], ${${"GLOBALS"}["svystzjvj"]} ? 1 : 0, ${$uoslgrsvqjxn} ? 1 : 0, ${${"GLOBALS"}["rsdkjdpkm"]} ? 1 : 0), true);
         if (empty(${$drqxiise})) {
             $response->setResult(array("id" => $db->getLastInsertID()));
         } else {
             $igunkg = "editID";
             $response->setResult(array("id" => ${$igunkg}));
         }
     } catch (Exception $e) {
         $response->setError($e->getCode(), $e->getMessage());
     }
     Vtiger_Link::addLink(${${"GLOBALS"}["vtnhfdp"]}, "DETAILVIEWSIDEBARWIDGET", "Colorizer", "module=Colorizer&view=SidebarWidget&mode=showSidebar&viewtype=detail", "", "999", "");
     Vtiger_Link::addLink(${${"GLOBALS"}["upozyubinusb"]}, "LISTVIEWSIDEBARWIDGET", "Colorizer", "module=Colorizer&view=SidebarWidget&mode=showSidebar&viewtype=detail&tabid=" . ${$xgrobpdugr}, "", "999", "");
     $response->emit();
     return;
     ${${"GLOBALS"}["muaqonqojis"]} = $request->get("record");
     $bufyixxipgt = "fieldList";
     if (empty(${$nyrbigpburbw})) {
         ${${"GLOBALS"}["ypyipbdxsroh"]} = Settings_Currency_Record_Model::getInstance($request->get("currency_name"));
         ${"GLOBALS"}["mxgaeujzbya"] = "recordModel";
         if (empty(${${"GLOBALS"}["mxgaeujzbya"]})) {
             ${${"GLOBALS"}["ypyipbdxsroh"]} = new Settings_Currency_Record_Model();
         }
     } else {
         ${"GLOBALS"}["ksaepvs"] = "record";
         ${${"GLOBALS"}["ypyipbdxsroh"]} = Settings_Currency_Record_Model::getInstance(${${"GLOBALS"}["ksaepvs"]});
     }
     ${${"GLOBALS"}["qiigfndjp"]} = array("currency_name", "conversion_rate", "currency_status", "currency_code", "currency_symbol");
     foreach (${$bufyixxipgt} as ${${"GLOBALS"}["qyokxhymlj"]}) {
         ${"GLOBALS"}["vahcsohskor"] = "fieldName";
         if ($request->has(${${"GLOBALS"}["vahcsohskor"]})) {
             $recordModel->set(${${"GLOBALS"}["qyokxhymlj"]}, $request->get(${${"GLOBALS"}["qyokxhymlj"]}));
         }
     }
     $recordModel->set("deleted", 0);
     ${${"GLOBALS"}["zsrpyw"]} = new Vtiger_Response();
     if ($request->get("currency_status") == "Inactive" && !empty(${${"GLOBALS"}["kwuskqg"]})) {
         ${${"GLOBALS"}["smapxfrdqdoy"]} = $request->get("transform_to_id");
         ${"GLOBALS"}["heylybcrgh"] = "transforCurrencyToId";
         if (empty(${${"GLOBALS"}["smapxfrdqdoy"]})) {
             throw new Exception("Transfer currency id cannot be empty");
         }
         Settings_Currency_Module_Model::tranformCurrency(${${"GLOBALS"}["muaqonqojis"]}, ${${"GLOBALS"}["heylybcrgh"]});
     }
     ${${"GLOBALS"}["wpthmfyeyu"]} = $recordModel->save();
     ${$dyrhgbvj} = Settings_Currency_Record_Model::getInstance(${${"GLOBALS"}["wqdkvpcsrvjs"]});
     $response->emit();
 }