Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezdiscountsubrule.php
Go to the documentation of this file.
1 <?php
17 class eZDiscountSubRule extends eZPersistentObject
18 {
19 static function definition()
20 {
21 return array( "fields" => array( "id" => array( 'name' => 'ID',
22 'datatype' => 'integer',
23 'default' => 0,
24 'required' => true ),
25 "name" => array( 'name' => "Name",
26 'datatype' => 'string',
27 'default' => '',
28 'required' => true ),
29 "discountrule_id" => array( 'name' => "DiscountRuleID",
30 'datatype' => 'integer',
31 'default' => 0,
32 'required' => true,
33 'foreign_class' => 'eZDiscountRule',
34 'foreign_attribute' => 'id',
35 'multiplicity' => '1..*' ),
36 "discount_percent" => array( 'name' => "DiscountPercent",
37 'datatype' => 'float',
38 'default' => 0,
39 'required' => true ),
40 "limitation" => array( 'name' => "Limitation",
41 'datatype' => 'string',
42 'default' => '',
43 'required' => true ) ),
44 "keys" => array( "id" ),
45 "increment_key" => "id",
46 "class_name" => "eZDiscountSubRule",
47 "name" => "ezdiscountsubrule" );
48 }
49
50 function setAttribute( $attr, $val )
51 {
52 switch( $attr )
53 {
54 case 'discount_percent':
55 {
56 $locale = eZLocale::instance();
57
58 $val = $locale->internalNumber( $val );
59 if ( $val < 0.0 )
60 $val = 0.0;
61 if ( $val > 100.0 )
62 $val = 100.0;
63 parent::setAttribute( $attr, $val );
64 } break;
65
66 default:
67 {
68 parent::setAttribute( $attr, $val );
69 } break;
70 }
71 }
72
73 static function fetch( $id, $asObject = true )
74 {
75 return eZPersistentObject::fetchObject( eZDiscountSubRule::definition(),
76 null,
77 array( "id" => $id ),
78 $asObject );
79 }
80
81 static function fetchList( $asObject = true )
82 {
83 return eZPersistentObject::fetchObjectList( eZDiscountSubRule::definition(),
84 null, null, null, null,
85 $asObject );
86 }
87
88 static function fetchByRuleID( $discountRuleID, $asObject = true )
89 {
90 return eZPersistentObject::fetchObjectList( eZDiscountSubRule::definition(),
91 null,
92 array( "discountrule_id" => $discountRuleID ),
93 null,
94 null,
95 $asObject );
96 }
97
98 static function create( $discountRuleID )
99 {
100 $row = array(
101 "id" => null,
102 "name" => ezpI18n::tr( 'kernel/shop/discountgroup', "New Discount Rule" ),
103 "discountrule_id" => $discountRuleID,
104 "discount_percent" => "",
105 "limitation" => "*" );
106 return new eZDiscountSubRule( $row );
107 }
108
113 function remove ( $id = null, $dumb = null )
114 {
115 eZPersistentObject::removeObject( eZDiscountSubRule::definition(),
116 array( "id" => $id ) );
117 }
118 }
119 ?>
eZDiscountSubRule
The class eZDiscountSubRule does.
Definition: ezdiscountsubrule.php:18
eZDiscountSubRule\setAttribute
setAttribute( $attr, $val)
Definition: ezdiscountsubrule.php:50
eZDiscountSubRule\fetchList
static fetchList( $asObject=true)
Definition: ezdiscountsubrule.php:81
eZDiscountSubRule\create
static create( $discountRuleID)
Definition: ezdiscountsubrule.php:98
eZDiscountSubRule\fetchByRuleID
static fetchByRuleID( $discountRuleID, $asObject=true)
Definition: ezdiscountsubrule.php:88
eZDiscountSubRule\fetch
static fetch( $id, $asObject=true)
Definition: ezdiscountsubrule.php:73
eZDiscountSubRule\definition
static definition()
Definition: ezdiscountsubrule.php:19
eZLocale\instance
static instance( $localeString=false)
Definition: ezlocale.php:1536
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\removeObject
static removeObject( $def, $conditions=null, $extraConditions=null)
Definition: ezpersistentobject.php:271
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.