Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezproductcurrency.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezproductcurrency.php 7848 2001-10-15 11:32:18Z ce $
5 //
6 // Definition of eZProductCurrency class
7 //
8 // Created on: <23-Feb-2001 16:47:27 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
29
32
37 // include_once( "classes/ezdb.php" );
38
39 class eZProductCurrency
40 {
44 function __construct( $id=-1 )
45 {
46 $this->PrefixSign = 0;
47
48 if ( $id != -1 )
49 {
50 $this->ID = $id;
51 $this->get( $this->ID );
52 }
53 }
54
58 function store()
59 {
60 $db =& eZDB::globalDatabase();
61 $db->begin();
62
63 $this->Name = $db->escapeString( $this->Name );
64 $this->Sign = $db->escapeString( $this->Sign );
65
66 if ( $this->Value == "" )
67 {
68 $this->Value = 1;
69 }
70
71 if ( !isset( $this->ID ) )
72 {
73 $timeStamp =& (new eZDateTime())->timeStamp( true );
74 $db->lock( "eZTrade_AlternativeCurrency" );
75 $nextID = $db->nextID( "eZTrade_AlternativeCurrency", "ID" );
76
77 $res[] = $db->query( "INSERT INTO eZTrade_AlternativeCurrency
78 ( ID,
79 Name,
80 Sign,
81 Value,
82 Created,
83 PrefixSign )
84 VALUES
85 ( '$nextID',
86 '$this->Name',
87 '$this->Sign',
88 '$this->Value',
89 '$timeStamp',
90 '$this->PrefixSign' )" );
91 $db->unlock();
92 $this->ID = $nextID;
93 }
94 else
95 {
96 $res[] = $db->query( "UPDATE eZTrade_AlternativeCurrency SET
97 Name='$this->Name',
98 Sign='$this->Sign',
99 Value='$this->Value',
100 Created=Created,
101 PrefixSign='$this->PrefixSign'
102 WHERE ID='$this->ID'" );
103 }
104
105 eZDB::finish( $res, $db );
106 return true;
107 }
108
112 function get( $id=-1 )
113 {
114 $db =& eZDB::globalDatabase();
115
116 if ( $id != -1 )
117 {
118 $db->array_query( $currency_array, "SELECT * FROM eZTrade_AlternativeCurrency WHERE ID='$id'" );
119
120 if ( count( $currency_array ) > 1 )
121 {
122 die( "Error: Product currencies with the same ID was found in the database. This shouldn't happen." );
123 }
124 else if( count( $currency_array ) == 1 )
125 {
126 $this->ID =& $currency_array[0][$db->fieldName( "ID" )];
127 $this->Name =& $currency_array[0][$db->fieldName( "Name" )];
128 $this->Value =& $currency_array[0][$db->fieldName( "Value" )];
129 $this->Sign =& $currency_array[0][$db->fieldName( "Sign" )];
130 $this->PrefixSign =& $currency_array[0][$db->fieldName( "PrefixSign" )];
131 }
132 }
133 }
134
138 function &getAll()
139 {
140 $db =& eZDB::globalDatabase();
141
142 $return_array = array();
143 $currency_array = array();
144
145 $db->array_query( $currency_array, "SELECT ID FROM eZTrade_AlternativeCurrency ORDER BY Created" );
146
147 for ( $i=0; $i < count($currency_array); $i++ )
148 {
149 $return_array[$i] = new eZProductCurrency( $currency_array[$i][$db->fieldName( "ID" )], 0 );
150 }
151
152 return $return_array;
153 }
154
158 function delete()
159 {
160 $db =& eZDB::globalDatabase();
161 $db->begin();
162
163 $res[] = $db->query( "DELETE FROM eZTrade_AlternativeCurrency WHERE ID='$this->ID'" );
164
165 eZDB::finish( $res, $db );
166
167
168 }
169
173 function id()
174 {
175 return $this->ID;
176 }
177
181 function name()
182 {
183 return $this->Name;
184 }
185
189 function value()
190 {
191 return number_format( $this->Value, 4, ".", "" );
192 }
193
197 function sign()
198 {
199 return $this->Sign;
200 }
201
205 function prefixSign()
206 {
207 if ( $this->PrefixSign == 1 )
208 return true;
209 else
210 return false;
211 }
212
216 function setName( $value )
217 {
218 $this->Name = $value;
219 }
220
224 function setValue( $value )
225 {
226 $newValue = number_format( $value, 4, ".", "" );
227 $value = (double) $newValue;
228 $this->Value = $value;
229 }
230
231
235 function setSign( $value )
236 {
237 $this->Sign = $value;
238 }
239
243 function setPrefixSign( $value )
244 {
245 if ( $value == true )
246 $this->PrefixSign = 1;
247 else
248 $this->PrefixSign = 0;
249 }
250
251 var $ID;
252 var $Name;
253 var $Sign;
254 var $PrefixSign;
255 var $Value;
256 }
257
258 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZProductCurrency
Definition: ezproductcurrency.php:40
eZProductCurrency\setName
setName( $value)
Definition: ezproductcurrency.php:216
eZProductCurrency\setPrefixSign
setPrefixSign( $value)
Definition: ezproductcurrency.php:243
eZProductCurrency\$PrefixSign
$PrefixSign
Definition: ezproductcurrency.php:254
eZProductCurrency\store
store()
Definition: ezproductcurrency.php:58
eZProductCurrency\value
value()
Definition: ezproductcurrency.php:189
eZProductCurrency\prefixSign
prefixSign()
Definition: ezproductcurrency.php:205
eZProductCurrency\name
name()
Definition: ezproductcurrency.php:181
eZProductCurrency\setSign
setSign( $value)
Definition: ezproductcurrency.php:235
eZProductCurrency\id
id()
Definition: ezproductcurrency.php:173
eZProductCurrency\__construct
__construct( $id=-1)
Definition: ezproductcurrency.php:44
eZProductCurrency\$Sign
$Sign
Definition: ezproductcurrency.php:253
eZProductCurrency\getAll
& getAll()
Definition: ezproductcurrency.php:138
eZProductCurrency\$Name
$Name
Definition: ezproductcurrency.php:252
eZProductCurrency\$Value
$Value
Definition: ezproductcurrency.php:255
eZProductCurrency\sign
sign()
Definition: ezproductcurrency.php:197
eZProductCurrency\$ID
$ID
Definition: ezproductcurrency.php:251
eZProductCurrency\setValue
setValue( $value)
Definition: ezproductcurrency.php:224
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$res
$res
Definition: ezstats/admin/cron.php:45
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.