Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

productreport.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: productreport.php 6230 2001-07-20 11:28:54Z jakobn $
5 //
6 // Created on: <11-Jan-2001 14:47:56 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 $ini =& eZINI::instance( 'site.ini' );
29 $Language = $ini->variable( "eZStatsMain", "Language" );
30
31 // include_once( "classes/eztemplate.php" );
32 // include_once( "classes/ezdate.php" );
33
34 // include_once( "ezstats/classes/ezpageview.php" );
35 // include_once( "ezstats/classes/ezpageviewquery.php" );
36
37 // include_once( "eztrade/classes/ezproduct.php" );
38 // include_once( "eztrade/classes/ezorder.php" );
39
40 $t = new eZTemplate( "kernel/ezstats/admin/" . $ini->variable( "eZStatsMain", "AdminTemplateDir" ),
41 "kernel/ezstats/admin/intl", $Language, "productreport.php" );
42
43 $t->setAllStrings();
44
45 $t->set_file( array(
46 "product_report_tpl" => "productreport.tpl"
47 ) );
48
49 $t->set_block( "product_report_tpl", "most_viewed_product_tpl", "most_viewed_product" );
50 $t->set_block( "product_report_tpl", "most_added_to_cart_products_tpl", "most_added_to_cart_products" );
51 $t->set_block( "product_report_tpl", "most_added_to_wishlist_products_tpl", "most_added_to_wishlist_products" );
52 $t->set_block( "product_report_tpl", "most_bought_products_tpl", "most_bought_products" );
53
54 $t->set_block( "product_report_tpl", "month_tpl", "month" );
55 $t->set_block( "month_tpl", "month_previous_tpl", "month_previous" );
56 $t->set_block( "month_tpl", "month_previous_inactive_tpl", "month_previous_inactive" );
57 $t->set_block( "month_tpl", "month_next_tpl", "month_next" );
58 $t->set_block( "month_tpl", "month_next_inactive_tpl", "month_next_inactive" );
59
60 if ( isset( $Year ) && !is_numeric( $Year ) || isset( $Month ) && !is_numeric( $Month ) )
61 {
62 $cur_date = new eZDate();
63 $Year = $cur_date->year();
64 $Month = $cur_date->month();
65 }
66
67 $query = new eZPageViewQuery();
68
69 $tmpProduct = new eZProduct();
70
71 // most viewed products
72 $productReport =& $query->topProductRequests( );
73
74 $productArray = array();
75 foreach ( $productReport as $product )
76 {
77 if ( preg_match( "#^/trade/productview/(.*?)/#", $product["URI"], $regArray ) )
78 {
79 $idx = $regArray[1];
80 $productArray[$idx] = array();
81 $productArray[$idx]["Count"] = false;
82 $count = $productArray[$idx]["Count"];
83
84 $productArray[$idx]["Count"] = $count + $product["Count"];
85 $productArray[$idx]["ID"] = $regArray[1];
86 }
87 }
88
89 if ( !empty( $productArray ) )
90 {
91 $i = 0;
92 foreach ( $productArray as $productItem )
93 {
94 $t->set_var( "bg_color", $i % 2 == 0 ? "bglight" : "bgdark" );
95 $t->set_var( "product_name", $tmpProduct->productName( $productItem["ID"] ) );
96 $t->set_var( "view_count", $productItem["Count"] );
97
98 $t->parse( "most_viewed_product", "most_viewed_product_tpl", true );
99 ++$i;
100 }
101 }
102 else
103 {
104 $t->set_var( "most_viewed_product", "" );
105 }
106
107 // mostly added to cart
108
109 $productReport =& $query->topProductAddToCart( );
110
111 $productArray = array();
112 foreach ( $productReport as $product )
113 {
114 if ( preg_match( "#^/trade/cart/add/(.*?)/#", $product["URI"], $regArray ) )
115 {
116 $idx = $regArray[1];
117
118 $count = $productArray[$idx]["Count"];
119
120 $productArray[$idx]["Count"] = $count + $product["Count"];
121 $productArray[$idx]["ID"] = $regArray[1];
122 }
123 }
124
125 if ( !empty( $productArray ) )
126 {
127 $i = 0;
128 foreach ( $productArray as $productItem )
129 {
130 $t->set_var( "bg_color", $i % 2 == 0 ? "bglight" : "bgdark" );
131 $t->set_var( "product_name", $tmpProduct->productName( $productItem["ID"] ) );
132 $t->set_var( "add_count", $productItem["Count"] );
133
134 $t->parse( "most_added_to_cart_products", "most_added_to_cart_products_tpl", true );
135 ++$i;
136 }
137 }
138 else
139 {
140 $t->set_var( "most_added_to_cart_products", "" );
141 }
142
143 // // mostly added to wishlist
144
145 $productReport =& $query->topProductAddToWishlist( );
146
147 $productArray = array();
148 foreach ( $productReport as $product )
149 {
150
151 if ( preg_match( "#^/trade/wishlist/add/(.*?)#", $product["URI"], $regArray ) )
152 {
153 $idx = $regArray[1];
154
155 $count = $productArray[$idx]["Count"];
156
157 $productArray[$idx]["Count"] = $count + $product["Count"];
158 $productArray[$idx]["ID"] = $regArray[1];
159 }
160 }
161
162 if ( !empty( $productArray ) )
163 {
164 $i = 0;
165 foreach ( $productArray as $productItem )
166 {
167 $t->set_var( "bg_color", $i % 2 == 0 ? "bglight" : "bgdark" );
168 $t->set_var( "product_name", $tmpProduct->productName( $productItem["ID"] ) );
169 $t->set_var( "add_count", $productItem["Count"] );
170
171 $t->parse( "most_added_to_wishlist_products", "most_added_to_wishlist_products_tpl", true );
172 ++$i;
173 }
174 }
175 else
176 {
177 $t->set_var( "most_added_to_wishlist_products", "" );
178 }
179
180 // Most bought product
181
182 $order = new eZOrder();
183 $productReport =& $order->mostPopularProduct();
184
185 if ( !empty( $productReport ) )
186 {
187 $i = 0;
188 foreach ( $productReport as $productItem )
189 {
190 $t->set_var( "bg_color", $i % 2 == 0 ? "bglight" : "bgdark" );
191 $t->set_var( "product_name", $tmpProduct->productName( $productItem["ProductID"] ) );
192
193 $t->set_var( "buy_count", $productItem["Count"] );
194 $t->set_var( "total_buy_count", $productItem["RealCount"] );
195
196 $t->parse( "most_bought_products", "most_bought_products_tpl", true );
197 ++$i;
198 }
199 }
200 else
201 {
202 $t->set_var( "most_bought_products", "" );
203 }
204
205
206 $next_month = new eZDate( $Year, $Month, 1, 0, 1, 0 );
207 $prev_month = new eZDate( $Year, $Month, 1, 0, -1, 0 );
208
209 $t->set_var( "next_month", $next_month->month() );
210 $t->set_var( "previous_month", $prev_month->month() );
211 $t->set_var( "next_year", $next_month->year() );
212 $t->set_var( "previous_year", $prev_month->year() );
213
214 $t->set_var( "month_next_inactive", "" );
215 $t->set_var( "month_next", "" );
216 $t->set_var( "month_previous", "" );
217 $t->set_var( "month_previous_inactive", "" );
218
219 $cur_date = new eZDate();
220
221 if ( $cur_date->isGreater( $next_month ) )
222 $t->parse( "month_next_inactive", "month_next_inactive_tpl" );
223 else
224 $t->parse( "month_next", "month_next_tpl" );
225
226 $t->parse( "month_previous", "month_previous_tpl" );
227
228 $t->parse( "month", "month_tpl" );
229
230 $t->set_var( "this_month", $Month );
231 $t->set_var( "this_year", $Year );
232
233
234 $t->pparse( "output", "product_report_tpl" );
235
236 ?>
$i
$i
Definition: admin/adlist.php:91
eZDate
Definition: ezdate.php:46
eZOrder
Definition: ezorder.php:52
eZPageViewQuery
Definition: ezpageviewquery.php:45
eZProduct
Definition: ezproduct.php:71
eZTemplate
Definition: eztemplate.php:107
$Month
$Month
Definition: ezcalendar/user/dayview.php:78
$product
$product
Definition: homepage.php:202
$count
$count
Definition: onlinetypelist.php:108
$productReport
$productReport
Definition: productreport.php:72
$order
$order
Definition: productreport.php:182
$t
$t
Definition: productreport.php:40
$cur_date
$cur_date
Definition: productreport.php:219
$next_month
$next_month
Definition: productreport.php:206
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: productreport.php:67
$Language
$Language
Definition: productreport.php:29
$ini
$ini
Definition: productreport.php:28
$productArray
$productArray
Definition: productreport.php:74
$tmpProduct
$tmpProduct
Definition: productreport.php:69
$prev_month
$prev_month
Definition: productreport.php:207
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.