示例#1
0
 /**
  * Function to get list view query for popup window
  * @param <String> $sourceModule Parent module
  * @param <String> $field parent fieldname
  * @param <Integer> $record parent id
  * @param <String> $listQuery
  * @return <String> Listview Query
  */
 public function getQueryByModuleField($sourceModule, $field, $record, $listQuery)
 {
     if ($sourceModule == 'Accounts' && $field == 'account_id' && $record || in_array($sourceModule, array('Campaigns', 'Products', 'Services', 'Emails', 'Potentials'))) {
         if ($sourceModule === 'Campaigns') {
             $condition = " vtiger_account.accountid NOT IN (SELECT accountid FROM vtiger_campaignaccountrel WHERE campaignid = '{$record}')";
         } elseif ($sourceModule === 'Products') {
             $condition = " vtiger_account.accountid NOT IN (SELECT crmid FROM vtiger_seproductsrel WHERE productid = '{$record}')";
         } elseif ($sourceModule === 'Services') {
             $condition = " vtiger_account.accountid NOT IN (SELECT relcrmid FROM vtiger_crmentityrel WHERE crmid = '{$record}' UNION SELECT crmid FROM vtiger_crmentityrel WHERE relcrmid = '{$record}') ";
         } elseif ($sourceModule === 'Emails') {
             $condition = ' vtiger_account.emailoptout = 0';
         } elseif ($sourceModule === 'Potentials') {
             $config = Settings_SalesProcesses_Module_Model::getConfig('potential');
             $currentUser = Users_Record_Model::getCurrentUserModel();
             $accessibleGroups = $currentUser->getAccessibleGroupForModule('Accounts');
             if ($config['add_potential'] && $accessibleGroups) {
                 $condition = " vtiger_crmentity.smownerid NOT IN (" . implode(',', array_keys($accessibleGroups)) . ")";
             } else {
                 return $listQuery;
             }
         } else {
             $condition = " vtiger_account.accountid != '{$record}'";
         }
         $position = stripos($listQuery, 'where');
         if ($position) {
             $overRideQuery = $listQuery . ' AND ' . $condition;
         } else {
             $overRideQuery = $listQuery . ' WHERE ' . $condition;
         }
         return $overRideQuery;
     }
 }
示例#2
0
 function getCalculations(Vtiger_Request $request)
 {
     $fromModule = $request->get('fromModule');
     $record = $request->get('record');
     $showtype = $request->get('showtype');
     $rqLimit = $request->get('limit');
     $db = PearDatabase::getInstance();
     $fields = ['id', 'name', 'calculationsstatus'];
     $limit = 10;
     $params = [];
     if (!empty($rqLimit)) {
         $limit = $rqLimit;
     }
     if ($fromModule == 'Accounts') {
         $fields[] = 'potentialid';
     } elseif ($fromModule == 'Potentials') {
         $fields[] = 'assigned_user_id';
     }
     $calculationConfig = Settings_SalesProcesses_Module_Model::getConfig('calculation');
     $calculationsStatus = $calculationConfig['calculationsstatus'];
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $module = 'Calculations';
     $instance = CRMEntity::getInstance($module);
     $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
     $queryGenerator = new QueryGenerator($module, $currentUser);
     $queryGenerator->setFields($fields);
     $sql = $queryGenerator->getQuery();
     if ($securityParameter != '') {
         $sql .= $securityParameter;
     }
     $calculationsStatusSearch = implode("','", $calculationsStatus);
     $showtype = $request->get('showtype');
     if ($showtype == 'archive') {
         $sql .= " AND vtiger_calculations.calculationsstatus IN ('{$calculationsStatusSearch}')";
     } else {
         $sql .= " AND vtiger_calculations.calculationsstatus NOT IN ('{$calculationsStatusSearch}')";
     }
     if ($fromModule == 'Accounts') {
         $sql .= ' AND vtiger_calculations.relatedid = ?';
         $params[] = $record;
     } elseif ($fromModule == 'Potentials') {
         $sql .= ' AND vtiger_calculations.potentialid = ?';
         $params[] = $record;
     }
     $sql .= ' LIMIT ' . $limit;
     $result = $db->pquery($sql, $params);
     $returnData = array();
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $returnData[] = $db->query_result_rowdata($result, $i);
     }
     return $returnData;
 }
示例#3
0
 public function process(Vtiger_Request $request)
 {
     global $log;
     $log->debug("Entering Settings_SalesProcesses_Configuration_View::process() method ...");
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $viewer = $this->getViewer($request);
     $config = Settings_SalesProcesses_Module_Model::getConfig();
     $viewer->assign('CONFIG', $config);
     $viewer->assign('CURRENTUSER', $currentUser);
     $viewer->assign('QUALIFIED_MODULE', $request->getModule(false));
     echo $viewer->view('Configuration.tpl', $request->getModule(false), true);
     $log->debug("Exiting Settings_SalesProcesses_Configuration_View::process() method ...");
 }
示例#4
0
 public function getData(Vtiger_Request $request, $widget)
 {
     $db = PearDatabase::getInstance();
     $fields = ['id', 'name', 'calculationsstatus', 'relatedid', 'hdnGrandTotal', 'assigned_user_id'];
     $limit = 10;
     $params = [];
     if (!empty($widget->get('limit'))) {
         $limit = $widget->get('limit');
     }
     $calculationConfig = Settings_SalesProcesses_Module_Model::getConfig('calculation');
     $calculationsStatus = $calculationConfig['calculationsstatus'];
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $module = 'Calculations';
     $instance = CRMEntity::getInstance($module);
     $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
     $queryGenerator = new QueryGenerator($module, $currentUser);
     $queryGenerator->setFields($fields);
     $sql = $queryGenerator->getQuery();
     if ($securityParameter != '') {
         $sql .= $securityParameter;
     }
     if (!empty($calculationsStatus)) {
         $calculationsStatusSearch = implode("','", $calculationsStatus);
         $sql .= " AND vtiger_calculations.calculationsstatus NOT IN ('{$calculationsStatusSearch}')";
     }
     $showtype = $request->get('showtype');
     if ($showtype == 'common') {
         $shownersTable = Vtiger_SharedOwner_UIType::getShownerTable($module);
         $sql .= ' AND vtiger_crmentity.crmid IN (SELECT DISTINCT crmid FROM ' . $shownersTable . ' WHERE userid = ?';
     } else {
         $sql .= ' AND vtiger_crmentity.smownerid = ?';
     }
     $params[] = $currentUser->getId();
     $sql .= ' LIMIT ' . $limit;
     $result = $db->pquery($sql, $params);
     $returnData = array();
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $returnData[] = $db->query_result_rowdata($result, $i);
     }
     return $returnData;
 }
示例#5
0
 public function getData(Vtiger_Request $request, $widget)
 {
     $db = PearDatabase::getInstance();
     $fields = ['id', 'potentialname', 'sales_stage', 'related_to', 'assigned_user_id'];
     $limit = 10;
     $params = [];
     if (!empty($widget->get('limit'))) {
         $limit = $widget->get('limit');
     }
     $potentialConfig = Settings_SalesProcesses_Module_Model::getConfig('potential');
     $potentialSalesStage = $potentialConfig['salesstage'];
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $module = 'Potentials';
     $instance = CRMEntity::getInstance($module);
     $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
     $queryGenerator = new QueryGenerator($module, $currentUser);
     $queryGenerator->setFields($fields);
     $sql = $queryGenerator->getQuery();
     if ($securityParameter != '') {
         $sql .= $securityParameter;
     }
     if (!empty($potentialSalesStage)) {
         $potentialSalesStageSearch = implode("','", $potentialSalesStage);
         $sql .= " AND vtiger_potential.sales_stage NOT IN ('{$potentialSalesStageSearch}')";
     }
     $showtype = $request->get('showtype');
     if ($showtype == 'common') {
         $sql .= ' AND FIND_IN_SET( ?, vtiger_crmentity.shownerid )';
     } else {
         $sql .= ' AND vtiger_crmentity.smownerid = ?';
     }
     $params[] = $currentUser->getId();
     $sql .= ' LIMIT ' . $limit;
     $result = $db->pquery($sql, $params);
     $returnData = array();
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $returnData[] = $db->query_result_rowdata($result, $i);
     }
     return $returnData;
 }
 public function getData(Vtiger_Request $request, $widget)
 {
     $db = PearDatabase::getInstance();
     $fields = ['id', 'assetname', 'dateinservice', 'parent_id'];
     $limit = 10;
     $params = [];
     if (!empty($widget->get('limit'))) {
         $limit = $widget->get('limit');
     }
     $assetConfig = Settings_SalesProcesses_Module_Model::getConfig('asset');
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $module = 'Assets';
     $instance = CRMEntity::getInstance($module);
     $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
     $queryGenerator = new QueryGenerator($module, $currentUser);
     $queryGenerator->setFields($fields);
     $sql = $queryGenerator->getQuery();
     if ($securityParameter != '') {
         $sql .= $securityParameter;
     }
     if (!empty($assetStatus)) {
         $assetStatus = implode("','", $assetConfig['assetstatus']);
         $sql .= " AND vtiger_assets.assetstatus NOT IN ('{$assetStatus}')";
     }
     $showtype = $request->get('showtype');
     if ($showtype == 'common') {
         $sql .= ' AND FIND_IN_SET( ?, vtiger_crmentity.shownerid )';
     } else {
         $sql .= ' AND vtiger_crmentity.smownerid = ?';
     }
     $sql .= ' AND vtiger_assets.pot_renewal = 0';
     $params[] = $currentUser->getId();
     $sql .= ' ORDER BY vtiger_assets.dateinservice ASC LIMIT ' . $limit;
     $result = $db->pquery($sql, $params);
     $returnData = array();
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $returnData[] = $db->query_result_rowdata($result, $i);
     }
     return $returnData;
 }