Jump to content


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About chambers9661

  • Rank
  1. Sorry i thought posting the link would solve this. Ok i have a form once submitted it goes to invoice.php in invoice.php there are 2 buttons. One goes back to edit page if needed. The other button saves the page as a pdf file to a file on my server using dompdf. At the moment when you click save invoice an alert pops up with a reminder. Once you select ok it saves the page as a pdf file to a folder on the server but stays on the same page. I am trying to remove the alert and then once save invoice clicked it saves to file on folder and then shows another page?. Here is full page invoice.php. invoice.php ( PHP script, ASCII text ) <?php require __DIR__.'/dompdf/autoload.inc.php'; require_once './controller.php'; use Dompdf\Dompdf; if(isset($_GET["invoice_id"]) && $_GET["invoice_id"]>0){ $invoiceID = $_GET["invoice_id"]; require_once './pdf.php'; $dompdf = new Dompdf(); $dompdf->loadHtml($html); $dompdf->render(); $output = $dompdf->output(); file_put_contents("./uploadinvoice/"."Invoice_Rose_Joinery_".$_GET["invoice_id"].".pdf", $output); $invoicename = isset($client["name"]) ? $client["name"] : ""; $invoiceaddress1 = isset($client["address1"]) ? $client["address1"] : ""; $invoiceaddress2 = isset($client["address2"]) ? $client["address2"] : ""; $invoiceaddress3 = isset($client["address3"]) ? $client["address3"] : ""; $invoiceaddress4 = isset($client["address4"]) ? $client["address4"] : ""; $invoiceaddress5 = isset($client["address5"]) ? $client["address5"] : ""; $invoiceitem1 =isset($invoice["invoiceitem1"]) ? $invoice["invoiceitem1"] :""; $invoiceitem2 =isset($invoice["invoiceitem2"]) ? $invoice["invoiceitem2"] :""; $invoiceitem3 =isset($invoice["invoiceitem3"]) ? $invoice["invoiceitem3"] :""; $invoiceitem4 =isset($invoice["invoiceitem4"]) ? $invoice["invoiceitem4"] :""; $invoiceitem5 =isset($invoice["invoiceitem5"]) ? $invoice["invoiceitem5"] :""; $invoiceitem6 =isset($invoice["invoiceitem6"]) ? $invoice["invoiceitem6"] :""; $invoiceitem7 =isset($invoice["invoiceitem7"]) ? $invoice["invoiceitem7"] :""; $invoiceitem1price = isset($invoice["invoiceitem1price"]) ? $invoice["invoiceitem1price"] : 0; $invoiceitem2price = isset($invoice["invoiceitem2price"]) ? $invoice["invoiceitem2price"] : 0; $invoiceitem3price = isset($invoice["invoiceitem3price"]) ? $invoice["invoiceitem3price"] : 0; $invoiceitem4price = isset($invoice["invoiceitem4price"]) ? $invoice["invoiceitem4price"] : 0; $invoiceitem5price = isset($invoice["invoiceitem5price"]) ? $invoice["invoiceitem5price"] : 0; $invoiceitem6price = isset($invoice["invoiceitem6price"]) ? $invoice["invoiceitem6price"] : 0; $invoiceitem7price = isset($invoice["invoiceitem7price"]) ? $invoice["invoiceitem7price"] : 0; $total = isset($invoice["total"]) ? $invoice["total"] : 0; $invoicedate = isset($invoice["invoiceDate"])? $invoice["invoiceDate"] :""; $invoicenumber = isset($invoice["invoiceNo"]) ? $invoice["invoiceNo"] : ""; $notes = isset($invoice["notes"]) ? $invoice["notes"] : ""; $sum1=$invoiceitem1price; $sum2=$invoiceitem2price; $sum3=$invoiceitem3price; $sum4=$invoiceitem4price; $sum5=$invoiceitem5price; $sum6=$invoiceitem6price; $sum7=$invoiceitem7price; $total = number_format($total, 2, ".", ""); $nameOfDay = $invoice["nameOfDay"]; $newDate = $invoice["created_at"]; } ?> <html> <head> <style type="text/css"> @media print { #printbtn { display : none; } } </style> <style type="text/css"> @media print { #backbtn { display : none; } } </style> <meta name="viewport" content="width=device-width,> <style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <meta charset="utf-8"> <title>Invoice</title> <meta name="generator" content="WYSIWYG Web Builder 14 - http://www.wysiwygwebbuilder.com"> <style type="text/css"> div#container { width: 320px; position: relative; margin: 0 auto 0 auto; text-align: left; } body { background-color: #FFFFFF; color: #000000; font-family: Arial; font-weight: normal; font-size: 12px; line-height: 1.1875; margin: 15; text-align: left; } a { color: #0000FF; text-decoration: none; } a:hover { color: #FF0000; text-decoration: none; } input:focus, textarea:focus, select:focus { outline: none; } @media only screen and (max-width: 320px) { div#container { width: 320px; } body { background-color: #FFFFFF; } } </style> <style> .back { display: block; width: 100%; border: none; background-color: #4CAF50; color: #000000; padding: 14px 28px; font-size: 20px; font-weight: bold; cursor: pointer; text-align: center; } </style> <style> .block { display: block; width: 100%; border: none; background-color: #4CAF50; color: #000000; padding: 14px 28px; font-size: 20px; font-weight: bold; cursor: pointer; text-align: center; } </style> <script> function myFunction() { alert("Your invoice will be saved to your account. To view it select the 'View Invoices' link from your account menu. Please remember to log the amount of this invoice using the 'Income' link."); } </script> </head> <body onload="parent.scrollTo(0,0);"> <a href="javascript:history.go(-1)"><button class="block" id ="backbtn">Back To Edit</button></a><br> <a id ="savepdf" href="invoice.php?invoice_id=<?=$invoiceID?>" value="Save This Invoice"><button class="block" id ="printbtn" onclick="myFunction()">Save Invoice</button></a></a> <?php // ALTER THIS TO RETREIVE CUSTOMER DATA $row = getdata("company"); if (count($row) > 0) { // Company Logo Or Header echo '<div style="position:absolute;left:20px;top:140px;z-index:0;">'; echo '<img src="companylogo.png">'; echo '</div>'; echo '<div style="position:absolute;left:20px;top:320px;z-index:0;">'; echo "<H1>Customer Invoice <H1>"; echo '</div>'; // My Company Details echo '<div style="position:absolute;left:20px;top:370px;z-index:0;">'; echo "<H3>Invoice From <H3>"; echo '</div>'; echo '<div style="position:absolute;left:20px;top:400px;z-index:0;">'; echo "<h3>" .$row["MYNAME"]. " <br> " .$row["MYADDRESS1"]. " <br> " .$row["MYADDRESS2"]. " <br> " .$row["MYADDRESS3"]. " <br> " .$row["MYADDRESS4"]. " <br> " .$row["MYADDRESS5"]. "</h3>"; echo '</div>'; // Customer Details echo '<div style="position:absolute;left:500px;top:370px;z-index:0;">'; echo "<h3> Invoice To</h3>"; echo '</div>'; echo '<div style="position:absolute;left:500px;top:400px;z-index:0;">'; echo "<h3>$invoicename <br> $invoiceaddress1 <br> $invoiceaddress2 <br> $invoiceaddress3 <br> $invoiceaddress4 <br> $invoiceaddress5</h3>"; echo '</div>'; echo '<div style="position:absolute;left:20px;top:550px;z-index:0;">'; echo "<H3>Invoice Date : "; echo date("l d F Y", strtotime($newDate)); echo '</div>'; echo '<div style="position:absolute;left:20px;top:520px;z-index:0;">'; echo "<H3>Invoice Reference : $notes</H3>"; echo '</div>'; // Remove backlshes if these details required echo '<div style="position:absolute;left:500px;top:520px;z-index:0;">'; echo "<H3>Contact Number 07801798153</H3>"; echo '</div>'; echo '<div style="position:absolute;left:500px;top:545px;z-index:0;">'; echo "<H3>E Mail admin@mywebchambers.co.uk</H3>"; echo '</div>'; // End of extra details echo '<div style="position:absolute;left:20px;top:600px;z-index:0;">'; echo "<H3>Details : </H3>"; echo '</div>'; echo '<div style="position:absolute;left:20px;top:650px;z-index:0;">'; echo "<H2>Description</H2>"; echo '</div>'; echo '<div style="position:absolute;left:20px;top:650px;z-index:0;">'; echo "<H2>Description</H2>"; echo '</div>'; echo '<div style="position:absolute;left:700px;top:650px;z-index:0;">'; echo "<H2>Amount</H2>"; echo '</div>'; // Invoice Details echo "<H3><table width=800 cellpadding=10 style='position:absolute;left:10px;top:680px; z-index:0;'>"; echo '<tr><th width="500px"></th><th width="20px"></th><th width="100px"></th></tr>'; if($sum1!=""){ echo "<tr><td>$invoiceitem1</td><td></td><td>&pound $invoiceitem1price</td> "; } if($sum2!=""){ echo "<tr><td>$invoiceitem2</td><td></td><td>&pound $invoiceitem2price</td> "; } if($sum3!=""){ echo "<tr><td>$invoiceitem3</td><td></td><td>&pound $invoiceitem3price</td> "; } if($sum4!=""){ echo "<tr><td>$invoiceitem4</td><td></td><td>&pound $invoiceitem4price</td> "; } if($sum5!=""){ echo "<tr><td>$invoiceitem5</td><td></td><td>&pound $invoiceitem5price</td> "; } if($sum6!=""){ echo "<tr><td>$invoiceitem6</td><td></td><td>&pound $invoiceitem6price</td> "; } if($sum7!=""){ echo "<tr><td>$invoiceitem7</td><td></td><td>&pound $invoiceitem7price</td> "; } echo "<tr><th width='800px' align=right><br><br>Total Amount Now Due</th><th></th><th><br><br>&pound $total</th></tr>"; echo "</table></H3>"; } ?> </body> </html>
  2. Hi I have a database in the database is a table called incomeuser1 there is a column called AMOUNT. Theres is also another table called expenseuser1 and a column called EXPAMOUNT. What code do i use to subtract one from other. For example if incomeuser1 AMOUNT was say 50.00. And expenseuser1 EXPAMOUNT was say 35.50 how do i subtract and echo the result as 14.50 using 2 decimal places ? Also if the sum was a minus figure how would i display that in red? Novice learner
  3. Hi there, I have a database with table column called EXPAMOUNT if EXPAMOUNT value was £5.50 it only displays £5.5. when i echo it. How do i get it to display 2 decimal places. So £5.50 My code at moment echo “Total Expenses &nbsp &pound” . $row[‘SUM(EXPAMOUNT)’]. “
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.