Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezshippinggroup.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezshippinggroup.php 7217 2001-09-14 12:29:11Z ce $
5 //
6 // Definition of eZShippingGroup class
7 //
8 // Created on: <22-Feb-2001 14:06:14 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
39 // include_once( "classes/ezdb.php" );
40 // include_once( "classes/ezdatetime.php" );
41
42
43 class eZShippingGroup
44 {
48 function __construct( $id=-1 )
49 {
50 if ( $id != -1 )
51 {
52 $this->ID = $id;
53 $this->get( $this->ID );
54 }
55 }
56
60 function store()
61 {
62 $db =& eZDB::globalDatabase();
63 $db->begin();
64
65 $this->Name = $db->escapeString( $this->Name );
66
67 if ( !isset( $this->ID ) )
68 {
69 $timeStamp =& (new eZDateTime())->timeStamp( true );
70 $db->lock( "eZTrade_ShippingGroup" );
71 $nextID = $db->nextID( "eZTrade_ShippingGroup", "ID" );
72 $res[] = $db->query( "INSERT INTO eZTrade_ShippingGroup
73 ( ID,
74 Name,
75 Created )
76 VALUES
77 ( '$nextID',
78 '$this->Name',
79 '$timeStamp' )" );
80 $db->unlock();
81 $this->ID = $nextID;
82 }
83 else
84 {
85 $res[] = $db->query( "UPDATE eZTrade_ShippingGroup SET
86 Name='$this->Name',
87 Created=Created
88 WHERE ID='$this->ID'" );
89 }
90
91 eZDB::finish( $res, $db );
92 return true;
93 }
94
98 function get( $id=-1 )
99 {
100 $db =& eZDB::globalDatabase();
101
102 if ( $id != -1 )
103 {
104 $db->array_query( $shipping_array, "SELECT * FROM eZTrade_ShippingGroup WHERE ID='$id'" );
105
106 if ( count( $shipping_array ) > 1 )
107 {
108 die( "Error: Shipping Groups's with the same ID was found in the database. This shouldn't happen." );
109 }
110 else if( count( $shipping_array ) == 1 )
111 {
112 $this->ID =& $shipping_array[0][$db->fieldName( "ID" )];
113 $this->Name =& $shipping_array[0][$db->fieldName( "Name" )];
114 }
115 }
116 }
117
121 function &getAll()
122 {
123 $db =& eZDB::globalDatabase();
124
125 $return_array = array();
126 $shipping_array = array();
127
128 $db->array_query( $shipping_array, "SELECT ID FROM eZTrade_ShippingGroup ORDER BY Created" );
129
130 for ( $i=0; $i<count($shipping_array); $i++ )
131 {
132 $return_array[$i] = new eZShippingGroup( $shipping_array[$i][$db->fieldName( "ID" )], 0 );
133 }
134 return $return_array;
135 }
136
140 function delete()
141 {
142 $db =& eZDB::globalDatabase();
143 $db->begin();
144
145 $res[] = $db->query( "DELETE FROM eZTrade_ShippingValue WHERE ShippingGroupID='$this->ID'" );
146 $res[] = $db->query( "DELETE FROM eZTrade_ShippingGroup WHERE ID='$this->ID'" );
147
148 eZDB::finish( $res, $db );
149 }
150
154 function id()
155 {
156 return $this->ID;
157 }
158
162 function name()
163 {
164 return $this->Name;
165 }
166
171 function setStartAddValue( $type, $startValue, $addValue )
172 {
173 if ( is_a( $type, "eZShippingType" ) )
174 {
175 $db =& eZDB::globalDatabase();
176 $typeID = $type->id();
177
178 $value_array = array();
179
180 $db->array_query( $value_array, "SELECT ID FROM eZTrade_ShippingValue
181 WHERE ShippingTypeID='$typeID' AND ShippingGroupID='$this->ID'" );
182
183 if ( count( $value_array ) == 1 )
184 {
185 $vid = $value_array[0][$db->fieldName( "ID" )];
186
187 $res[] = $db->query( "UPDATE eZTrade_ShippingValue SET StartValue='$startValue',
188 AddValue='$addValue'
189 WHERE ID='$vid'
190 " );
191 }
192 else
193 {
194 $db->lock( "eZTrade_ShippingValue" );
195 $nextID = $db->nextID( "eZTrade_ShippingValue", "ID" );
196 $res[] = $db->query( "INSERT INTO eZTrade_ShippingValue
197 ( ID,
198 StartValue,
199 AddValue,
200 ShippingTypeID,
201 ShippingGroupID )
202 VALUES
203 ( '$nextID',
204 '$startValue',
205 '$addValue',
206 '$typeID',
207 '$this->ID' )" );
208 $db->unlock();
209 }
210 }
211 eZDB::finish( $res, $db );
212 }
213
219 function &startAddValue( $type )
220 {
221 $ret = array();
222
223 if ( is_a( $type, "eZShippingType" ) )
224 {
225 $db =& eZDB::globalDatabase();
226 $typeID = $type->id();
227
228 $value_array = array();
229
230 $db->array_query( $value_array, "SELECT * FROM eZTrade_ShippingValue
231 WHERE ShippingTypeID='$typeID' AND ShippingGroupID='$this->ID'" );
232
233 $ret = array( "StartValue" => $value_array[0][$db->fieldName( "StartValue" )],
234 "AddValue" => $value_array[0][$db->fieldName( "AddValue" )]);
235 }
236
237 return $ret;
238 }
239
240
244 function setName( $value )
245 {
246 $this->Name = $value;
247 }
248
249 var $ID;
250 var $Name;
251 }
252
253 ?>
$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
eZShippingGroup
Definition: ezshippinggroup.php:44
eZShippingGroup\store
store()
Definition: ezshippinggroup.php:60
eZShippingGroup\id
id()
Definition: ezshippinggroup.php:154
eZShippingGroup\startAddValue
& startAddValue( $type)
Definition: ezshippinggroup.php:219
eZShippingGroup\__construct
__construct( $id=-1)
Definition: ezshippinggroup.php:48
eZShippingGroup\$Name
$Name
Definition: ezshippinggroup.php:250
eZShippingGroup\getAll
& getAll()
Definition: ezshippinggroup.php:121
eZShippingGroup\setName
setName( $value)
Definition: ezshippinggroup.php:244
eZShippingGroup\$ID
$ID
Definition: ezshippinggroup.php:249
eZShippingGroup\name
name()
Definition: ezshippinggroup.php:162
eZShippingGroup\setStartAddValue
setStartAddValue( $type, $startValue, $addValue)
Definition: ezshippinggroup.php:171
$type
$type
Definition: classes/admin/linkselect.php:220
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$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+.