Ignore:
Timestamp:
Oct 28, 2012, 9:32:54 PM (12 years ago)
Author:
chronos
Message:
  • Opraveno: SQL dotazy obsahující odkazy na tabulky Product a StockItem.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/zivnost.php

    r438 r454  
    6565
    6666    // SmallAssets
    67     $DbResult = $this->Database->query('SELECT SUM(Price) FROM Product WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination = 0))');
     67    $DbResult = $this->Database->query('SELECT SUM(SellPrice) FROM StockItem WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination IS NULL))');
    6868    //$Output .= $Database->error;
    6969    $Row = $DbResult->fetch_array();
    7070    $Balance['SmallAssets']['Start'] = $Row[0] + 0;
    71     $DbResult = $this->Database->query('SELECT SUM(Price) FROM Product WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination = 0))');
     71    $DbResult = $this->Database->query('SELECT SUM(SellPrice) FROM StockItem WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination IS NULL))');
    7272    $Row = $DbResult->fetch_array();
    7373    $Balance['SmallAssets']['End'] = $Row[0] + 0;
     
    281281        $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    282282        $Output .= '<tr><th>Název</th><th>Hodnota [Kč]</th><th>Datum zakoupení</th><th>Datum vyřezení</th></tr>';
    283         $DbResult = $this->Database->query('SELECT * FROM Product WHERE Used != 0');
     283        $DbResult = $this->Database->query('SELECT Product.Name AS Name, StockItem.SellPrice AS Price, StockItem.TimeEnlistment AS TimeEnlistment, StockItem.TimeElimination AS TimeElimination '.
     284          'FROM StockItem JOIN Product ON Product.Id = StockItem.Product '.
     285          'WHERE (TimeElimination IS NOT NULL)');
    284286        while($Row = $DbResult->fetch_array())
    285287        {
     
    339341        $Output .= '<strong>Roční přehledy</strong><br/>';
    340342        $Output .= $this->ShowFinanceYears();
    341         $Year = $_GET['year'] * 1;
    342         $Output .= '<a href="?table=Incomes&amp;year='.$Year.'">Příjmy</a><br />';
    343         $Output .= '<a href="?table=Expenses&amp;year='.$Year.'">Výdaje</a><br />';
    344         $Output .= '<a href="?table=Claims&amp;year='.$Year.'">Pohledávky</a><br />';
    345         $Output .= '<a href="?table=Liabilities&amp;year='.$Year.'">Závazky</a><br />';
    346         $Output .= '<a href="?table=Advantages&amp;year='.$Year.'">Zálohy</a><br />';
     343        if(array_key_exists('year', $_GET))
     344        {
     345          $Year = $_GET['year'] * 1;
     346          $Output .= '<a href="?table=Incomes&amp;year='.$Year.'">Příjmy</a><br />';
     347          $Output .= '<a href="?table=Expenses&amp;year='.$Year.'">Výdaje</a><br />';
     348          $Output .= '<a href="?table=Claims&amp;year='.$Year.'">Pohledávky</a><br />';
     349          $Output .= '<a href="?table=Liabilities&amp;year='.$Year.'">Závazky</a><br />';
     350          $Output .= '<a href="?table=Advantages&amp;year='.$Year.'">Zálohy</a><br />';
     351        }
    347352    }
    348353    return($Output);
Note: See TracChangeset for help on using the changeset viewer.