Source for file SHOP_ORDERITEM.phpclass

Documentation is available at SHOP_ORDERITEM.phpclass

  1. <?php
  2. /**
  3.   * openCSP class file SHOP_ORDERITEM.phpclass
  4.   *
  5.   * @project Open CSP-Management
  6.   * @package default
  7.   *
  8.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-16.10.2008
  12.   * @version $Id: SHOP_ORDERITEM.phpclass,v 1.1 2008/10/16 02:21:48 pitlinz Exp $
  13.   */
  14.  
  15.     // ---------------------------------------------------------
  16.     // requirements
  17.     // ---------------------------------------------------------
  18.  
  19.     pcf_require_class('DBMS_TABLEOBJ',"db/");
  20.  
  21. /**
  22.   * openCSP class SHOP_ORDERITEM
  23.   *
  24.   * @project Open CSP-Management
  25.   * @package default
  26.   *
  27.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  28.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  29.   *
  30.   * @since pk-16.10.2008
  31.   * @version $Id: SHOP_ORDERITEM.phpclass,v 1.1 2008/10/16 02:21:48 pitlinz Exp $
  32.   */
  33. class SHOP_ORDERITEM extends DBMS_TABLEOBJ
  34. {
  35.     // ---------------------------------------------------------------------------
  36.     // constants
  37.     // ---------------------------------------------------------------------------
  38.     
  39.     /**
  40.      * @constant string CLASS_SRC_FILE
  41.      */
  42.     const CLASS_SRC_FILE = __FILE__;
  43.  
  44.     // ---------------------------------------------------------------------------
  45.     // class (static)
  46.     // ---------------------------------------------------------------------------
  47.     
  48.     /*** class vars ------------------------------------------------------ */
  49.     
  50.     /*** class methods --------------------------------------------------- */
  51.     
  52.     // ---------------------------------------------------------------------------
  53.     // object vars
  54.     // ---------------------------------------------------------------------------
  55.     
  56.     /*** compostion --------------------------------------------------- */
  57.     
  58.     /*** attributes  -------------------------------------------------- */
  59.     
  60.     /**
  61.      * the database table
  62.      *
  63.      * @var string 
  64.      */
  65.     protected $myTable = "T_SHOP_ORDER_ITEM";    
  66.     
  67.     // ---------------------------------------------------------------------------
  68.     // factory / construct
  69.     // ---------------------------------------------------------------------------
  70.     
  71.     public static function factoryFromRow($arr_row)
  72.     {
  73.         $obj_ret new SHOP_ORDERITEM();
  74.         $obj_ret->setDBRow($arr_row);
  75.         return $obj_ret;
  76.     }
  77.     
  78.     // ---------------------------------------------------------------------------
  79.     // getter / setter
  80.     // ---------------------------------------------------------------------------    
  81.  
  82.     /**
  83.      * sets the order id
  84.      *
  85.      * @param int $aId 
  86.      */
  87.     public function setOrderId($aId)
  88.     {
  89.         $this->setDBField('ORD_ID',intval($aId));
  90.     }
  91.     
  92.     /**
  93.      * sets the quantity order
  94.      *
  95.      * @param float $quant 
  96.      */    
  97.     public function setQuant($quant)
  98.     {
  99.         $this->setDBField('OIT_QUANT',floatval($quant));
  100.     }
  101.     
  102.     /**
  103.      * sets the part text
  104.      *
  105.      * @param string $aText 
  106.      */
  107.     public function setPartText($aText)
  108.     {
  109.         $this->setDBField('OIT_PAR_TEXT',$aText);
  110.     }
  111.     
  112.     /**
  113.      * sets the part number
  114.      * 
  115.      * NOTE: this only a output column do not use to identify the part
  116.      *
  117.      * @param string $aNumber 
  118.      */
  119.     public function setPartNumber($aNumber)
  120.     {
  121.         $this->setDBField('OIT_PAR_NUMBER',$aNumber);
  122.     }
  123.     
  124.     
  125.     // ---------------------------------------------------------------------------
  126.     // product / parts
  127.     // ---------------------------------------------------------------------------    
  128.     
  129.     /**
  130.      * sets the part
  131.      *
  132.      * @param PRO_PART $aPart 
  133.      */
  134.     public function setPart(&$aPart)
  135.     {
  136.         if (!pcf_class_implements($aPart,'INFA_PRO_PART'))
  137.         {
  138.             throw new Exception("\$aPart (" get_class($aPart") does not implement INFA_PRO_PART");
  139.         
  140.         
  141.         $this->setDBField('PAR_ID',$aPart->getId());
  142.         $this->setDBField('OIT_PAR_DATA',base64_encode(serialize($aPart->getDBRow())));
  143.         
  144.         $this->setDBField('PRO_ID',$aPart->getProductId());
  145.         $this->setDBField('OIT_PRO_DATA',base64_encode(serialize($aPart->getProduct()->getDBRow())));
  146.         
  147.         $this->setDBField('OIT_PRICE',$aPart->getPrice());        
  148.     }
  149.     
  150.     // ---------------------------------------------------------------------------
  151.     // attributes
  152.     // ---------------------------------------------------------------------------    
  153.     
  154.     /**
  155.      * returns the part attributes
  156.      *
  157.      * @return array 
  158.      */
  159.     public function getAttributes()
  160.     {
  161.         $str_attr $this->getDBField('PAR_ATTRIB');
  162.         if (!empty($str_attr))
  163.         {
  164.             return unserialize(base64_decode($str_attr));
  165.         else {
  166.             return array();
  167.         }        
  168.     }
  169.     
  170.     /**
  171.      * sets the attribute values
  172.      * 
  173.      * NOTE: does overwrite already set values
  174.      *
  175.      * @param array $attribs 
  176.      */
  177.     public function setAttributes($attribs)
  178.     {
  179.         $this->setDBField('PAR_ATTRIB',base64_encode(serialize($attribs)));
  180.     }
  181.     
  182.     /**
  183.      * sets an attribut value
  184.      *
  185.      * @param string $name 
  186.      * @param mixed $value 
  187.      */
  188.     public function setAttribut($name,$value)
  189.     {
  190.         $arr_attr $this->getAttributes();
  191.         $arr_attr[$name$value;
  192.         $this->setAttributes($arr_attr);                
  193.     }
  194.     
  195.     /**
  196.      * returns an attribut value
  197.      * 
  198.      * @param string $name 
  199.      */
  200.     public function getAttribut($name)
  201.     {
  202.         $arr_attr $this->getAttributes();
  203.         if (isset($arr_attr[$name]))
  204.         {
  205.             return $arr_attr[$name];
  206.         else {
  207.             return Null;
  208.         }
  209.     }
  210. }
  211.  
  212. ?>

Documentation generated on Thu, 08 Jan 2009 17:48:32 +0100 by phpDocumentor 1.4.0a2