[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Contacts/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 Contacts_Record_Model extends Vtiger_Record_Model {
  12  
  13      /**

  14       * Function returns the url for create event

  15       * @return <String>

  16       */
  17  	function getCreateEventUrl() {
  18          $calendarModuleModel = Vtiger_Module_Model::getInstance('Calendar');
  19          return $calendarModuleModel->getCreateEventRecordUrl().'&contact_id='.$this->getId();
  20      }
  21  
  22      /**

  23       * Function returns the url for create todo

  24       * @return <String>

  25       */
  26  	function getCreateTaskUrl() {
  27          $calendarModuleModel = Vtiger_Module_Model::getInstance('Calendar');
  28          return $calendarModuleModel->getCreateTaskRecordUrl().'&contact_id='.$this->getId();
  29      }
  30  
  31  
  32      /**

  33       * Function to get List of Fields which are related from Contacts to Inventory Record

  34       * @return <array>

  35       */
  36  	public function getInventoryMappingFields() {
  37          return array(
  38                  array('parentField'=>'account_id', 'inventoryField'=>'account_id', 'defaultValue'=>''),
  39  
  40                  //Billing Address Fields

  41                  array('parentField'=>'mailingcity', 'inventoryField'=>'bill_city', 'defaultValue'=>''),
  42                  array('parentField'=>'mailingstreet', 'inventoryField'=>'bill_street', 'defaultValue'=>''),
  43                  array('parentField'=>'mailingstate', 'inventoryField'=>'bill_state', 'defaultValue'=>''),
  44                  array('parentField'=>'mailingzip', 'inventoryField'=>'bill_code', 'defaultValue'=>''),
  45                  array('parentField'=>'mailingcountry', 'inventoryField'=>'bill_country', 'defaultValue'=>''),
  46                  array('parentField'=>'mailingpobox', 'inventoryField'=>'bill_pobox', 'defaultValue'=>''),
  47  
  48                  //Shipping Address Fields

  49                  array('parentField'=>'otherstreet', 'inventoryField'=>'ship_street', 'defaultValue'=>''),
  50                  array('parentField'=>'othercity', 'inventoryField'=>'ship_city', 'defaultValue'=>''),
  51                  array('parentField'=>'otherstate', 'inventoryField'=>'ship_state', 'defaultValue'=>''),
  52                  array('parentField'=>'otherzip', 'inventoryField'=>'ship_code', 'defaultValue'=>''),
  53                  array('parentField'=>'othercountry', 'inventoryField'=>'ship_country', 'defaultValue'=>''),
  54                  array('parentField'=>'otherpobox', 'inventoryField'=>'ship_pobox', 'defaultValue'=>'')
  55          );
  56      }
  57      
  58      /**

  59       * Function to get Image Details

  60       * @return <array> Image Details List

  61       */
  62  	public function getImageDetails() {
  63          $db = PearDatabase::getInstance();
  64          $imageDetails = array();
  65          $recordId = $this->getId();
  66  
  67          if ($recordId) {
  68              $sql = "SELECT vtiger_attachments.*, vtiger_crmentity.setype FROM vtiger_attachments
  69                          INNER JOIN vtiger_seattachmentsrel ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
  70                          INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_attachments.attachmentsid
  71                          WHERE vtiger_crmentity.setype = 'Contacts Image' and vtiger_seattachmentsrel.crmid = ?";
  72  
  73              $result = $db->pquery($sql, array($recordId));
  74  
  75              $imageId = $db->query_result($result, 0, 'attachmentsid');
  76              $imagePath = $db->query_result($result, 0, 'path');
  77              $imageName = $db->query_result($result, 0, 'name');
  78  
  79              //decode_html - added to handle UTF-8 characters in file names

  80              $imageOriginalName = decode_html($imageName);
  81  
  82              if(!empty($imageName)){
  83                  $imageDetails[] = array(
  84                          'id' => $imageId,
  85                          'orgname' => $imageOriginalName,
  86                          'path' => $imagePath.$imageId,
  87                          'name' => $imageName
  88                  );
  89              }
  90          }
  91          return $imageDetails;
  92      }
  93  }


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