| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- namespace MGModule\DNSManager2\models\whmcs\product;
- use MGModule\DNSManager2 as main;
- /**
- * Description of product
- *
- * @Table(name=tblproducts,preventUpdate,prefixed=false)
- * @author Michal Czech <michael@modulesgarden.com>
- */
- class product extends main\mgLibs\models\orm{
- /**
- *
- * @Column(int)
- * @var int
- */
- public $id;
-
- /**
- *
- * @Column()
- * @var string
- */
- public $type;
-
- /**
- *
- * @Column(int)
- * @var int
- */
- public $gid;
-
- /**
- * @Column()
- * @var string
- */
- public $name;
-
- /**
- * @Column(name=servertype)
- * @var string
- */
- public $serverType;
- /**
- * @Column(name=servergroup)
- * @var int
- */
- public $serverGroupID;
-
- /**
- *
- * @var main\models\service\server
- */
- private $_server;
-
- /**
- *
- * @var configuration
- */
- private $_configuration;
-
- /**
- *
- * @var main\models\whmcs\customFields\repository
- */
- private $_customFields;
-
- /**
- * Create Product
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @param int $id
- * @param array $params
- */
- function __construct($id = null, $params = array()) {
- $this->id = $id;
- $this->load($params);
- }
-
- /**
- * Load Product
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @param array $params
- */
- function load($params = array()){
- if(empty($params))
- {
- $fields = static::fieldDeclaration();
-
- for($i=1;$i<25;$i++)
- {
- $fields['configoption'.$i] = 'configoption'.$i;
- }
-
- $params = main\mgLibs\MySQL\query::select(
- $fields
- , static::tableName()
- , array(
- 'id' => $this->id
- )
- )->fetch();
- }
- $this->fillProperties($params);
-
- if(isset($params['serverGroupID']))
- {
- $this->serverGroupID = $params['serverGroupID'];
- }
-
- if(isset($params['configoption1']))
- {
- $this->_configuration = $this->loadConfiguration($params);
- }
- }
-
- /**
- * Load Server
- *
- * @return \MGModule\DNSManager2\models\service\server
- */
- protected function loadServer(){
- if(empty($this->serverGroupID))
- {
- $this->load();
- }
- $server = main\mgLibs\MySQL\query::query("
- SELECT
- S.id
- FROM
- tblservers S
- JOIN
- tblservergroupsrel R
- ON S.id = R.serverid
- WHERE
- R.groupid = :groupID
- AND disabled = 0
- ",array(
- 'groupID' => $this->serverGroupID
- ))->fetchColumn();
-
- return new main\models\whmcs\servers\server($server);
- }
-
- /**
- * Get Server
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @return main\models\service\server
- */
- function getServer(){
- if(empty($this->_server))
- {
- $this->_server = $this->loadServer();
- }
-
- return $this->_server;
- }
-
- /**
- * Load Configuration
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @param array $params
- * @return \MGModule\DNSManager2\models\product\configuration
- */
- protected function loadConfiguration($params = array()){
- return new configuration($this->id,$params);
- }
-
- /**
- * Get Configuration
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @return configuration
- */
- function configuration(){
- if(empty($this->_configuration))
- {
- $this->_configuration = $this->loadConfiguration();
- }
-
- return $this->_configuration;
- }
-
- /**
- * Get Custom Fields
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @return main\models\whmcs\customFields\repository
- */
- function customFields(){
- if(empty($this->_customFields))
- {
- $this->_customFields = new main\models\whmcs\customFields\repository('product', $this->id);
- }
-
- return $this->_customFields;
- }
-
- function configOptionsGroups(){
-
- }
- }
|