Advertisement
Guest User

Untitled

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