[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Vtiger/models/ -> CompanyDetails.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  /**
  12   * CompanyDetails Record Model class
  13   */
  14  class Vtiger_CompanyDetails_Model extends Vtiger_Base_Model {
  15  
  16      /**
  17       * Function to get the Company Logo
  18       * @return Vtiger_Image_Model instance
  19       */
  20  	public function getLogo(){
  21          $logoName = decode_html($this->get('logoname'));
  22          $logoModel = new Vtiger_Image_Model();
  23          if(!empty($logoName)) {
  24              $companyLogo = array();
  25              $companyLogo['imagepath'] = "test/logo/$logoName";
  26              $companyLogo['alt'] = $companyLogo['title'] = $companyLogo['imagename'] = $logoName;
  27              $logoModel->setData($companyLogo);
  28          }
  29          return $logoModel;
  30      }
  31  
  32      /**
  33       * Function to get the instance of the CompanyDetails model for a given organization id
  34       * @param <Number> $id
  35       * @return Vtiger_CompanyDetails_Model instance
  36       */
  37      public static function getInstanceById($id = 1) {
  38          $companyDetails = Vtiger_Cache::get('vtiger', 'organization');
  39          if (!$companyDetails) {
  40              $db = PearDatabase::getInstance();
  41              $sql = 'SELECT * FROM vtiger_organizationdetails WHERE organization_id=?';
  42              $params = array($id);
  43              $result = $db->pquery($sql, $params);
  44              $companyDetails = new self();
  45              if ($result && $db->num_rows($result) > 0) {
  46                  $resultRow = $db->query_result_rowdata($result, 0);
  47                  $companyDetails->setData($resultRow);
  48              }
  49              Vtiger_Cache::set('vtiger','organization',$companyDetails);
  50          }
  51          return $companyDetails;
  52      }
  53  
  54  }


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