- Timestamp:
- Jan 10, 2009, 4:29:49 PM (16 years ago)
- Location:
- www/finance
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/bills.php
r129 r133 5 5 { 6 6 var $SpecificSymbol = 1; // počítačová sít 7 var $FileFolder = 'doklady'; 8 var $FileNamePrefix = 'doklad-'; 7 9 8 10 function GenerateBill($BillId) … … 30 32 'Zděchov 208<br>'. 31 33 '75607 Zděchov<br>'. 32 'IČ O: 75904535<br>'.34 'IČ: 75904535<br>'. 33 35 'DIČ: CZ8303255884<br>'. 34 36 'Účet: 218098370 / 0300<br>'. 35 'Ne jsemplátce DPH<br>'.37 'Neplátce DPH<br>'. 36 38 '</td><td valign="top">'. 37 39 '<strong>Odběratel:</strong><br>'. … … 46 48 '<tr><td width="50%" valign="top">'. 47 49 '<strong>Platební podmínky:</strong><br>'. 48 'Číslo dokladu: '.$Bill[' id'].'<br>'.50 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 49 51 'Variabilní symbol: '.$User['id'].'<br>'. 50 52 'Specifický symbol: '.$this->SpecificSymbol.'<br>'. … … 54 56 '<br>'. 55 57 'Datum vystavení: '.HumanDate($Bill['time_create']).'<br>'. 56 'Datum splatnosti: '.HumanDate($Bill['time_due']).'<br>'. 57 'Fakturované období: '.HumanDate($Bill['time_from']).' - '.HumanDate($Bill['time_to']).'<br>'. 58 '</td></tr>'. 58 'Datum zdanitel. plnění: '.HumanDate($Bill['time_create']).'<br>'. 59 'Datum splatnosti: '.HumanDate($Bill['time_due']).'<br>'; 60 if(($Bill['time_from'] != '0000-00-00 00:00:00') and ($Bill['time_to'] != '0000-00-00 00:00:00')) 61 $Output .= 'Fakturované období: '.HumanDate($Bill['time_from']).' - '.HumanDate($Bill['time_to']).'<br>'; 62 $Output .= '</td></tr>'. 59 63 '<tr><td colspan="2">'. 60 64 '<hr>'. … … 67 71 foreach($Dodavka as $Polozka) 68 72 { 69 $Output .= '<tr><td>'.$Polozka['description'].'</td><td align="right">'.$Polozka['quantity'].'</td><td align="right">'.$Polozka['price'].' Kč</td><td align="right">'.($Polozka['quantity'] * $Polozka['price']).'Kč</td></tr>';73 $Output .= '<tr><td>'.$Polozka['description'].'</td><td align="right">'.$Polozka['quantity'].'</td><td align="right">'.$Polozka['price'].' Kč</td><td align="right">'.($Polozka['quantity'] * $Polozka['price']).' Kč</td></tr>'; 70 74 $Total += ($Polozka['quantity'] * $Polozka['price']); 71 75 } 72 $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.' 76 $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.' Kč</th></tr>'; 73 77 $Output .= '</table>'. 74 78 '</td></tr>'. … … 79 83 } 80 84 81 function CreateBill($UserId, $Items, $TimeFrom, $TimeTo )82 { 83 global $Database; 84 85 $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) ));85 function CreateBill($UserId, $Items, $TimeFrom, $TimeTo, $BillCode) 86 { 87 global $Database; 88 89 $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)); 86 90 $BillId = $Database->insert_id; 87 91 foreach($Items as $Item) … … 92 96 $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId)); 93 97 //echo($PdfData); 94 $Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 98 file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData); 99 //$Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 95 100 return($BillId); 96 101 } … … 101 106 102 107 $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId)); 103 $Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 108 //echo($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf'); 109 echo(file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData)); 110 //$Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 104 111 } 105 112 … … 108 115 global $Database; 109 116 110 $DbResult = $Database->select('finance_bills', 'pdf', 'id='.$BillId); 111 if($DbResult->num_rows == 1) 112 { 113 $DbRow = $DbResult->fetch_array(); 117 //$DbResult = $Database->select('finance_bills', 'pdf', 'id='.$BillId); 118 //if($DbResult->num_rows == 1) 119 //{ 120 // $DbRow = $DbResult->fetch_array(); 121 $FileName = $this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf'; 122 if(file_exists($FileName)) 123 { 114 124 Header('Content-Type: application/pdf'); 115 Header('Content-Disposition: attachment; filename=" faktura-'.$BillId.'.pdf"');116 echo( $DbRow['pdf']);125 Header('Content-Disposition: attachment; filename="'.$this->FileNamePrefix.$BillId.'.pdf"'); 126 echo(file_get_contents($FileName)); 117 127 } else echo('Faktura nenalezena'); 118 128 } … … 123 133 124 134 Header('Content-Type: application/pdf'); 125 Header('Content-Disposition: attachment; filename=" faktura-'.$BillId.'.pdf"');135 Header('Content-Disposition: attachment; filename="'.$this->FileNamePrefix.$BillId.'.pdf"'); 126 136 echo($this->HtmlToPdf($this->GenerateBill($BillId))); 137 } 138 139 function HasPDFFile($BillId) 140 { 141 return(file_exists($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf')); 127 142 } 128 143 -
www/finance/include.php
r50 r133 120 120 } 121 121 122 function GetNextDocumentLineNumber($Id) 123 { 124 global $Database; 125 126 $DbResult = $Database->query('SELECT Shortcut, NextNumber FROM DocumentLine WHERE Id='.$Id); 127 $DbRow = $DbResult->fetch_assoc(); 128 $Result = $DbRow['Shortcut'].$DbRow['NextNumber']; 129 $Database->query('UPDATE DocumentLine SET NextNumber = NextNumber + 1 WHERE Id='.$Id); 130 return($Result); 131 } 132 122 133 ?> -
www/finance/manage.php
r76 r133 225 225 while($Bill = $DbResult->fetch_array()) 226 226 { 227 file_put_contents('doklady/ Doklad'.$Bill['id'].'.pdf', $Bill['pdf']);227 file_put_contents('doklady/doklad-'.$Bill['id'].'.pdf', $Bill['pdf']); 228 228 echo($Bill['id'].','); 229 229 } … … 231 231 } 232 232 233 ConvertPDFDataToFiles(); 234 235 //ImportOldData(); 233 function CheckPDFFiles() 234 { 235 global $Database, $InvoiceGenerator; 236 237 $DbResult = $Database->query('SELECT * FROM finance_bills'); 238 while($Bill = $DbResult->fetch_array()) 239 { 240 file_put_contents('doklady2/doklad-'.$Bill['id'].'.pdf', file_get_contents('doklady/doklad-'.$Bill['id'].'.pdf')); 241 //echo($InvoiceGenerator->HasPDFFile($Bill['id']).','); 242 } 243 244 } 245 246 //ConvertPDFDataToFiles(); 247 248 //CheckPDFFiles(); 249 ImportOldData(); 236 250 237 251 ?> -
www/finance/prepocet.php
r129 r133 181 181 $TimePeriodText = date('j.n.Y', $PeriodFrom).' - '.date('j.n.Y', $PeriodTo); 182 182 echo($TimePeriodText.': '.$PayPerMonth." * ".$MonthCount." = ".$PayPerPeriod."\n"); 183 $BillId = $InvoiceGenerator->CreateBill($User['id'], array(array('description' => 'Připojení k síti', 'price' => $PayPerPeriod, 'quantity' => 1)), $PeriodFrom, $PeriodTo); 184 $Database->insert('finance_operations', array('money' => -$PayPerPeriod, 'user' => $User['id'], 'type' => 2, 'date' => 'NOW()', 'comment' => 'Připojení k síti za období '.$TimePeriodText, 'group' => 1, 'bill_id' => $BillId)); 183 $BillCode = GetNextDocumentLineNumber(6); // Faktury vydané 184 $BillId = $InvoiceGenerator->CreateBill($User['id'], array(array('description' => 'Připojení k síti', 'price' => $PayPerPeriod, 'quantity' => 1)), $PeriodFrom, $PeriodTo, $BillCode); 185 $Database->insert('finance_operations', array('money' => -$PayPerPeriod, 'user' => $User['id'], 'type' => 2, 'date' => 'NOW()', 'comment' => 'Připojení k síti za období '.$TimePeriodText, 'group' => 1, 'bill_id' => $BillId, 'BillCode' => $BillCode)); 185 186 } else echo("\n"); 186 187 }
Note:
See TracChangeset
for help on using the changeset viewer.