[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Accounts/models/ -> Record.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 Accounts_Record_Model extends Vtiger_Record_Model {
  12  
  13      /**
  14       * Function returns the details of Accounts Hierarchy
  15       * @return <Array>
  16       */
  17  	function getAccountHierarchy() {
  18          $focus = CRMEntity::getInstance($this->getModuleName());
  19          $hierarchy = $focus->getAccountHierarchy($this->getId());
  20          $i=0;
  21          foreach($hierarchy['entries'] as $accountId => $accountInfo) {
  22              preg_match('/<a href="+/', $accountInfo[0], $matches);
  23              if($matches != null) {
  24                  preg_match('/[.\s]+/', $accountInfo[0], $dashes);
  25                  preg_match("/<a(.*)>(.*)<\/a>/i",$accountInfo[0], $name);
  26  
  27                  $recordModel = Vtiger_Record_Model::getCleanInstance('Accounts');
  28                  $recordModel->setId($accountId);
  29                  $hierarchy['entries'][$accountId][0] = $dashes[0]."<a href=".$recordModel->getDetailViewUrl().">".$name[2]."</a>";
  30              }
  31          }
  32          return $hierarchy;
  33      }
  34  
  35      /**
  36       * Function returns the url for create event
  37       * @return <String>
  38       */
  39  	function getCreateEventUrl() {
  40          $calendarModuleModel = Vtiger_Module_Model::getInstance('Calendar');
  41          return $calendarModuleModel->getCreateEventRecordUrl().'&parent_id='.$this->getId();
  42      }
  43  
  44      /**
  45       * Function returns the url for create todo
  46       * @retun <String>
  47       */
  48  	function getCreateTaskUrl() {
  49          $calendarModuleModel = Vtiger_Module_Model::getInstance('Calendar');
  50          return $calendarModuleModel->getCreateTaskRecordUrl().'&parent_id='.$this->getId();
  51      }
  52  
  53      /**
  54       * Function to check duplicate exists or not
  55       * @return <boolean>
  56       */
  57  	public function checkDuplicate() {
  58          $db = PearDatabase::getInstance();
  59  
  60          $query = "SELECT 1 FROM vtiger_crmentity WHERE setype = ? AND label = ? AND deleted = 0";
  61                  $params = array($this->getModule()->getName(), decode_html($this->getName())); 
  62  
  63          $record = $this->getId();
  64          if ($record) {
  65              $query .= " AND crmid != ?";
  66              array_push($params, $record);
  67          }
  68  
  69          $result = $db->pquery($query, $params);
  70          if ($db->num_rows($result)) {
  71              return true;
  72          }
  73          return false;
  74      }
  75  
  76      /**
  77       * Function to get List of Fields which are related from Accounts to Inventory Record.
  78       * @return <array>
  79       */
  80  	public function getInventoryMappingFields() {
  81          return array(
  82                  //Billing Address Fields
  83                  array('parentField'=>'bill_city', 'inventoryField'=>'bill_city', 'defaultValue'=>''),
  84                  array('parentField'=>'bill_street', 'inventoryField'=>'bill_street', 'defaultValue'=>''),
  85                  array('parentField'=>'bill_state', 'inventoryField'=>'bill_state', 'defaultValue'=>''),
  86                  array('parentField'=>'bill_code', 'inventoryField'=>'bill_code', 'defaultValue'=>''),
  87                  array('parentField'=>'bill_country', 'inventoryField'=>'bill_country', 'defaultValue'=>''),
  88                  array('parentField'=>'bill_pobox', 'inventoryField'=>'bill_pobox', 'defaultValue'=>''),
  89  
  90                  //Shipping Address Fields
  91                  array('parentField'=>'ship_city', 'inventoryField'=>'ship_city', 'defaultValue'=>''),
  92                  array('parentField'=>'ship_street', 'inventoryField'=>'ship_street', 'defaultValue'=>''),
  93                  array('parentField'=>'ship_state', 'inventoryField'=>'ship_state', 'defaultValue'=>''),
  94                  array('parentField'=>'ship_code', 'inventoryField'=>'ship_code', 'defaultValue'=>''),
  95                  array('parentField'=>'ship_country', 'inventoryField'=>'ship_country', 'defaultValue'=>''),
  96                  array('parentField'=>'ship_pobox', 'inventoryField'=>'ship_pobox', 'defaultValue'=>'')
  97          );
  98      }
  99  }


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