Projekt

Allgemein

Profil

GX-Bug #39819 » product.php

Till Tepelmann, 13.08.2014 18:37

 
1
<?php
2
/* --------------------------------------------------------------
3
   product.php 2014-06-03 gm
4
   Gambio GmbH
5
   http://www.gambio.de
6
   Copyright (c) 2014 Gambio GmbH
7
   Released under the GNU General Public License (Version 2)
8
   [http://www.gnu.org/licenses/gpl-2.0.html]
9
   --------------------------------------------------------------
10

    
11

    
12
   based on:
13
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
14
   (c) 2002-2003 osCommerce(Coding Standards); www.oscommerce.com
15
   (c) 2005 XT-Commerce - community made shopping http://www.xt-commerce.com ($Id: product.php 1316 2005-10-21 15:30:58Z mz $)
16

    
17
   Released under the GNU General Public License
18
   ---------------------------------------------------------------------------------------*/
19

    
20
// BOF GM_MOD:
21
require_once(DIR_FS_INC . 'xtc_get_products_stock.inc.php');
22
require_once(DIR_FS_CATALOG . 'gm/inc/gm_prepare_number.inc.php');
23

    
24
class product_ORIGIN {
25

    
26
	/**
27
	 *
28
	 * Constructor
29
	 *
30
	 */
31
	function product_ORIGIN($pID = 0) {
32
		$this->pID = (int)$pID;
33
		$this->useStandardImage=false;
34
		$this->standardImage='noimage.gif';
35
		if ($pID == 0) {
36
			$this->isProduct = false;
37
			return;
38
		}
39
		// query for Product
40
		$group_check = "";
41
		if (GROUP_CHECK == 'true') {
42
			$group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
43
		}
44

    
45
		$fsk_lock = "";
46
		if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
47
			$fsk_lock = ' and p.products_fsk18!=1';
48
		}
49

    
50
		$product_query = "SELECT
51
								p.*,
52
								pd.*,
53
								qud.quantity_unit_id,
54
								qud.unit_name
55
							FROM " . TABLE_PRODUCTS . " p
56
							LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd USING (products_id)
57
							LEFT JOIN products_quantity_unit pqu USING (products_id)
58
							LEFT JOIN quantity_unit_description qud ON (pqu.quantity_unit_id = qud.quantity_unit_id AND qud.language_id = '" . (int)$_SESSION['languages_id'] . "')
59
							WHERE
60
								p.products_id = '" . (int)$this->pID . "' AND
61
								p.products_status = '1'
62
								" . $group_check . $fsk_lock . " AND
63
								pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
64

    
65
		$product_query = xtDBquery($product_query);
66

    
67
		if (!xtc_db_num_rows($product_query, true)) {
68
			$this->isProduct = false;
69
		} else {
70
			$this->isProduct = true;
71
			$this->data = xtc_db_fetch_array($product_query, true);
72
		}
73

    
74
	}
75

    
76
	/**
77
	 *
78
	 *  Query for attributes count
79
	 *
80
	 */
81

    
82
	function getAttributesCount() {
83

    
84
		$products_attributes_query = xtDBquery("select count(*) as total from ".TABLE_PRODUCTS_OPTIONS." popt, ".TABLE_PRODUCTS_ATTRIBUTES." patrib where patrib.products_id='".$this->pID."' and patrib.options_id = popt.products_options_id and popt.language_id = '".(int) $_SESSION['languages_id']."'");
85
		$products_attributes = xtc_db_fetch_array($products_attributes_query, true);
86
		return $products_attributes['total'];
87

    
88
	}
89

    
90
	/**
91
	 *
92
	 * Query for reviews count
93
	 *
94
	 */
95

    
96
	function getReviewsCount() {
97
		$reviews_query = xtDBquery("select count(*) as total from ".TABLE_REVIEWS." r, ".TABLE_REVIEWS_DESCRIPTION." rd where r.products_id = '".$this->pID."' and r.reviews_id = rd.reviews_id and rd.languages_id = '".$_SESSION['languages_id']."' and rd.reviews_text !=''");
98
		$reviews = xtc_db_fetch_array($reviews_query, true);
99
		return $reviews['total'];
100
	}
101

    
102
	/**
103
	 *
104
	 * select reviews
105
	 *
106
	 */
107

    
108
	function getReviews($p_limit = false) {
109

    
110
		$data_reviews = array ();
111

    
112
		if($p_limit !== false && (int)$p_limit == 0)
113
		{
114
			return $data_reviews;
115
		}
116

    
117
		$t_limit = '';
118
		if((int)$p_limit > 0)
119
		{
120
			$t_limit = ' LIMIT ' . (int)$p_limit;
121
		}
122
		$reviews_query = xtDBquery("select
123
									                                 r.reviews_rating,
124
									                                 r.reviews_id,
125
									                                 r.customers_name,
126
									                                 r.date_added,
127
									                                 r.last_modified,
128
									                                 r.reviews_read,
129
									                                 rd.reviews_text
130
									                                 from ".TABLE_REVIEWS." r,
131
									                                 ".TABLE_REVIEWS_DESCRIPTION." rd
132
									                                 where r.products_id = '".$this->pID."'
133
									                                 and  r.reviews_id=rd.reviews_id
134
									                                 and rd.languages_id = '".$_SESSION['languages_id']."'
135
									                                 order by reviews_id DESC"
136
																	 . $t_limit
137
																	);
138
		if (xtc_db_num_rows($reviews_query, true)) {
139
			$row = 0;
140
			$data_reviews = array ();
141
			while ($reviews = xtc_db_fetch_array($reviews_query, true)) {
142
				$row ++;
143
				$data_reviews[] = array (
144
										'AUTHOR'	=> $reviews['customers_name'], 
145
										'DATE'		=> xtc_date_short($reviews['date_added']), 
146
										'RATING'	=> xtc_image('templates/'.CURRENT_TEMPLATE.'/img/stars_'.$reviews['reviews_rating'].'.gif', sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])), 
147
										'TEXT'		=> $reviews['reviews_text'],
148
										'LINK'		=> xtc_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id='.$this->pID.'&reviews_id='.$reviews['reviews_id'])
149
										);
150
				if ($row == PRODUCT_REVIEWS_VIEW)
151
					break;
152
			}
153
		}
154
		return $data_reviews;
155

    
156
	}
157

    
158
	/**
159
	 *
160
	 * return model if set, else return name
161
	 *
162
	 */
163

    
164
	function getBreadcrumbModel() {
165

    
166
		if ($this->data['products_model'] != "")
167
			return $this->data['products_model'];
168
		return $this->data['products_name'];
169

    
170
	}
171

    
172
	/**
173
	 *
174
	 * get also purchased products related to current
175
	 *
176
	 */
177

    
178
	function getAlsoPurchased()
179
	{
180
		// BOF YOOCHOOSE
181
	    if (defined('YOOCHOOSE_ACTIVE') && YOOCHOOSE_ACTIVE) {
182
            require_once (DIR_WS_INCLUDES . 'yoochoose/recommendations.php');
183
            require_once (DIR_WS_INCLUDES . 'yoochoose/functions.php');
184
            return recommendData(getAlsoPurchasedStrategy(), $this->pID, MAX_DISPLAY_ALSO_PURCHASED);
185
        }
186
        // EOF YOOCHOOSE
187
		
188
		global $xtPrice;
189

    
190
		$module_content = array ();
191

    
192
		$fsk_lock = "";
193
		if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
194
			$fsk_lock = ' and p.products_fsk18!=1';
195
		}
196
		$group_check = "";
197
		if (GROUP_CHECK == 'true') {
198
			$group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
199
		}
200
		
201
		// BOF GM_MOD:
202
		$orders_query = "select
203
														                                  p.products_fsk18,
204
														                                  p.products_id,
205
														                                  p.products_price,
206
														                                  p.products_tax_class_id,
207
														                                  p.products_image,
208
																						  								pd.gm_alt_text,
209
														                                  pd.products_name,
210
																						  pd.products_meta_description,
211
														                                  p.products_vpe,
212
						                           										  p.products_vpe_status,
213
						                           										  p.products_vpe_value,
214
														                                  pd.products_short_description FROM ".TABLE_ORDERS_PRODUCTS." opa, ".TABLE_ORDERS_PRODUCTS." opb, ".TABLE_ORDERS." o, ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_DESCRIPTION." pd
215
														                                  where opa.products_id = '".$this->pID."'
216
														                                  and opa.orders_id = opb.orders_id
217
														                                  and opb.products_id != '".$this->pID."'
218
														                                  and opb.products_id = p.products_id
219
														                                  and opb.orders_id = o.orders_id
220
														                                  and p.products_status = '1'
221
														                                  and pd.language_id = '".(int) $_SESSION['languages_id']."'
222
														                                  and opb.products_id = pd.products_id
223
							AND o.date_purchased > DATE_SUB(NOW(),INTERVAL 100 DAY)
224
														                                  ".$group_check."
225
														                                  ".$fsk_lock."
226
														                                  group by p.products_id order by o.date_purchased desc limit ".MAX_DISPLAY_ALSO_PURCHASED;
227
		$orders_query = xtDBquery($orders_query);
228
		while ($orders = xtc_db_fetch_array($orders_query, true)) {
229

    
230
			$module_content[] = $this->buildDataArray($orders);
231

    
232
		}
233

    
234
		return $module_content;
235

    
236
	}
237

    
238
	/**
239
	 *
240
	 *
241
	 *  Get Cross sells
242
	 *
243
	 *
244
	 */
245
	function getCrossSells() {
246
		global $xtPrice;
247

    
248
		$cs_groups = "SELECT products_xsell_grp_name_id FROM ".TABLE_PRODUCTS_XSELL." WHERE products_id = '".$this->pID."' GROUP BY products_xsell_grp_name_id";
249
		$cs_groups = xtDBquery($cs_groups);
250
		$cross_sell_data = array ();
251
		if (xtc_db_num_rows($cs_groups, true)>0) {
252
		while ($cross_sells = xtc_db_fetch_array($cs_groups, true)) {
253

    
254
			$fsk_lock = '';
255
			if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
256
				$fsk_lock = ' AND p.products_fsk18!=1';
257
			}
258
			$group_check = "";
259
			if (GROUP_CHECK == 'true') {
260
				$group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
261
			}
262
				
263
				// BOF GM_MOD:
264
				$cross_query = "
265
								SELECT
266
									p.products_fsk18,
267
									p.products_tax_class_id,
268
									p.products_id,
269
									p.products_image,
270
									pd.products_name,
271
									pd.products_short_description,
272
									pd.products_meta_description,
273
									p.products_fsk18,
274
									p.products_price,
275
									pd.gm_alt_text,
276
									p.products_vpe,
277
									p.products_vpe_status,
278
									p.products_vpe_value,
279
									xp.sort_order 
280
								FROM " . 
281
									TABLE_PRODUCTS_XSELL			. " xp, " . 
282
									TABLE_PRODUCTS					. " p,	" .
283
									TABLE_PRODUCTS_DESCRIPTION		. " pd
284
								WHERE
285
									xp.products_id = '" . $this->pID . "' 
286
								AND
287
									xp.xsell_id = p.products_id " . 
288
								$fsk_lock . 
289
								$group_check . "
290
								AND 
291
									p.products_id = pd.products_id 
292
								AND 
293
									xp.products_xsell_grp_name_id='".$cross_sells['products_xsell_grp_name_id']."'							
294
								AND 
295
									pd.language_id = '".$_SESSION['languages_id']."'
296
								AND 
297
									p.products_status = '1'
298
								ORDER BY 
299
									xp.sort_order ASC";
300

    
301
			$cross_query = xtDBquery($cross_query);
302
			if (xtc_db_num_rows($cross_query, true) > 0)
303
				$cross_sell_data[$cross_sells['products_xsell_grp_name_id']] = array ('GROUP' => xtc_get_cross_sell_name($cross_sells['products_xsell_grp_name_id']), 'PRODUCTS' => array ());
304

    
305
			while ($xsell = xtc_db_fetch_array($cross_query, true)) {
306

    
307
				$cross_sell_data[$cross_sells['products_xsell_grp_name_id']]['PRODUCTS'][] = $this->buildDataArray($xsell);
308
			}
309

    
310
		}
311
		return $cross_sell_data;
312

    
313
		}
314
	}
315

    
316

    
317
	/**
318
	 *
319
	 * get reverse cross sells
320
	 *
321
	 */
322

    
323
	 function getReverseCrossSells() {
324
	 			global $xtPrice;
325

    
326

    
327
			$fsk_lock = '';
328
			if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
329
				$fsk_lock = ' and p.products_fsk18!=1';
330
			}
331
			$group_check = "";
332
			if (GROUP_CHECK == 'true') {
333
				$group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
334
			}
335
			
336
			// BOF GM_MOD:
337
			$cross_query = xtDBquery("
338
									SELECT
339
										p.products_fsk18,
340
										p.products_tax_class_id,
341
										p.products_id,
342
										p.products_image,
343
										pd.products_name,
344
										pd.products_short_description,
345
										pd.products_meta_description,
346
										p.products_fsk18,
347
										p.products_price,
348
										pd.gm_alt_text,
349
										p.products_vpe,
350
										p.products_vpe_status,
351
										p.products_vpe_value,
352
										xp.sort_order 
353
									FROM " . 
354
										TABLE_PRODUCTS_XSELL		." xp,	".
355
										TABLE_PRODUCTS				." p,	".
356
										TABLE_PRODUCTS_DESCRIPTION	." pd	
357
									WHERE
358
										xp.xsell_id = '" . $this->pID . "' 
359
									AND 
360
										xp.products_id = p.products_id " . 
361
									$fsk_lock . 
362
									$group_check. "
363
									AND 
364
										p.products_id = pd.products_id 
365
									AND 
366
										pd.language_id = '".$_SESSION['languages_id']."'
367
									AND 
368
										p.products_status = '1'
369
									ORDER BY
370
										xp.sort_order ASC
371
									");
372

    
373

    
374
			while ($xsell = xtc_db_fetch_array($cross_query, true)) {
375

    
376
				$cross_sell_data[] = $this->buildDataArray($xsell);
377
			}
378

    
379

    
380
		return $cross_sell_data;
381

    
382

    
383

    
384
	 }
385

    
386

    
387
	function getGraduated() {
388
		global $xtPrice;
389

    
390
		$staffel_query = xtDBquery("SELECT
391
				                                     quantity,
392
				                                     personal_offer
393
				                                     FROM
394
				                                     ".TABLE_PERSONAL_OFFERS_BY.(int) $_SESSION['customers_status']['customers_status_id']."
395
				                                     WHERE
396
				                                     products_id = '".$this->pID."'
397
				                                     ORDER BY quantity ASC");
398

    
399
		$staffel = array ();
400
		while ($staffel_values = xtc_db_fetch_array($staffel_query, true)) {
401
			//$staffel[] = array ('stk' => (double)$staffel_values['quantity'], 'price' => (double)$staffel_values['personal_offer'] * (double)$xtPrice->currencies[$_SESSION['currency']]['value']);
402
			$staffel[] = array ('stk' => (double)$staffel_values['quantity'], 'price' => (double)$staffel_values['personal_offer']);
403
		}
404
		
405
		$staffel_data = array ();
406
		for ($i = 0, $n = sizeof($staffel); $i < $n; $i ++) {
407
			// BOF GM_MOD
408
			$quantity_output = '';
409
			
410
			$quantity = (double)$staffel[$i]['stk'];
411
				
412
			if($quantity < (double)$this->data['gm_min_order'])
413
			{
414
				$quantity = (double)$this->data['gm_min_order'];
415
			}
416
			
417
			if(isset($staffel[$i+1]['stk']))
418
			{
419
				if((double)$staffel[$i+1]['stk'] - (double)$this->data['gm_graduated_qty'] > $quantity)
420
				{
421
					$quantity_output = gm_prepare_number($quantity, $xtPrice->currencies[$_SESSION['currency']]['decimal_point']) . '-' . gm_prepare_number(($staffel[$i+1]['stk'] - (double)$this->data['gm_graduated_qty']), $xtPrice->currencies[$_SESSION['currency']]['decimal_point']);
422
				}
423
				elseif((double)$staffel[$i+1]['stk'] - (double)$this->data['gm_graduated_qty'] == $quantity)
424
				{
425
					$quantity_output = gm_prepare_number($quantity, $xtPrice->currencies[$_SESSION['currency']]['decimal_point']);
426
				}
427
			}
428
			else
429
			{
430
				$quantity -= (double)$this->data['gm_graduated_qty'];
431
				$quantity_output = '> ' . gm_prepare_number($quantity, $xtPrice->currencies[$_SESSION['currency']]['decimal_point']);
432
			}
433
						
434
			$vpe = '';
435
			
436
			if($this->data['products_vpe_status'] == 1 && $this->data['products_vpe_value'] != 0.0 && $staffel[$i]['price'] > 0)
437
			{
438
				$vpe = $staffel[$i]['price'] - $staffel[$i]['price'] / 100 * $discount;
439
				$vpe = $vpe * (1 / $this->data['products_vpe_value']);
440
			}
441
			
442
			require_once (DIR_FS_INC.'xtc_get_vpe_name.inc.php');
443
			
444
			if($quantity_output != '')
445
			{
446
				if($vpe)
447
				{
448
					$staffel_data[$i] = array ('QUANTITY' => $quantity_output,
449
												'VPE' => trim($xtPrice->xtcFormat($vpe, true, $this->data['products_tax_class_id']).TXT_PER.xtc_get_vpe_name($this->data['products_vpe'])),
450
												'PRICE' => $xtPrice->xtcFormat($staffel[$i]['price'] - $staffel[$i]['price'] / 100 * $discount, true, $this->data['products_tax_class_id']),
451
												'UNIT' => $this->data['unit_name']);
452
				}
453
				else
454
				{
455
					$staffel_data[$i] = array ('QUANTITY' => $quantity_output,
456
												'VPE' => $vpe,
457
												'PRICE' => $xtPrice->xtcFormat($staffel[$i]['price'] - $staffel[$i]['price'] / 100 * $discount, true, $this->data['products_tax_class_id']),
458
												'UNIT' => $this->data['unit_name']);
459
				}
460
			}
461
			// EOF GM_MOD
462
		}
463
		
464
		return $staffel_data;
465

    
466
	}
467
	/**
468
	 *
469
	 * valid flag
470
	 *
471
	 */
472

    
473
	function isProduct() {
474
		return $this->isProduct;
475
	}
476

    
477
	// beta
478
	function getBuyNowButton($id, $name) {
479
		global $PHP_SELF;
480
		return '<a href="'.xtc_href_link(basename($PHP_SELF), 'action=buy_now&BUYproducts_id='.$id.'&'.xtc_get_all_get_params(array ('action')), 'NONSSL').'">'.xtc_image_button('button_buy_now.gif', TEXT_BUY.$name.TEXT_NOW).'</a>';
481

    
482
	}
483

    
484
	function getVPEtext($product, $price) {
485
		global $xtPrice;
486

    
487
		require_once (DIR_FS_INC.'xtc_get_vpe_name.inc.php');
488

    
489
		if (!is_array($product))
490
			$product = $this->data;
491

    
492
		if ($product['products_vpe_status'] == 1 && $product['products_vpe_value'] != 0.0 && $price > 0) {
493
			return $xtPrice->xtcFormat($price * (1 / $product['products_vpe_value']), true).TXT_PER.xtc_get_vpe_name($product['products_vpe']);
494
		}
495

    
496
		return;
497

    
498
	}
499
		
500
	
501
	// BOF GM_MOD
502
	function gm_min_order($pID){
503
		$min_ordery = 1;
504
		$gm_get_min_order = xtc_db_query("SELECT gm_min_order, gm_graduated_qty FROM products WHERE products_id = '" . $pID . "'");
505
		if(xtc_db_num_rows($gm_get_min_order) == 1){
506
			$qty = xtc_db_fetch_array($gm_get_min_order);
507
			if($qty['gm_min_order'] >= $qty['gm_graduated_qty']) $min_order = $qty['gm_min_order'];
508
			else $min_order = $qty['gm_graduated_qty'];
509
			if($min_order <= 0) $min_order = 1;
510
		}
511
		
512
		$min_order = (double)$min_order;
513
		$min_order = gm_convert_qty($min_order, false);
514
		
515
		return $min_order;
516
	}
517
	// EOF GM_MOD	
518
		
519
		
520
	function buildDataArray(&$array,$image='thumbnail') {
521
		global $xtPrice,$main;
522
		// BOF GM_MOD
523
		global $PHP_SELF, $gmSEOBoost;
524

    
525
		if(isset($array['cat_url']) == false) $array['cat_url'] = '';
526
		if(isset($array['expires_date']) == false) $array['expires_date'] = '';
527
		if(isset($array['gm_alt_text']) == false) $array['gm_alt_text'] = '';
528
		if(isset($array['gm_show_weight']) == false) $array['gm_show_weight'] = '';
529
		if(isset($array['ID']) == false) $array['ID'] = '';
530
		if(isset($array['products_description']) == false) $array['products_description'] = '';
531
		if(isset($array['products_fsk18']) == false) $array['products_fsk18'] = '';
532
		if(isset($array['products_id']) == false) $array['products_id'] = '';
533
		if(isset($array['products_image_h']) == false) $array['products_image_h'] = '';
534
		if(isset($array['products_image_w']) == false) $array['products_image_w'] = '';
535
		if(isset($array['products_image']) == false) $array['products_image'] = '';
536
		if(isset($array['products_meta_description']) == false) $array['products_meta_description'] = '';
537
		if(isset($array['products_name']) == false) $array['products_name'] = '';
538
		if(isset($array['products_price']) == false) $array['products_price'] = '';
539
		if(isset($array['products_shippingtime']) == false) $array['products_shippingtime'] = '';
540
		if(isset($array['products_short_description']) == false) $array['products_short_description'] = '';
541
		if(isset($array['products_tax_class_id']) == false) $array['products_tax_class_id'] = '';
542
		if(isset($array['products_weight']) == false) $array['products_weight'] = '';
543
		
544
		
545
		$tax_rate = $xtPrice->TAX[$array['products_tax_class_id']];
546

    
547
		$products_price = $xtPrice->xtcGetPrice($array['products_id'], $format = true, 1, $array['products_tax_class_id'], $array['products_price'], 1);
548

    
549
		// BOF GM_MOD
550
		$buy_now = '';
551
		$gm_buy_now_url = '';
552
		$gm_qty = '';
553
		$t_qty_array = array();
554
		$gm_buy_now = xtc_draw_hidden_field('products_id', $array['products_id'], 'class="gm_products_id"');
555
		if ($_SESSION['customers_status']['customers_status_show_price'] != '0' && $xtPrice->gm_check_price_status($array['products_id']) == 0) {
556
			if ($_SESSION['customers_status']['customers_fsk18'] == '1') {
557
				if ($array['products_fsk18'] == '0'){
558
					$buy_now = $this->getBuyNowButton($array['products_id'], $array['products_name']);
559
					$gm_buy_now_url = xtc_href_link(basename($PHP_SELF), 'action=buy_now&BUYproducts_id='.$array['products_id'].'&'.xtc_get_all_get_params(array ('action')), 'NONSSL');
560
					$gm_qty = xtc_draw_input_field('products_qty', $this->gm_min_order($array['products_id']), 'size="3" id="gm_attr_calc_qty_' . $array['products_id'] . '" onkeyup="gm_calc_prices_listing(\'' . $array['products_id'] . '\')"', 'text', true, "gm_listing_form gm_class_input" );
561
					$gm_buy_now .= xtc_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'class="gm_image_button"');
562
					$t_qty_array = array('NAME' => 'products_qty', 
563
											'VALUE' => $this->gm_min_order($array['products_id']),
564
											'SIZE' => '3',
565
											'ID' => 'gm_attr_calc_qty_' . $array['products_id'],
566
											'ONKEYUP' => 'gm_calc_prices_listing(\'' . $array['products_id'] . '\')',
567
											'CLASS' => 'gm_listing_form gm_class_input',
568
											'TYPE' => 'text');
569

    
570
				}
571
			} else {
572
				$buy_now = $this->getBuyNowButton($array['products_id'], $array['products_name']);
573
				$gm_buy_now_url = xtc_href_link(basename($PHP_SELF), 'action=buy_now&BUYproducts_id='.$array['products_id'].'&'.xtc_get_all_get_params(array ('action')), 'NONSSL');
574
				$gm_qty = xtc_draw_input_field('products_qty', $this->gm_min_order($array['products_id']), 'size="3" id="gm_attr_calc_qty_' . $array['products_id'] . '" onkeyup="gm_calc_prices_listing(\'' . $array['products_id'] . '\')"',  'text', true, "gm_listing_form gm_class_input" );
575
				$gm_buy_now .= xtc_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'class="gm_image_button"');
576
				$t_qty_array = array('NAME' => 'products_qty',
577
											'VALUE' => $this->gm_min_order($array['products_id']),
578
											'SIZE' => '3',
579
											'ID' => 'gm_attr_calc_qty_' . $array['products_id'],
580
											'ONKEYUP' => 'gm_calc_prices_listing(\'' . $array['products_id'] . '\')',
581
											'CLASS' => 'gm_listing_form gm_class_input',
582
											'TYPE' => 'text');
583
			}
584
		}
585
		
586
		$t_shipping_status_id = $array['products_shippingtime'];
587
		if($xtPrice->gm_check_price_status($array['products_id']) == 1 || $xtPrice->gm_check_price_status($array['products_id']) == 2){
588
			if($array['products_price'] > 0 && $xtPrice->gm_check_price_status($array['products_id']) == 2){
589
				$gm_tax_info = $main->getTaxInfo($tax_rate);
590
			}
591
			else $gm_tax_info = '';
592
			$gm_shipping_link = '';
593
			$t_shipping_info_link_active = '';
594
			$shipping_status_name = '';
595
			$shipping_status_image = '';
596
		}
597
		else {
598
			$gm_tax_info = $main->getTaxInfo($tax_rate);
599
			$gm_shipping_link = $main->getShippingLink(true);
600
			
601
			if(ACTIVATE_SHIPPING_STATUS == 'true'){
602
				$shipping_status_name = $main->getShippingStatusName($t_shipping_status_id);
603
				$shipping_status_image = $main->getShippingStatusImage($t_shipping_status_id);
604
				$t_shipping_info_link_active = $main->getShippingStatusInfoLinkActive($t_shipping_status_id);
605
			}
606
			else{
607
				$shipping_status_name = '';
608
				$shipping_status_image = '';
609
				$t_shipping_info_link_active = '';
610
			}
611
		}
612
		
613
		if($gmSEOBoost->boost_products) {
614
			$gm_product_link = xtc_href_link($gmSEOBoost->get_boosted_product_url($array['products_id'], $array['products_name']) );
615
		} else {
616
			$gm_product_link = xtc_href_link(FILENAME_PRODUCT_INFO, xtc_product_link($array['products_id'], $array['products_name']));
617
		}
618
		
619
		$gm_products_stock = gm_convert_qty(xtc_get_products_stock($array['products_id']), false);
620
		
621
		// set image size once a time if !exist
622
		if(isset($array['products_image_w']) && empty($array['products_image_w']) && xtc_not_null($array['products_image'])) {
623
			$gm_imagesize = $this->productImageSize($array['products_id'], $array['products_image']);
624
			$array['products_image_w'] = $gm_imagesize[0];
625
			$array['products_image_h'] = $gm_imagesize[1];	
626
		} 
627

    
628
		$gm_cat_search = '';
629
		if(isset($_GET['cat'])) $gm_cat_search = '&cat=' . $_GET['cat'];
630
		if(isset($_GET['keywords'])){
631
				$gm_cat_search = '&keywords=' . $_GET['keywords'];
632
				if(isset($_GET['page'])) $gm_cat_search .= '&page=' . $_GET['page'];
633
		}		
634

    
635
		$t_form_array = array();
636
		$t_form_array = array('ID' => 'gm_add_to_cart_'.$array['products_id'],
637
								'ACTION_URL' => xtc_href_link('index.php', 'action=buy_now&BUYproducts_id=' . $array['products_id'] . $gm_cat_search, 'NONSSL', true, true, true),
638
								'METHOD' => 'post',
639
								'ONSUBMIT' => 'return gm_quantity_check_listing(\'' . $array['products_id'] . '\')'
640
								);
641

    
642
		$t_data_array = array (	'PRODUCTS_NAME'						=> htmlspecialchars_wrapper($array['products_name']),
643
				'COUNT'								=> $array['ID'],
644
				'PRODUCTS_ID'						=> $array['products_id'],
645
				'PRODUCTS_VPE'						=> $this->getVPEtext($array, $products_price['plain']),
646
				'PRODUCTS_IMAGE'					=> $this->productImage($array['products_image'], $image),
647
				'PRODUCTS_IMAGE_W'					=> $array['products_image_w'],
648
				'PRODUCTS_IMAGE_H'					=> $array['products_image_h'],
649
				'PRODUCTS_IMAGE_WIDTH'				=> PRODUCT_IMAGE_THUMBNAIL_WIDTH,
650
				'PRODUCTS_IMAGE_PADDING'			=> ((PRODUCT_IMAGE_THUMBNAIL_HEIGHT + 8) - $array['products_image_h'])/2,
651
				'PRODUCTS_IMAGE_ALT'				=> $array['gm_alt_text'],
652
				'PRODUCTS_LINK'						=> $gm_product_link,
653
				'PRODUCTS_PRICE'					=> $products_price['formated'],
654
				'PRODUCTS_TAX_INFO'					=> $gm_tax_info,
655
				'PRODUCTS_SHIPPING_LINK'			=> $gm_shipping_link,
656
				'PRODUCTS_BUTTON_BUY_NOW'			=> $buy_now,
657
				'GM_PRODUCTS_BUTTON_BUY_NOW_URL'	=> $gm_buy_now_url,
658
				'GM_PRODUCTS_BUTTON_BUY_NOW'		=> $gm_buy_now,
659
				'PRODUCTS_SHIPPING_NAME'			=> $shipping_status_name,
660
				'PRODUCTS_SHIPPING_IMAGE'			=> $shipping_status_image,
661
				'PRODUCTS_SHIPPING_LINK_ACTIVE'		=> $t_shipping_info_link_active,
662
				'PRODUCTS_DESCRIPTION'				=> $array['products_description'],
663
				'PRODUCTS_EXPIRES'					=> $array['expires_date'],
664
				'PRODUCTS_CATEGORY_URL'				=> $array['cat_url'],
665
				'PRODUCTS_SHORT_DESCRIPTION'		=> $array['products_short_description'],
666
				'PRODUCTS_FSK18'					=> $array['products_fsk18'],
667
								'GM_FORM_ACTION'					=> xtc_draw_form('gm_add_to_cart_'.$array['products_id'], xtc_href_link('index.php', 'action=buy_now&BUYproducts_id=' . $array['products_id'] . $gm_cat_search, 'NONSSL', true, true, true), 'post', 'onsubmit="return gm_quantity_check_listing(\'' . $array['products_id'] . '\')"'),
668
				'FORM_DATA'							=> $t_form_array,
669
				'QTY_DATA'							=> $t_qty_array,
670
				'GM_FORM_END'						=> '</form>',
671
				'GM_PRODUCTS_QTY'					=> $gm_qty,
672
				'GM_PRODUCTS_STOCK'					=> $gm_products_stock,
673
								'PRODUCTS_META_DESCRIPTION'			=> $array['products_meta_description'],
674
								'PRODUCTS_WEIGHT'					=> gm_prepare_number((double)$array['products_weight'], $xtPrice->currencies[$xtPrice->actualCurr]['decimal_point']),
675
								'SHOW_PRODUCTS_WEIGHT'				=> $array['gm_show_weight']);
676
		
677
		return $t_data_array;
678
		// EOF GM_MOD
679
	}
680

    
681

    
682
	function productImage($name, $type) {
683

    
684
		switch ($type) {
685
			case 'info' :
686
				$path = DIR_WS_INFO_IMAGES;
687
				break;
688
			case 'thumbnail' :
689
				$path = DIR_WS_THUMBNAIL_IMAGES;
690
				break;
691
			case 'popup' :
692
				$path = DIR_WS_POPUP_IMAGES;
693
				break;
694
		}
695

    
696
		if ($name == '') {
697
			if ($this->useStandardImage == 'true' && $this->standardImage != '')
698
				return $path.$this->standardImage;
699
		} else {
700
			// check if image exists
701
			if (!file_exists($path.$name)) {
702
				if ($this->useStandardImage == 'true' && $this->standardImage != '')
703
					$name = $this->standardImage;
704
			}
705
			return $path.$name;
706
		}
707
	}
708

    
709
	function productImageSize($pid, $image) {
710
			$gm_imagesize = @getimagesize(DIR_WS_THUMBNAIL_IMAGES . $image);
711
			$gm_query = xtc_db_query("
712
									UPDATE " . 
713
										TABLE_PRODUCTS . "
714
									SET
715
										products_image_w = '" . $gm_imagesize[0] . "',
716
										products_image_h = '" . $gm_imagesize[1] . "'
717
									WHERE
718
										products_id = '" . $pid . "'						
719
									");
720
			return $gm_imagesize;
721
	}
722
}
723
?>
    (1-1/1)