Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('fpdf.php');
- require('lib/swift_required.php');
- /*
- $serverName = "(local)\SQLEXPRESS";
- $connectionInfo = array( "Database"=>"APNCDR_new");
- $conn = sqlsrv_connect( $serverName, $connectionInfo);
- $theDate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";
- $date = date('d/m/Y',strtotime($theDate));
- $Cycle = $_GET["Cycle"];
- $tsql = "SELECT Cycle, CustomerName
- FROM Customers
- WHERE Cycle='$Cycle'";
- $stmt = sqlsrv_query( $conn, $tsql);
- if( $stmt === false)
- {
- echo "Error in query preparation/execution.\n";
- die( print_r( sqlsrv_errors(), true));
- }
- */
- $theDate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";
- $date = date('d/m/Y',strtotime($theDate));
- $Cy = $_GET["val"];
- $dt = $_GET["Cycle"];
- $myServer = "LAMSSQL";
- $myUser = "sa";
- $myPass = "bevotexas";
- $myDB = "APNCDR_new";
- $dbhandle = mssql_connect($myServer, $myUser, $myPass)
- or die("cant connect");
- $Selected = mssql_Select_db($myDB, $dbhandle)
- or die("cant connect to db");
- $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')";
- $result = mssql_query($query);
- $numRows = mssql_num_rows($result);
- while( $row = mssql_fetch_array($result))
- {
- $pdf=new FPDF();
- $pdf->AddPage();
- $pdf->SetFont('Arial','B',16);
- $pdf->Image('apn_logo_only.jpg',15,10,20);
- $pdf->Ln(1);
- $pdf->SetFont('Arial','B',14);
- $pdf->Cell(25);
- $pdf->Cell(60,5,'Asia Pacific Network, Inc',0,0,'L');
- $pdf->Cell(50);
- $pdf->SetFont('Arial','B',22);
- $pdf->Cell(50,5,'Invoice',0,0,'R');
- $pdf->SetFont('Arial','',10);
- $pdf->Ln(5);
- $pdf->Cell(25);
- $pdf->Cell(60,5,'8409 Pickwick Lane',0,0,'L');
- $pdf->Ln(5);
- $pdf->Cell(25);
- $pdf->Cell(60,5,'137 Dallas TX 75202',0,0,'L');
- $pdf->Cell(40);
- $pdf->Cell(30,5,'Date',1,0,'C');
- $pdf->Cell(30,5,'Invoice #',1,0,'C');
- $pdf->Ln(5);
- $pdf->Cell(125);
- $ddate = date('m/d/Y', strtotime($row["INVDATE"]));
- $pdf->Cell(30,10,$ddate,1,0,'C');
- $pdf->Cell(30,10,$row["INVNUM"],1,0,'C');
- $pdf->Ln(5);
- $pdf->Cell(25);
- $pdf->SetFont('Arial','',8);
- $pdf->Cell(60,5,'biling@asiapacificnetwork.net',0,0,'L');
- $pdf->Ln(5);
- $pdf->Cell(125);
- $val= "Usage Period \n ".$row["USAGEFROM"]."GMT \n to \n".$row["USAGETO"]." GMT";
- $pdf->MultiCell(60,5,$val,1,'C','');
- $pdf->SetXY(20,45);
- $pdf->SetFont('Arial','B',10);
- $pdf->Cell(80,5,'Bill To',1,0,'L');
- $val2= $row["CUSTOMERNAME"];
- $pdf->Ln();
- $pdf->Cell(10);
- $pdf->MultiCell(80,5,$val2,0,'L','');
- $pdf->Rect(20,50,80,30);
- $pdf->SetFont('Arial','',10);
- $pdf->SetXY(20,55);
- $val10 = $row["ADDRESS"];
- $pdf->MultiCell(80,5,$val10,0,'L','');
- $pdf->SetXY(150,60);
- $pdf->Cell(30,5,'Terms',1,0,'C');
- $pdf->SetXY(150,65);
- $pdf->Cell(30,10,$row["TERMS"],1,0,'C');
- $pdf->Ln(20);
- $pdf->Cell(10);
- $pdf->MultiCell(35,5,'Beginning Prepaid Balance',1,'C','');
- $pdf->SetXY(55,85);
- $pdf->MultiCell(25,10,'Payments',1,'C','');
- $pdf->SetXY(80,85);
- $pdf->MultiCell(25,10,'Adjustment',1,'C','');
- $pdf->SetXY(105,85);
- $pdf->MultiCell(30,10,'Balance Forward',1,'C','');
- $pdf->SetXY(135,85);
- $pdf->MultiCell(30,5,'Current Invoice Amount',1,'C','');
- $pdf->SetXY(165,85);
- $pdf->MultiCell(35,5,'Ending Prepaid Balance',1,'C','');
- $pdf->SetXY(20,95);
- $pdf->MultiCell(35,20,$row["PREVBAL"],0,'C','');
- $pdf->SetXY(55,95);
- $pdf->MultiCell(25,20,$row["PAYMENTS"],0,'C','');
- $pdf->SetXY(80,95);
- $pdf->MultiCell(25,20,$row["ADJUSTMENTS"],0,'C','');
- $pdf->SetXY(105,95);
- $pdf->MultiCell(30,20,$row["BALANCEFWD"],0,'C','');
- $pdf->SetXY(135,95);
- $pdf->MultiCell(30,20,$row["INVTOTAL"],0,'C','');
- $pdf->SetXY(165,95);
- $pdf->MultiCell(35,20,$row["BALANCEEND"],0,'C','');
- $pdf->Rect(20,95,35,20);
- $pdf->Rect(55,95,25,20);
- $pdf->Rect(80,95,25,20);
- $pdf->Rect(105,95,30,20);
- $pdf->Rect(135,95,30,20);
- $pdf->Rect(165,95,35,20);
- $pdf->ln(5);
- $pdf->Cell(10);
- $pdf->Cell(180,5,'Payment Methods',1,0,'C');
- $pdf->Ln(10);
- $pdf->Cell(10);
- $pdf->SetFont('Arial','B',8);
- $var3= "(Philippines PHP Account)\nBanco De Oro\nSalcedo Brance, Salcedo Village\nAccount - 204-005-1712 \n\n\n";
- $pdf->MultiCell(60,5,$var3,1,'C','');
- $var4= "(Phillpine USD Account)\nBanco De Oro\nSalcedo Branch,Salcedo Village\n Account - 204-005-4355\nSwift Code: BNORPHMM \n\n";
- $pdf->SetXY(80,130);
- $pdf->MultiCell(60,5,$var4,1,'C','');
- $var5= "(USA USD ACCOUNT)\nWachovia Bank\nAccount - 20000-297-39-842\nRouting Number(Domestic) - 111 025 013\nSwift Code (International): PNBPUS33\n\n";
- $pdf->SetXY(140,130);
- $pdf->MultiCell(60,5,$var5,1,'C','');
- $pdf->Ln(5);
- $pdf->SetFont('Arial','B',10);
- $pdf->Cell(10);
- $pdf->Cell(30,5,'Minutes',1,0,'C');
- $pdf->Cell(90,5,'Description',1,0,'C');
- $pdf->Cell(30,5,'Rate',1,0,'C');
- $pdf->Cell(30,5,'Amount',1,0,'C');
- $pdf->SetFont('Arial','B',8);
- $pdf->Rect(20,165,30,95);
- $pdf->Rect(50,165,90,95);
- $pdf->Rect(140,165,30,95);
- $pdf->Rect(170,165,30,95);
- $id = $row["CUSTID"];
- $name = $row["CUSTOMERNAME"];
- $myServer1 = "LAMSSQL";
- $myUser1 = "sa";
- $myPass1 = "bevotexas";
- $myDB1 = "APNCDR_new";
- $dbhandle1 = mssql_connect($myServer1, $myUser1, $myPass1)
- or die("cant connect");
- $Selected1 = mssql_Select_db($myDB1, $dbhandle1)
- or die("cant connect to db");
- $query1 = "SELECT CYCLE, INVDATE, CUSTID, LINETYPE, UNITS, DESCRIPTION, Rate, AMOUNT FROM InvoicePrintDtl WHERE (CUSTID = '$id')";
- $result1 = mssql_query($query1);
- $numRows1 = mssql_num_rows($result1);
- $pdf->ln(6);
- $pdf->SetFont('Arial','B',6);
- while( $row2 = mssql_fetch_array($result1))
- {
- $pdf->Cell(10);
- $dunits = number_format($row2["UNITS"],2);
- $pdf->Cell(30,2,$dunits,0,0,'R');
- $pdf->Cell(90,2,$row2["DESCRIPTION"],0,0,'L');
- $drate = number_format($row2["Rate"],4);
- $pdf->Cell(30,2,$drate,0,0,'R');
- $damt = number_format($row2["AMOUNT"],2);
- $pdf->Cell(30,2,$damt,0,0,'R');
- $pdf->ln();
- }
- $pdf->Output('D:\Fileshared\Invoices\C'.$id." ".$name." ".$row["INVDATE"].' INVOICE.pdf', 'F');
- /*
- $transport = Swift_SmtpTransport::newInstance('tls://smtp.gmail.com', 465)
- ->setUsername('lorddefiant18@gmail.com')
- ->setPassword('taenamojb')
- ;
- $mailer = Swift_Mailer::newInstance($transport);
- $message = Swift_Message::newInstance();
- $message->setSubject('Invoice');
- $message->setBody('Your invoice', 'text/html');
- $message->setFrom('ACCOUNTING@APNTELECOM.COM');
- $message->addTo($row["email"]);
- $message->attach(Swift_Attachment::fromPath('C'.$id." ".$name." ".$row["INVDATE"].' INVOICE.pdf'));
- $result = $mailer->send($message);
- */
- //$pdf->Output();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement