<?php

/**
 * Subclass for representing a row from the 'tblproduct' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Tblproduct extends BaseTblproduct
{
	/**
	 * Initializes internal state of Tblproduct object.
	 * @see        parent::__construct()
	 */
	public function __construct()
	{
		// Make sure that parent constructor is always invoked, since that
		// is where any default values for this object are set.
		parent::__construct();
	}

  public function getUserLicense($userid) {
    return TblprolicensePeer::retrieveByPk(1, $userid, $this->getProId(), $this->getProVersion());
  }

  public function createUserLicense($userid, $time = null) {
    $now = date('Y-m-d H:i:s');
    $tbllic = new Tblprolicense();
    $tbllic->setLiType(1);
    $tbllic->setLiCustomer($userid);
    $tbllic->setLiProduct($this->getProId());
    $tbllic->setLiVersion($this->getProVersion());
    $tbllic->setLiLevel($this->getProLevel());
    $tbllic->setLiCreatedate($now);
    if ($time != null) $tbllic->setLiExpiredate(date('Y-m-d H:i:s', strtotime($now." + $time year")));
    $tbllic->save();
  }
}
