00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 include_once( "kernel/classes/ezpersistentobject.php" );
00045 include_once( "kernel/classes/ezvattype.php" );
00046
00047 class eZOrderItem extends eZPersistentObject
00048 {
00049 function eZOrderItem( $row )
00050 {
00051 $this->eZPersistentObject( $row );
00052 }
00053
00054 function definition()
00055 {
00056 return array( "fields" => array( 'id' => array( 'name' => 'ID',
00057 'datatype' => 'integer',
00058 'default' => 0,
00059 'required' => true ),
00060 'order_id' => array( 'name' => 'OrderID',
00061 'datatype' => 'integer',
00062 'default' => 0,
00063 'required' => true,
00064 'foreign_class' => 'eZOrder',
00065 'foreign_attribute' => 'id',
00066 'multiplicity' => '1..*' ),
00067 'description' => array( 'name' => 'Description',
00068 'datatype' => 'string',
00069 'default' => '',
00070 'required' => true ),
00071 'price' => array( 'name' => 'Price',
00072 'datatype' => 'float',
00073 'default' => 0,
00074 'required' => true ),
00075 'vat_value' => array( 'name' => 'VATValue',
00076 'datatype' => 'integer',
00077 'default' => 0,
00078 'required' => true ),
00079 'is_vat_inc' => array( 'name' => 'IsVATIncluded',
00080 'datatype' => 'integer',
00081 'default' => 0,
00082 'required' => true ),
00083 'type' => array( 'name' => 'Type',
00084 'datatype' => 'string',
00085 'required' => false ) ),
00086 'keys' => array( 'id' ),
00087 'function_attributes' => array( 'vat_value' => 'vatValue',
00088 'price_inc_vat' => 'priceIncVat',
00089 'price_ex_vat' => 'priceExVAT' ),
00090 'increment_key' => 'id',
00091 'class_name' => 'eZOrderItem',
00092 'name' => 'ezorder_item' );
00093 }
00094
00095 function fetchList( $orderID, $asObject = true )
00096 {
00097 $returnValue = eZPersistentObject::fetchObjectList( eZOrderItem::definition(),
00098 null,
00099 array( "order_id" => $orderID ),
00100 null,
00101 null,
00102 $asObject );
00103 return $returnValue;
00104 }
00105
00106 function fetchListByType( $orderID, $itemType, $asObject = true )
00107 {
00108 return eZPersistentObject::fetchObjectList( eZOrderItem::definition(),
00109 null,
00110 array( 'order_id' => $orderID, 'type' => $itemType ),
00111 null,
00112 null,
00113 $asObject );
00114
00115 }
00116
00117 function &vatValue()
00118 {
00119 return $this->VATValue;
00120 }
00121
00122 function &priceIncVAT()
00123 {
00124 if ( $this->attribute( 'is_vat_inc' ) == 1 )
00125 {
00126 return $this->Price;
00127 }
00128 else
00129 {
00130 $incVATPrice = $this->Price * ( $this->vatValue() + 100 ) / 100;
00131 return $incVATPrice;
00132 }
00133
00134 }
00135
00136 function &priceExVAT()
00137 {
00138 if ( $this->attribute( 'is_vat_inc' ) == 1 )
00139 {
00140 $exVATPrice = $this->Price / ( $this->vatValue() + 100 ) * 100;
00141 return $exVATPrice;
00142 }
00143 else
00144 return $this->Price;
00145
00146 }
00147
00148
00149
00150
00151
00152
00153
00154 function cleanup()
00155 {
00156 $db =& eZDB::instance();
00157 $db->query( "DELETE FROM ezorder_item" );
00158 }
00159 }
00160
00161 ?>