Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. <?php
  2. require_once('tcpdf/tcpdf_include.php');
  3. require("../inc/db_connect.inc.php");
  4. setlocale(LC_MONETARY, 'de_DE');
  5.  
  6. $billCOMPANY = 'Tekoplan GmbH';
  7. $from = strtotime('2018-05-01');
  8. $to = strtotime("+1 month", $from);
  9. $monthYEAR=date("F Y",$from);
  10.  
  11. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  12. // set document information
  13. $pdf->SetCreator(PDF_CREATOR);
  14. $pdf->SetAuthor('Markus Stapf');
  15. $pdf->SetTitle('Rechnungsausgangsbuch');
  16. $pdf->SetSubject('MSIS-HOSTING');
  17. $pdf->SetKeywords('Rechnungsausgangsbuch, MSIS-HOSTING, Webdesign');
  18.  
  19. // remove default header/footer
  20. $pdf->setPrintHeader(false);
  21. $pdf->setPrintFooter(false);
  22.  
  23. // set default monospaced font
  24. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  25.  
  26. // set margins
  27. $pdf->SetMargins(10, PDF_MARGIN_TOP, 10);
  28.  
  29. // set auto page breaks
  30. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  31.  
  32. // set image scale factor
  33. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  34.  
  35. // set some language-dependent strings (optional)
  36. if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
  37. require_once(dirname(__FILE__).'/lang/eng.php');
  38. $pdf->setLanguageArray($l);
  39. }
  40. // ---------------------------------------------------------
  41.  
  42. $i=0;
  43. $x=0;
  44. $y=0;
  45. $sql = "SELECT * FROM billlist WHERE billCOMPANY='$billCOMPANY' AND billTYP='RG' AND billDATE>='$from' AND billDATE<='$to' ORDER by billDATE"; //115
  46. $result = mysql_query($sql, $link);
  47. while($row_bill = @mysql_fetch_array($result))
  48. {
  49. $i=$i+1;
  50.  
  51. $billID = $row_bill['ID'];
  52. $billDATE = date("d.m.Y",$row_bill['billDATE']);
  53. $billTYP = $row_bill['billTYP'];
  54. $billNR = $row_bill['billNR'];
  55. $billBOOK = $row_bill['billBOOK'];
  56. $billTOPDF = $row_bill['billTOPDF'];
  57. $billTOEMAIL = $row_bill['billTOEMAIL'];
  58. $billPRINT = $row_bill['billPRINT'];
  59. $billCUSTOMERNR = $row_bill['billCUSTOMERNR'];
  60. $billCUSTOMERNAME = $row_bill['billCUSTOMERNAME'];
  61. $billSUM = $row_bill['billSUM'];
  62. $billDISCOUNT = $row_bill['billDISCOUNT'];
  63. $billDEMAND = $row_bill['billDEMAND'];
  64. $billPAID = $row_bill['billPAID'];
  65. $billBANKACCOUNT = $row_bill['billBANKACCOUNT'];
  66. $billPAIDDATE = $row_bill['billPAIDDATE'];
  67.  
  68. $sql = "SELECT * FROM customers WHERE customerNR='$billCUSTOMERNR'";
  69. $resultcustomer = mysql_query($sql, $link);
  70. while($row_customer = @mysql_fetch_array($resultcustomer))
  71. {
  72. $customerNAME = $row_customer['customerNAME'];
  73. $customerFIRSTNAME = $row_customer['customerFIRSTNAME'];
  74. $customerCOMPANY = $row_customer['customerCOMPANY'];
  75. $customerSTREET = $row_customer['customerSTREET'];
  76. $customerZIP = $row_customer['customerZIP'];
  77. $customerCITY = $row_customer['customerCITY'];
  78. $customerCOUNTRY = $row_customer['customerCOUNTRY'];
  79. $customerUID= $row_customer['customerUID'];
  80. $customerUIDOK = $row_customer['customerUIDOK'];
  81. }
  82.  
  83. $x=$x+$billSUM;
  84. $x=money_format('%.2n',$x);
  85.  
  86. if($customerUIDOK==1)
  87. {
  88. $billNETTO = $billSUM;
  89. $billBRUTTO = $billSUM;
  90. $billMWST = '0';
  91. }
  92. else
  93. {
  94. $billNETTO = $billSUM;
  95. $billBRUTTO = $billNETTO * 1.19;
  96. $billMWST = $billBRUTTO - $billNETTO;
  97. $billDEMAND = $billDEMAND * 1.19;
  98. }
  99.  
  100. if($billPAID!='paid')
  101. {
  102. $billDEMAND=0;
  103. $status="offen";
  104. }
  105. else
  106. {
  107. $status="bezahlt";
  108. }
  109.  
  110. $code='
  111. <tr class="td_white">
  112. <td height="35" valign="top">'.$billDATE.'</td>
  113. <td valign="top">'.$billNR.'</td>
  114. <td valign="top">'.$billCUSTOMERNR.'</td>
  115. <td valign="top">'.$customerNAME.', '.$customerFIRSTNAME.' <br />'.$customerCOMPANY.'<br />'.$customerSTREET.'<br />'.$customerZIP.' '.$customerCITY.'<br />'.$customerCOUNTRY.' <br /></td>
  116. <td valign="top">'.$customerUID.'</td>
  117. <td valign="top">'.$status.'</td>
  118. <td valign="top">'.money_format('%.2n',$billNETTO).'</td>
  119. <td valign="top">'.money_format('%.2n',$billBRUTTO).'</td>
  120. <td valign="top">'.money_format('%.2n',$billMWST).'</td>
  121. <td valign="top">'.money_format('%.2n',$billDEMAND).'</td>
  122. <td valign="top">'.$billPAIDDATE.'</td>
  123. <td valign="top">'.$billBANKACCOUNT.'</td>
  124. </tr>';
  125. $tr .= $code; //115 Einträge
  126.  
  127.  
  128. if ($i % 12 == 0)
  129. {
  130.  
  131. $y=$y+$billDEMAND;
  132. $y=money_format('%.2n',$y);
  133. $w=$w+$billMWST;
  134. $w=money_format('%.2n',$w);
  135. $v=$v+$billBRUTTO;
  136. $v=money_format('%.2n',$v);
  137.  
  138. $tabelle1 = '
  139. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  140. <tr class="td_grey">
  141. <td width="80" class="td_grey">Datum</td>
  142. <td class="td_grey" width="80">Beleg-Nr.</td>
  143. <td class="td_grey" width="70">Kunden-Nr.</td>
  144. <td class="td_grey" width="280">Kunde</td>
  145. <td class="td_grey" width="80">USt.ID.</td>
  146. <td class="td_grey" width="80">Status</td>
  147. <td class="td_grey" width="120">NETTO</td>
  148. <td class="td_grey" width="120">BRUTTO</td>
  149. <td class="td_grey" width="80">MwSt.</td>
  150. <td class="td_grey" width="120">IST</td>
  151. <td class="td_grey" width="80">Zahldatum</td>
  152. <td class="td_grey" width="200">Konto</td>
  153. </tr>
  154. '.$tr.'
  155. <tr class="td_grey">
  156. <td class="td_grey" width="670">Zwischensumme:</td>
  157. <td class="td_grey" width="120">'.$x.'</td>
  158. <td class="td_grey" width="120">'.$v.'</td>
  159. <td class="td_grey" width="80">'.$w.'</td>
  160. <td class="td_grey" width="120">'.$y.'</td>
  161. <td class="td_grey" width="80">&nbsp;</td>
  162. <td class="td_grey" width="200">&nbsp;</td>
  163. </tr>
  164. </table>
  165. ';
  166. $html .= $tabelle1;
  167.  
  168. $pdf->SetDisplayMode('fullpage', 'SinglePage', 'UseNone');
  169.  
  170. // set font
  171. $pdf->SetFont('dejavusans', '', 7.5);
  172. // add a page
  173. $pdf->AddPage('L', 'A3');
  174. // Print a text
  175. $pdf->writeHTML($html, true, false, true, false, '');
  176. $tr="";
  177. }
  178. }
  179.  
  180. // ---------------------------------------------------------
  181.  
  182. //Close and output PDF document
  183. $pdf->Output('Rechnungsausgangsbuch.pdf', 'I');
  184.  
  185. //============================================================+
  186. // END OF FILE
  187. //============================================================+
  188.  
  189. // Anzahl Seiten
  190.  
  191.  
  192.  
  193. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement