<?php

namespace MGModule\DNSManager2\models\whmcs\client;
use MGModule\DNSManager2 as main;

/**
 * Client Model
 *
 * @author Michal Czech <michael@modulesgarden.com>
 */
class client extends \MGModule\DNSManager2\mgLibs\models\orm{
    static $tableStructure = array(
        'name'  => 'tblclients'
    );
    static $fieldDeclaration = array(
        'id'
        ,'firstname'
        ,'lastname'
        ,'email'
    );
    
    public $id;
    public $firstname;
    public $lastname;
    public $email;
    
    /**
     * Load Client
     * 
     * @author Michal Czech <michael@modulesgarden.com>
     * @param int $id
     * @param array $data
     */
    function __construct($id = 0,$data = array())
    {
        $this->id = $id;
        
        if($id && empty($data))
        {
            $data = main\mgLibs\MySQL\query::select(
                    self::$fieldDeclaration,
                    self::$tableStructure['name'],
                    array(
                        'id'    => $id
                    )
            );
        }

        if(!empty($data))
        {
            $this->fillProperties($data);
        }
    }
}
