Esempio n. 1
0
 public function process($fieldName, $moduleName)
 {
     $viewer = new Vtiger_Viewer();
     $viewer->assign('FLD_NAME', $fieldName);
     $viewer->assign('FLD_ID', $fieldName);
     return $viewer->view($this->tplAddress, "Settings:OSSProjectTemplates", true);
 }
Esempio n. 2
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $this->getModule($request);
     $sourceModule = $request->get('src_module');
     $sourceRecord = $request->get('src_record');
     //list of records is narrowed to contacts related to help desks account, only in Help Desk Contacts relation view
     if ($moduleName == 'Contacts' && $sourceModule == 'HelpDesk' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=HelpDesk') === 0) {
         $request->set('related_parent_module', 'Accounts');
         $helpDeskRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'HelpDesk');
         $request->set('related_parent_id', $helpDeskRecord->get('parent_id'));
         $viewer->assign('SWITCH', true);
     }
     if ($moduleName == 'Contacts' && $sourceModule == 'SSalesProcesses' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=SSalesProcesses') === 0) {
         $request->set('related_parent_module', 'Accounts');
         $moduleRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'SSalesProcesses');
         $request->set('related_parent_id', $moduleRecord->get('related_to'));
         $viewer->assign('SWITCH', true);
     }
     if ($moduleName == 'Contacts' && $sourceModule == 'Project' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=Project') === 0) {
         $request->set('related_parent_module', 'Accounts');
         $moduleRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'Project');
         $request->set('related_parent_id', $moduleRecord->get('linktoaccountscontacts'));
         $viewer->assign('SWITCH', true);
     }
     parent::initializeListViewContents($request, $viewer);
 }
function ShowModuleIdField($selected_module, $tab_only = false)
{
    $db = PearDatabase::getInstance();
    $names = array('Emails', 'PBXManager', 'ModComments', 'SMSNotifier', 'OSSPdf');
    foreach ($names as $id) {
        $in .= "'" . $id . "',";
    }
    $in = trim($in, ',');
    $query = "select tabid, name, customized from vtiger_tab where isentitytype = '1' and presence <> '2' and name not in ( {$in} )";
    $wynik = $db->query($query, true);
    $tablist = array();
    for ($i = 0; $i < $db->num_rows($wynik); $i++) {
        $tablist[$i]['id'] = $db->query_result($wynik, $i, "tabid");
        $label = $db->query_result($wynik, $i, "name");
        if ($db->query_result($wynik, $i, "customized") == 0) {
            $tablist[$i]['label'] = getTranslatedString($label);
        } else {
            $tablist[$i]['label'] = getTranslatedString($label, $label);
        }
    }
    if ($selected_module == '') {
        $SMODULE = $tablist[0]['id'];
    } else {
        $SMODULE = $selected_module;
    }
    if ($tab_only == false) {
        $viewer = new Vtiger_Viewer();
        $viewer->assign("TABLIST", $tablist);
        $viewer->assign("SMODULE", $SMODULE);
        $viewer->assign("SELECTED_MODULE", $selected_module);
        return $viewer->fetch('modules/OSSPdf/FieldModuleid.tpl');
    } else {
        return $tablist;
    }
}
Esempio n. 4
0
 public static function showErrorPage($errorMessage, $errorDetails = false, $customActions = false)
 {
     $viewer = new Vtiger_Viewer();
     $viewer->assign('ERROR_MESSAGE', $errorMessage);
     $viewer->assign('ERROR_DETAILS', $errorDetails);
     $viewer->assign('CUSTOM_ACTIONS', $customActions);
     $viewer->assign('MODULE', 'Import');
     $viewer->view('ImportError.tpl', 'Import');
 }
Esempio n. 5
0
 function viewController()
 {
     $smarty = new Vtiger_Viewer();
     foreach ($this->parameters as $k => $v) {
         $smarty->assign($k, $v);
     }
     $smarty->assign("IS_SAFARI", Mobile::isSafari());
     $smarty->assign("SKIN", Mobile::config('Default.Skin'));
     return $smarty;
 }
Esempio n. 6
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $searchValue = $request->get('search_value');
     /*if(empty($orderBy) && empty($searchValue) && empty($pageNumber)) {
           $orderParams = Vtiger_ListView_Model::getSortParamsSession($moduleName);
           if($orderParams) {
               $pageNumber = $orderParams['page'];
               $orderBy = $orderParams['orderby'];
               $sortOrder = $orderParams['sortorder'];
               $searchValue = $orderParams['search_value'];
           }
       } else {
           $params = array('page' => $pageNumber, 'orderby' => $orderBy, 'sortorder' => $sortOrder, 'search_value' => $searchValue);
           Vtiger_ListView_Model::setSortParamsSession($moduleName, $params);
       }*/
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "icon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "icon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $listViewModel = new Portal_ListView_Model();
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($searchValue)) {
         $listViewModel->set('search_value', $searchValue);
     }
     $listviewEntries = $listViewModel->getListViewEntries($pagingModel);
     $viewer->assign('LISTVIEW_ENTRIES', $listviewEntries);
     $viewer->assign('ALPHABET_VALUE', $searchValue);
     $viewer->assign('COLUMN_NAME', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('RECORD_COUNT', count($listviewEntries));
     $viewer->assign('CURRENT_PAGE', $pageNumber);
     $viewer->assign('PAGING_INFO', $listViewModel->calculatePageRange($listviewEntries, $pagingModel));
 }
Esempio n. 7
0
 public function changePassword($data)
 {
     global $site_URL;
     $request = new Vtiger_Request($data);
     $userName = $request->get('username');
     $viewer = Vtiger_Viewer::getInstance();
     $companyModel = Vtiger_CompanyDetails_Model::getInstanceById();
     $companyName = $companyModel->get('organizationname');
     $organisationDetails = $companyModel->getLogo();
     $logoTitle = $organisationDetails->get('title');
     $logoName = $organisationDetails->get('imagename');
     $moduleName = 'Users';
     $viewer->assign('LOGOURL', $site_URL . '/test/logo/' . $logoName);
     $viewer->assign('TITLE', $logoTitle);
     $viewer->assign('COMPANYNAME', $companyName);
     $viewer->assign('USERNAME', $userName);
     $changePasswordTrackUrl = $site_URL . "/modules/Users/actions/ForgotPassword.php";
     $viewer->assign('TRACKURL', $changePasswordTrackUrl);
     $expiryTime = (int) $request->get('time') + 24 * 60 * 60;
     $currentTime = time();
     if ($expiryTime > $currentTime) {
         $secretToken = uniqid();
         $secretHash = md5($userName . $secretToken);
         $options = array('handler_path' => 'modules/Users/handlers/ForgotPassword.php', 'handler_class' => 'Users_ForgotPassword_Handler', 'handler_function' => 'changePassword', 'onetime' => 1, 'handler_data' => array('username' => $userName, 'secret_token' => $secretToken, 'secret_hash' => $secretHash));
         $trackURL = Vtiger_ShortURL_Helper::generateURL($options);
         $shortURLID = explode('id=', $trackURL);
         $viewer->assign('SHORTURL_ID', $shortURLID[1]);
         $viewer->assign('SECRET_HASH', $secretHash);
     } else {
         $viewer->assign('LINK_EXPIRED', true);
     }
     $viewer->assign('TRACKURL', $changePasswordTrackUrl);
     $viewer->assign('MODULE', $moduleName);
     $viewer->view('ForgotPassword.tpl', $moduleName);
 }
Esempio n. 8
0
 public function changePassword($request)
 {
     $request = new Vtiger_Request($request);
     $viewer = Vtiger_Viewer::getInstance();
     $userName = $request->get('username');
     $newPassword = $request->get('password');
     $confirmPassword = $request->get('confirmPassword');
     $shortURLID = $request->get('shorturl_id');
     $secretHash = $request->get('secret_hash');
     $shortURLModel = Vtiger_ShortURL_Helper::getInstance($shortURLID);
     $secretToken = $shortURLModel->handler_data['secret_token'];
     $validateData = array('username' => $userName, 'secret_token' => $secretToken, 'secret_hash' => $secretHash);
     $valid = $shortURLModel->compareEquals($validateData);
     if ($valid) {
         $userId = getUserId_Ol($userName);
         $user = Users::getActiveAdminUser();
         $wsUserId = vtws_getWebserviceEntityId('Users', $userId);
         vtws_changePassword($wsUserId, '', $newPassword, $confirmPassword, $user);
     } else {
         $viewer->assign('ERROR', true);
     }
     $shortURLModel->delete();
     $viewer->assign('USERNAME', $userName);
     $viewer->assign('PASSWORD', $newPassword);
     $viewer->view('FPLogin.tpl', 'Users');
 }
Esempio n. 9
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     $listViewModel = Settings_Vtiger_ListView_Model::getInstance($qualifiedModuleName);
     $listViewModel->set('orderby', 'sequence');
     $pagingModel = new Vtiger_Paging_Model();
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $viewer->assign('MODULE_MODEL', $listViewModel->getModule());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
 }
Esempio n. 10
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $sourceModule = $request->get('sourceModule');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "icon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "icon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $listViewModel = RecycleBin_ListView_Model::getInstance($moduleName, $sourceModule);
     $moduleModel = RecycleBin_Module_Model::getInstance($moduleName);
     $linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view'));
     $linkModels = $moduleModel->getListViewMassActions($linkParams);
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('LISTVIEW_LINKS', $moduleModel->getListViewLinks());
     $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     $viewer->assign('LISTVIEW_ENTIRES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('MODULE_LIST', $moduleModel->getAllModuleList());
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $viewer->assign('LISTVIEW_COUNT', $this->listViewCount);
     }
     $viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
 }
Esempio n. 11
0
 public function process($fieldName, $moduleName, $editView)
 {
     $viewer = new Vtiger_Viewer();
     $viewer->assign('OPTION_LIST', $this->getOptions($fieldName));
     $viewer->assign('FLD_ID', $fieldName);
     $viewer->assign('EDIT_VIEW', $editView);
     $viewer->assign('FLD_NAME', $fieldName);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('FLD_REQUIRED', $this->fieldIsRequired($fieldName, $moduleName));
     return $viewer->view($this->tplAddress, "Settings:OSSProjectTemplates", true);
 }
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $widgetView = new Reports_ChartDetail_View();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $widget = Vtiger_Widget_Model::getInstance($request->get('linkid'), $currentUser->getId());
     $widget->applyTemplateRecordId($request->get('report_record_id'));
     $viewer = new Vtiger_Viewer();
     $viewer->assign('WIDGET', $widget);
     $viewer->assign('MODULE_NAME', $moduleName);
     $content = $request->get('content');
     $reportDisplay = $widgetView->getReport($request, true);
     if (!empty($content)) {
         echo $reportDisplay;
     } else {
         $viewer->assign('CHART_REPORT_WIDGET_CONTENTS', $reportDisplay);
         $viewer->view('dashboards/ChartReportWidget.tpl', $moduleName);
     }
 }
Esempio n. 13
0
 public static function getLayoutFile($name)
 {
     $basePath = 'layouts' . '/' . vglobal('defaultLayout') . '/';
     $filePath = Vtiger_Loader::resolveNameToPath('~' . $basePath . $name);
     if (is_file($filePath)) {
         return $basePath . $name;
     }
     $basePath = 'layouts' . '/' . Vtiger_Viewer::getDefaultLayoutName() . '/';
     return $basePath . $name;
 }
Esempio n. 14
0
	public function checkLimits(Vtiger_Request $request)
	{
		$moduleName = $request->getModule();
		$record = $request->get('record');
		$currency = $request->get('currency');
		$price = $request->get('price');
		$limitConfig = $request->get('limitConfig');
		$limitFieldName = 'creditlimit';
		$balanceFieldName = 'inventorybalance';

		$moduleInstance = Vtiger_Module_Model::getInstance('Accounts');
		$limitField = Vtiger_Field_Model::getInstance($limitFieldName, $moduleInstance);
		$balanceField = Vtiger_Field_Model::getInstance($balanceFieldName, $moduleInstance);
		if (!$limitField->isActiveField() || !$balanceField->isActiveField()) {
			$response = new Vtiger_Response();
			$response->setResult(['status' => true]);
			$response->emit();
			return;
		}
		$recordModel = Vtiger_Record_Model::getInstanceById($record, 'Accounts');
		$limitID = $recordModel->get($limitFieldName);
		$balance = $recordModel->get($balanceFieldName);
		$limit = reset(Vtiger_InventoryLimit_UIType::getValues($limitID))['value'];

		$baseCurrency = Vtiger_Util_Helper::getBaseCurrency();
		$symbol = $baseCurrency['currency_symbol'];
		if ($baseCurrency['id'] != $currency) {
			$selectedCurrency = Vtiger_Functions::getCurrencySymbolandRate($currency);
			$price = floatval($price) * $selectedCurrency['rate'];
			$symbol = $selectedCurrency['symbol'];
		}
		$totalPrice = $price + $balance;

		$status = $totalPrice > $limit ? false : true;
		if (!$status) {
			$viewer = new Vtiger_Viewer();
			$viewer->assign('PRICE', $price);
			$viewer->assign('BALANCE', $balance);
			$viewer->assign('SYMBOL', $symbol);
			$viewer->assign('LIMIT', $limit);
			$viewer->assign('TOTALS', $totalPrice);
			$viewer->assign('LIMIT_CONFIG', $limitConfig);
			$html = $viewer->view('InventoryLimitAlert.tpl', $moduleName, true);
		}
		$response = new Vtiger_Response();
		$response->setResult([
			'status' => $status,
			'html' => $html
		]);
		$response->emit();
	}
Esempio n. 15
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $this->getModule($request);
     $recordId = $request->get('record');
     $tooltipViewModel = Vtiger_TooltipView_Model::getInstance($moduleName, $recordId);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('MODULE_MODEL', $tooltipViewModel->getRecord()->getModule());
     $viewer->assign('TOOLTIP_FIELDS', $tooltipViewModel->getFields());
     $viewer->assign('RECORD', $tooltipViewModel->getRecord());
     $viewer->assign('RECORD_STRUCTURE', $tooltipViewModel->getStructure());
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
 }
 public function changePassword($request)
 {
     $request = new Vtiger_Request($request);
     $viewer = Vtiger_Viewer::getInstance();
     $username = $request->get('username');
     $newPassword = $request->get('password');
     $confirmPassword = $request->get('confirmPassword');
     $userId = getUserId_Ol($username);
     $user = Users::getActiveAdminUser();
     $wsUserId = vtws_getWebserviceEntityId('Users', $userId);
     vtws_changePassword($wsUserId, '', $newPassword, $confirmPassword, $user);
     $viewer->assign('USERNAME', $username);
     $viewer->assign('PASSWORD', $newPassword);
     $viewer->view('FPLogin.tpl', 'Users');
 }
Esempio n. 17
0
 /**
  * Constructor - Sets the templateDir and compileDir for the Smarty files
  * @param <String> - $media Layout/Media name
  */
 function __construct($media = '')
 {
     parent::__construct();
     $THISDIR = dirname(__FILE__);
     $templatesDir = '';
     $compileDir = '';
     $templateDir = [];
     if (!empty($media)) {
         self::$currentLayout = $media;
         $customTemplatesDir = $THISDIR . '/../../custom/layouts/' . $media;
         $templateDir[] = $THISDIR . '/../../layouts/' . $media;
         $compileDir = $THISDIR . '/../../cache/templates_c/' . $media;
     }
     $defaultLayout = vglobal('defaultLayout');
     if ($defaultLayout && is_file(vglobal('root_directory') . '/layouts/' . $defaultLayout)) {
         $templateDir[] = $THISDIR . '/../../layouts/' . $defaultLayout;
     }
     if (empty($templatesDir) || !file_exists($templatesDir)) {
         self::$currentLayout = self::getDefaultLayoutName();
         $templateDir[] = $THISDIR . '/../../custom/layouts/' . self::getDefaultLayoutName();
         $templateDir[] = $THISDIR . '/../../layouts/' . self::getDefaultLayoutName();
         $compileDir = $THISDIR . '/../../cache/templates_c/' . self::getDefaultLayoutName();
     }
     if (!file_exists($compileDir)) {
         mkdir($compileDir, 0777, true);
     }
     $this->setTemplateDir($templateDir);
     $this->setCompileDir($compileDir);
     self::$debugViewer = SysDebug::get('DEBUG_VIEWER');
     // FOR SECURITY
     // Escape all {$variable} to overcome XSS
     // We need to use {$variable nofilter} to overcome double escaping
     // TODO: Until we review the use disabled.
     //$this->registerFilter('variable', array($this, 'safeHtmlFilter'));
     // FOR DEBUGGING: We need to have this only once.
     static $debugViewerURI = false;
     if (self::$debugViewer && $debugViewerURI === false) {
         $debugViewerURI = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
         if (!empty($_POST)) {
             $debugViewerURI .= '?' . http_build_query($_POST);
         } else {
             $debugViewerURI = $_SERVER['REQUEST_URI'];
         }
         $this->log("URI: {$debugViewerURI}, TYPE: " . $_SERVER['REQUEST_METHOD']);
     }
 }
Esempio n. 18
0
 public function changePassword($data) {
     global $site_URL;
     $request = new Vtiger_Request($data);
     $viewer = Vtiger_Viewer::getInstance();
     $companyModel = Vtiger_CompanyDetails_Model::getInstanceById();
     $companyName = $companyModel->get('organizationname');
     $organisationDetails = $companyModel->getLogo();
     $logoTitle = $organisationDetails->get('title');
     $logoName = $organisationDetails->get('imagepath');
     $moduleName = 'Users';
     $viewer->assign('LOGOURL', $site_URL . $logoName);
     $viewer->assign('TITLE', $logoTitle);
     $viewer->assign('COMPANYNAME', $companyName);
     $viewer->assign('USERNAME', $request->get('username'));
     $changePasswordTrackUrl = $site_URL . "modules/Users/actions/ForgotPassword.php";
     $viewer->assign('TRACKURL', $changePasswordTrackUrl);
     $viewer->view('ForgotPassword.tpl', $moduleName);
 }
 /**
  * @param $data     - Config Array of this Input with the following Structure
  *                      array(
  *                          'label' => 'Label the Function should use',
  *                          'name' => 'The Fieldname, which should submit the value, the Workflow will be write to Environment',
  *                          'config' => Key-Value Array with all configurations, done by admin
  *                      )
  * @param \Workflow\VTEntity $context - Current Record, which is assigned to the Workflow
  * @return array - The rendered content, shown to the user with the following structure
  *                  array(
  *                      'html' => '<htmlContentOfThisInputField>',
  *                      'javascript' => 'A Javascript executed after html is shown'
  *                  )
  *
  */
 public function renderFrontend($data, $context)
 {
     $adb = \PearDatabase::getInstance();
     /**
      * @var \Vtiger_Viewer $viewer
      */
     $viewer = \Vtiger_Viewer::getInstance();
     $html = '';
     $script = '';
     $fieldId = 'field_' . preg_replace('/[^a-zA-Z0-9_]/', '_', $data['name']);
     $field1 = '<div class="insertReferencefield" style="float:right;" data-name="' . $data['name'] . '][accountid" data-module="Accounts"></div>';
     $field2 = '<div class="insertReferencefield" style="float:right;" data-name="' . $data['name'] . '][contactid" data-module="Contacts" data-parentfield="' . $data['name'] . '][accountid"></div>';
     $html .= "<label><div style='min-height:26px;padding:2px 0;'><div style=''><strong>" . $data['label'] . "</strong></div><div style='text-align:right;'><div style='overflow:hidden;'><strong>Organization</strong><br/>" . $field1 . "</div><div style='overflow:hidden;'><strong>Contact</strong><br/>" . $field2 . "</div></div></div></label>";
     $script = '';
     if (!empty($data['config']['nullable'])) {
         $script .= 'jQuery("#' . $fieldId . '").select2("val", "");';
     }
     $script .= 'jQuery(function() { jQuery("#contactid_contactid_display").attr("readonly", "readonly"); });';
     return array('html' => $html, 'javascript' => $script);
 }
Esempio n. 20
0
 /**
  * Initialize Update
  * @access private
  */
 function initUpdate($moduleInstance, $zipfile, $overwrite)
 {
     $module = $this->getModuleNameFromZip($zipfile);
     if (!$moduleInstance || $moduleInstance->name != $module) {
         self::log('Module name mismatch!');
         return false;
     }
     if ($module != null) {
         $unzip = new Vtiger_Unzip($zipfile, $overwrite);
         // Unzip selectively
         $unzip->unzipAllEx(".", ['include' => ['templates', "modules/{$module}", 'cron', 'languages', 'layouts', 'settings/actions', 'settings/views', 'settings/models', 'settings/templates', 'settings/connectors', 'settings/libraries']], ['templates' => "layouts/" . Vtiger_Viewer::getDefaultLayoutName() . "/modules/{$module}", 'cron' => "cron/modules/{$module}", 'settings/actions' => "modules/Settings/{$module}/actions", 'settings/views' => "modules/Settings/{$module}/views", 'settings/models' => "modules/Settings/{$module}/models", 'settings/connectors' => "modules/Settings/{$module}/connectors", 'settings/libraries' => "modules/Settings/{$module}/libraries", 'settings/templates' => "layouts/" . Vtiger_Viewer::getDefaultLayoutName() . "/modules/Settings/{$module}", 'images' => "layouts/" . Vtiger_Viewer::getDefaultLayoutName() . "/skins/images/{$module}", 'settings' => 'modules/Settings', 'layouts' => 'layouts']);
         // If data is not yet available
         if (empty($this->_modulexml)) {
             $this->__parseManifestFile($unzip);
         }
         if ($unzip) {
             $unzip->close();
         }
     }
     return $module;
 }
Esempio n. 21
0
 /**
  * Getting template name
  * @return string templateName
  */
 public function getTemplateName($view, $moduleName)
 {
     $tpl = $view . $this->name . '.tpl';
     $filename = 'layouts' . DIRECTORY_SEPARATOR . Yeti_Layout::getActiveLayout() . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . 'inventoryfields' . DIRECTORY_SEPARATOR . $tpl;
     if (is_file($filename)) {
         return $tpl;
     }
     $filename = 'layouts' . DIRECTORY_SEPARATOR . Yeti_Layout::getActiveLayout() . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'Vtiger' . DIRECTORY_SEPARATOR . 'inventoryfields' . DIRECTORY_SEPARATOR . $tpl;
     if (is_file($filename)) {
         return $tpl;
     }
     $filename = 'layouts' . DIRECTORY_SEPARATOR . Vtiger_Viewer::getDefaultLayoutName() . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . 'inventoryfields' . DIRECTORY_SEPARATOR . $tpl;
     if (is_file($filename)) {
         return $tpl;
     }
     $filename = 'layouts' . DIRECTORY_SEPARATOR . Vtiger_Viewer::getDefaultLayoutName() . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'Vtiger' . DIRECTORY_SEPARATOR . 'inventoryfields' . DIRECTORY_SEPARATOR . $tpl;
     if (is_file($filename)) {
         return $tpl;
     }
     return $view . 'Base' . '.tpl';
 }
Esempio n. 22
0
	public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer) {
		$moduleName = $request->getModule();
		$cvId = $request->get('viewname');
		$pageNumber = $request->get('page');
		$orderBy = $request->get('orderby');
		$sortOrder = $request->get('sortorder');
		if($sortOrder == "ASC"){
			$nextSortOrder = "DESC";
			$sortImage = "icon-chevron-down";
		}else{
			$nextSortOrder = "ASC";
			$sortImage = "icon-chevron-up";
		}

		if(empty ($pageNumber)){
			$pageNumber = '1';
		}

		$listViewModel = EmailTemplates_ListView_Model::getInstance($moduleName, $cvId);
		$linkParams = array('MODULE'=>$moduleName, 'ACTION'=>$request->get('view'), 'CVID'=>$cvId);
		$linkModels = $listViewModel->getListViewMassActions($linkParams);
		$pagingModel = new Vtiger_Paging_Model();
		$pagingModel->set('page', $pageNumber);

		if(!empty($orderBy)) {
			$listViewModel->set('orderby', $orderBy);
			$listViewModel->set('sortorder',$sortOrder);
		}

		$searchKey = $request->get('search_key');
		$searchValue = $request->get('search_value');
		$operator = $request->get('operator');
		if(!empty($operator)) {
			$listViewModel->set('operator', $operator);
			$viewer->assign('OPERATOR',$operator);
			$viewer->assign('ALPHABET_VALUE',$searchValue);
		}
		if(!empty($searchKey) && !empty($searchValue)) {
			$listViewModel->set('search_key', $searchKey);
			$listViewModel->set('search_value', $searchValue);
		}
		if(!$this->listViewHeaders){
			$this->listViewHeaders = $listViewModel->getListViewHeaders();
		}
		if(!$this->listViewEntries){
			$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
		}
		$noOfEntries = count($this->listViewEntries);
		$viewer->assign('VIEWID', $cvId);
		$viewer->assign('MODULE', $moduleName);
		
		if(!$this->listViewLinks){
			$this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
		}
		$viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
		$viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION']);

		$viewer->assign('PAGING_MODEL', $pagingModel);
		$viewer->assign('PAGE_NUMBER',$pageNumber);

		$viewer->assign('ORDER_BY',$orderBy);
		$viewer->assign('SORT_ORDER',$sortOrder);
		$viewer->assign('NEXT_SORT_ORDER',$nextSortOrder);
		$viewer->assign('SORT_IMAGE',$sortImage);
		$viewer->assign('COLUMN_NAME',$orderBy);

		$viewer->assign('LISTVIEW_ENTIRES_COUNT',$noOfEntries);
		$viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
		$viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);

		if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
			if(!$this->listViewCount){
				$this->listViewCount = $listViewModel->getListViewCount();
			}
			$viewer->assign('LISTVIEW_COUNT', $this->listViewCount);
		}

		$viewer->assign('IS_MODULE_EDITABLE', $listViewModel->getModule()->isPermitted('EditView'));
		$viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
	}
Esempio n. 23
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     //src_module value is added to just to stop showing inactive products
     $request->set('src_module', $request->getModule());
     $moduleName = $this->getModule($request);
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $currencyId = $request->get('currency_id');
     //To handle special operation when selecting record from Popup
     $getUrl = $request->get('get_url');
     // To handle subproducts in popup view
     $subProductsPopup = $request->get('subProductsPopup');
     $parentProductId = $request->get('productid');
     //Check whether the request is in multi select mode
     $multiSelectMode = $request->get('multi_select');
     if (empty($multiSelectMode)) {
         $multiSelectMode = false;
     }
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     if ($subProductsPopup && $parentProductId) {
         $listViewModel->set('subProductsPopup', true);
         $listViewModel->set('productId', $parentProductId);
         $viewer->assign('SUBPRODUCTS_POPUP', $subProductsPopup);
         $viewer->assign('PARENT_PRODUCT_ID', $parentProductId);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('GETURL', $getUrl);
     $viewer->assign('CURRENCY_ID', $currencyId);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('MULTI_SELECT', $multiSelectMode);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('MODULE', $request->getModule());
     $viewer->assign('GETURL', 'getTaxesURL');
     $viewer->assign('VIEW', 'SubProductsPopup');
     $viewer->assign('MAIN_PRODUCT_POPUP', true);
 }
Esempio n. 24
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $sourceModule = $request->get('sourceModule');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "glyphicon glyphicon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "glyphicon glyphicon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $moduleModel = RecycleBin_Module_Model::getInstance($moduleName);
     //If sourceModule is empty, pick the first module name from the list
     if (empty($sourceModule)) {
         foreach ($moduleModel->getAllModuleList() as $model) {
             $sourceModule = $model->get('name');
             break;
         }
     }
     $listViewModel = RecycleBin_ListView_Model::getInstance($moduleName, $sourceModule);
     $linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view'));
     $linkModels = $moduleModel->getListViewMassActions($linkParams);
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('LISTVIEW_LINKS', $moduleModel->getListViewLinks());
     $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('MODULE_LIST', $moduleModel->getAllModuleList());
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('DELETED_RECORDS_TOTAL_COUNT', $moduleModel->getDeletedRecordsTotalCount());
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
 }
Esempio n. 25
0
 /**
  * Function returns the css files
  * @param <Array> $cssFileNames
  * @param <String> $fileExtension
  * @return <Array of Vtiger_CssScript_Model>
  *
  * First check if $cssFileName exists
  * if not, check under layout folder $cssFileName eg:layouts/basic/$cssFileName
  */
 function checkAndConvertCssStyles($cssFileNames, $fileExtension = 'css')
 {
     $cssStyleInstances = [];
     foreach ($cssFileNames as $cssFileName) {
         $cssScriptModel = new Vtiger_CssScript_Model();
         if (strpos($cssFileName, 'http://') === 0 || strpos($cssFileName, 'https://') === 0) {
             $cssStyleInstances[] = $cssScriptModel->set('href', $cssFileName);
             continue;
         }
         $completeFilePath = Vtiger_Loader::resolveNameToPath($cssFileName, $fileExtension);
         if (file_exists($completeFilePath)) {
             if (strpos($cssFileName, '~') === 0) {
                 $filePath = ltrim(ltrim($cssFileName, '~'), '/');
             } else {
                 $filePath = str_replace('.', '/', $cssFileName) . '.' . $fileExtension;
             }
             $minFilePath = str_replace('.css', '.min.css', $filePath);
             if (Vtiger_Functions::getMinimizationOptions($fileExtension) && is_file(Vtiger_Loader::resolveNameToPath('~' . $minFilePath, $fileExtension))) {
                 $filePath = $minFilePath;
             }
             $cssStyleInstances[$cssFileName] = $cssScriptModel->set('href', $filePath);
             continue;
         } else {
             $preLayoutPath = '';
             if (strpos($cssFileName, '~') === 0) {
                 $cssFile = ltrim(ltrim($cssFileName, '~'), '/');
                 $preLayoutPath = '~';
             } else {
                 $cssFile = $cssFileName;
             }
             // Checking if file exists in selected layout
             $layoutPath = 'layouts' . '/' . Yeti_Layout::getActiveLayout();
             $fallBackFilePath = Vtiger_Loader::resolveNameToPath($preLayoutPath . $layoutPath . '/' . $cssFile, $fileExtension);
             if (is_file($fallBackFilePath)) {
                 if (empty($preLayoutPath)) {
                     $filePath = str_replace('.', '/', $cssFile) . '.css';
                 }
                 $minFilePath = str_replace('.css', '.min.css', $filePath);
                 if (Vtiger_Functions::getMinimizationOptions($fileExtension) && is_file(Vtiger_Loader::resolveNameToPath('~' . $layoutPath . '/' . $minFilePath, $fileExtension))) {
                     $filePath = $minFilePath;
                 }
                 $cssStyleInstances[$cssFileName] = $cssScriptModel->set('href', $layoutPath . '/' . $filePath);
                 continue;
             }
             // Checking if file exists in default layout
             $layoutPath = 'layouts' . '/' . Vtiger_Viewer::getDefaultLayoutName();
             $fallBackFilePath = Vtiger_Loader::resolveNameToPath($preLayoutPath . $layoutPath . '/' . $cssFile, $fileExtension);
             if (is_file($fallBackFilePath)) {
                 if (empty($preLayoutPath)) {
                     $filePath = str_replace('.', '/', $cssFile) . '.css';
                 }
                 $minFilePath = str_replace('.css', '.min.css', $filePath);
                 if (Vtiger_Functions::getMinimizationOptions($fileExtension) && is_file(Vtiger_Loader::resolveNameToPath('~' . $layoutPath . '/' . $minFilePath, $fileExtension))) {
                     $filePath = $minFilePath;
                 }
                 $cssStyleInstances[$cssFileName] = $cssScriptModel->set('href', $layoutPath . '/' . $filePath);
                 continue;
             }
         }
     }
     return $cssStyleInstances;
 }
Esempio n. 26
0
 static function throwNewException($Message)
 {
     $request = new Vtiger_Request($_REQUEST);
     if (!$request->get('action') != '') {
         $viewer = new Vtiger_Viewer();
         $viewer->assign('MESSAGE', $Message);
         $viewer->view('OperationNotPermitted.tpl', 'Vtiger');
     } else {
         echo $Message;
     }
 }
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceModule = $request->get('src_module');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
         $sourceRecordModel = Vtiger_Record_Model::getInstanceById($sourceRecord, $sourceModule);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     //get the unit prices for the pricebooks based on the product currency
     $productUnitPrice = Vtiger_Functions::getUnitPrice($sourceRecord, $sourceModule);
     $productPriceDetails = getPriceDetailsForProduct($sourceRecord, $productUnitPrice, 'available', $sourceModule);
     $productCurrencyPrice = array();
     foreach ($productPriceDetails as $priceDetails) {
         $productCurrencyPrice[$priceDetails['curid']] = $priceDetails['curvalue'];
     }
     foreach ($this->listViewEntries as $recordId => $recordModel) {
         $recordDetails = $recordModel->getRawData();
         $priceBookCurrencyId = $recordDetails['currency_id'];
         $recordModel->set('unit_price', $productCurrencyPrice[$priceBookCurrencyId]);
     }
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('SOURCE_RECORD_MODEL', $sourceRecordModel);
     //PARENT_MODULE is used for only translations
     $viewer->assign('PARENT_MODULE', 'PriceBooks');
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('VIEW', 'ProductPriceBookPopup');
 }
Esempio n. 28
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     //src_module value is added to just to stop showing inactive products
     $request->set('src_module', $request->getModule());
     $moduleName = $this->getModule($request);
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceModule = $request->get('src_module');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $currencyId = $request->get('currency_id');
     $potentialId = $request->get('potentialid');
     $searchParams = $request->get('search_params');
     //To handle special operation when selecting record from Popup
     $getUrl = $request->get('get_url');
     //Check whether the request is in multi select mode
     $multiSelectMode = $request->get('multi_select');
     if (empty($multiSelectMode)) {
         $multiSelectMode = false;
     }
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     $searchParmams = $request->get('search_params');
     if (empty($searchParmams)) {
         $searchParmams = array();
     }
     $transformedSearchParams = Vtiger_Util_Helper::transferListSearchParamsToFilterCondition($searchParmams, $moduleModel);
     $listViewModel->set('search_params', $transformedSearchParams);
     //To make smarty to get the details easily accesible
     foreach ($searchParmams as $fieldListGroup) {
         foreach ($fieldListGroup as $fieldSearchInfo) {
             $fieldSearchInfo['searchValue'] = $fieldSearchInfo[2];
             $fieldSearchInfo['fieldName'] = $fieldName = $fieldSearchInfo[0];
             $searchParmams[$fieldName] = $fieldSearchInfo;
         }
     }
     if (Settings_SalesProcesses_Module_Model::checkRelatedToPotentialsLimit() && Settings_SalesProcesses_Module_Model::isLimitForModule($sourceModule)) {
         if ($potentialId == '') {
             $potentialId = -1;
         }
         $listViewModel->set('potential_id', $potentialId);
         $viewer->assign('INVENTORY_LIMITED_FROM_POTENTIALS', true);
     }
     $productModel = Vtiger_Module_Model::getInstance('Products');
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries && $productModel->isActive()) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     if (!$productModel->isActive()) {
         $this->listViewEntries = array();
         $viewer->assign('LBL_MODULE_DISABLED', true);
     }
     foreach ($this->listViewEntries as $key => $listViewEntry) {
         $productId = $listViewEntry->getId();
         $subProducts = $listViewModel->getSubProducts($productId);
         if ($subProducts) {
             $listViewEntry->set('subProducts', $subProducts);
         }
     }
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('RELATED_MODULE', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('GETURL', $getUrl);
     $viewer->assign('CURRENCY_ID', $currencyId);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('POPUPTYPE', vglobal('popupType'));
     if (AppConfig::performance('LISTVIEW_COMPUTE_PAGE_COUNT')) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('MULTI_SELECT', $multiSelectMode);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('TARGET_MODULE', $moduleName);
     $viewer->assign('MODULE', $request->getModule());
     $viewer->assign('GETURL', 'getTaxesURL');
     $viewer->assign('VIEW', 'ProductsPopup');
     $viewer->assign('SEARCH_DETAILS', $searchParmams);
 }
Esempio n. 29
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $cvId = $this->viewName;
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "icon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "icon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $cvId);
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view'), 'CVID' => $cvId);
     $linkModels = $listViewModel->getListViewMassActions($linkParams);
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $pagingModel->set('viewid', $request->get('viewname'));
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $operator = $request->get('operator');
     if (!empty($operator)) {
         $listViewModel->set('operator', $operator);
         $viewer->assign('OPERATOR', $operator);
         $viewer->assign('ALPHABET_VALUE', $searchValue);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     $searchParmams = $request->get('search_params');
     if (empty($searchParmams)) {
         $searchParmams = array();
     }
     $transformedSearchParams = $this->transferListSearchParamsToFilterCondition($searchParmams, $listViewModel->getModule());
     $listViewModel->set('search_params', $transformedSearchParams);
     //To make smarty to get the details easily accesible
     foreach ($searchParmams as $fieldListGroup) {
         foreach ($fieldListGroup as $fieldSearchInfo) {
             $fieldSearchInfo['searchValue'] = $fieldSearchInfo[2];
             $fieldSearchInfo['fieldName'] = $fieldName = $fieldSearchInfo[0];
             $searchParmams[$fieldName] = $fieldSearchInfo;
         }
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('MODULE', $moduleName);
     if (!$this->listViewLinks) {
         $this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
     }
     $viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
     $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION']);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     if ($moduleName == 'SalesOrder') {
         /**
          * красим поле "сумма счета" (cf_773) или "оплата водителю"(cf_791)
          * по полям "дата оплаты счета"(cf_819) и  "водитель оплачен"/"водитель поставлен на оплату" (cf_892/897 )
          */
         $filterFields = $listViewModel->get('query_generator')->getFields();
         if (in_array('cf_773', $filterFields) || in_array('cf_791', $filterFields)) {
             $analysisFields = $listViewModel->getFieldsForPainting($this->listViewEntries);
             foreach ($this->listViewEntries as $key => &$entry) {
                 $rawData = $entry->getRawData();
                 $billPayedAt = $analysisFields[$rawData['salesorderid']]['cf_819'];
                 $driverQueue = $analysisFields[$rawData['salesorderid']]['cf_897'];
                 $driverPayed = $analysisFields[$rawData['salesorderid']]['cf_892'];
                 //дополняем значениями
                 if (!empty($billPayedAt)) {
                     $rawData['colored_bill'] = 'rgb(73, 215, 73)';
                     //нам оплатили
                 } else {
                     $rawData['colored_bill'] = '';
                     //нам не оплатили
                 }
                 if ($driverPayed == '1') {
                     $rawData['colored_driver'] = 'rgb(249, 81, 81)';
                     //если оплатили
                 } elseif ($driverQueue == '1') {
                     $rawData['colored_driver'] = 'yellow';
                     //поставлен в очередь на оплату
                 } else {
                     $rawData['colored_driver'] = 'white';
                     //должны
                 }
                 $this->listViewEntries[$key]->setRawData($rawData);
             }
         }
         /**
          * прописываем ширины для некоторых столбцов
          */
         $fieldsWidth = array('bill_street' => 120, 'ship_street' => 120, 'cf_864' => 120, 'smownerid' => 120, 'description' => 200);
         foreach ($this->listViewHeaders as $key => $header) {
             if (isset($fieldsWidth[$header->get('column')])) {
                 $this->listViewHeaders[$key]->set('listviewwidth', $fieldsWidth[$header->get('column')]);
             } else {
                 $this->listViewHeaders[$key]->set('listviewwidth', '');
             }
         }
     }
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('LIST_VIEW_MODEL', $listViewModel);
     $viewer->assign('GROUPS_IDS', Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId()));
     $viewer->assign('IS_MODULE_EDITABLE', $listViewModel->getModule()->isPermitted('EditView'));
     $viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
     $viewer->assign('SEARCH_DETAILS', $searchParmams);
 }
Esempio n. 30
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $this->getModule($request);
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceModule = $request->get('src_module');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $currencyId = $request->get('currency_id');
     $relatedParentModule = $request->get('related_parent_module');
     $relatedParentId = $request->get('related_parent_id');
     //To handle special operation when selecting record from Popup
     $getUrl = $request->get('get_url');
     //Check whether the request is in multi select mode
     $multiSelectMode = $request->get('multi_select');
     if (empty($multiSelectMode)) {
         $multiSelectMode = false;
     }
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (vglobal('popupAjax')) {
         $pagingModel->set('noLimit', true);
     }
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     $isRecordExists = Vtiger_Util_Helper::checkRecordExistance($relatedParentId);
     if ($isRecordExists) {
         $relatedParentModule = '';
         $relatedParentId = '';
     } else {
         if ($isRecordExists === NULL) {
             $relatedParentModule = '';
             $relatedParentId = '';
         }
     }
     if (!empty($relatedParentModule) && !empty($relatedParentId)) {
         $parentRecordModel = Vtiger_Record_Model::getInstanceById($relatedParentId, $relatedParentModule);
         $listViewModel = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $moduleName, $label);
     } else {
         $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
     }
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     $searchParmams = $request->get('search_params');
     if (empty($searchParmams)) {
         $searchParmams = array();
     }
     $transformedSearchParams = Vtiger_Util_Helper::transferListSearchParamsToFilterCondition($searchParmams, $moduleModel);
     $listViewModel->set('search_params', $transformedSearchParams);
     //To make smarty to get the details easily accesible
     foreach ($searchParmams as $fieldListGroup) {
         foreach ($fieldListGroup as $fieldSearchInfo) {
             $fieldSearchInfo['searchValue'] = $fieldSearchInfo[2];
             $fieldSearchInfo['fieldName'] = $fieldName = $fieldSearchInfo[0];
             $searchParmams[$fieldName] = $fieldSearchInfo;
         }
     }
     if (!empty($relatedParentModule) && !empty($relatedParentId)) {
         $this->listViewHeaders = $listViewModel->getHeaders();
         $models = $listViewModel->getEntries($pagingModel);
         $noOfEntries = count($models);
         foreach ($models as $recordId => $recordModel) {
             foreach ($this->listViewHeaders as $fieldName => $fieldModel) {
                 $recordModel->set($fieldName, $recordModel->getDisplayValue($fieldName));
             }
             $models[$recordId] = $recordModel;
         }
         $this->listViewEntries = $models;
         if (count($this->listViewEntries) > 0) {
             $parent_related_records = true;
         }
     } else {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     // If there are no related records with parent module then, we should show all the records
     if (!$parent_related_records && !empty($relatedParentModule) && !empty($relatedParentId)) {
         $relatedParentModule = null;
         $relatedParentId = null;
         $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
         $listViewModel->set('search_params', $transformedSearchParams);
         if (!empty($orderBy)) {
             $listViewModel->set('orderby', $orderBy);
             $listViewModel->set('sortorder', $sortOrder);
         }
         if (!empty($sourceModule)) {
             $listViewModel->set('src_module', $sourceModule);
             $listViewModel->set('src_field', $sourceField);
             $listViewModel->set('src_record', $sourceRecord);
         }
         if (!empty($searchKey) && !empty($searchValue)) {
             $listViewModel->set('search_key', $searchKey);
             $listViewModel->set('search_value', $searchValue);
         }
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     // End
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('RELATED_MODULE', $moduleName);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('RELATED_PARENT_MODULE', $relatedParentModule);
     $viewer->assign('RELATED_PARENT_ID', $relatedParentId);
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('GETURL', $getUrl);
     $viewer->assign('CURRENCY_ID', $currencyId);
     $viewer->assign('POPUPTYPE', vglobal('popupType'));
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('MULTI_SELECT', $multiSelectMode);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('SEARCH_DETAILS', $searchParmams);
 }