Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. <?php
  2. require('fpdf.php');
  3. /*
  4. $serverName = "(local)\SQLEXPRESS";
  5. $connectionInfo = array( "Database"=>"APNCDR_new");
  6. $conn = sqlsrv_connect( $serverName, $connectionInfo);
  7. $theDate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";
  8. $date = date('d/m/Y',strtotime($theDate));
  9. $Cycle = $_GET["Cycle"];
  10. $tsql = "SELECT Cycle, CustomerName
  11. FROM Customers
  12. WHERE Cycle='$Cycle'";
  13. $stmt = sqlsrv_query( $conn, $tsql);
  14. if( $stmt === false)
  15. {
  16. echo "Error in query preparation/execution.\n";
  17. die( print_r( sqlsrv_errors(), true));
  18. }
  19.  
  20. */
  21. $theDate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";
  22. $date = date('d/m/Y',strtotime($theDate));
  23. $Cycle = $_GET["Cycle"];
  24.  
  25. $myServer = "LAMSSQL";
  26. $myUser = "sa";
  27. $myPass = "bevotexas";
  28. $myDB = "APNCDR_new";
  29. $dbhandle = mssql_connect($myServer, $myUser, $myPass)
  30. or die("cant connect");
  31. $Selected = mssql_Select_db($myDB, $dbhandle)
  32. or die("cant connect to db");
  33. $query = "SELECT CYCLE, BRAND, INVNUM, USAGEFROM, ADDRESS, CUSTOMERNAME, email, BILLTO, BALANCEEND, INVTOTAL, BALANCEFWD, ADJUSTMENTS, PAYMENTS, PREVBAL, CUSTID, INVDATE, TERMS, USAGETO FROM InvoicePrint WHERE (CYCLE = N'$Cycle')";
  34.  
  35. $result = mssql_query($query);
  36. $numRows = mssql_num_rows($result);
  37.  
  38.  
  39. while( $row = mssql_fetch_array($result))
  40. {
  41. $pdf=new FPDF();
  42. $pdf->AddPage();
  43. $pdf->SetFont('Arial','B',16);
  44. $pdf->Image('apn_logo_only.jpg',15,10,20);
  45. $pdf->Ln(1);
  46. $pdf->SetFont('Arial','B',14);
  47. $pdf->Cell(25);
  48. $pdf->Cell(60,5,'Asia Pacific Network, Inc',0,0,'L');
  49. $pdf->Cell(50);
  50. $pdf->SetFont('Arial','B',22);
  51. $pdf->Cell(50,5,'Invoice',0,0,'R');
  52. $pdf->SetFont('Arial','',10);
  53. $pdf->Ln(5);
  54. $pdf->Cell(25);
  55. $pdf->Cell(60,5,'8409 Pickwick Lane',0,0,'L');
  56. $pdf->Ln(5);
  57. $pdf->Cell(25);
  58. $pdf->Cell(60,5,'137 Dallas TX 75202',0,0,'L');
  59. $pdf->Cell(40);
  60. $pdf->Cell(30,5,'Date',1,0,'C');
  61. $pdf->Cell(30,5,'Invoice #',1,0,'C');
  62. $pdf->Ln(5);
  63. $pdf->Cell(125);
  64. $ddate = date('m/d/Y', strtotime($row["INVDATE"]));
  65. $pdf->Cell(30,10,$ddate,1,0,'C');
  66. $pdf->Cell(30,10,$row["INVNUM"],1,0,'C');
  67. $pdf->Ln(5);
  68. $pdf->Cell(25);
  69. $pdf->SetFont('Arial','',8);
  70. $pdf->Cell(60,5,'biling@asiapacificnetwork.net',0,0,'L');
  71. $pdf->Ln(5);
  72. $pdf->Cell(125);
  73. $val= "Usage Period \n ".$row["USAGEFROM"]."GMT \n to \n".$row["USAGETO"]." GMT";
  74. $pdf->MultiCell(60,5,$val,1,'C','');
  75. $pdf->SetXY(20,45);
  76. $pdf->SetFont('Arial','B',10);
  77. $pdf->Cell(80,5,'Bill To',1,0,'L');
  78. $val2= $row["CUSTOMERNAME"];
  79. $pdf->Ln();
  80. $pdf->Cell(10);
  81. $pdf->MultiCell(80,5,$val2,0,'L','');
  82. $pdf->Rect(20,50,80,30);
  83. $pdf->SetFont('Arial','',10);
  84. $pdf->SetXY(20,55);
  85. $val10 = $row["ADDRESS"];
  86. $pdf->MultiCell(80,5,$val10,0,'L','');
  87. $pdf->SetXY(150,60);
  88. $pdf->Cell(30,5,'Terms',1,0,'C');
  89. $pdf->SetXY(150,65);
  90. $pdf->Cell(30,10,$row["TERMS"],1,0,'C');
  91. $pdf->Ln(20);
  92. $pdf->Cell(10);
  93. $pdf->MultiCell(35,5,'Beginning Prepaid Balance',1,'C','');
  94. $pdf->SetXY(55,85);
  95. $pdf->MultiCell(25,10,'Payments',1,'C','');
  96. $pdf->SetXY(80,85);
  97. $pdf->MultiCell(25,10,'Adjustment',1,'C','');
  98. $pdf->SetXY(105,85);
  99. $pdf->MultiCell(30,10,'Balance Forward',1,'C','');
  100. $pdf->SetXY(135,85);
  101. $pdf->MultiCell(30,5,'Current Invoice Amount',1,'C','');
  102. $pdf->SetXY(165,85);
  103. $pdf->MultiCell(35,5,'Ending Prepaid Balance',1,'C','');
  104. $pdf->SetXY(20,95);
  105. $pdf->MultiCell(35,20,$row["PREVBAL"],0,'C','');
  106. $pdf->SetXY(55,95);
  107. $pdf->MultiCell(25,20,$row["PAYMENTS"],0,'C','');
  108. $pdf->SetXY(80,95);
  109. $pdf->MultiCell(25,20,$row["ADJUSTMENTS"],0,'C','');
  110. $pdf->SetXY(105,95);
  111. $pdf->MultiCell(30,20,$row["BALANCEFWD"],0,'C','');
  112. $pdf->SetXY(135,95);
  113. $pdf->MultiCell(30,20,$row["INVTOTAL"],0,'C','');
  114. $pdf->SetXY(165,95);
  115. $pdf->MultiCell(35,20,$row["BALANCEEND"],0,'C','');
  116. $pdf->Rect(20,95,35,20);
  117. $pdf->Rect(55,95,25,20);
  118. $pdf->Rect(80,95,25,20);
  119. $pdf->Rect(105,95,30,20);
  120. $pdf->Rect(135,95,30,20);
  121. $pdf->Rect(165,95,35,20);
  122. $pdf->ln(5);
  123. $pdf->Cell(10);
  124. $pdf->Cell(180,5,'Payment Methods',1,0,'C');
  125. $pdf->Ln(10);
  126. $pdf->Cell(10);
  127. $pdf->SetFont('Arial','B',8);
  128. $var3= "(Philippines PHP Account)\nBanco De Oro\nSalcedo Brance, Salcedo Village\nAccount - 204-005-1712 \n\n\n";
  129. $pdf->MultiCell(60,5,$var3,1,'C','');
  130. $var4= "(Phillpine USD Account)\nBanco De Oro\nSalcedo Branch,Salcedo Village\n Account - 204-005-4355\nSwift Code: BNORPHMM \n\n";
  131. $pdf->SetXY(80,130);
  132. $pdf->MultiCell(60,5,$var4,1,'C','');
  133. $var5= "(USA USD ACCOUNT)\nWachovia Bank\nAccount - 20000-297-39-842\nRouting Number(Domestic) - 111 025 013\nSwift Code (International): PNBPUS33\n\n";
  134. $pdf->SetXY(140,130);
  135. $pdf->MultiCell(60,5,$var5,1,'C','');
  136. $pdf->Ln(5);
  137. $pdf->SetFont('Arial','B',10);
  138. $pdf->Cell(10);
  139. $pdf->Cell(30,5,'Minutes',1,0,'C');
  140. $pdf->Cell(90,5,'Description',1,0,'C');
  141. $pdf->Cell(30,5,'Rate',1,0,'C');
  142. $pdf->Cell(30,5,'Amount',1,0,'C');
  143. $pdf->SetFont('Arial','B',8);
  144.  
  145.  
  146. $pdf->Rect(20,165,30,95);
  147. $pdf->Rect(50,165,90,95);
  148. $pdf->Rect(140,165,30,95);
  149. $pdf->Rect(170,165,30,95);
  150.  
  151. $id = $row["CUSTID"];
  152. $name = $row["CUSTOMERNAME"];
  153. $myServer1 = "LAMSSQL";
  154. $myUser1 = "sa";
  155. $myPass1 = "bevotexas";
  156. $myDB1 = "APNCDR_new";
  157. $dbhandle1 = mssql_connect($myServer1, $myUser1, $myPass1)
  158. or die("cant connect");
  159. $Selected1 = mssql_Select_db($myDB1, $dbhandle1)
  160. or die("cant connect to db");
  161. $query1 = "SELECT CYCLE, INVDATE, CUSTID, LINETYPE, UNITS, DESCRIPTION, Rate, AMOUNT FROM InvoicePrintDtl WHERE (CUSTID = '$id')";
  162.  
  163. $result1 = mssql_query($query1);
  164. $numRows1 = mssql_num_rows($result1);
  165. $pdf->ln(6);
  166. $pdf->SetFont('Arial','B',6);
  167. while( $row2 = mssql_fetch_array($result1))
  168. {
  169. $pdf->Cell(10);
  170. $dunits = number_format($row2["UNITS"],2);
  171. $pdf->Cell(30,2,$dunits,0,0,'R');
  172. $pdf->Cell(90,2,$row2["DESCRIPTION"],0,0,'L');
  173. $drate = number_format($row2["Rate"],4);
  174. $pdf->Cell(30,2,$drate,0,0,'R');
  175. $damt = number_format($row2["AMOUNT"],2);
  176. $pdf->Cell(30,2,$damt,0,0,'R');
  177. $pdf->ln();
  178. }
  179. //$pdf->Cell(0,0,''.$row["CustomerName"],0,0,'L');
  180. $pdf->Output('D:\Fileshared\Invoices\C'.$id." ".$name." ".$row["INVDATE"].' INVOICE.pdf', 'F');
  181. //$pdf->Output();
  182. }
  183.  
  184. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement