catalog_stat.php
7.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<form method="post" name="v_data">
<table cellpadding="5" cellspacing="5" border="0">
<tr>
<td>
Ìåñÿö:
</td>
<td>
<select name="mons">
<?
if(!isset($_REQUEST['oll_orders']))
{
if (!isset($_POST['mons']))
{
$_POST['mons'] = date("n");
}
}
else
{
$_POST['mons'] = "oll";
}
if ($_POST['mons']=="oll")
{
?>
<option value="oll" selected="true">Çà âñå âðåìÿ</option>
<?
}
for ( $i = 1; $i <= 12; $i ++ )
{
mons_name($i, &$mons_name);
if ($i==$_POST['mons'])
{
?>
<option value="<? echo $i?>" selected="true"><? echo $mons_name; ?></option>
<?
}
else
{
?>
<option value="<? echo $i?>"><? echo $mons_name; ?></option>
<?
}
}
?>
</select>
</td>
<td>
<input type="submit" value="Ñòàòèñòèêà çàêàçîâ çà âûáðàíûé ìåñÿö">
</td>
<td>
<input type="submit" value="Çà âñå âðåìÿ" name="oll_orders">
</td>
</tr>
</table>
</form>
<?
if (!empty($_POST['mons']))
{
mons_name($_POST['mons'], &$mons_name);
$m_b = $_POST['mons'];
$m_e = $_POST['mons']+1;
$ls_sql="SELECT id, name FROM catalogs_rubrics where level = 0 order by sort";
$result = mysql_query($ls_sql);
$num_results = mysql_num_rows($result);
?>
<table cellpadding="5" cellspacing="5" border="0" width="100%">
<?
for ($i = 0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
$id = htmlspecialchars(stripcslashes($row["id"]));
$name = htmlspecialchars(stripcslashes($row["name"]));
?>
<tr>
<td>
<?
echo $name."<br>";
?>
<table cellpadding="5" cellspacing="5" border="0" width="100%">
<tr>
<td width="300px" class="td_top">
</td>
<td width="300px" class="td_top">
Çàêàçàíî òîâàðîâ
</td>
<td class="td_top">
Íà ñóììó
</td>
</tr>
<?
$ls_sql="SELECT id, name FROM catalogs_rubrics where parent_id = $id";
$result_1 = mysql_query($ls_sql);
$num_results_1 = mysql_num_rows($result_1);
for ($j = 0; $j < $num_results_1; $j++)
{
$row_1 = mysql_fetch_array($result_1);
$id_1 = htmlspecialchars(stripcslashes($row_1["id"]));
$neme_1 = htmlspecialchars(stripcslashes($row_1["name"]));
if (($j%2) == 0)
{
$td_class = "td_1";
}
else
{
$td_class = "td_2";
}
?>
<tr>
<td class="<? echo $td_class; ?>">
<?
echo $neme_1;
?>
</td>
<td class="<? echo $td_class; ?>">
<?
//$ls_sql="SELECT catalogs_orders_products.order_id, catalogs_orders_products.product_id as modif_id, catalogs_products.id as product_id, catalogs_orders_products.count as count_product FROM catalogs_orders_products inner join catalogs_modifications on catalogs_orders_products.product_id = catalogs_modifications.id inner join catalogs_products on catalogs_modifications.product_id = catalogs_products.id where catalogs_products.rubric_id = $id_1";
if(!isset($_REQUEST['oll_orders']))
{
$ls_sql="SELECT sum(catalogs_orders_products.count) FROM catalogs_orders_products inner join catalogs_modifications on catalogs_orders_products.product_id = catalogs_modifications.id inner join catalogs_products on catalogs_modifications.product_id = catalogs_products.id inner join catalogs_orders on catalogs_orders_products.order_id = catalogs_orders.id where catalogs_products.rubric_id = $id_1 and catalogs_orders.total <> 0 and catalogs_orders.mktime > ".mktime(0, 0, 0, $m_b, 1, date("Y"))." and catalogs_orders.mktime < ".mktime(0, 0, 0, $m_e, 1, date("Y"))."";
}
else
{
$ls_sql="SELECT sum(catalogs_orders_products.count) FROM catalogs_orders_products inner join catalogs_modifications on catalogs_orders_products.product_id = catalogs_modifications.id inner join catalogs_products on catalogs_modifications.product_id = catalogs_products.id inner join catalogs_orders on catalogs_orders_products.order_id = catalogs_orders.id where catalogs_products.rubric_id = $id_1 and catalogs_orders.total <> 0";
}
$result_3 = mysql_query($ls_sql);
$row_3 = mysql_fetch_row($result_3);
$catalog_sum = $row_3[0];
echo $catalog_sum;
?>
</td>
<td class="<? echo $td_class; ?>">
<?
if(!isset($_REQUEST['oll_orders']))
{
$ls_sql="SELECT sum(catalogs_orders.total) FROM catalogs_orders_products inner join catalogs_modifications on catalogs_orders_products.product_id = catalogs_modifications.id inner join catalogs_products on catalogs_modifications.product_id = catalogs_products.id inner join catalogs_orders on catalogs_orders_products.order_id = catalogs_orders.id where catalogs_products.rubric_id = $id_1 and catalogs_orders.total <> 0 and catalogs_orders.mktime > ".mktime(0, 0, 0, $m_b, 1, date("Y"))." and catalogs_orders.mktime < ".mktime(0, 0, 0, $m_e, 1, date("Y"))."";
}
else
{
$ls_sql="SELECT sum(catalogs_orders.total) FROM catalogs_orders_products inner join catalogs_modifications on catalogs_orders_products.product_id = catalogs_modifications.id inner join catalogs_products on catalogs_modifications.product_id = catalogs_products.id inner join catalogs_orders on catalogs_orders_products.order_id = catalogs_orders.id where catalogs_products.rubric_id = $id_1 and catalogs_orders.total <> 0";
}
$result_4 = mysql_query($ls_sql);
$order_sum = mysql_result($result_4, '0');
echo "Âñåãî: ".$order_sum." ãðí. <br><br>Èç íèõ:<br><br>";
if(!isset($_REQUEST['oll_orders']))
{
$ls_sql="SELECT catalogs_orders.status, sum(catalogs_orders.total) FROM catalogs_orders_products inner join catalogs_modifications on catalogs_orders_products.product_id = catalogs_modifications.id inner join catalogs_products on catalogs_modifications.product_id = catalogs_products.id inner join catalogs_orders on catalogs_orders_products.order_id = catalogs_orders.id where catalogs_products.rubric_id = $id_1 and catalogs_orders.total <> 0 and catalogs_orders.mktime > ".mktime(0, 0, 0, $m_b, 1, date("Y"))." and catalogs_orders.mktime < ".mktime(0, 0, 0, $m_e, 1, date("Y"))." group by catalogs_orders.status";
}
else
{
$ls_sql="SELECT catalogs_orders.status, sum(catalogs_orders.total) FROM catalogs_orders_products inner join catalogs_modifications on catalogs_orders_products.product_id = catalogs_modifications.id inner join catalogs_products on catalogs_modifications.product_id = catalogs_products.id inner join catalogs_orders on catalogs_orders_products.order_id = catalogs_orders.id where catalogs_products.rubric_id = $id_1 and catalogs_orders.total <> 0 group by catalogs_orders.status";
}
$result_5 = mysql_query($ls_sql);
$num_results_5 = mysql_num_rows($result_5);
for ($k = 0; $k < $num_results_5; $k++)
{
$row_5 = mysql_fetch_array($result_5);
$status = htmlspecialchars(stripcslashes($row_5["status"]));
$order = htmlspecialchars(stripcslashes($row_5["sum(catalogs_orders.total)"]));
status_name($status, &$status_name);
echo $status_name.": ".$order." ãðí. <br>";
}
?>
</td>
<?
}
?>
</table>
<?
}
?>
</tr>
</td>
</table>
<?
}
?>