Changeset 156 for www


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.
Location:
www
Files:
1 added
7 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();
  • www/finance/index.php

    r153 r156  
    1414    $Output = '<table><tr><td valign="top">';
    1515
    16     $Output .= '<table><tr><td width="30%">';
    17         if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php">Vaše finanční operace (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).</a><br /><br /><br />';
     16    if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />';
    1817       
    1918    $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />';
     
    2524    //$Output .= '<a href="faktury/">Faktury za internet</a><br />';
    2625    //$Output .= '<a href="inventory.php">Výpis skladových zásob</a><br />';
    27     $Output .= '</td><td width="50%">';
    28 
    29     $Output .= '</td></tr></table><br />';
    30 
    31     $Output .= '<strong>Souhrn:</strong><br />';
     26   
     27    $Output .= '<br /><strong>Souhrn:</strong><br />';
    3228
    3329    $DbResult = $this->Database->query("SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1");
  • 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    {
  • www/finance/monthly_overall.php

    r152 r156  
    1313
    1414    $Output = '<table cellspacing="0" cellpadding="2" border="1"><tr><th>Rok</th><th>Měsíc</th><th>Internet [Kč]</th><th>Účastníků</th><th>Správa [Kč/účastníka]</th><th>Správa [Kč]</th><th>Spotřeba [Kč/kWh]</th><th>Spotřeba [Kč]</th><th>Obrat [Kč]</th><th>Průměrná cena [Kč/účastníka]</th><th align="center">Investice [Kč]</th></tr>';
    15     $Total = array('money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0);
     15    $Total = array('money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0, 'investment' => 0);
    1616    $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC');
    1717    while($Month = $DbResult->fetch_array())
    1818    {
    1919      $DateParts = explode('-', $Month['date']);
    20       $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'.$MonthNames[$DateParts[1]*1].'</td><td align="center">'.$Month['money'].'</td><td align="center">'.$Month['member_count'].'</td><td align="center">'.$Month['administration'].'</td><td align="center">'.$Month['administration_total'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['consumption_total'].'</td><td align="center">'.$Month['total_paid'].'</td><td align="center">'.round($Month['total_paid'] / $Month['member_count']).'</td><td align="center">'.$Month['investment'].'</td></tr>';
     20      $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'.$MonthNames[$DateParts[1] * 1].'</td><td align="center">'.$Month['money'].'</td><td align="center">'.$Month['member_count'].'</td><td align="center">'.$Month['administration'].'</td><td align="center">'.$Month['administration_total'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['consumption_total'].'</td><td align="center">'.$Month['total_paid'].'</td><td align="center">'.round($Month['total_paid'] / $Month['member_count']).'</td><td align="center">'.$Month['investment'].'</td></tr>';
    2121
    2222      $Total['money'] += $Month['money'];
  • www/finance/user_state.php

    r154 r156  
    1818    $UserId = $this->System->Modules['User']->User['Id'];
    1919    if(!array_key_exists('show', $_GET)) $_GET['show'] = '';
    20     $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User='.$UserId.'))');
    21     $Row2 = $DbResult->fetch_array();
    22     $TarifName = $Tarify[$Row2['inet_tarif_next']]['name'];
     20    $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))');
     21    $Subject = $DbResult->fetch_assoc();
     22    $DbResult = $this->Database->query('SELECT InternetTariffCurrentMonth FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.')');
     23    $Member = $DbResult->fetch_assoc();
     24    $TarifName = $Tarify[$Member['InternetTariffCurrentMonth']]['name'];
     25        $TarifPrice = $Tarify[$Member['InternetTariffCurrentMonth']]['price'];
    2326    $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">';
    2427
    2528    // Tabulka operaci
    26     $Output .= 'Výpis operací pro účastníka '.$Row2['Name'].':<br>';
     29    $DbResult = $this->Database->query('SELECT CONCAT(SecondName, " ", FirstName) as Name FROM User WHERE Id='.$UserId);
     30    $User = $DbResult->fetch_assoc();
     31    $Output .= 'Výpis operací pro účastníka '.$User['Name'].':<br>';
    2732    $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>';
    2833    $Operations = array();
    29     $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$UserId.') UNION ALL '.
    30       '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$UserId.') ORDER BY Time DESC');
     34    $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') UNION ALL '.
     35      '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].') ORDER BY Time DESC');
    3136    while($DbRow = $DbResult->fetch_array())
    3237      $Operations[] = $DbRow;
     
    4045    //echo('<tr><td>&nbsp;</td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr>
    4146    $Output .= '</table>';
    42     $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$UserId.') + '.
    43       '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$UserId.')) as Total');
     47    $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') + '.
     48      '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].')) as Total');
    4449    $DbRow = $DbResult->fetch_array();
    4550    $Total = $DbRow['Total'];
     
    4752    $Output .= '</td><td valign="top">';
    4853
    49     if($Row2['role'] == 2)
     54    $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>';
     55
     56    $DbResult = $this->Database->query('SELECT SUM(consumption) AS Total FROM network_devices WHERE user='.$UserId.' AND used=1');
     57        $ConsumptionBonus = $DbResult->fetch_assoc();
     58        $ConsumptionBonus = W2Kc($ConsumptionBonus['Total']);
     59
     60        $Total = 0;
     61    $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
     62      '<tr><th>Část</th><th>Cena [Kč]</th></tr>'.
     63      '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>';
     64        $Total += $TarifPrice;
     65        if($ConsumptionBonus != 0)
     66      $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$ConsumptionBonus)  .'</td></tr>';
     67        $Total += -$ConsumptionBonus;
     68    $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>';
     69    //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>');
     70    $Output .= '<br />';
     71   
     72    if($ConsumptionBonus != 0)
    5073    {
    51       $Output .= 'Variabilní symbol pro platby: <strong>'.$Row2['id'].'</strong><br><br>';
    52 
    53       // Měsíční bilance
    54       if($Row2['inet'] == 1) $InternetPrice = round($Row2['monthly_inet']); else $InternetPrice = 0;
    55       if($Row2['overheads'] == 0)
    56       {
    57         $PoplatekSprava = 0;
    58         $PoplatekSpotreba = 0;
    59         $PrijemSpotreba = $Row2['plus'];
    60       } else {
    61         $PoplatekSprava = $Sprava;
    62         $PoplatekSpotreba = $Row2['consumption'];
    63         $PrijemSpotreba = $Row2['plus'];
    64       }
    65       $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
    66       '<tr><th>Část</th><th>Cena [Kč]</th></tr>'.
    67       '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$InternetPrice.'</td></tr>'.
    68       //'<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'.
    69       //'<tr><td>Poplatek za spotřebu</td><td>'.$PoplatekSpotreba.'</td></tr>'.
    70       '<tr><td>Příjem za spotřebu</td><td>'.(-1*$PrijemSpotreba)  .'</td></tr>'.
    71       '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice // + $PoplatekSprava + $PoplatekSpotreba
    72         - $PrijemSpotreba).'</strong></td></tr></table>';
    73       //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>');
    74       $Output .= '<br>';
    75    
    76     /*
    77 
    78     // Rozpis ceny za zařízení
    79     echo('Výpis podílu na zařízení segmentů:');
    80     echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>');
    81     $ID = $Row2['network_segment'];
    82     $Money = 0;
    83     while($ID > 0)
    84     {
    85       $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID);
    86       $Row = $DbResult->fetch_array();
    87       if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId)))
    88       {     
    89         $Money += $Row['price']/$Row['users'];
    90         echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].'&nbsp;</td><td>'.round($Row['price']/$Row['users']).'</td></tr>');
    91       }
    92       $ID = $Row['parent'];
    93     }
    94     echo('<tr><td><strong>Celkem</strong></td><td>&nbsp;</td><td>&nbsp;</td><td><strong>'.round($Money).'</strong></td></tr>');
    95     echo('</table><br>');
    96 
    97     // Rozpis platba spotřeby segmentů
    98     echo('Výpis podílu na spotřebě segmentů:');
    99     echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>');
    100     $ID = $Row2['network_segment'];
    101     $Money = 0;
    102     while($ID>0)
    103     {
    104       $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID);
    105       $Row = $DbResult->fetch_array();
    106       $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']);
    107       echo('<tr><td>'.$Row['name'].'</td><td>'.W2Kc($Row['consumption']).'</td><td>'.$Row['users_overheads'].'&nbsp;</td><td>'.round(W2Kc($Row['consumption'])/$Row['users_overheads']).'</td></tr>');
    108       $ID = $Row['parent'];
    109     }
    110     echo('<tr><td><strong>Celkem</strong></td><td>&nbsp;</td><td>&nbsp;</td><td><strong>'.round($Money).'</strong></td></tr>');
    111     echo('</table><br>');
    112     */
    113 
    114       $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>';
     74          $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>';
    11575      $Output .= '<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>';
    116       $DbResult = $this->Database->query("SELECT * FROM network_devices WHERE user=".$UserId." AND used=1");
     76      $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE user='.$UserId.' AND used=1');
    11777      $TotalW = 0;
    11878      $TotalPrice = 0;
    119       while($Row = $DbResult->fetch_array())
     79      while($Row = $DbResult->fetch_assoc())
    12080      {
    12181        $Output .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>';
     
    12585      $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>';
    12686      $Output .= '</table>';
    127     }
     87        }
    12888    $Output .= '</td></tr></table>';
    12989    return($Output);
    13090  }
    131 
    13291}
    13392
  • www/finance/user_state_ip.php

    r154 r156  
    1414    global $Tarify, $Sprava;
    1515
    16     if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
     16        $UserId = GetMemberByIP(GetRemoteAddress());
    1717
    18     //$UserId = $this->System->Modules['User']->User['Id'];
    19         $UserId = GetMemberByIP(GetRemoteAddress());
    20     if(!array_key_exists('show',$_GET)) $_GET['show'] = '';
    21     $DbResult = $this->Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE id=".$UserId);
    22     $Row2 = $DbResult->fetch_array();
    23     $TarifName = $Tarify[$Row2['inet_tarif_next']]['name'];
     18    if(!array_key_exists('show', $_GET)) $_GET['show'] = '';
     19    $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))');
     20    $Subject = $DbResult->fetch_assoc();
     21    $DbResult = $this->Database->query('SELECT InternetTariffCurrentMonth FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.')');
     22    $Member = $DbResult->fetch_assoc();
     23    $TarifName = $Tarify[$Member['InternetTariffCurrentMonth']]['name'];
     24        $TarifPrice = $Tarify[$Member['InternetTariffCurrentMonth']]['price'];
    2425    $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">';
    2526
    2627    // Tabulka operaci
    27     $Output .= 'Výpis operací pro účastníka '.$Row2['fullname'].':<br>';
     28    $DbResult = $this->Database->query('SELECT CONCAT(SecondName, " ", FirstName) as Name FROM User WHERE Id='.$UserId);
     29    $User = $DbResult->fetch_assoc();
     30    $Output .= 'Výpis operací pro účastníka '.$User['Name'].':<br>';
    2831    $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>';
    2932    $Operations = array();
    30     $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$UserId.') UNION ALL '.
    31       '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$UserId.') ORDER BY Time DESC');
     33    $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') UNION ALL '.
     34      '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].') ORDER BY Time DESC');
    3235    while($DbRow = $DbResult->fetch_array())
    3336      $Operations[] = $DbRow;
     
    4144    //echo('<tr><td>&nbsp;</td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr>
    4245    $Output .= '</table>';
    43     $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$UserId.') + '.
    44       '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$UserId.')) as Total');
     46    $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') + '.
     47      '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].')) as Total');
    4548    $DbRow = $DbResult->fetch_array();
    4649    $Total = $DbRow['Total'];
     
    4851    $Output .= '</td><td valign="top">';
    4952
    50     if($Row2['role'] == 2)
     53    $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>';
     54
     55    $DbResult = $this->Database->query('SELECT SUM(consumption) AS Total FROM network_devices WHERE user='.$UserId.' AND used=1');
     56        $ConsumptionBonus = $DbResult->fetch_assoc();
     57        $ConsumptionBonus = W2Kc($ConsumptionBonus['Total']);
     58
     59        $Total = 0;
     60    $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
     61      '<tr><th>Část</th><th>Cena [Kč]</th></tr>'.
     62      '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>';
     63        $Total += $TarifPrice;
     64        if($ConsumptionBonus != 0)
     65      $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$ConsumptionBonus)  .'</td></tr>';
     66        $Total += -$ConsumptionBonus;
     67    $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>';
     68    //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>');
     69    $Output .= '<br />';
     70   
     71    if($ConsumptionBonus != 0)
    5172    {
    52       $Output .= 'Variabilní symbol pro platby: <strong>'.$Row2['id'].'</strong><br><br>';
    53 
    54       // Měsíční bilance
    55       if($Row2['inet'] == 1) $InternetPrice = round($Row2['monthly_inet']); else $InternetPrice = 0;
    56       if($Row2['overheads'] == 0)
    57       {
    58         $PoplatekSprava = 0;
    59         $PoplatekSpotreba = 0;
    60         $PrijemSpotreba = $Row2['plus'];
    61       } else {
    62         $PoplatekSprava = $Sprava;
    63         $PoplatekSpotreba = $Row2['consumption'];
    64         $PrijemSpotreba = $Row2['plus'];
    65       }
    66       $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
    67       '<tr><th>Část</th><th>Cena [Kč]</th></tr>'.
    68       '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$InternetPrice.'</td></tr>'.
    69       //'<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'.
    70       //'<tr><td>Poplatek za spotřebu</td><td>'.$PoplatekSpotreba.'</td></tr>'.
    71       '<tr><td>Příjem za spotřebu</td><td>'.(-1*$PrijemSpotreba)  .'</td></tr>'.
    72       '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice // + $PoplatekSprava + $PoplatekSpotreba
    73         - $PrijemSpotreba).'</strong></td></tr></table>';
    74       //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>');
    75       $Output .= '<br>';
    76    
    77     /*
    78 
    79     // Rozpis ceny za zařízení
    80     echo('Výpis podílu na zařízení segmentů:');
    81     echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>');
    82     $ID = $Row2['network_segment'];
    83     $Money = 0;
    84     while($ID > 0)
    85     {
    86       $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID);
    87       $Row = $DbResult->fetch_array();
    88       if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId)))
    89       {     
    90         $Money += $Row['price']/$Row['users'];
    91         echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].'&nbsp;</td><td>'.round($Row['price']/$Row['users']).'</td></tr>');
    92       }
    93       $ID = $Row['parent'];
    94     }
    95     echo('<tr><td><strong>Celkem</strong></td><td>&nbsp;</td><td>&nbsp;</td><td><strong>'.round($Money).'</strong></td></tr>');
    96     echo('</table><br>');
    97 
    98     // Rozpis platba spotřeby segmentů
    99     echo('Výpis podílu na spotřebě segmentů:');
    100     echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>');
    101     $ID = $Row2['network_segment'];
    102     $Money = 0;
    103     while($ID>0)
    104     {
    105       $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID);
    106       $Row = $DbResult->fetch_array();
    107       $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']);
    108       echo('<tr><td>'.$Row['name'].'</td><td>'.W2Kc($Row['consumption']).'</td><td>'.$Row['users_overheads'].'&nbsp;</td><td>'.round(W2Kc($Row['consumption'])/$Row['users_overheads']).'</td></tr>');
    109       $ID = $Row['parent'];
    110     }
    111     echo('<tr><td><strong>Celkem</strong></td><td>&nbsp;</td><td>&nbsp;</td><td><strong>'.round($Money).'</strong></td></tr>');
    112     echo('</table><br>');
    113     */
    114 
    115       $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>';
     73          $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>';
    11674      $Output .= '<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>';
    117       $DbResult = $this->Database->query("SELECT * FROM network_devices WHERE user=".$UserId." AND used=1");
     75      $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE user='.$UserId.' AND used=1');
    11876      $TotalW = 0;
    11977      $TotalPrice = 0;
    120       while($Row = $DbResult->fetch_array())
     78      while($Row = $DbResult->fetch_assoc())
    12179      {
    12280        $Output .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>';
     
    12684      $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>';
    12785      $Output .= '</table>';
    128     }
     86        }
    12987    $Output .= '</td></tr></table>';
    13088    return($Output);
    13189  }
    132 
    13390}
    13491
  • www/form_classes.php

    r154 r156  
    120120  'TFinanceSubject' => array(
    121121    'Type' => 'Reference',
    122     'Table' => 'User',
    123     'Id' => 'id',
    124     'Name' => 'CONCAT(SecondName, " ", FirstName)',
    125     'Filter' => 'role=2',
     122    'Table' => 'Subject',
     123    'Id' => 'Id',
     124    'Name' => 'Name',
     125    'Filter' => '1',
    126126  ),
    127127  'TNetworkDevice' => array(
Note: See TracChangeset for help on using the changeset viewer.