Ve statistikach umozneno zobrazeni podle mesice
authorThomas Mudrunka <tomas@mudrunka.cz>
Sat, 20 Aug 2011 00:51:11 +0000 (02:51 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Sat, 20 Aug 2011 00:51:11 +0000 (02:51 +0200)
assistants/stats.inc.php

index 404a601fd709434e44a93f72d69168b6000e65ab..bd84300c4e9961fefc5c5a4a925ff8340a948b62 100644 (file)
@@ -1,9 +1,29 @@
 <?php
+$script = $_SERVER['SCRIPT_NAME'].'/assistant/stats';
+$month=date('Y-m');
+$month_sql='';
+if(isset($_GET['month'])) {
+       $month = htmlspecialchars($_GET['month']);
+       $month_sql = " AND DATE_FORMAT(item_valid_from, '%Y-%m') = ".$this->db->quote($_GET['month']);
+}
+?>
+
+<form action="<?=$script?>/" method="GET">
+       YYYY-MM: <input type="text" name="month" autofocus value="<?=$month?>" />
+       <input type="submit" value="SELECT BY MONTH" />
+</form>
+<?php
+
+if($month_sql == '') $month='';
 $queries = array( //TODO: use build_query_select()!!!
-       'Nakoupeno celkem' => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0',
-       'Použito celkem' => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0 AND status_id = 2',
-       'Prodáno celkem' => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0 AND status_id = 3',
-       'Počet kusů skladem' => 'SELECT room_id,room_name,model_id,model_name,model_barcode,COUNT(item_id)'.
+       "Nakoupeno celkem $month"
+               => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0'.$month_sql,
+       "Použito celkem $month"
+               => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0 AND status_id = 2'.$month_sql,
+       "Prodáno celkem $month"
+               => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0 AND status_id = 3'.$month_sql,
+       "Počet kusů skladem"
+               => 'SELECT room_id,room_name,model_id,model_name,model_barcode,COUNT(item_id)'.
                ' FROM item LEFT JOIN model USING(model_id) LEFT JOIN room USING(room_id)'.
                ' WHERE item_valid_till=0 AND status_id=1'.
                ' GROUP BY model_id,room_id'.
This page took 0.113274 seconds and 4 git commands to generate.