From: Thomas Mudrunka Date: Thu, 12 Apr 2012 09:59:27 +0000 (+0200) Subject: Betaverze novych financnich statistik X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=c8fe68ff20c753edddd4379268612f5a41e2d7b8;p=mirrors%2FSokoMan.git Betaverze novych financnich statistik --- diff --git a/assistants/stats/financial.inc.php b/assistants/stats/financial.inc.php index 3f38df3..d06edba 100644 --- a/assistants/stats/financial.inc.php +++ b/assistants/stats/financial.inc.php @@ -1,9 +1,14 @@ db->quote($_GET['month']); + $month_q = $this->db->quote($_GET['month']); + $month_sql = " AND DATE_FORMAT(item_valid_from, '%Y-%m') = ".$month_q; + $month_sql_bought = " AND DATE_FORMAT(item_date_bought, '%Y-%m') = ".$month_q; + $month_sql_sold = " AND DATE_FORMAT(item_date_sold, '%Y-%m') = ".$month_q; } echo $this->html->form($URL, 'GET', array( @@ -14,14 +19,23 @@ echo $this->html->form($URL, 'GET', array( if($month_sql == '') $month=''; $queries += array( //TODO: use build_query_select()!!! "Nakoupeno celkem $month" + => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0'.$month_sql_bought, + "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, + => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0 AND status_id = 2'.$month_sql_sold, "Prodáno celkem $month" + => 'SELECT COUNT(item_id),SUM(item_price_out),SUM(item_price_in),(SUM(item_price_out)-SUM(item_price_in)) as sale_profit FROM item WHERE item_valid_till=0 AND status_id = 3'.$month_sql_sold, + "Prodáno celkem $month" => 'SELECT COUNT(item_id),SUM(item_price_out),SUM(item_price_in),(SUM(item_price_out)-SUM(item_price_in)) as sale_profit FROM item WHERE item_valid_till=0 AND status_id = 3'.$month_sql, "Skladem celkem $month" => 'SELECT COUNT(item_id),SUM(item_price_in) FROM item WHERE item_valid_till=0 AND status_id = 1'.$month_sql, "Bilance celkem =(prodej - všechny nákupy) $month" + => "SELECT ( + SUM(item_price_out) + -(SELECT SUM(item_price_in) FROM item WHERE item_valid_till=0$month_sql_bought) + ) FROM item WHERE item_valid_till=0 AND ( status_id = 3 )$month_sql_sold", + "Bilance celkem =(prodej - všechny nákupy) $month" => "SELECT ( SUM(item_price_out) -(SELECT SUM(item_price_in) FROM item WHERE item_valid_till=0$month_sql)