Changeset 156 for www/finance/bills.php


Ignore:
Timestamp:
Feb 17, 2009, 10:00:28 PM (16 years ago)
Author:
george
Message:
  • Opraveno: Některé soubory financí aktualizovány na nové rozvržení tabulek User, Member, Subject.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/finance/bills.php

    r152 r156  
    1111    global $SpecificSymbol;
    1212 
    13     $DbResult = $this->Database->select('finance_bills', '*', 'id='.$BillId);
    14     $Bill = $DbResult->fetch_array();
     13    $DbResult = $this->Database->select('FinanceBills', '*', 'Id='.$BillId);
     14    $Bill = $DbResult->fetch_assoc();
    1515 
    16     $DbResult = $this->Database->select('users', '*', 'id='.$Bill['user_id']);
    17     $User = $DbResult->fetch_array();
     16    $DbResult = $this->Database->select('Subject', '*', 'Id='.$Bill['Subject']);
     17    $Subject = $DbResult->fetch_assoc();
    1818
    1919    $Dodavka = array();
    20     $DbResult = $this->Database->select('finance_bills_items', '*', 'bill_id='.$BillId);
    21     while($Item = $DbResult->fetch_array())
    22     {
    23       $Dodavka[$Item['id']] = $Item;
     20    $DbResult = $this->Database->select('FinanceBillsItems', '*', 'Bill='.$BillId);
     21    while($Item = $DbResult->fetch_assoc())
     22    {
     23      $Dodavka[$Item['Id']] = $Item;
    2424    }
    2525 
     
    4040        '</td><td valign="top">'.
    4141        '<strong>Odběratel:</strong><br>'.
    42         $User['subject_name'].'<br>'.
    43         $User['street'].'<br>'.
    44         $User['psc'].' '.$User['town'].'<br>';
    45         if($User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>';
    46         if($User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>';
     42        $Subject['Name'].'<br>'.
     43        $Subject['AddressStreet'].'<br>'.
     44        $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
     45        if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
     46        if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
    4747        $Output .=
    4848        '</td></tr>'.
     
    5151        '<strong>Platební podmínky:</strong><br>'.
    5252        'Číslo dokladu: '.$Bill['BillCode'].'<br>'.
    53         'Variabilní symbol: '.$User['id'].'<br>'.
     53        'Variabilní symbol: '.$Subject['Id'].'<br>'.
    5454        'Specifický symbol: '.$this->SpecificSymbol.'<br>'.
    5555        'Konstantní symbol:<br>'.
     
    5757        '</td><td valign="top">'.
    5858        '<br>'.
    59         'Datum vystavení: '.HumanDate($Bill['time_create']).'<br>'.
    60         'Datum zdanitel. plnění: '.HumanDate($Bill['time_create']).'<br>'.
    61         'Datum splatnosti: '.HumanDate($Bill['time_due']).'<br>';
    62         if(($Bill['time_from'] != '0000-00-00 00:00:00') and ($Bill['time_to'] != '0000-00-00 00:00:00'))
    63           $Output .= 'Fakturované období: '.HumanDate($Bill['time_from']).' - '.HumanDate($Bill['time_to']).'<br>';
     59        'Datum vystavení: '.HumanDate($Bill['TimeCreate']).'<br>'.
     60        'Datum zdanitel. plnění: '.HumanDate($Bill['TimeCreate']).'<br>'.
     61        'Datum splatnosti: '.HumanDate($Bill['TimeDue']).'<br>';
     62        if(($Bill['TimeFrom'] != '0000-00-00 00:00:00') and ($Bill['TimeTo'] != '0000-00-00 00:00:00'))
     63          $Output .= 'Fakturované období: '.HumanDate($Bill['TimeFrom']).' - '.HumanDate($Bill['TimeTo']).'<br>';
    6464        $Output .= '</td></tr>'.
    6565        '<tr><td colspan="2">'.
     
    7373        foreach($Dodavka as $Polozka)
    7474        {
    75           $Output .= '<tr><td>'.$Polozka['description'].'</td><td align="right">'.$Polozka['quantity'].'</td><td align="right">'.$Polozka['price'].'&nbsp;Kč</td><td align="right">'.($Polozka['quantity'] * $Polozka['price']).'&nbsp;Kč</td></tr>';
    76           $Total += ($Polozka['quantity'] * $Polozka['price']);
     75          $Output .= '<tr><td>'.$Polozka['Description'].'</td><td align="right">'.$Polozka['Quantity'].'</td><td align="right">'.$Polozka['Price'].'&nbsp;Kč</td><td align="right">'.($Polozka['Quantity'] * $Polozka['Price']).'&nbsp;Kč</td></tr>';
     76          $Total += ($Polozka['Quantity'] * $Polozka['Price']);
    7777        }
    7878        $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.'&nbsp;Kč</th></tr>';
     
    9494        '<font size="5"><strong>PŘÍJMOVÝ POKLADNÍ DOKLAD</strong></font><br><br>'.
    9595        'Číslo dokladu: '.$Bill['BillCode'].'<br>'.
    96         'Datum vystavení: '.HumanDate($Bill['time_create']).'<br>'.
     96        'Datum vystavení: '.HumanDate($Bill['TimeCreate']).'<br>'.
    9797        '</td></tr>'.
    9898        '<tr><td colspan="2"><strong>Přijato od:</strong><br>'.
    99         $User['subject_name'].'<br>'.
    100         $User['street'].'<br>'.
    101         $User['psc'].' '.$User['town'].'<br>';
    102         if($User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>';
    103         if($User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>';
     99        $Subject['Name'].'<br>'.
     100        $Subject['AddressStreet'].'<br>'.
     101        $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
     102        if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
     103        if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
    104104        $Total = 0;
    105105                $Description = '';
    106106        foreach($Dodavka as $Polozka)
    107107        {
    108           $Description .= $Polozka['description'].'<br>';
    109           $Total += ($Polozka['quantity'] * $Polozka['price']);
     108          $Description .= $Polozka['Description'].'<br>';
     109          $Total += ($Polozka['Quantity'] * $Polozka['Price']);
    110110        }
    111111        $Output .= '</td></tr>'.
     
    120120  }
    121121
    122   function CreateBill($UserId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type)
    123   {
    124     $this->Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'time_from' => TimeToMysqlDateTime($TimeFrom), 'time_to' => TimeToMysqlDateTime($TimeTo), 'time_due' => TimeToMysqlDateTime($TimeFrom + 15*24*3600), 'BillCode' => $BillCode, 'Type' => 'invoice'));
     122  function CreateBill($SubjectId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type)
     123  {
     124    $this->Database->insert('FinanceBills', array('TimeCreate' => TimeToMysqlDateTime(time()), 'Subject' => $SubjectId, 'TimeFrom' => TimeToMysqlDateTime($TimeFrom), 'TimeTo' => TimeToMysqlDateTime($TimeTo), 'TimeDue' => TimeToMysqlDateTime($TimeFrom + 15*24*3600), 'BillCode' => $BillCode, 'Type' => 'invoice'));
    125125    $BillId = $this->Database->insert_id;
    126126    foreach($Items as $Item)
    127127    {
    128       $this->Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity']));
     128      $this->Database->insert('FinanceBillsItems', array('Bill' => $BillId, 'Description' => $Item['Description'], 'Price' => $Item['Price'], 'Quantity' => $Item['Quantity']));
    129129    }
    130130    //Header('Content-Type: application/pdf');
     
    136136  }
    137137
    138   function CreateIncomeBill($UserId, $Description, $Price, $BillCode)
    139   {
    140     $this->Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income'));
     138  function CreateIncomeBill($SubjectId, $Description, $Price, $BillCode)
     139  {
     140    $this->Database->insert('FinanceBills', array('TimeCreate' => TimeToMysqlDateTime(time()), 'Subject' => $SubjectId, 'BillCode' => $BillCode, 'Type' => 'income'));
    141141    $BillId = $this->Database->insert_id;
    142     $this->Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1));
     142    $this->Database->insert('FinanceBillsItems', array('Bill' => $BillId, 'Description' => $Description, 'Price' => $Price, 'Quantity' => 1));
    143143    //Header('Content-Type: application/pdf');
    144144    $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId));
     
    206206      echo($Row['id']."<br>\n");
    207207      $Time = MysqlDateToTime($Row['date']);
    208       $BillId = $this->CreateBill($Row['user'], array(array('description' => 'Poplatek za připojení k síti', 'price' => (-$Row['money']), 'quantity' => 1)), $Time, $Time + (date("t", time()) - 1) * 24 * 3600); 
     208      $BillId = $this->CreateBill($Row['user'], array(array('Description' => 'Poplatek za připojení k síti', 'Price' => (-$Row['money']), 'Quantity' => 1)), $Time, $Time + (date("t", time()) - 1) * 24 * 3600); 
    209209     $this->Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId));
    210210    }
     
    214214  {
    215215    global $Database;
    216     if(array_key_exists('user', $_GET))
     216    if(array_key_exists('subject', $_GET))
    217217    {
    218218 
    219       $DbResult = $this->Database->select('finance_bills', '*', 'user_id='.$_GET['user']);
     219      $DbResult = $this->Database->select('FinanceBills', '*', 'Subject='.$_GET['subject']);
    220220      while($Item = $DbResult->fetch_array())
    221221      {
    222         echo('<a href="?bill='.$Item['id'].'">faktura '.$Item['id'].'</a> <a href="?billpdf='.$Item['id'].'">Uložené PDF</a> <a href="?billpdf2='.$Item['id'].'">Generované PDF</a> <a href="?regenerate='.$Item['id'].'">Přegenerovat</a><br>');
     222        echo('<a href="?bill='.$Item['Id'].'">faktura '.$Item['Id'].'</a> <a href="?billpdf='.$Item['Id'].'">Uložené PDF</a> <a href="?billpdf2='.$Item['Id'].'">Generované PDF</a> <a href="?regenerate='.$Item['Id'].'">Přegenerovat</a><br>');
    223223      }
    224224    } else
     
    241241    if(array_key_exists('generate', $_GET))
    242242    {
    243       $this->CreateBill(1, array(array('description' => 'Poplatek za připojení k síti', 'price' => 1000, 'quantity' => 1)), time(), time());
     243      $this->CreateBill(1, array(array('Description' => 'Poplatek za připojení k síti', 'Price' => 1000, 'Quantity' => 1)), time(), time());
    244244    } else
    245245    {
    246246      ShowHeader('Doklady', 'Doklady');
    247       echo('Faktury:<br>');
    248       $DbResult = $this->Database->select('users', '*, CONCAT(second_name," ", first_name)  as fullname', '1 ORDER BY fullname');
    249       while($User = $DbResult->fetch_array())
     247      echo('Faktury:<br />');
     248      $DbResult = $this->Database->select('Subject', '*', '1 ORDER BY Name');
     249      while($Subject = $DbResult->fetch_assoc())
    250250      {
    251         echo('<a href="?user='.$User['id'].'">'.$User['fullname'].'</a><br>');
     251        echo('<a href="?user='.$Subject['Id'].'">'.$Subject['Name'].'</a><br />');
    252252      }
    253253      ShowFooter();
Note: See TracChangeset for help on using the changeset viewer.