Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

productedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: productedit.php 9904 2004-07-09 11:44:47Z br $
5 //
6 // Created on: <19-Sep-2000 10:56:05 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
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 the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezcachefile.php" );
30 // include_once( "classes/ezhttptool.php" );
31 // include_once( "ezuser/classes/ezobjectpermission.php" );
32 // include_once( "eztrade/classes/ezpricegroup.php" );
33 // include_once( "eztrade/classes/ezproductpermission.php" );
34 // include_once( "eztrade/classes/ezproductpricerange.php" );
35
36 // include_once( "ezxml/classes/ezxml.php" );
37
38 function deleteCache( $ProductID, $CategoryID, $CategoryArray, $Hotdeal )
39 {
40 $product = new eZProduct( $ProductID );
41 if ( is_a( $product, "eZProduct" ) )
42 {
43 $CategoryID =& $product->categoryDefinition( false );
44 $CategoryArray =& $product->categories( false );
45 $Hotdeal = $product->isHotDeal();
46 $ProductID = $product->id();
47 }
48
49 $files = eZCacheFile::files( "kernel/eztrade/cache/", array( array( "productview", "productprint" ),
50 $ProductID, $CategoryID ),
51 "cache", "," );
52 foreach ( $files as $file )
53 {
54 $file->delete();
55 }
56 $files = eZCacheFile::files( "kernel/eztrade/cache/", array( "productlist",
57 array_merge( array( $CategoryID ), $CategoryArray ) ),
58 "cache", "," );
59
60 foreach ( $files as $file )
61 {
62 $file->delete();
63 }
64 if ( $Hotdeal )
65 {
66 $files = eZCacheFile::files( "kernel/eztrade/cache/", array( "hotdealslist", NULL ),
67 "cache", "," );
68 foreach ( $files as $file )
69 {
70 $file->delete();
71 }
72 }
73 $files =& eZCacheFile::files( "kernel/ezarticle/cache/",
74 array( "articlefrontpage",
75 NULL,
76 NULL),
77 "cache", "," );
78 foreach( $files as $file )
79 {
80 $file->delete();
81 }
82
83 }
84
85 $ini =& eZINI::instance( 'site.ini' );
86
87 $Language = $ini->variable( "eZTradeMain", "Language" );
88 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true";
89 $ShowQuantity = $ini->variable( "eZTradeMain", "ShowQuantity" ) == "true";
90 $ShowModuleLinker = $ini->variable( "eZTradeMain", "ShowModuleLinker" ) == "true";
91
92 $CSVDelimiter = $ini->variable( "eZTradeMain", "CSVDelimiter" );
93 $DefaultDealerPriceGroup = $ini->variable( "eZTradeMain", "DefaultDealerPriceGroup" );
94
95 // include_once( "eztrade/classes/ezproduct.php" );
96 // include_once( "eztrade/classes/ezproductcategory.php" );
97 // include_once( "eztrade/classes/ezvattype.php" );
98 // include_once( "eztrade/classes/ezshippinggroup.php" );
99
100 // must have to generate XML
101 // include_once( "ezarticle/classes/ezarticlegenerator.php" );
102
103 if ( isset($CSVImport) )
104 {
105 // include_once( "eztrade/classes/ezcsvimport.php" );
106 //get default target category ID
107 $CategoryID = $ini->variable( "eZTradeMain", "CSVImportCat" );
108 //read CSV file
109 $ProductImport = new eZCSVImport();
110 $csvArray = $ProductImport->csvFileToArray($ImportCSVDir, $CSVDelimiter, 'none', TRUE, TRUE, FALSE);
111 // print_r($csvArray); exit();
112 foreach ( $csvArray as $row )
113 {
114 // make a new product
115 // build the product
116 /*
117 $row[0] = Name
118 $row[1] = Product_Number
119 $row[2] = Keywords
120 $row[3] = Lead_In
121 $row[4] = Description
122 $row[5] = External_Link
123 $row[6] = Quantity
124 $row[7] = StockDate
125 $row[8] = Shipping_group
126 $row[9] = Weight
127 $row[10] = BoxType
128 $row[11] = Duration
129 $row[12] = IsHotDeal
130 $row[13] = Discontinued
131 $row[14] = Tax_Amount
132 $row[15] = IncludesVAT
133 $row[16] = Price
134 $row[17] = ListPrice
135 $row[18] = DealerPrice
136 $row[19] = Show_Product
137 $row[20] = Show_Price
138 $row[21] = FlatUPS
139 $row[22] = FlatUSPS
140 $row[23] = FlatCombine
141 */
142
143 $product = new eZProduct();
144 $generator = new eZArticleGenerator();
145
146 // check to see if product already exists
147 $item = $product->findProductNumber($row[1]);
148 // update fields if true
149 if ( $item )
150 {
151 if ( eZXML::domTree( $contents ) )
152 {
153 if ( $item->name() != $row[0] )
154 $item->setName( $row[0] );
155
156 $contentsArray =& $generator->decodeXML( $item->contents() );
157
158 if ( $contentsArray[0] != $row[3] )
159 $item->setBrief( $row[3] );
160 if ( $contentsArray[1] != $row[4] )
161 $item->setDescription( $row[4] );
162
163 if ( ($contentsArray[0] != $row[3]) || ($contentsArray[1] != $row[4]) )
164 {
165 $Contents = array( $row[3], $row[4] );
166 $contents =& $generator->generateXML( $Contents );
167 $item->setContents( $contents );
168 }
169
170 if ( $item->keywords() != $row[2] )
171 $item->setKeywords( $row[2] );
172 if ( $item->productNumber != $row[1] )
173 $item->setProductNumber( $row[1] );
174 if ( $item->externalLink != $row[5] )
175 $item->setExternalLink( $row[5] );
176 //set delivery date if quantity = 0
177 if ( is_numeric($row[6]) && $row[6] == 0 && $row[7] != "" )
178 {
179 $dateArray = explode('/', $row[7]);
180 $DateInStock = new eZDate( $dateArray[2], $dateArray[1], $dateArray[0] );
181 $date = $DateInStock->timeStamp();
182 if ( $item->stockDate != $date )
183 $item->setStockDate( $date );
184 }
185
186 if ( $row[6] > 0 || $row[7] == "" )
187 $item->setStockDate('');
188
189 $vattype = $item->vatType();
190 if ( $vattype->id() != $row[14] && $row[14] > 0 )
191 {
192 $newVATType = new eZVATType( $row[14] );
193 $item->setVATType( $newVATType );
194 }
195
196 $boxtype = $item->boxType();
197 if ($boxtype && $boxtype->id() != $row[10] && $row[10] > 0 )
198 {
199 $newBoxType = new eZBoxType( $row[10] );
200 $item->setBoxType( $newBoxType );
201 }
202
203 if ($boxtype && $row[10]=='' )
204 {
205 $newBoxType = new eZBoxType();
206 $item->setBoxType( $newBoxType );
207 }
208
209 if ( !$item->shippingGroup() )
210 $item->setShippingGroup( $row[8] );
211
212 $shippingGroup = $item->shippingGroup();
213
214 if ( $shippingGroup && $shippingGroup->id() != $row[8] )
215 {
216 $newShippingGroup = new eZShippingGroup( $row[8] );
217 $item->setShippingGroup( $newShippingGroup );
218 }
219
220 if ( $row[20] == "on" )
221 $item->setShowPrice( true );
222 else if ( $row[20] == "off" )
223 $item->setShowPrice( false );
224 if ( $item->weight() != $row[9] )
225 $item->setWeight( $row[9] );
226 //product is not a voucher
227 $item->setProductType( 1 );
228 $item->setShowProduct( $row[19] == "on" );
229 $item->setDiscontinued( $row[13] == "on" );
230
231 if ( $row[12] == "on" )
232 $item->setIsHotDeal( true );
233 else if ( $row[12] == "off" )
234 $item->setIsHotDeal( false );
235 $item->setPrice( $row[16] );
236 $item->setListPrice( $row[17] );
237 if ( $row[15] == "true" )
238 $item->setIncludesVAT( true );
239 else if ( $row[15] == "false" )
240 $item->setIncludesVAT( false );
241 if ( $row[11] > 0 )
242 $item->setExpiryTime( $row[11] );
243 // Flat Rate
244 if ( is_numeric( $row[21] ) )
245 $item->setFlatUPS( $row[21] );
246 else
247 $item->setFlatUPS( 'off' );
248
249 if ( is_numeric( $row[22] ) )
250 $item->setFlatUSPS( $row[22] );
251 else
252 $item->setFlatUSPS( 'off' );
253
254 $item->setFlatCombine( $row[23] );
255
256 //store product
257 $item->store();
258 $itemID = $item->id();
259 //set dealer price
260 if ( $row[18] != '' )
261 {
262 eZPriceGroup::removePrices( $itemID, -1, -1, $DefaultDealerPriceGroup );
263 eZPriceGroup::addPrice( $itemID, $DefaultDealerPriceGroup, $row[18] );
264 }
265
266 if ( $row[18] == '' )
267 eZPriceGroup::removePrices( $itemID, -1, -1, $DefaultDealerPriceGroup );
268
269 //set quantity data
270 $item->setTotalQuantity( is_numeric( $row[6] ) ? $row[6] : false );
271 // setup the category
272 // $category = new eZProductCategory( $CategoryID );
273 // $item->setCategoryDefinition( $category );
274 // eZProductCategory::addProduct( $item, $CategoryID );
275 // set write permissions
276 /* eZObjectPermission::removePermissions( $itemID, "trade_product", 'w' );
277 eZObjectPermission::setPermission( 1, $itemID, "trade_product", 'w' );
278 // set read permissions
279 eZObjectPermission::removePermissions( $itemID, "trade_product", 'r' );
280 eZObjectPermission::setPermission( -1, $itemID, "trade_product", 'r' ); */
281 }
282
283 }
284
285
286 if (!$item)
287 {
288 $Contents = array( $row[3], $row[4] );
289 // $generator = new eZArticleGenerator();
290 $contents =& $generator->generateXML( $Contents );
291
292 if ( eZXML::domTree( $contents ) )
293 {
294 $product->setName( $row[0] );
295 $product->setContents( $contents );
296 $product->setBrief( $row[3] );
297 $product->setDescription( $row[4] );
298 $product->setKeywords( $row[2] );
299 $product->setProductNumber( $row[1] );
300 $product->setExternalLink( $row[5] );
301 //set delivery date if quantity = 0
302 if ( is_numeric($row[6]) && $row[6] == 0 )
303 {
304 $dateArray = explode('/', $row[7]);
305 $DateInStock = new eZDate( $dateArray[2], $dateArray[1], $dateArray[0] );
306 $date = $DateInStock->timeStamp();
307 $product->setStockDate( $date );
308 }
309
310 $vattype = new eZVATType( $row[14] );
311 $product->setVATType( $vattype );
312
313 if ($row[10])
314 {
315 $boxtype = new eZBoxType( $row[10] );
316 $product->setBoxType( $boxtype );
317 }
318 $shippingGroup = new eZShippingGroup( $row[8] );
319 $product->setShippingGroup( $shippingGroup );
320
321 if ( $row[20] == "on" )
322 $product->setShowPrice( true );
323 else if ( $row[20] == "off" )
324 $product->setShowPrice( false );
325 if ( $row[9] )
326 $product->setWeight( $row[9] );
327 //product is not a voucher
328 $product->setProductType( 1 );
329 $product->setShowProduct( $row[19] == "on" );
330 $product->setDiscontinued( $row[13] == "on" );
331
332 if ( $row[12] == "on" )
333 $product->setIsHotDeal( true );
334 else if ( $row[12] == "off" )
335 $product->setIsHotDeal( false );
336 $product->setPrice( $row[16] );
337 $product->setListPrice( $row[17] );
338 if ( $row[15] == "true" )
339 $product->setIncludesVAT( true );
340 else if ( $row[15] == "false" )
341 $product->setIncludesVAT( false );
342 if ( $row[11] > 0 )
343 $product->setExpiryTime( $row[11] );
344
345 if ( is_numeric( $row[21] ) )
346 $product->setFlatUPS( $row[21] );
347 else
348 $product->setFlatUPS( 'off' );
349
350 if ( is_numeric( $row[22] ) )
351 $product->setFlatUSPS( $row[22] );
352 else
353 $product->setFlatUSPS( 'off' );
354
355 $product->setFlatCombine( $row[23] );
356 //store product
357 $product->store();
358 $productID = $product->id();
359 if ( $row[18] != '' )
360 {
361 eZPriceGroup::removePrices( $productID, -1, -1, $DefaultDealerPriceGroup );
362 eZPriceGroup::addPrice( $productID, $DefaultDealerPriceGroup, $row[18] );
363 }
364
365 if ( $row[18] == '' )
366 eZPriceGroup::removePrices( $productID, -1, -1, $DefaultDealerPriceGroup );
367 //set quantity data
368 $product->setTotalQuantity( is_numeric( $row[6] ) ? $row[6] : false );
369 // setup the category
370 $category = new eZProductCategory( $CategoryID );
371 $product->setCategoryDefinition( $category );
372 eZProductCategory::addProduct( $product, $CategoryID );
373 // set write permissions
374 eZObjectPermission::removePermissions( $productID, "trade_product", 'w' );
375 eZObjectPermission::setPermission( 1, $productID, "trade_product", 'w' );
376 // set read permissions
377 eZObjectPermission::removePermissions( $productID, "trade_product", 'r' );
378 eZObjectPermission::setPermission( -1, $productID, "trade_product", 'r' );
379 }
380 }
381 }
382 eZHTTPTool::header( "Location: /trade/categorylist/parent/$CategoryID/" );
383 exit();
384 }
385
386 if ( isSet( $SubmitPrice ) )
387 {
388 for ( $i = 0; $i < count( $ProductEditArrayID ); $i++ )
389 {
390 if ( $Price[$i] != "" and is_numeric( $Price[$i] ) )
391 {
392 $product = new eZProduct( $ProductEditArrayID[$i] );
393 $product->setPrice( $Price[$i] );
394 $product->store();
395 deleteCache( $product, false, false, false );
396 }
397 }
398 if ( isset( $Query ) )
399 eZHTTPTool::header( "Location: /trade/search/$Offset/$Query" );
400 else
401 eZHTTPTool::header( "Location: /trade/categorylist/parent/$CategoryID/$Offset" );
402
403 exit();
404 }
405
406
407 if ( isSet( $UpdateProducts ) )
408 {
409 /* echo "<pre>";
410 print_r( $Discontinued );
411 print_r($ShowPrice);
412 echo "</pre>";
413 exit (); */
414
415 for ( $i = 0; $i < count( $ProductEditArrayID ); $i++ )
416 {
417 $product = new eZProduct( $ProductEditArrayID[$i] );
418
419 if ( $Name[$i] != $product->name() )
420 $product->setName($Name[$i]);
421
422 if ( $Price[$i] != "" and is_numeric( $Price[$i] ) )
423 $product->setPrice( $Price[$i] );
424
425 if ( $ListPrice[$i] != "" and is_numeric( $ListPrice[$i] ) )
426 $product->setListPrice( $ListPrice[$i] );
427
428 // if ( $Brief[$i] != $product->brief() || $Description[$i] != $product->description() )
429 // {
430 $Contents = array( $Brief[$i], $Description[$i] );
431 $generator = new eZArticleGenerator();
432 $contents =& $generator->generateXML( $Contents );
433 // }
434
435 if ( $contents && eZXML::domTree( $contents ) )
436 {
437 $product->setContents( $contents );
438 $was_hotdeal = $product->isHotDeal();
439
440 if ( $Keywords[$i] != "" )
441 $product->setKeywords( $Keywords[$i] );
442
443 if ( $ProductNumber[$i] != $product->productNumber() )
444 $product->setProductNumber( $ProductNumber[$i] );
445
446 if ( $ExternalLink[$i] != $product->externalLink() )
447 $product->setExternalLink( $ExternalLink[$i] );
448
449 $VatType =& $product->vatType();
450
451 if ( $VATTypeID[$i] and $VATTypeID[$i] != $VatType->id() )
452 {
453 $vattype = new eZVATType( $VATTypeID[$i] );
454 $product->setVATType( $vattype );
455 }
456
457 /* Flat and Free Shipping section */
458 if ( $FlatFeeUPS[$i] ) {
459 if ( is_numeric( $FlatFeeUPS[$i] ) )
460 $product->setFlatUPS( $FlatFeeUPS[$i] );
461 else
462 $product->setFlatUPS( 'off' );
463 } else {
464 $product->setFlatUPS('off' );
465 }
466 if ( $FlatFeeUSPS[$i] ) {
467 if ( is_numeric( $FlatFeeUSPS[$i] ) )
468 $product->setFlatUSPS( $FlatFeeUSPS[$i] );
469 else
470 $product->setFlatUSPS( 'off' );
471 } else {
472 $product->setFlatUSPS('off' );
473 }
474
475 $product->setFlatCombine( $FlatCombine[$i] == "on" );
476 // $BoxType =& $product->boxType();
477
478 // if ( $BoxTypeID[$i] > 0 && $BoxTypeID[$i] != $BoxType->id() )
479 if ( $BoxTypeID[$i] > 0 )
480 {
481 $boxtype = new eZBoxType( $BoxTypeID[$i] );
482 $product->setBoxType( $boxtype );
483 }
484 elseif ( $BoxTypeID[$i] == 0 )
485 $product->setBoxType( "" );
486
487 $ShippingGroup =& $product->shippingGroup();
488
489 if ( $ShippingGroupID[$i] and $ShippingGroupID[$i] != $ShippingGroup->id() )
490 {
491 $shippingGroup = new eZShippingGroup( $ShippingGroupID[$i] );
492 $product->setShippingGroup( $shippingGroup );
493 }
494
495 if ( $ShowPrice[$i] == "on" )
496 $product->setShowPrice( true );
497 else
498 $product->setShowPrice( false );
499
500 $product->setShowProduct( $Active[$i] == "on" );
501 $product->setDiscontinued( $Discontinued[$i] == "on" );
502
503 /* if ( $Discontinued[$i] == "on" )
504 $product->setDiscontinued( true );
505 else
506 $product->setDiscontinued( false );
507
508 if ( $Active[$i] == "on" )
509 $product->setShowProduct( true );
510 else
511 $product->setShowProduct( false );
512 */
513 if ( $IsHotDeal[$i] == "on" )
514 $product->setIsHotDeal( true );
515 else
516 $product->setIsHotDeal( false );
517
518 if ( $ShowQuantity && is_numeric($Quantity[$i]) && $Quantity[$i] != $product->totalQuantity() )
519 $product->setTotalQuantity( is_numeric( $Quantity[$i] ) ? $Quantity[$i] : false );
520
521 if ( isset($Quantity[$i]) && $Quantity[$i] == 0 ) {
522 $DateInStock = new eZDate( $StockYear[$i], $StockMonth[$i], $StockDay[$i] );
523 $date = $DateInStock->timeStamp();
524 $product->setStockDate( $date );
525 }
526
527 if ( is_numeric($Quantity[$i]) && $Quantity[$i] > 0 )
528 $product->setStockDate( "" );
529
530 if ( $Weight[$i]>0 && is_numeric($Weight[$i]) && $Weight[$i] != $product->weight() )
531 $product->setWeight( $Weight[$i] );
532
533 if ( $IncludesVAT[$i] == "true" )
534 $product->setIncludesVAT( true );
535 else
536 $product->setIncludesVAT( false );
537 $product->store();
538
539 //update categories
540
541 $old_maincategory = $product->categoryDefinition();
542 $old_categories = array_merge( $old_maincategory->id(), $product->categories( false ) );
543 $old_categories = array_unique( $old_categories );
544
545 $new_categories = array_unique( array_merge( $MainCategoryID[$i], $CategoryArray[$i] ) );
546
547 $remove_categories = array_diff( $old_categories, $new_categories );
548 $add_categories = array_diff( $new_categories, $old_categories );
549
550 foreach ( $remove_categories as $categoryItem )
551 {
552 eZProductCategory::removeProduct( $product, $categoryItem );
553 }
554 // add a product to the categories
555 $category = new eZProductCategory( $MainCategoryID[$i] );
556 $product->setCategoryDefinition( $category );
557
558 foreach ( $add_categories as $categoryItem )
559 {
560 eZProductCategory::addProduct( $product, $categoryItem );
561 }
562
563
564 // clear the cache files.
565 deleteCache( $ProductID, $CategoryID, $old_categories, $was_hotdeal or $product->isHotDeal() );
566
567 }
568 }
569 // for array debugging use
570 // echo "<pre>";
571 // print_r($CategoryArray);
572 // print_r($MainCategoryID);
573 // echo "<br>"."specified element:"."<br>";
574 // print_r($CategoryArray[1]);
575 // echo "</pre>";
576
577 if ( isSet( $Query ) )
578 eZHTTPTool::header( "Location: /trade/search/$Offset/$Query" );
579 else
580 eZHTTPTool::header( "Location: /trade/categorylist/parent/$CategoryID/$Offset" );
581
582 exit();
583
584
585 }
586
587
588 if ( isset( $DeleteProducts ) )
589 {
590 $Action = "DeleteProducts";
591 }
592
593 if ( isset( $Action ) && $Action == "Update" or isset( $Action ) && $Action == "Insert" )
594 {
595 $parentCategory = new eZProductCategory();
596 $parentCategory->get( $CategoryID );
597
598 if ( isset( $Action ) && $Action == "Insert" )
599 {
600 $product = new eZProduct();
601 }
602 else
603 {
604 $product = new eZProduct();
605 $product->get( $ProductID );
606 $was_hotdeal = $product->isHotDeal();
607
608 }
609
610 $product->setName( $Name );
611
612 $generator = new eZArticleGenerator();
613 $contents =& $generator->generateXML( $Contents );
614
615 if ( eZXML::domTree( $contents ) )
616 {
617 $product->setContents( $contents );
618
619 $product->setKeywords( $Keywords );
620 $product->setProductNumber( $ProductNumber );
621 $product->setCatalogNumber( $CatalogNumber );
622 $product->setExternalLink( $ExternalLink );
623
624 $vattype = new eZVATType( $VatTypeID );
625 $product->setVATType( $vattype );
626
627 $boxtype = new eZBoxType( $BoxTypeID );
628 $product->setBoxType( $boxtype );
629
630 $shippingGroup = new eZShippingGroup( $ShippingGroupID );
631 $product->setShippingGroup( $shippingGroup );
632
633 if ( $ShowPrice == "on" )
634 {
635 $product->setShowPrice( true );
636 }
637 else
638 {
639 $product->setShowPrice( false );
640 }
641
642 if ( $UseVoucher == true )
643 {
644 $product->setProductType( 2 );
645 }
646 else
647 {
648 $product->setProductType( 1 );
649 }
650
651 $product->setShowProduct( $Active == "on" );
652 $product->setDiscontinued( $Discontinued == "on" );
653
654 if ( $IsHotDeal == "on" )
655 {
656 $product->setIsHotDeal( true );
657 }
658 else
659 {
660 $product->setIsHotDeal( false );
661 }
662
663 $product->setPrice( $Price );
664 $product->setListPrice( $ListPrice );
665
666 if ( $Weight>0 && is_numeric($Weight) )
667 $product->setWeight( $Weight );
668
669 if ( $IncludesVAT == "true" )
670 {
671 $product->setIncludesVAT( true );
672 }
673 else
674 {
675 $product->setIncludesVAT( false );
676 }
677 /* Flat and Free Shipping section */
678 if ( $FlatFeeUPS ) {
679 if ( is_numeric( $FlatFeeUPS ) )
680 $product->setFlatUPS( $FlatFeeUPS );
681 else {
682 $product->setFlatUPS( 'off' );
683 }
684 } else {
685 $product->setFlatUPS('off' );
686 }
687 if ( $FlatFeeUSPS ) {
688 if ( is_numeric( $FlatFeeUSPS ) )
689 $product->setFlatUSPS( $FlatFeeUSPS );
690 else
691 $product->setFlatUSPS( 'off' );
692 } else {
693 $product->setFlatUSPS('off' );
694 }
695 $product->setFlatCombine( $FlatCombine == "on" );
696
697 if ( $Expiry > 0 )
698 $product->setExpiryTime( $Expiry );
699
700 if ( is_numeric($Quantity) && $Quantity == 0 ) {
701 $DateInStock = new eZDate( $StockYear, $StockMonth, $StockDay );
702 $date = $DateInStock->timeStamp();
703
704 $product->setStockDate( $date );
705 }
706
707 if ( is_numeric($Quantity) && $Quantity > 0 )
708 $product->setStockDate( "" );
709
710 $product->store();
711 // print_r($product); exit();
712 $ProductID = $product->id();
713 $productID = $product->id();
714
715 if ( $product->productType() == 2 )
716 {
717 $range =& $product->priceRange();
718 if ( !$range )
719 $range = new eZProductPriceRange();
720 $range->setMin( $MinPrice );
721 $range->setMax( $MaxPrice );
722 $range->setProduct( $product );
723 $range->store();
724 }
725
726 if ( $ShowQuantity )
727 {
728 $product->setTotalQuantity( is_numeric( $Quantity ) ? $Quantity : false );
729 }
730
731 if ( $ProductID )
732 eZPriceGroup::removePrices( $ProductID, -1 );
733
734 if( isset( $PriceGroup ) && isset( $PriceGroupID ) )
735 {
736 $count = max( count( $PriceGroup ), count( $PriceGroupID ) );
737 }
738 else
739 {
740 $count = false;
741 }
742 for ( $i = 0; $i < $count; $i++ )
743 {
744 if ( is_numeric( $PriceGroupID[$i] ) and $PriceGroup[$i] != "" )
745 {
746 eZPriceGroup::addPrice( $productID, $PriceGroupID[$i], $PriceGroup[$i] );
747 }
748 }
749
750
751 eZObjectPermission::removePermissions( $ProductID, "trade_product", 'w' );
752 if( isset( $WriteGroupArray ) )
753 {
754 if( $WriteGroupArray[0] == 0 )
755 {
756 eZObjectPermission::setPermission( -1, $productID, "trade_product", 'w' );
757 }
758 else
759 {
760 foreach ( $WriteGroupArray as $groupID )
761 {
762 eZObjectPermission::setPermission( $groupID, $productID, "trade_product", 'w' );
763 }
764 }
765 }
766 else
767 {
768 eZObjectPermission::removePermissions( $ProductID, "trade_product", 'w' );
769 }
770
771 /* read access thingy */
772 eZObjectPermission::removePermissions( $ProductID, "trade_product", 'r' );
773 if ( isset( $ReadGroupArray ) )
774 {
775 if( $ReadGroupArray[0] == 0 )
776 {
777 eZObjectPermission::setPermission( -1, $productID, "trade_product", 'r' );
778 }
779 else // some groups are selected.
780 {
781 foreach ( $ReadGroupArray as $groupID )
782 {
783 eZObjectPermission::setPermission( $groupID, $productID, "trade_product", 'r' );
784 }
785 }
786 }
787 else
788 {
789 eZObjectPermission::removePermissions( $ProductID, "trade_product", 'r' );
790 }
791
792 // Calculate which categories are new and which are unused
793
794 if ( isset( $Action ) && $Action == "Update" )
795 {
796 $old_maincategory = $product->categoryDefinition();
797
798 $old_categories = array_merge( array( $old_maincategory->id() ), $product->categories( false ) );
799 $old_categories = array_unique( $old_categories );
800
801 if( isset( $CategoryArray ) )
802 {
803 $new_categories = array_unique( array_merge( array( $CategoryID ), $CategoryArray ) );
804 }
805 else
806 {
807 $new_categories = array( $CategoryID );
808 }
809 $remove_categories = array_diff( $old_categories, $new_categories );
810 $add_categories = array_diff( $new_categories, $old_categories );
811
812 foreach ( $remove_categories as $categoryItem )
813 {
814 eZProductCategory::removeProduct( $product, $categoryItem );
815 }
816 }
817 else
818 {
819 if( isset( $CategoryArray ) )
820 {
821 $add_categories = array_unique( array_merge( array( $CategoryID ), $CategoryArray ) );
822 }
823 else
824 {
825 $add_categories = array( $CategoryID );
826 }
827 }
828
829 // add a product to the categories
830 $category = new eZProductCategory( $CategoryID );
831 $categorySetResult = $product->setCategoryDefinition( $category );
832
833 if( empty( $add_categories ) )
834 {
835 $add_categories = array( $old_maincategory->id() );
836 }
837
838 foreach ( $add_categories as $categoryItem )
839 {
840 eZProductCategory::addProduct( $product, $categoryItem );
841 }
842
843 // clear the cache files.
844 deleteCache( $ProductID, $CategoryID, $old_categories, $was_hotdeal or $product->isHotDeal() );
845
846 // preview
847 if ( isset( $Preview ) )
848 {
849 eZHTTPTool::header( "Location: /trade/productedit/productpreview/$productID/" );
850 exit();
851 }
852
853 if( isset( $AddItem ) )
854 {
855 switch ( $ItemToAdd )
856 {
857 // add options
858 case "Option":
859 {
860 eZHTTPTool::header( "Location: /trade/productedit/optionlist/$productID/" );
861 exit();
862 }
863 break;
864
865 // add files
866 case "File":
867 {
868 // add files
869 eZHTTPTool::header( "Location: /trade/productedit/filelist/$productID/" );
870 exit();
871 }
872 break;
873
874 // add images
875 case "Image":
876 {
877 eZHTTPTool::header( "Location: /trade/productedit/imagelist/$productID/" );
878 exit();
879 }
880 break;
881
882 // attribute
883 case "Attribute":
884 {
885 eZHTTPTool::header( "Location: /trade/productedit/attributeedit/$productID/" );
886 exit();
887 }
888 break;
889
890 // attribute
891 case "ModuleLinker":
892 {
893 eZHTTPTool::header( "Location: /trade/productedit/link/list/$productID/" );
894 exit();
895 }
896 break;
897
898 case "Form":
899 {
900 // add form
901 eZHTTPTool::header( "Location: /trade/productedit/formlist/$productID/" );
902 exit();
903 }
904 break;
905 }
906 }
907
908 // get the category to redirect to
909 $category = $product->categoryDefinition();
910 $categoryID = $category->id();
911
912 eZHTTPTool::header( "Location: /trade/categorylist/parent/$categoryID" );
913 exit();
914 }
915 else
916 {
917 $Contents_Override = $Contents;
918 if ( isset( $Action ) && $Action == "Update" )
919 {
920 $Action = "Edit";
921 }
922 else
923 {
924 $Action = "Insert";
925 }
926 }
927 }
928
929 if ( isset( $Action ) && $Action == "Cancel" )
930 {
931 if ( is_numeric( $ProductID ) )
932 {
933 $product = new eZProduct( $ProductID );
934 $category = $product->categoryDefinition();
935 $categoryID = $category->id();
936 eZHTTPTool::header( "Location: /trade/categorylist/parent/$categoryID" );
937 exit();
938 }
939 else
940 {
941 eZHTTPTool::header( "Location: /trade/categorylist/parent/" );
942 exit();
943 }
944 }
945
946 if ( isset( $Action ) && $Action == "DeleteProducts" )
947 {
948 if ( count ( $ProductArrayID ) != 0 )
949 {
950 foreach ( $ProductArrayID as $ProductID )
951 {
952 $product = new eZProduct();
953 $product->get( $ProductID );
954
955 $categories = $product->categories();
956
957 $categoryArray = $product->categories();
958 $categoryIDArray = array();
959 foreach ( $categoryArray as $cat )
960 {
961 $categoryIDArray[] = $cat->id();
962 }
963
964 // clear the cache files.
965 deleteCache( $ProductID, $CategoryID, $categoryIDArray, $product->isHotDeal() );
966
967 $category = $product->categoryDefinition( );
968 $categoryID = $category->id();
969
970 $product->delete();
971 eZPriceGroup::removePrices( $ProductID, -1 );
972 }
973 }
974
975 if ( isset( $Query ) )
976 eZHTTPTool::header( "Location: /trade/search/$Offset/$Query" );
977 else
978 eZHTTPTool::header( "Location: /trade/categorylist/parent/$categoryID/$Offset" );
979 exit();
980 }
981
982 if ( isset( $Action ) && $Action == "Delete" )
983 {
984 $product = new eZProduct();
985 $product->get( $ProductID );
986
987 $categories = $product->categories();
988
989 $categoryArray = $product->categories();
990 $categoryIDArray = array();
991 foreach ( $categoryArray as $cat )
992 {
993 $categoryIDArray[] = $cat->id();
994 }
995
996 // clear the cache files.
997 deleteCache( $ProductID, $CategoryID, $categoryIDArray, $product->isHotDeal() );
998
999 $category = $product->categoryDefinition( );
1000 $categoryID = $category->id();
1001
1002 $product->delete();
1003
1004 eZPriceGroup::removePrices( $ProductID, -1 );
1005
1006 eZHTTPTool::header( "Location: /trade/categorylist/parent/$categoryID/" );
1007 exit();
1008 }
1009
1010 $t = new eZTemplate( "kernel/eztrade/admin/" . $ini->variable( "eZTradeMain", "AdminTemplateDir" ),
1011 "kernel/eztrade/admin/intl/", $Language, "productedit.php" );
1012
1013 $t->set_file( "product_edit_tpl", "productedit.tpl" );
1014
1015 $t->set_block( "product_edit_tpl", "value_tpl", "value" );
1016 $t->set_block( "product_edit_tpl", "multiple_value_tpl", "multiple_value" );
1017
1018 $t->set_block( "product_edit_tpl", "module_linker_button_tpl", "module_linker_button" );
1019 $t->set_block( "product_edit_tpl", "group_item_tpl", "group_item" );
1020
1021 $t->set_block( "product_edit_tpl", "vat_select_tpl", "vat_select" );
1022 $t->set_block( "product_edit_tpl", "box_select_tpl", "box_select" );
1023 $t->set_block( "product_edit_tpl", "shipping_select_tpl", "shipping_select" );
1024 $t->set_block( "product_edit_tpl", "quantity_item_tpl", "quantity_item" );
1025 $t->set_block( "quantity_item_tpl", "day_item_tpl", "day_item" );
1026
1027 $t->set_block( "product_edit_tpl", "read_group_item_tpl", "read_group_item" );
1028 $t->set_block( "product_edit_tpl", "write_group_item_tpl", "write_group_item" );
1029
1030 $t->set_block( "product_edit_tpl", "price_range_tpl", "price_range" );
1031 $t->set_block( "product_edit_tpl", "normal_price_tpl", "normal_price" );
1032 $t->set_block( "product_edit_tpl", "list_price_tpl", "list_price" );
1033
1034 $t->set_block( "product_edit_tpl", "price_group_list_tpl", "price_group_list" );
1035 $t->set_block( "price_group_list_tpl", "price_groups_item_tpl", "price_groups_item" );
1036 $t->set_block( "price_groups_item_tpl", "price_group_header_item_tpl", "price_group_header_item" );
1037 $t->set_block( "price_groups_item_tpl", "price_group_item_tpl", "price_group_item" );
1038 $t->set_block( "price_group_list_tpl", "price_groups_no_item_tpl", "price_groups_no_item" );
1039
1040 $t->setAllStrings();
1041
1042 $t->set_var( "brief_value", "" );
1043 $t->set_var( "description_value", "" );
1044 $t->set_var( "name_value", "" );
1045 $t->set_var( "keywords_value", "" );
1046 $t->set_var( "product_nr_value", "" );
1047 $t->set_var( "product_catalog_number", "" );
1048 $t->set_var( "price_value", "" );
1049 $t->set_var( "list_price", "" );
1050 $t->set_var( "expiry_value", "" );
1051
1052 $t->set_var( "weight_value", "");
1053 $t->set_var( "flat_fee_ups", "");
1054 $t->set_var( "flat_fee_usps", "");
1055
1056 $t->set_var( "showprice_checked", "" );
1057 $t->set_var( "showproduct_checked", "" );
1058 $t->set_var( "discontinued_checked", "" );
1059 $t->set_var( "is_hot_deal_checked", "" );
1060
1061 $t->set_var( "price_min", "0" );
1062 $t->set_var( "price_max", "0" );
1063
1064 $t->set_var( "external_link", "" );
1065
1066 $t->set_var( "action_value", "insert" );
1067 $t->set_var( "product_id", 0 );
1068 $t->set_var( "flat_combine_checked", "");
1069
1070 $writeGroupsID = array();
1071 $readGroupsID = array();
1072
1073 $PriceGroup = array();
1074 $PriceGroupID = array();
1075
1076 $VatType = false;
1077 $BoxType = false;
1078
1079 // edit
1080 if ( isset( $Action ) && $Action == "Edit" )
1081 {
1082 $product = new eZProduct();
1083 $product->get( $ProductID );
1084
1085 $t->set_var( "name_value", htmlspecialchars($product->name()) );
1086 $t->set_var( "keywords_value", $product->keywords() );
1087 $t->set_var( "product_nr_value", $product->productNumber() );
1088 $t->set_var( "product_catalog_number", $product->catalogNumber() );
1089 $t->set_var( "price_value", $product->price() );
1090 $t->set_var( "list_price", $product->listPrice() );
1091 $t->set_var( "expiry_value", $product->expiryTime() ? $product->expiryTime() : "" );
1092 $t->set_var( "external_link", $product->externalLink() );
1093
1094 $generator = new eZArticleGenerator();
1095 // var_dump( $product->contents() ); die('funny');
1096
1097 if( $product->contents() !== "" )
1098 {
1099 $contentsArray =& $generator->decodeXML( $product->contents() );
1100 }
1101 else
1102 {
1103 $contentsArray = array( "", "" );
1104 }
1105
1106 if ( isset( $Contents_Override ) && count( $Contents_Override ) == 2 )
1107 {
1108 $t->set_var( "brief_value", $Contents_Override[0] );
1109 $t->set_var( "description_value", $Contents_Override[1] );
1110 }
1111 else
1112 {
1113 $t->set_var( "brief_value", $contentsArray[0] );
1114 $t->set_var( "description_value", $contentsArray[1] );
1115 }
1116
1117
1118 $t->set_var( "action_value", "update" );
1119 $t->set_var( "product_id", $product->id() );
1120
1121 if ( $product->showPrice() == true )
1122 $t->set_var( "showprice_checked", "checked" );
1123
1124 if ( $product->showProduct() == true )
1125 $t->set_var( "showproduct_checked", "checked" );
1126
1127 if ( $product->discontinued() == true )
1128 $t->set_var( "discontinued_checked", "checked" );
1129
1130 if ( $product->isHotDeal() == true )
1131 $t->set_var( "is_hot_deal_checked", "checked" );
1132
1133 if ( $product->weight() > 0 )
1134 $t->set_var( "weight_value", $product->weight() );
1135 else
1136 $t->set_var( "weight_value", "" );
1137
1138 if ( $product->productType() == 2 )
1139 $t->set_var( "mark_as_voucher", "checked" );
1140
1141 if ( $product->includesVAT() == true )
1142 $t->set_var( "include_vat", "checked" );
1143
1144 if ( $product->excludedVAT() == true )
1145 $t->set_var( "exclude_vat", "checked" );
1146
1147 if ($product->FlatUPS() == 'off')
1148 $t->set_var( "flat_fee_ups", '' );
1149 else
1150 $t->set_var( "flat_fee_ups", $product->FlatUPS );
1151
1152 if ($product->FlatUSPS() == 'off')
1153 $t->set_var( "flat_fee_usps", '' );
1154 else
1155 $t->set_var( "flat_fee_usps", $product->FlatUSPS );
1156
1157 if ($product->FlatCombine())
1158 $t->set_var( "flat_combine_checked", 'checked' );
1159
1160 $VatType =& $product->vatType();
1161
1162 $BoxType =& $product->BoxType();
1163
1164 $Quantity = $product->totalQuantity();
1165
1166 if ( $product->stockDate() )
1167 {
1168 $Stock = new eZDate();
1169 $Stock->setTimeStamp( $product->stockDate() );
1170 $StockYear = $Stock->year();
1171 $StockMonth = $Stock->month();
1172 $StockDay = $Stock->day();
1173 }
1174 else
1175 {
1176 $StockYear = "";
1177 $StockMonth = 1;
1178 $StockDay = 1;
1179 }
1180
1181 for ( $i = 1; $i <= 31; $i++ )
1182 {
1183 $t->set_var( "day_id", $i );
1184 $t->set_var( "day_value", $i );
1185 $t->set_var( "selected", "" );
1186 // if ( ( $StockDay == "" and $i == 1 ) or $StockDay == $i )
1187 if ( $StockDay == $i )
1188 $t->set_var( "selected", "selected" );
1189 if ( $StockDay == "" and $i == date(j) )
1190 $t->set_var( "selected", "selected" );
1191 $t->parse( "day_item", "day_item_tpl", true );
1192 }
1193
1194 $month_array = array( 1 => "select_january",
1195 2 => "select_february",
1196 3 => "select_march",
1197 4 => "select_april",
1198 5 => "select_may",
1199 6 => "select_june",
1200 7 => "select_july",
1201 8 => "select_august",
1202 9 => "select_september",
1203 10 => "select_october",
1204 11 => "select_november",
1205 12 => "select_december" );
1206
1207 foreach ( $month_array as $month )
1208 {
1209 $t->set_var( $month, "" );
1210 }
1211
1212 $var_name =& $month_array[$StockMonth];
1213 if ( $var_name == "" ) {
1214 // $dateMonth = date(n);
1215 $var_name =& $month_array[date(n)];
1216 }
1217
1218 $t->set_var( $var_name, "selected" );
1219
1220 if ( $StockYear )
1221 $t->set_var( "stockyear", $StockYear );
1222 else
1223 $t->set_var( "stockyear", date("Y") );
1224
1225
1226 $prices = eZPriceGroup::prices( $ProductID );
1227
1228 $PriceGroup = array();
1229 $PriceGroupID = array();
1230
1231 foreach ( $prices as $price )
1232 {
1233 $PriceGroup[] = $price["Price"];
1234 $PriceGroupID[] = $price["PriceID"];
1235 }
1236
1237 if ( isset( $UseVoucher ) && $UseVoucher )
1238 {
1239 $priceRange =& $product->priceRange();
1240 }
1241
1242 $writeGroupsID = eZObjectPermission::getGroups( $ProductID, "trade_product", 'w' , false );
1243 $readGroupsID = eZObjectPermission::getGroups( $ProductID, "trade_product", 'r', false );
1244
1245 // $VatType =& $product->vatType();
1246 $ShippingGroup =& $product->shippingGroup();
1247 }
1248
1249 if ( isset( $UseVoucher ) && $UseVoucher )
1250 {
1251 if ( isset( $priceRange ) && $priceRange )
1252 {
1253 $t->set_var( "price_max", $priceRange->max() );
1254 $t->set_var( "price_min", $priceRange->min() );
1255 }
1256 else
1257 {
1258 $t->set_var( "price_max", "0" );
1259 $t->set_var( "price_min", "0" );
1260 }
1261
1262 $t->set_var( "url_action", "voucher" );
1263 $t->set_var( "normal_price", "" );
1264 $t->set_var( "list_price", "" );
1265 $t->parse( "price_range", "price_range_tpl" );
1266 }
1267 else
1268 {
1269 $t->set_var( "url_action", "productedit" );
1270 $t->set_var( "price_range", "" );
1271 $t->parse( "normal_price", "normal_price_tpl" );
1272 $t->parse( "list_price", "list_price_tpl" );
1273 }
1274
1275 $category = new eZProductCategory();
1276 $categoryArray = $category->getTree();
1277
1278 foreach ( $categoryArray as $catItem )
1279 {
1280 if ( isset( $Action ) && $Action == "Edit" )
1281 {
1282 $defCat = $product->categoryDefinition();
1283 if ( $product->existsInCategory( $catItem[0] ) &&
1284 ( $defCat->id() != $catItem[0]->id() ) )
1285 {
1286 $t->set_var( "multiple_selected", "selected" );
1287 }
1288 else
1289 {
1290 $t->set_var( "multiple_selected", "" );
1291 }
1292
1293 if ( $defCat->id() == $catItem[0]->id() )
1294 {
1295 $t->set_var( "selected", "selected" );
1296 }
1297 else
1298 {
1299 $t->set_var( "selected", "" );
1300 }
1301 }
1302 else
1303 {
1304 $t->set_var( "selected", "" );
1305 $t->set_var( "multiple_selected", "" );
1306 }
1307
1308 // if ( isset( $Action ) && $Action == "Edit" )
1309 // {
1310 // if ( $product->existsInCategory( $catItem ) )
1311 // $t->set_var( "selected", "selected" );
1312 // else
1313 // $t->set_var( "selected", "" );
1314 // }
1315 // else
1316 // {
1317 // $t->set_var( "selected", "" );
1318 // }
1319
1320 $t->set_var( "option_value", $catItem[0]->id() );
1321 $t->set_var( "option_name", $catItem[0]->name() );
1322
1323 if ( $catItem[1] > 0 )
1324 $t->set_var( "option_level", str_repeat( "&nbsp;", $catItem[1] ) );
1325 else
1326 $t->set_var( "option_level", "" );
1327
1328 $t->parse( "value", "value_tpl", true );
1329 $t->parse( "multiple_value", "multiple_value_tpl", true );
1330 }
1331
1332 // show the VAT values
1333
1334 $vat = new eZVATType();
1335 $vatTypes = $vat->getAll();
1336
1337 foreach ( $vatTypes as $type )
1338 {
1339 if ( $VatType and ( $VatType->id() == $type->id() ) )
1340 {
1341 $t->set_var( "vat_selected", "selected" );
1342 }
1343 else
1344 {
1345 $t->set_var( "vat_selected", "" );
1346 }
1347
1348 $t->set_var( "vat_id", $type->id() );
1349 $t->set_var( "vat_name", $type->name() . " (" . $type->value() . ")%" );
1350
1351 $t->parse( "vat_select", "vat_select_tpl", true );
1352 }
1353
1354 // show the box values
1355
1356 $box = new eZBoxType();
1357 $boxTypes = $box->getAll();
1358
1359 foreach ( $boxTypes as $type )
1360 {
1361 if ( $BoxType and ( $BoxType->id() == $type->id() ) )
1362 {
1363 $t->set_var( "box_selected", "selected" );
1364 }
1365 else
1366 {
1367 $t->set_var( "box_selected", "" );
1368 }
1369
1370 $t->set_var( "box_id", $type->id() );
1371 $t->set_var( "box_name", $type->name()." (".$type->length()."x".$type->width()."x".$type->height()." in)" );
1372
1373 $t->parse( "box_select", "box_select_tpl", true );
1374 }
1375
1376 // show shipping groups
1377
1378 $group = new eZShippingGroup();
1379
1380 $groups =& $group->getAll();
1381
1382 foreach ( $groups as $group )
1383 {
1384 if ( isset( $ShippingGroup ) && $ShippingGroup and $ShippingGroup->id() == $group->id() )
1385 {
1386 $t->set_var( "selected", "selected" );
1387 }
1388 else
1389 {
1390 $t->set_var( "selected", "" );
1391 }
1392
1393 $t->set_var( "shipping_group_id", $group->id() );
1394
1395 $t->set_var( "shipping_group_name", $group->name() );
1396
1397 $t->parse( "shipping_select", "shipping_select_tpl", true );
1398 }
1399
1400 // Show quantity
1401 $t->set_var( "quantity_item", "" );
1402 $t->set_var( "quantity_value", isset( $Quantity ) ? $Quantity : false );
1403 if ( isset( $ShowQuantity ) && $ShowQuantity )
1404 {
1405 $t->parse( "quantity_item", "quantity_item_tpl" );
1406 }
1407
1408 // Show price groups
1409
1410 $t->set_var( "price_group_list", "" );
1411 $t->set_var( "price_groups_item", "" );
1412 $t->set_var( "price_groups_no_item", "" );
1413
1414 if ( $ShowPriceGroups )
1415 {
1416 $price_groups = eZPriceGroup::getAll();
1417 $count = max( count( $PriceGroup ), count( $PriceGroupID ) );
1418
1419 $NewPriceGroup = array();
1420 for ( $i = 0; $i < $count; $i++ )
1421 {
1422 $NewPriceGroup[$PriceGroupID[$i]] = $PriceGroup[$i];
1423 }
1424
1425 $prices = array();
1426 $price_ids = array();
1427 $price_names = array();
1428 foreach ( $price_groups as $price_group )
1429 {
1430 $price_id = $price_group->id();
1431
1432 if ( isset( $NewPriceGroup[$price_id] ) )
1433 $prices[] = $NewPriceGroup[$price_id];
1434
1435 $price_ids[] = $price_id;
1436 $price_names[] = $price_group->name();
1437 }
1438 $PriceGroup = $prices;
1439 $PriceGroupID = $price_ids;
1440 $t->set_var( "price_group_header_item", "" );
1441 $t->set_var( "price_group_item", "" );
1442
1443 for ( $i = 0; $i < count( $PriceGroup ); $i++ )
1444 {
1445 $t->set_var( "price_group_name", $price_names[$i] );
1446 $t->parse( "price_group_header_item", "price_group_header_item_tpl", true );
1447 $t->set_var( "price_group_value", $PriceGroup[$i] );
1448 $t->set_var( "price_group_id", $PriceGroupID[$i] );
1449 $t->parse( "price_group_item", "price_group_item_tpl", true );
1450 }
1451
1452 if ( count( $price_groups ) > 0 )
1453 {
1454 $t->parse( "price_groups_item", "price_groups_item_tpl" );
1455 $t->parse( "price_group_list", "price_group_list_tpl" );
1456 }
1457 // else
1458 // $t->parse( "price_groups_no_item", "price_groups_no_item_tpl" );
1459 }
1460
1461 if ( isset( $ShippingGroup ) && $ShippingGroup and ( $ShippingGroup->id() == $group->id() ) )
1462 {
1463 $t->set_var( "selected", "selected" );
1464 }
1465 else
1466 {
1467 $t->set_var( "selected", "" );
1468 }
1469
1470 $t->set_var( "shipping_group_id", $group->id() );
1471
1472 $t->set_var( "shipping_group_name", $group->name() );
1473
1474 $t->set_var( "module_linker_button", "" );
1475 if ( $ShowModuleLinker )
1476 $t->parse( "module_linker_button", "module_linker_button_tpl" );
1477
1478 // group selector
1479 $group = new eZUserGroup();
1480 $groupList = $group->getAll();
1481
1482 $t->set_var( "selected", "" );
1483 foreach ( $groupList as $groupItem )
1484 {
1485 // for the group owner selector
1486 $t->set_var( "read_id", $groupItem->id() );
1487 $t->set_var( "read_name", $groupItem->name() );
1488
1489 if ( in_array( $groupItem->id(), $readGroupsID ) )
1490 $t->set_var( "selected", "selected" );
1491 else
1492 $t->set_var( "selected", "" );
1493
1494 if ( in_array( "-1", $readGroupsID ) )
1495 $t->set_var( "all_selected", "selected" );
1496 else
1497 $t->set_var( "all_selected", "" );
1498
1499 $t->parse( "read_group_item", "read_group_item_tpl", true );
1500
1501 // for the read access groups selector
1502 $t->set_var( "write_name", $groupItem->name() );
1503 $t->set_var( "write_id", $groupItem->id() );
1504 if ( in_array( $groupItem->id(), $writeGroupsID ) )
1505 $t->set_var( "is_selected", "selected" );
1506 else
1507 $t->set_var( "is_selected", "" );
1508
1509 if ( in_array( "-1", $writeGroupsID ) )
1510 $t->set_var( "all_write_selected", "selected" );
1511 else
1512 $t->set_var( "all_write_selected", "" );
1513
1514 $t->parse( "write_group_item", "write_group_item_tpl", true );
1515 }
1516
1517 $t->pparse( "output", "product_edit_tpl" );
1518
1519 ?>
$i
$i
Definition: admin/adlist.php:91
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$month
else $month
Definition: appointmentedit.php:660
$Description
$Description
Definition: articlelistrss.php:38
$files
$files
Definition: articlepreview.php:91
$date
$date
Definition: bugpreview.php:66
eZArticleGenerator
Definition: ezarticlegenerator.php:40
eZBoxType
Definition: ezboxtype.php:40
eZCSVImport
Definition: ezcsvimport.php:32
eZDate
Definition: ezdate.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZObjectPermission\getGroups
static getGroups( $objectID, $moduleTable, $permission, $GroupReturn=true)
Definition: ezobjectpermission.php:365
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
eZObjectPermission\removePermissions
static removePermissions( $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:320
eZPriceGroup\getAll
static & getAll( $as_object=true)
Definition: ezpricegroup.php:127
eZPriceGroup\removePrices
static removePrices( $productid, $optionid=0, $valueid=0, $priceid='')
Definition: ezpricegroup.php:499
eZPriceGroup\addPrice
addPrice( $productid, $priceid, $price, $optionid=0, $valueid=0)
Definition: ezpricegroup.php:473
eZPriceGroup\prices
static prices( $productid, $optionid=0, $valueid=0)
Definition: ezpricegroup.php:461
eZProductCategory
Definition: ezproductcategory.php:90
eZProductCategory\removeProduct
static removeProduct(&$value, $categoryid=false)
Definition: ezproductcategory.php:589
eZProductCategory\addProduct
static addProduct(&$value, $categoryid=false)
Definition: ezproductcategory.php:548
eZProductPriceRange
Definition: ezproductpricerange.php:48
eZProduct
Definition: ezproduct.php:71
eZShippingGroup
Definition: ezshippinggroup.php:44
eZTemplate
Definition: eztemplate.php:107
eZUserGroup
Definition: ezusergroup.php:66
eZVATType
Definition: ezvattype.php:41
eZXML\domTree
static domTree( $xmlDoc, $params=array())
Definition: ezxml.php:60
$item
$item
Definition: classes/admin/linklist.php:228
$type
$type
Definition: classes/admin/linkselect.php:220
$Action
$Action
Definition: companysearch.php:80
$categories
$categories
Definition: ezarticle/admin/categoryedit.php:636
$contents
$contents
Definition: ezarticle/user/extendedsearch.php:52
$row
$row
Definition: ezcalendar/user/dayview.php:403
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$cat
if(isset( $DeleteCategories)) $cat
Definition: ezforum/admin/categoryedit.php:49
$groupID
$groupID
Definition: ezgroupeventcalendar/user/dayview.php:90
$Preview
$Preview
Definition: ezmessage/user/messageedit.php:121
$priceRange
$priceRange
Definition: eztrade/user/extendedsearch.php:85
exit
exit
Definition: folder.php:81
$product
$product
Definition: homepage.php:202
$count
$count
Definition: onlinetypelist.php:108
$Name
$Name
Definition: polledit.php:250
$price
$price
Definition: pricegroupedit.php:39
deleteCache
deleteCache( $ProductID, $CategoryID, $CategoryArray, $Hotdeal)
Definition: productedit.php:38
$writeGroupsID
$writeGroupsID
Definition: productedit.php:1070
$box
foreach( $vatTypes as $type) $box
Definition: productedit.php:1356
$category
$category
Definition: productedit.php:1275
$groups
$groups
Definition: productedit.php:1380
$CSVDelimiter
$CSVDelimiter
Definition: productedit.php:92
$VatType
$VatType
Definition: productedit.php:1076
$DefaultDealerPriceGroup
$DefaultDealerPriceGroup
Definition: productedit.php:93
$vat
foreach( $categoryArray as $catItem) $vat
Definition: productedit.php:1334
$BoxType
$BoxType
Definition: productedit.php:1077
$groupList
$groupList
Definition: productedit.php:1480
$Language
$Language
Definition: productedit.php:87
$ini
$ini
Definition: productedit.php:85
$PriceGroupID
$PriceGroupID
Definition: productedit.php:1074
$PriceGroup
$PriceGroup
Definition: productedit.php:1073
$ShowPriceGroups
$ShowPriceGroups
Definition: productedit.php:88
$t
if(isset($CSVImport)) if(isSet( $SubmitPrice)) if(isSet( $UpdateProducts)) if(isset( $DeleteProducts)) if(isset( $Action) && $Action=="Update" or isset( $Action) && $Action=="Insert") if(isset( $Action) && $Action=="Cancel") if(isset( $Action) && $Action=="DeleteProducts") if(isset( $Action) && $Action=="Delete") $t
Definition: productedit.php:1010
$boxTypes
$boxTypes
Definition: productedit.php:1357
$vatTypes
$vatTypes
Definition: productedit.php:1335
$group
foreach( $boxTypes as $type) $group
Definition: productedit.php:1378
$ShowQuantity
$ShowQuantity
Definition: productedit.php:89
$categoryArray
$categoryArray
Definition: productedit.php:1276
$readGroupsID
$readGroupsID
Definition: productedit.php:1071
$ShowModuleLinker
$ShowModuleLinker
Definition: productedit.php:90
$Quantity
if( $product->catalogNumber() !="") $Quantity
Definition: productpreview.php:491
$ShowPrice
$ShowPrice
Definition: productpreview.php:48
$categoryID
else $categoryID
Definition: productview.php:66
$shippingGroup
$shippingGroup
Definition: shippingtypes.php:139
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.