[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Settings/Vtiger/models/ -> TermsAndConditions.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 Settings_Vtiger_TermsAndConditions_Model extends Vtiger_Base_Model{
  12      
  13      const tableName = 'vtiger_inventory_tandc';
  14      
  15      public function getText(){
  16          return $this->get('tandc');
  17      }
  18      
  19      public function setText($text){
  20          return $this->set('tandc',$text);
  21      }
  22      
  23      public function getType(){
  24          return "Inventory";
  25      }
  26      
  27      public function save() {
  28          $db = PearDatabase::getInstance();
  29          $query = 'SELECT 1 FROM '.self::tableName;
  30          $result = $db->pquery($query,array());
  31          if($db->num_rows($result) > 0) {
  32              $query = 'UPDATE '.self::tableName.' SET tandc=?';
  33              $params = array($this->getText());
  34          }else{
  35              $query = 'INSERT INTO '.self::tableName.' (id,type,tandc) VALUES(?,?,?)';
  36              $params = array($db->getUniqueID(self::tableName, $this->getType(), $this->getText()));
  37          }
  38          $result = $db->pquery($query, $params);
  39      }
  40      
  41      public static function getInstance() {
  42          $db = PearDatabase::getInstance();
  43          $query = 'SELECT tandc FROM '.self::tableName;
  44          $result = $db->pquery($query,array());
  45          $instance = new self();
  46          if($db->num_rows($result) > 0) {
  47              $text = $db->query_result($result,0,'tandc');
  48              $instance->setText($text);
  49          }
  50          return $instance;
  51      }
  52  }


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