Zakladni framework pro preklady (+ cesky preklad)
[mirrors/SokoMan.git] / assistants / stats.inc.php
CommitLineData
fff6ce40 1<?php
b4c58cd0
TM
2$month=date('Y-m');
3$month_sql='';
4if(isset($_GET['month'])) {
5 $month = htmlspecialchars($_GET['month']);
6 $month_sql = " AND DATE_FORMAT(item_valid_from, '%Y-%m') = ".$this->db->quote($_GET['month']);
7}
8?>
9
de77377e 10<form action="<?=$URL?>/" method="GET">
b4c58cd0
TM
11 YYYY-MM: <input type="text" name="month" autofocus value="<?=$month?>" />
12 <input type="submit" value="SELECT BY MONTH" />
13</form>
14<?php
15
16if($month_sql == '') $month='';
fff6ce40 17$queries = array( //TODO: use build_query_select()!!!
b4c58cd0
TM
18 "Nakoupeno celkem $month"
19 => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0'.$month_sql,
20 "Použito celkem $month"
21 => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0 AND status_id = 2'.$month_sql,
22 "Prodáno celkem $month"
23 => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0 AND status_id = 3'.$month_sql,
24 "Počet kusů skladem"
25 => 'SELECT room_id,room_name,model_id,model_name,model_barcode,COUNT(item_id)'.
fff6ce40
TM
26 ' FROM item LEFT JOIN model USING(model_id) LEFT JOIN room USING(room_id)'.
27 ' WHERE item_valid_till=0 AND status_id=1'.
28 ' GROUP BY model_id,room_id'.
29 ' ORDER BY room_id,model_id;'
30);
31
32foreach($queries as $description => $sql) {
33 echo "<h2>$description</h2>";
326a9fc9 34 echo $this->html->render_item_table($result = $this->db->safe_query_fetch($sql));
fff6ce40 35}
This page took 0.153172 seconds and 4 git commands to generate.