Changeset 152 for www/finance/bills.php


Ignore:
Timestamp:
Feb 16, 2009, 2:09:57 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Další soubory přepracované do nového systému zobrazování.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/finance/bills.php

    r151 r152  
    11<?php
    22
    3 class InvoiceGenerator
     3class Bill extends Module
    44{
    55  var $SpecificSymbol = 1; // počítačová sít
     
    99  function GenerateBill($BillId)
    1010  {
    11     global $Database, $SpecificSymbol;
     11    global $SpecificSymbol;
    1212 
    13     $DbResult = $Database->select('finance_bills', '*', 'id='.$BillId);
     13    $DbResult = $this->Database->select('finance_bills', '*', 'id='.$BillId);
    1414    $Bill = $DbResult->fetch_array();
    1515 
    16     $DbResult = $Database->select('users', '*', 'id='.$Bill['user_id']);
     16    $DbResult = $this->Database->select('users', '*', 'id='.$Bill['user_id']);
    1717    $User = $DbResult->fetch_array();
    1818
    1919    $Dodavka = array();
    20     $DbResult = $Database->select('finance_bills_items', '*', 'bill_id='.$BillId);
     20    $DbResult = $this->Database->select('finance_bills_items', '*', 'bill_id='.$BillId);
    2121    while($Item = $DbResult->fetch_array())
    2222    {
     
    122122  function CreateBill($UserId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type)
    123123  {
    124     global $Database;
    125  
    126     $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'));
    127     $BillId = $Database->insert_id;
     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'));
     125    $BillId = $this->Database->insert_id;
    128126    foreach($Items as $Item)
    129127    {
    130       $Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity']));
     128      $this->Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity']));
    131129    }
    132130    //Header('Content-Type: application/pdf');
     
    134132    //echo($PdfData);
    135133    file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData);
    136     //$Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);
     134    //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);
    137135    return($BillId);
    138136  }
     
    140138  function CreateIncomeBill($UserId, $Description, $Price, $BillCode)
    141139  {
    142     global $Database;
    143  
    144     $Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income'));
    145     $BillId = $Database->insert_id;
    146     $Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1));
     140    $this->Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income'));
     141    $BillId = $this->Database->insert_id;
     142    $this->Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1));
    147143    //Header('Content-Type: application/pdf');
    148144    $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId));
    149145    //echo($PdfData);
    150146    file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData);
    151     //$Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);
     147    //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);
    152148    return($BillId);
    153149  }
     
    160156    //echo($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf');
    161157    echo(file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData));
    162     //$Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);
     158    //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);
    163159  }
    164160
     
    167163    global $Database;
    168164   
    169     //$DbResult = $Database->select('finance_bills', 'pdf', 'id='.$BillId);
     165    //$DbResult = $this->Database->select('finance_bills', 'pdf', 'id='.$BillId);
    170166    //if($DbResult->num_rows == 1)
    171167    //{
     
    204200    global $Database;
    205201   
    206     $DbResult = $Database->select('finance_operations', '*', '(date="2008-02-01" AND comment="Poplatek za měsíc Únor") OR '.
     202    $DbResult = $this->Database->select('finance_operations', '*', '(date="2008-02-01" AND comment="Poplatek za měsíc Únor") OR '.
    207203    '(date="2008-01-01" AND comment="Poplatek za měsíc Leden") OR (date="2007-12-01" AND comment="Poplatek za měsíc Prosinec") AND (bill_id = 0)');
    208204    while($Row = $DbResult->fetch_array())
     
    211207      $Time = MysqlDateToTime($Row['date']);
    212208      $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); 
    213      $Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId));
     209     $this->Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId));
    214210    }
    215211  }
     
    221217    {
    222218 
    223       $DbResult = $Database->select('finance_bills', '*', 'user_id='.$_GET['user']);
     219      $DbResult = $this->Database->select('finance_bills', '*', 'user_id='.$_GET['user']);
    224220      while($Item = $DbResult->fetch_array())
    225221      {
     
    250246      ShowHeader('Doklady', 'Doklady');
    251247      echo('Faktury:<br>');
    252       $DbResult = $Database->select('users', '*, CONCAT(second_name," ", first_name)  as fullname', '1 ORDER BY fullname');
     248      $DbResult = $this->Database->select('users', '*, CONCAT(second_name," ", first_name)  as fullname', '1 ORDER BY fullname');
    253249      while($User = $DbResult->fetch_array())
    254250      {
     
    260256}
    261257
    262 $InvoiceGenerator = new InvoiceGenerator;
    263 
    264258?>
Note: See TracChangeset for help on using the changeset viewer.