[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Services/models/ -> Module.php (source)

   1  <?php
   2  /*+***********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   *************************************************************************************/
  10  
  11  class Services_Module_Model extends Products_Module_Model {
  12      
  13      /**
  14       * Function to get list view query for popup window
  15       * @param <String> $sourceModule Parent module
  16       * @param <String> $field parent fieldname
  17       * @param <Integer> $record parent id
  18       * @param <String> $listQuery
  19       * @return <String> Listview Query
  20       */
  21  	public function getQueryByModuleField($sourceModule, $field, $record, $listQuery) {
  22          $supportedModulesList = array('Leads', 'Accounts', 'HelpDesk', 'Potentials');
  23          if (($sourceModule == 'PriceBooks' && $field == 'priceBookRelatedList')
  24                  || in_array($sourceModule, $supportedModulesList)
  25                  || in_array($sourceModule, getInventoryModules())) {
  26  
  27              $condition = " vtiger_service.discontinued = 1 ";
  28  
  29              if ($sourceModule == 'PriceBooks' && $field == 'priceBookRelatedList') {
  30                  $condition .= " AND vtiger_service.serviceid NOT IN (SELECT productid FROM vtiger_pricebookproductrel WHERE pricebookid = '$record') ";
  31              } elseif (in_array($sourceModule, $supportedModulesList)) {
  32                  $condition .= " AND vtiger_service.serviceid NOT IN (SELECT relcrmid FROM vtiger_crmentityrel WHERE crmid = '$record' UNION SELECT crmid FROM vtiger_crmentityrel WHERE relcrmid = '$record') ";
  33              }
  34  
  35              $pos = stripos($listQuery, 'where');
  36              if ($pos) {
  37                  $split = spliti('where', $listQuery);
  38                  $overRideQuery = $split[0] . ' WHERE ' . $split[1] . ' AND ' . $condition;
  39              } else {
  40                  $overRideQuery = $listQuery . ' WHERE ' . $condition;
  41              }
  42              return $overRideQuery;
  43          }
  44      }
  45      
  46      /**
  47       * Function returns query for Services-PriceBooks Relationship
  48       * @param <Vtiger_Record_Model> $recordModel
  49       * @param <Vtiger_Record_Model> $relatedModuleModel
  50       * @return <String>
  51       */
  52  	function get_service_pricebooks($recordModel, $relatedModuleModel) {
  53          $query = 'SELECT vtiger_pricebook.pricebookid, vtiger_pricebook.bookname, vtiger_pricebook.active, vtiger_crmentity.crmid, 
  54                          vtiger_crmentity.smownerid, vtiger_pricebookproductrel.listprice, vtiger_service.unit_price
  55                      FROM vtiger_pricebook
  56                      INNER JOIN vtiger_pricebookproductrel ON vtiger_pricebook.pricebookid = vtiger_pricebookproductrel.pricebookid
  57                      INNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_pricebook.pricebookid
  58                      INNER JOIN vtiger_service on vtiger_service.serviceid = vtiger_pricebookproductrel.productid
  59                      INNER JOIN vtiger_pricebookcf on vtiger_pricebookcf.pricebookid = vtiger_pricebook.pricebookid
  60                      LEFT JOIN vtiger_users ON vtiger_users.id=vtiger_crmentity.smownerid
  61                      LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid '
  62                      . Users_Privileges_Model::getNonAdminAccessControlQuery($relatedModuleModel->getName()) .'
  63                      WHERE vtiger_service.serviceid = '.$recordModel->getId().' and vtiger_crmentity.deleted = 0';
  64          
  65          return $query;
  66      }
  67  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1