Pridany statistiky
authorThomas Mudrunka <tomas@mudrunka.cz>
Sat, 20 Aug 2011 00:19:03 +0000 (02:19 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Sat, 20 Aug 2011 00:19:03 +0000 (02:19 +0200)
assistants/stats.inc.php [new file with mode: 0644]
index.php

diff --git a/assistants/stats.inc.php b/assistants/stats.inc.php
new file mode 100644 (file)
index 0000000..404a601
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+$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)'.
+               ' 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'.
+               ' ORDER BY room_id,model_id;'
+);
+
+foreach($queries as $description => $sql) {
+       echo "<h2>$description</h2>";
+       echo $this->html->render_item_table($result = $this->db->safe_query($sql)->fetchAll(PDO::FETCH_ASSOC));
+}
index 93c32ad5c66573742be5913efc541e84cb55cbd8..8f37200644000085749f7c776b3cf8c5e281608d 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -148,6 +148,7 @@ class Sklad_HTML extends HTML {
                <li><a href="$script/">Home</a></li>
                <li><a href="#">Assistants</a>
                        <menu>
+                               <li><a href="$script/assistant/stats">stats</a></li>
                                <li><a href="$script/assistant/store">store</a></li>
                                <li><a href="$script/assistant/dispose">dispose</a></li>
                                <li><a href="$script/assistant/sell">sell</a></li>
@@ -224,7 +225,7 @@ EOF;
                );
                foreach($table as $id => $row) {
                        foreach($collapse as $link => $title)
-                               if(isset($table[$id][$link])) {
+                               if(isset($table[$id][$link]) && isset($row[$title])) {
                                        $type = @array_shift(preg_split('/_/', $link));
                                        if($link != $title) unset($table[$id][$link]);
                                        $table[$id][$title]=$this->link($row[$title], $type.'/'.$row[$link].'/');
This page took 0.150773 seconds and 4 git commands to generate.