[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZDiscountSubRule class 4 // 5 // Created on: <27-Nov-2002 13:05:59 wy> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezdiscountrule.php 30 */ 31 32 /*! 33 \class eZDiscountSubRule ezdiscountsubrule.php 34 \brief The class eZDiscountSubRule does 35 36 */ 37 38 include_once ( "kernel/classes/ezpersistentobject.php" ); 39 40 class eZDiscountSubRule extends eZPersistentObject 41 { 42 /*! 43 Constructor 44 */ 45 function eZDiscountSubRule( $row ) 46 { 47 $this->eZPersistentObject( $row ); 48 } 49 50 function definition() 51 { 52 return array( "fields" => array( "id" => array( 'name' => 'ID', 53 'datatype' => 'integer', 54 'default' => 0, 55 'required' => true ), 56 "name" => array( 'name' => "Name", 57 'datatype' => 'string', 58 'default' => '', 59 'required' => true ), 60 "discountrule_id" => array( 'name' => "DiscountRuleID", 61 'datatype' => 'integer', 62 'default' => 0, 63 'required' => true, 64 'foreign_class' => 'eZDiscountRule', 65 'foreign_attribute' => 'id', 66 'multiplicity' => '1..*' ), 67 "discount_percent" => array( 'name' => "DiscountPercent", 68 'datatype' => 'float', 69 'default' => 0, 70 'required' => true ), 71 "limitation" => array( 'name' => "Limitation", 72 'datatype' => 'string', 73 'default' => '', 74 'required' => true ) ), 75 "keys" => array( "id" ), 76 "increment_key" => "id", 77 "class_name" => "eZDiscountSubRule", 78 "name" => "ezdiscountsubrule" ); 79 } 80 81 /*! 82 \reimp 83 */ 84 function setAttribute( $attr, $val ) 85 { 86 switch( $attr ) 87 { 88 case 'discount_percent': 89 { 90 include_once ( 'lib/ezlocale/classes/ezlocale.php' ); 91 $locale = eZLocale::instance(); 92 93 $val = $locale->internalNumber( $val ); 94 if ( $val < 0.0 ) 95 $val = 0.0; 96 if ( $val > 100.0 ) 97 $val = 100.0; 98 eZPersistentObject::setAttribute( $attr, $val ); 99 } break; 100 101 default: 102 { 103 eZPersistentObject::setAttribute( $attr, $val ); 104 } break; 105 } 106 } 107 108 function fetch( $id, $asObject = true ) 109 { 110 return eZPersistentObject::fetchObject( eZDiscountSubRule::definition(), 111 null, 112 array( "id" => $id ), 113 $asObject ); 114 } 115 116 function &fetchList( $asObject = true ) 117 { 118 $objectList = eZPersistentObject::fetchObjectList( eZDiscountSubRule::definition(), 119 null, null, null, null, 120 $asObject ); 121 return $objectList; 122 } 123 124 function fetchByRuleID( $discountRuleID, $asObject = true ) 125 { 126 return eZPersistentObject::fetchObjectList( eZDiscountSubRule::definition(), 127 null, 128 array( "discountrule_id" => $discountRuleID ), 129 null, 130 null, 131 $asObject ); 132 } 133 134 function create( $discountRuleID ) 135 { 136 $row = array( 137 "id" => null, 138 "name" => ezi18n( 'kernel/shop/discountgroup', "New Discount Rule" ), 139 "discountrule_id" => $discountRuleID, 140 "discount_percent" => "", 141 "limitation" => "*" ); 142 return new eZDiscountSubRule( $row ); 143 } 144 145 /*! 146 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 147 the calls within a db transaction; thus within db->begin and db->commit. 148 */ 149 function remove ( $id ) 150 { 151 eZPersistentObject::removeObject( eZDiscountSubRule::definition(), 152 array( "id" => $id ) ); 153 } 154 } 155 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |