[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Campaigns/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 Campaigns_Module_Model extends Vtiger_Module_Model {
  12  
  13      /**
  14       * Function to get Specific Relation Query for this Module
  15       * @param <type> $relatedModule
  16       * @return <type>
  17       */
  18  	public function getSpecificRelationQuery($relatedModule) {
  19          if ($relatedModule === 'Leads') {
  20              $specificQuery = 'AND vtiger_leaddetails.converted = 0';
  21              return $specificQuery;
  22          }
  23          return parent::getSpecificRelationQuery($relatedModule);
  24       }
  25      
  26      /**
  27       * Function to check whether the module is summary view supported
  28       * @return <Boolean> - true/false
  29       */
  30  	public function isSummaryViewSupported() {
  31          return false;
  32      }
  33  
  34      /**
  35       * Function to get list view query for popup window
  36       * @param <String> $sourceModule Parent module
  37       * @param <String> $field parent fieldname
  38       * @param <Integer> $record parent id
  39       * @param <String> $listQuery
  40       * @return <String> Listview Query
  41       */
  42  	public function getQueryByModuleField($sourceModule, $field, $record, $listQuery) {
  43          if (in_array($sourceModule, array('Leads', 'Accounts', 'Contacts'))) {
  44              switch($sourceModule) {
  45                  case 'Leads'        : $tableName = 'vtiger_campaignleadrel';        $relatedFieldName = 'leadid';        break;
  46                  case 'Accounts'        : $tableName = 'vtiger_campaignaccountrel';        $relatedFieldName = 'accountid';    break;
  47                  case 'Contacts'        : $tableName = 'vtiger_campaigncontrel';        $relatedFieldName = 'contactid';    break;
  48              }
  49  
  50              $condition = " vtiger_campaign.campaignid NOT IN (SELECT campaignid FROM $tableName WHERE $relatedFieldName = '$record')";
  51              $pos = stripos($listQuery, 'where');
  52  
  53              if ($pos) {
  54                  $split = spliti('where', $listQuery);
  55                  $overRideQuery = $split[0] . ' WHERE ' . $split[1] . ' AND ' . $condition;
  56              } else {
  57                  $overRideQuery = $listQuery. ' WHERE ' . $condition;
  58              }
  59              return $overRideQuery;
  60          }
  61      }
  62  }


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