Changeset 156 for www/finance/manage.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/manage.php

    r152 r156  
    6363  {
    6464    $Output = '';
    65     if(array_key_exists('user', $_GET))
    66     {
    67       $DbResult = $this->Database->select('finance_bills', '*', 'user_id='.$_GET['user']);
     65    if(array_key_exists('subject', $_GET))
     66    {
     67      $DbResult = $this->Database->select('FinanceBills', '*', 'Subject='.$_GET['subject']);
    6868      while($Item = $DbResult->fetch_array())
    6969      {
    70         $Output .= '<a href="?Operation=Bills&amp;bill='.$Item['id'].'">faktura '.$Item['id'].'</a> <a href="?Operation=Bills&amp;billpdf='.$Item['id'].'">Uložené PDF</a> <a href="?Operation=Bills&amp;billpdf2='.$Item['id'].'">Generované PDF</a> <a href="?Operation=Bills&amp;regenerate='.$Item['id'].'">Přegenerovat</a><br />';
     70        $Output .= '<a href="?Operation=Bills&amp;bill='.$Item['Id'].'">faktura '.$Item['Id'].'</a> <a href="?Operation=Bills&amp;billpdf='.$Item['Id'].'">Uložené PDF</a> <a href="?Operation=Bills&amp;billpdf2='.$Item['Id'].'">Generované PDF</a> <a href="?Operation=Bills&amp;regenerate='.$Item['Id'].'">Přegenerovat</a><br />';
    7171      }
    7272    } else
     
    8989    if(array_key_exists('generate', $_GET))
    9090    {
    91       $Output .= $this->System->Modules['Bill']->CreateBill(1, array(array('description' => 'Poplatek za připojení k síti', 'price' => 1000, 'quantity' => 1)), time(), time());
     91      $Output .= $this->System->Modules['Bill']->CreateBill(1, array(array('Description' => 'Poplatek za připojení k síti', 'Price' => 1000, 'Quantity' => 1)), time(), time());
    9292    } else
    9393    {
    9494      //ShowHeader('Faktury', 'Faktury');
    9595      $Output .= 'Faktury:<br />';
    96       $DbResult = $this->Database->select('users', '*, CONCAT(second_name," ", first_name)  as fullname', '1 ORDER BY fullname');
    97       while($User = $DbResult->fetch_array())
    98       {
    99         $Output .= '<a href="?Operation=Bills&amp;user='.$User['id'].'">'.$User['fullname'].'</a><br />';
     96      $DbResult = $this->Database->select('Subject', '*', '1 ORDER BY Name');
     97      while($Subject = $DbResult->fetch_array())
     98      {
     99        $Output .= '<a href="?Operation=Bills&amp;subject='.$Subject['Id'].'">'.$Subject['Name'].'</a><br />';
    100100      }
    101101      //ShowFooter();
     
    133133    if($TimePayment != '') $TimePayment = TimeToMysqlDateTime($TimePayment);
    134134    $this->Database->insert('FinanceClaimsLiabilities', array('Text' => $Text, 'Subject' => $Subject, 'TimeCreation' => TimeToMysqlDateTime($Time), 'TimeDue' => TimeToMysqlDateTime($Time + 3600*24*15), 'TimePayment' => $TimePayment, 'Value' => $Value, 'Bill' => $BillId));
    135     $Output = $this->Database->LastQuery.'<br />';
     135    $Output = '.'; //$this->Database->LastQuery.'<br />';
    136136    $LastInsertTime = $Time;
    137137    $this->CheckAdvancesAndLiabilities($Subject);
     
    227227  function ImportOldData()
    228228  {
    229     global $InvoiceGenerator;
    230 
    231229    $Output = '';
    232230    $this->Database->query('TRUNCATE TABLE FinanceCashFlow');
     
    239237
    240238    // Transfer finance before era
    241     $DbResult = $this->Database->query('SELECT * FROM users WHERE role=2');
    242     while($User = $DbResult->fetch_array())
    243     {
    244       $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$User['id'].' AND date < "2007-12-01"');
    245       $Row = $DbResult2->fetch_array();
     239    $DbResult = $this->Database->query('SELECT * FROM Subject');
     240    while($Subject = $DbResult->fetch_assoc())
     241    {
     242      $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$Subject['Id'].' AND date < "2007-12-01"');
     243      $Row = $DbResult2->fetch_row();
    246244      $TotalAdvance = $Row[0];
    247245      //echo($User['second_name'].' '.$User['first_name'].' '.$TotalAdvance.'<br>');
     
    249247      if($TotalAdvance > 0)
    250248      {
    251         $this->InsertMoney($User['id'], $TotalAdvance, 0, 1, mktime(0, 0, 0, 12, 1, 2007), 'Přijatá záloha (z období před daňovou evidencí)');
     249        $this->InsertMoney($Subject['Id'], $TotalAdvance, 0, 1, mktime(0, 0, 0, 12, 1, 2007), 'Přijatá záloha (z období před daňovou evidencí)');
    252250      }
    253251      // Dluh
    254252      if($TotalAdvance < 0)
    255253      {
    256         $this->InsertLiability($User['id'], (-$Row[0]), mktime(0, 0, 0, 12, 1, 2007), 0, 'Připojení k síti (z období před daňovou evidencí)');
     254        $this->InsertLiability($Subject['Id'], (-$Row[0]), mktime(0, 0, 0, 12, 1, 2007), 0, 'Připojení k síti (z období před daňovou evidencí)');
    257255        //echo($Database->LastQuery.'<br>');
    258256      }
     
    263261    //  while($User = $DbResult->fetch_array())
    264262    //  {
    265     $DbResult2 = $this->Database->query('SELECT finance_operations.*, users.role as role FROM finance_operations JOIN users ON users.id = finance_operations.user WHERE finance_operations.date >= "2007-12-01"');
    266     while($Operation = $DbResult2->fetch_array())
     263    $DbResult2 = $this->Database->query('SELECT finance_operations.* FROM finance_operations JOIN Subject ON Subject.Id = finance_operations.user WHERE finance_operations.date >= "2007-12-01"');
     264    while($Operation = $DbResult2->fetch_assoc())
    267265    {
    268266      //echo($Operation['comment'].'<br>');
     
    288286      } else
    289287      {
    290         $DbResult = $this->Database->query('SELECT role FROM users WHERE id='.$Operation['user']);
     288        $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$Operation['user']);
    291289        while($User = $DbResult->fetch_array())
    292290        $this->InsertLiability($Operation['user'], -$Operation['money'], MysqlDateToTime($Operation['date']), $Operation['bill_id'], $Operation['comment'], MysqlDateToTime($Operation['date']));
    293291        $Output .= $Operation['user'].' '.$Operation['comment'].' '.MysqlDateToTime($Operation['date']).'<br />';
    294292
    295         if(($Operation['role'] == 2))
    296         {
     293//        if(($Operation['role'] == 2))
     294       // {
    297295          $Output .= 'A';
    298296          $this->Database->insert('FinanceAdvances', array('Subject' => $Operation['user'], 'Value' => $Operation['money'], 'TimeCreation' => MysqlDateToTime($Operation['date']), 'CashFlowId' => 0, 'Direction' => 'In'));
    299297          $this->CheckAdvancesAndLiabilities($Operation['user']);
    300         } else InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), $Operation['comment']);
     298        //} else InsertMoney($Operation['user'], $Operation['money'], 0, 1, MysqlDateToTime($Operation['date']), $Operation['comment']);
    301299      }
    302300    }
     
    314312    {
    315313      //$Database->insert('FinanceSmallAsset', array());
    316       $Items[] = array('description' => $Device['name'], 'quantity' => $Device['count'], 'price' => 0); //$Device['price']);
     314      $Items[] = array('Description' => $Device['name'], 'Quantity' => $Device['count'], 'Price' => 0); //$Device['price']);
    317315      $LastId = $Device['id'];
    318316      $TotalPrice += $Device['price'] * $Device['count'];
     
    320318    }
    321319    //print_r($Items);
    322     $BillId = $InvoiceGenerator->CreateBill($Subject, $Items, $Time, $Time);
     320    $BillId = $this->System->Modules['Bill']->CreateBill($Subject, $Items, $Time, $Time);
    323321    $DbResult = $this->Database->query('UPDATE network_devices SET TimeEnlistment = "'.TimeToMysqlDateTime($Time).'" WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id <> 73) AND (id <= '.$LastId.')');
    324322    //echo($Database->error);
     
    336334    {
    337335      // $Database->insert('FinanceSmallAsset', array());
    338       $Items[] = array('description' => $Device['name'], 'quantity' => $Device['count'], 'price' => 0); //$Device['price']);
     336      $Items[] = array('Description' => $Device['name'], 'Quantity' => $Device['count'], 'Price' => 0); //$Device['price']);
    339337      $TotalPrice += $Device['price'] * $Device['count'];
    340338    }
    341339    //print_r($Items);
    342     $BillId = $InvoiceGenerator->CreateBill($Subject, $Items, $Time, $Time);
     340    $BillId = $this->System->Modules['Bill']->CreateBill($Subject, $Items, $Time, $Time);
    343341    $DbResult = $this->Database->query('UPDATE network_devices SET TimeEnlistment = "'.TimeToMysqlDateTime($Time).'" WHERE used <> 0 AND date < "'.TimeToMysqlDateTime($Time).'" AND (id > '.$LastId.')');
    344342    $this->InsertLiability($Subject, 0, $Time, $BillId, 'Nákup infrastruktury', $Time);
     
    354352  function ConvertPDFDataToFiles()
    355353  {
    356     $DbResult = $this->Database->query('SELECT * FROM finance_bills');
     354    $DbResult = $this->Database->query('SELECT * FROM FinanceBills');
    357355    while($Bill = $DbResult->fetch_array())
    358356    {
     
    366364    global $Database, $InvoiceGenerator;
    367365
    368     $DbResult = $this->Database->query('SELECT * FROM finance_bills');
     366    $DbResult = $this->Database->query('SELECT * FROM FinanceBills');
    369367    while($Bill = $DbResult->fetch_array())
    370368    {
Note: See TracChangeset for help on using the changeset viewer.