Bifter Posted July 1, 2008 Share Posted July 1, 2008 Hi All, Basically i have written the code below, which outputs to browser just fine, however I would like to print ,email and save(locally and remotely) but am getting myself in allsorts of a mess, I don’t expect anyone to write the for me I would just like a gentle nudge in the correct direction...Please! /* Avaya - From Form*/ $LinesAnalogue = $_POST['LinesAnalogue']; $LinesISDN2 = $_POST['LinesISDN2']; $LinesISDN30 = $_POST['LinesISDN30']; $DigitalExt = $_POST['DigitalExt']; $AnalogueExt = $_POST['AnalogueExt']; $Voicemail = $_POST['Voicemail']; $BasicHand = $_POST['BasicHand']; $GeneralHand = $_POST['GeneralHand']; $ExecHand = $_POST['ExecHand']; /* Main Unit */ $MainUnit = array( array('Unit' => 'Avaya', 'Price' => '406'), array('Unit' => 'Cisco', 'Price' => '1500'), array('Unit' => 'Samsung', 'Price' => '995') ); /* Line Cards */ $LineCard = array( array('Card' => 'Analogue Card/s', 'Price' => '232'), array('Card' => 'ISDN2e Card/s', 'Price' => '275'), array('Card' => 'ISDN30e Card/s', 'Price' => '530'), array('Card' => 'Cisco ISDN2e Card/s', 'Price' => '200'), array('Card' => 'Cisco ISDN30e Card/s', 'Price' => '600'), array('Card' => 'Samsung Analogue Card/s', 'Price' => '345'), array('Card' => 'Samsung ISDN2e Card/s', 'Price' => '395'), array('Card' => 'Samsund ISDN30e Card/s', 'Price' => '530') ); /* Extension Cards */ $ExtCard = array( array('Card' => 'Digital Extension Card/s', 'Price' => '319'), array('Card' => 'Analogue Extension Card/s', 'Price' => '145'), array('Card' => 'Cisco Switch', 'Price' => '1200'), array('Card' => 'Samsung Digital Extension Card/s', 'Price' => '295'), array('Card' => 'Samsung Analogue Extension Card/s', 'Price' => '295'), ); /* Voicemail */ $VoicemailPrice = array( array('Card' => 'Avaya', 'Price' => '500'), array('Card' => 'Cisco', 'Price' => '600'), array('Card' => 'Samsung', 'Price' => '100'), ); /* Handsets */ $Phones = array( array('Phone' => 'Basic Model/s', 'Price' => '72'), array('Phone' => 'General Model/s', 'Price' => '152'), array('Phone' => 'Executive Model/s', 'Price' => '218'), array('Phone' => 'Cisco Basic Model/s', 'Price' => '135'), array('Phone' => 'Cisco General Model/s', 'Price' => '192'), array('Phone' => 'Cisco Executive Model/s', 'Price' => '297'), array('Phone' => 'Samsung Basic Model/s', 'Price' => '100'), array('Phone' => 'Samsung General Model/s', 'Price' => '150'), array('Phone' => 'Samsung Executive Model/s', 'Price' => '230') ); /* Extras */ $Instal = array( array('Phone' => 'Avaya', 'Price' => '400'), array('Phone' => 'Cisco', 'Price' => '1200'), array('Phone' => 'Samsung', 'Price' => '400') ); $Train = array( array('Phone' => 'Avaya', 'Price' => '400'), array('Phone' => 'Cisco', 'Price' => '500'), array('Phone' => 'Samsung', 'Price' => '400') ); ob_start("callback"); echo "<table width=\"57%\" align=\"center\" cellpadding=5 class=bordered>"; echo "<tr><th>Total Lines Required </th>"; echo "<th>Total Extensions Required</th>"; echo "<th>Total Phones Required</th></tr>"; echo "<tr><td>"; echo "<div align=\"center\">"; echo NumLines (); echo "</td><td>"; echo "<div align=\"center\">"; echo TotalExtension (); echo "</td><td>"; echo "<div align=\"center\">"; echo NumPhones (); echo "</div>"; echo "</td></tr>"; echo "</table>" . "<br />"; echo "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">"; echo "<tr>"; echo "<td align=\"center\"><table cellpadding=5 width=98% class=bordered bgcolor=#EFEFEF style=\"margin-bottom: 10px\">"; echo "<tr>"; echo "<th colspan=4><img src=\"http://www.flipsolutions.co.uk/images/quoting/avaya.png\" width=\"120\" height=\"49\"></th>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" class=label><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr>"; echo "<td><div align=\"center\"><strong>Part</strong></div></td>"; echo "<td width=\"25%\"><div align=\"center\"><strong>Price Per Unit </strong></div></td>"; echo "<td width=\"26%\"><div align=\"center\"><strong>Amount Required </strong></div></td>"; echo "<td width=\"17%\"><div align=\"center\"><strong>Line Total </strong></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Main Unit </div></td>"; echo "<td><div align=\"center\">£406.00</div></td>"; echo "<td><div align=\"center\">1</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo MainUnit (); echo "<br /></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Analogue Card </div></td>"; echo "<td><div align=\"center\">£232.00</div></td>"; echo "<td><div align=\"center\">"; echo AnaNumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo AnaLineTotal (); echo "<br /></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">ISDN2e Card </div></td>"; echo "<td><div align=\"center\">£275.00</div></td>"; echo "<td><div align=\"center\">"; echo ISDN2NumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo ISDN2LineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">ISDN30e Card </div></td>"; echo "<td><div align=\"center\">£530.00</div></td>"; echo "<td><div align=\"center\">"; echo ISDN30NumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo ISDN30LineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Digital Extension Card </div></td>"; echo "<td><div align=\"center\">£319.00</div></td>"; echo "<td><div align=\"center\">"; echo DigExtNumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo DigExtLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Analogue Extension Card </div></td>"; echo "<td><div align=\"center\">£145.00</div></td>"; echo "<td><div align=\"center\">"; echo AnaExtNumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo AnaExtLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Voicemail</div></td>"; echo "<td><div align=\"center\">£500.00</div></td>"; echo "<td><div align=\"center\">1</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo Voicemail (); echo "<br /><br /></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Basic Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/5402.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/5402_large.png\" /><br />Avaya 5402 Terminal</span></a> </div></div></td>"; echo "<td><div align=\"center\">£72.00</div></td>"; echo "<td><div align=\"center\">"; echo $BasicHand; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo BasPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Mid Range Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/5410.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/5410_large.png\" /><br />Avaya 5410 Terminal</span></a> </div></div></td>"; echo "<td><div align=\"center\">£152.00</div></td>"; echo "<td><div align=\"center\">"; echo $GeneralHand; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo MidPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Executive Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/5420.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/5420_large.png\" /><br />Avaya 5420 Terminal</span></a> </div></div></td>"; echo "<td><div align=\"center\">£218.00</div></td>"; echo "<td><div align=\"center\">"; echo $ExecHand; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo ExecPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\"><b>Hardware Total</b></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "<b>" . "£"; echo HardTotal () . "<br />" . "</b>"; echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Installation</div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo InstallLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Training</div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo TrainLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td><div align=\"center\">Total</div></td>"; echo "<td><div align=\"center\">"; echo "<b>£</b>"; echo "<b>"; echo Total (); echo "</b>"; echo "</div></td>"; echo "</tr>"; echo "</table></td>"; echo "</tr>"; echo "</table></td>"; echo "<td align=\"center\"><table cellpadding=5 width=98% class=bordered bgcolor=#EFEFEF style=\"margin-bottom: 10px\">"; echo "<tr>"; echo "<th colspan=4><img src=\"http://www.flipsolutions.co.uk/images/quoting/cisco.png\" width=\"89\" height=\"49\"></th>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" class=label><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr>"; echo "<td><div align=\"center\"><strong>Part</strong></div></td>"; echo "<td width=\"25%\"><div align=\"center\"><strong>Price Per Unit </strong></div></td>"; echo "<td width=\"26%\"><div align=\"center\"><strong>Amount Required </strong></div></td>"; echo "<td width=\"17%\"><div align=\"center\"><strong>Line Total </strong></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Main Router</div></td>"; echo "<td><div align=\"center\">£1,500.00</div></td>"; echo "<td><div align=\"center\">1</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoMainUnit (); echo "<br /></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">ISDN2e Card </div></td>"; echo "<td><div align=\"center\">£200.00</div></td>"; echo "<td><div align=\"center\">"; echo CiscoISDN2NumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoISDN2LineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">ISDN30e Card </div></td>"; echo "<td><div align=\"center\">£600.00</div></td>"; echo "<td><div align=\"center\">"; echo CiscoISDN30NumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoISDN30LineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Switch</div></td>"; echo "<td><div align=\"center\">£1,200</div></td>"; echo "<td><div align=\"center\">"; echo CiscoDigExtNumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoDigExtLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Voicemail</div></td>"; echo "<td><div align=\"center\">£600.00</div></td>"; echo "<td><div align=\"center\">1</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoVoicemail (); echo "<br /><br /></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Basic Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/7906.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/7906_large.png\" /><br />Cisco 7906G Handset</span></a> </div></div></td>"; echo "<td><div align=\"center\">£135.00</div></td>"; echo "<td><div align=\"center\">"; echo $BasicHand ; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoBasPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Mid Range Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/7941.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/7941_large.png\" /><br />Cisco 7941G Handset</span></a> </div></div></td>"; echo "<td><div align=\"center\">£192.00</div></td>"; echo "<td><div align=\"center\">"; echo $GeneralHand ; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoMidPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Executive Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/7970.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/7970_large.png\" /><br />Cisco 7970G Handset</span></a> </div></div></td>"; echo "<td><div align=\"center\">£297.00</div></td>"; echo "<td><div align=\"center\">"; echo $ExecHand ; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoExecPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\"><b>Hardware Total</b></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "<b>" . "£"; echo CiscoHardTotal () . "<br />" . "</b>"; echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Installation</div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoInstallLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Training</div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo CiscoTrainLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td><div align=\"center\">Total</div></td>"; echo "<td><div align=\"center\">"; echo "<b>£</b>"; echo "<b>"; echo CiscoTotal (); echo "</b>"; echo "</div></td>"; echo "</tr>"; echo "</table></td>"; echo "</tr>"; echo "</table></td>"; echo "<td align=\"center\"><table cellpadding=5 width=98% class=bordered bgcolor=#EFEFEF style=\"margin-bottom: 10px\">"; echo "<tr>"; echo "<th colspan=4><img src=\"http://www.flipsolutions.co.uk/images/quoting/samsung.png\" width=\"114\" height=\"49\"></th>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" class=label><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr>"; echo "<td><div align=\"center\"><strong>Part</strong></div></td>"; echo "<td width=\"25%\"><div align=\"center\"><strong>Price Per Unit </strong></div></td>"; echo "<td width=\"26%\"><div align=\"center\"><strong>Amount Required </strong></div></td>"; echo "<td width=\"17%\"><div align=\"center\"><strong>Line Total </strong></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Main Unit </div></td>"; echo "<td><div align=\"center\">£995.00</div></td>"; echo "<td><div align=\"center\">1</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamMainUnit (); echo "<br /></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Analogue Card </div></td>"; echo "<td><div align=\"center\">£345.00</div></td>"; echo "<td><div align=\"center\">"; echo SamAnaNumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamAnaLineTotal (); echo "<br /></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">ISDN2e Card </div></td>"; echo "<td><div align=\"center\">£395.00</div></td>"; echo "<td><div align=\"center\">"; echo SamISDN2NumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamISDN2LineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">ISDN30e Card </div></td>"; echo "<td><div align=\"center\">£530.00</div></td>"; echo "<td><div align=\"center\">"; echo SamISDN30NumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamISDN30LineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Digital Extension Card </div></td>"; echo "<td><div align=\"center\">£295.00</div></td>"; echo "<td><div align=\"center\">"; echo SamDigExtNumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamDigExtLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Analogue Extension Card </div></td>"; echo "<td><div align=\"center\">£295.00</div></td>"; echo "<td><div align=\"center\">"; echo SamAnaExtNumReq (); echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamAnaExtLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Voicemail</div></td>"; echo "<td><div align=\"center\">£1,000.00</div></td>"; echo "<td><div align=\"center\">1</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamVoicemail (); echo "<br /><br /></div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Basic Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/5007s.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/5007s_large.png\" /><br />Samsung DS-5007s Handset</span></a> </div>"; echo "<td><div align=\"center\">£100.00</div></td>"; echo "<td><div align=\"center\">"; echo $BasicHand; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamBasPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Mid Range Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/5014s.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/5014s_large.png\" /><br />Samsung DS-5014s Handset</span></a> </div>"; echo "<td><div align=\"center\">£150.00</div></td>"; echo "<td><div align=\"center\">"; echo $GeneralHand; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamMidPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Mid Range Handset <div class=\"gallerycontainer\"> <a class=\"thumbnail\" href=\"#thumb\"><img src=\"http://www.flipsolutions.co.uk/images/quoting/5038s.png\" width=\"98px\" height=\"81px\" border=\"0\" /><span><img src=\"http://www.flipsolutions.co.uk/images/quoting/5038s_large.png\" /><br />Samsung DS-5038s Handset</span></a> </div></td>"; echo "<td><div align=\"center\">£230.00</div></td>"; echo "<td><div align=\"center\">"; echo $ExecHand; echo "</div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamExecPhoneLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\"><b>Hardware Total</b></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "<b>" . "£"; echo SamHardTotal () . "<br />" . "</b>"; echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Installation</div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamInstallLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td><div align=\"center\">Training</div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\"></div></td>"; echo "<td><div align=\"center\">"; echo "£"; echo SamTrainLineTotal (); echo "<br /</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td><div align=\"center\">Total</div></td>"; echo "<td><div align=\"center\">"; echo "<b>£</b>"; echo "<b>"; echo SamTotal (); echo "</b>"; echo "</table></td>"; echo "</tr>"; echo "</table></td>"; echo "</tr>"; echo "</table>"; $out1 = ob_get_contents(); ob_end_clean(); var_dump($out1); /*----------*/ /* Avaya */ /*----------*/ /* Main Unit */ function MainUnit ($MainUnit) { global $MainUnit; return $MainUnit['0']['Price'] . "<br>"; } /* Analogue Card */ function AnaLineTotal ($LineCard,$LinesAnalogue) { global $LinesAnalogue; global $LineCard; if ($LinesAnalogue <= 0 ) { return "Not Required" . "<br>"; } elseif ($LinesAnalogue <= 5 ) { return $LineCard['0']['Price'] . "<br>"; } elseif ($LinesAnalogue <= 8 ) { return $LineCard['0']['Price'] * 2 . "<br>"; } elseif ($LinesAnalogue <= 12 ) { return $LineCard['0']['Price'] * 3 . "<br>"; } elseif ($LinesAnalogue >= 13 ) { return "Please Call" . "<br>"; } } /* Number Required */ function AnaNumReq ($LinesAnalogue) { global $LinesAnalogue; if ($LinesAnalogue <= 0 ) { return "Not Required" . "<br>"; } elseif ($LinesAnalogue <= 5 ) { return "1" . "<br>"; } elseif ($LinesAnalogue <= 8 ) { return "2" . "<br>"; } elseif ($LinesAnalogue <= 12 ) { return "3" . "<br>"; } elseif ($LinesAnalogue >= 13 ) { return "Please Call" . "<br>"; } } /* ISDN2 Card */ function ISDN2LineTotal ($LineCard,$LinesISDN2) { global $LinesISDN2; global $LineCard; if ($LinesISDN2 <= 0 ) { return "Not Required" . "<br>"; } elseif ($LinesISDN2 <= 8 ) { return $LineCard['1']['Price'] . "<br>"; } elseif ($LinesISDN2 <= 16 ) { return $LineCard['1']['Price'] * 2 . "<br>"; } elseif ($LinesISDN2 >= 17 ) { return "Please Call" . "<br>"; } } /* Number Required */ function ISDN2NumReq ($LinesISDN2) { global $LinesISDN2; if ($LinesISDN2 <= 0 ) { return "Not Required" . "<br>"; } elseif ($LinesISDN2 <= 8 ) { return "1" . "<br>"; } elseif ($LinesISDN2 <= 16 ) { return "2" . "<br>"; } elseif ($LinesISDN2 >= 17 ) { return "Please Call" . "<br>"; } } /* ISDN30 Card */ function ISDN30LineTotal ($LineCard,$LinesISDN30) { global $LinesISDN30; global $LineCard; if ($LinesISDN30 <= 0 ) { return "Not Required" . "<br>"; } elseif ($LinesISDN30 <= 30 ) { return $LineCard['2']['Price'] . "<br>"; } elseif ($LinesISDN30 <= 60 ) { return $LineCard['2']['Price'] * 2 . "<br>"; } elseif ($LinesISDN30 >= 61 ) { return "Please Call" . "<br>"; } } /* Number Required */ function ISDN30NumReq ($LinesISDN30) { global $LinesISDN30; if ($LinesISDN30 <= 0 ) { return "Not Required" . "<br>"; } elseif ($LinesISDN30 <= 30 ) { return "1" . "<br>"; } elseif ($LinesISDN30 <= 60 ) { return "2" . "<br>"; } elseif ($LinesISDN30 >= 61 ) { return "Please Call" . "<br>"; } } /* Total Number of Lines */ function NumLines ($LinesAnalogue,$LinesISDN2,$LinesISDN30) { global $LinesAnalogue; global $LinesISDN2; global $LinesISDN30; return $LinesAnalogue + $LinesISDN2 + $LinesISDN30; } /* Digital Extension Card */ function DigExtLineTotal ($ExtCard,$DigitalExt) { global $DigitalExt; global $ExtCard; if ($DigitalExt <= 0 ) { return "Not Required" . "<br>"; } elseif ($DigitalExt <= 8 ) { return $ExtCard['0']['Price'] . "<br>"; } elseif ($DigitalExt <= 16 ) { return $ExtCard['0']['Price'] * 2 . "<br>"; } elseif ($DigitalExt <= 24 ) { return $ExtCard['0']['Price'] * 3 . "<br>"; } elseif ($DigitalExt >= 25 ) { return "Please Call" . "<br>"; } } /* Number Required */ function DigExtNumReq ($DigitalExt) { global $DigitalExt; if ($DigitalExt <= 0 ) { return "Not Required" . "<br>"; } elseif ($DigitalExt <= 8 ) { return "1" . "<br>"; } elseif ($DigitalExt <= 16 ) { return "2" . "<br>"; } elseif ($DigitalExt <= 24 ) { return "3" . "<br>"; } elseif ($DigitalExt >= 25 ) { return "Please Call" . "<br>"; } } /* Analogue Extension Card */ function AnaExtLineTotal ($ExtCard,$AnalogueExt) { global $AnalogueExt; global $ExtCard; if ($AnalogueExt <= 0 ) { return "Not Required" . "<br>"; } elseif ($AnalogueExt <= 4 ) { return $ExtCard['1']['Price'] . "<br>"; } elseif ($AnalogueExt <= 8 ) { return $ExtCard['1']['Price'] * 2 . "<br>"; } elseif ($AnalogueExt <= 12 ) { return $ExtCard['1']['Price'] * 3 . "<br>"; } elseif ($AnalogueExt >= 13 ) { return "Please Call" . "<br>"; } } /* Number Required */ function AnaExtNumReq ($AnalogueExt) { global $AnalogueExt; if ($AnalogueExt <= 0 ) { return "Not Required" . "<br>"; } elseif ($AnalogueExt <= 4 ) { return "1" . "<br>"; } elseif ($AnalogueExt <= 8 ) { return "2" . "<br>"; } elseif ($AnalogueExt <= 12 ) { return "3" . "<br>"; } elseif ($AnalogueExt >= 13 ) { return "Please Call" . "<br>"; } } /* Total Extensions */ function TotalExtension ($DigitalExt,$AnalogueExt) { global $DigitalExt; global $AnalogueExt; return $DigitalExt + $AnalogueExt; } /* echo "Total Number of Extensions : "; echo TotalExtension ( ) . "<br>"; */ /* Voicemail */ function Voicemail ($VoicemailPrice,$Voicemail) { global $Voicemail; global $VoicemailPrice; if ($Voicemail == 1 ) { return $VoicemailPrice['0']['Price'] . "<br>"; } else return "Not Required" . "<br>"; } /* Basic Phone */ function BasPhoneLineTotal ($Phones,$BasicHand) { global $BasicHand; global $Phones; if ($BasicHand <= 0 ) { return "Not Required" . "<br>"; } else return $BasicHand * $Phones['0']['Price'] . "<br>"; } /* Mid Range Phone */ function MidPhoneLineTotal ($Phones,$GeneralHand) { global $GeneralHand; global $Phones; if ($GeneralHand <= 0 ) { return "Not Required" . "<br>"; } else return $GeneralHand * $Phones['1']['Price'] . "<br>"; } /* Executive Phone */ function ExecPhoneLineTotal ($Phones,$ExecHand) { global $ExecHand; global $Phones; if ($ExecHand <= 0 ) { return "Not Required" . "<br>"; } else return $ExecHand * $Phones['2']['Price'] . "<br>"; } /* Total Number of Phones */ function NumPhones ($BasicHand,$GeneralHand,$ExecHand) { global $BasicHand; global $GeneralHand; global $ExecHand; return $BasicHand + $GeneralHand + $ExecHand; } /* Installation */ function InstallLineTotal ($Instal,$TotalExt) { Global $Instal; $TotalExt = TotalExtension ( ); if ($TotalExt <= 0 ) { return "Not Required" . "<br>"; } elseif ($TotalExt <= 10 ) { return $Instal['0']['Price'] . "<br>"; } elseif ($TotalExt <= 20 ) { return ($Instal['0']['Price'] / 2) * 3 . "<br>"; } elseif ($TotalExt <= 40 ) { return $Instal['0']['Price'] * 2 . "<br>"; } elseif ($TotalExt >= 41 ) { return "Subject to Survey" . "<br>"; } } /* Training */ function TrainLineTotal ($Train,$TotalExt) { Global $Train; $TotalExt = TotalExtension ( ); if ($TotalExt <= 0 ) { return "Not Required" . "<br>"; } elseif ($TotalExt <= 20 ) { return $Train['0']['Price'] . "<br>"; } elseif ($TotalExt <= 30 ) { return ($Train['0']['Price'] / 2) * 3 . "<br>"; } elseif ($TotalExt >= 31 ) { return "Subject to Survey" . "<br>"; } } /* Phone Total */ function PhoneTotal ( ) { return BasPhoneLineTotal () + MidPhoneLineTotal () + ExecPhoneLineTotal (); } /* *---------------------------------- * Avaya Hardware Total *---------------------------------- */ function HardTotal ( ) { return Total ( ) - (InstallLineTotal () + TrainLineTotal ()) ; } /* *---------------------------------- * Running Total *---------------------------------- */ function Total ( ) { return MainUnit () + AnaLineTotal () + ISDN2LineTotal () + ISDN30LineTotal () + AnaExtLineTotal () + DigExtLineTotal () + Voicemail () + PhoneTotal () + InstallLineTotal () + TrainLineTotal (); } I have cut down the code a bit, nothing important missing.... Quote Link to comment Share on other sites More sharing options...
JD* Posted July 1, 2008 Share Posted July 1, 2008 Does it need to do all three automatically, or upon user request? Also, how does it need to be saved (csv, text, etc)? Quote Link to comment Share on other sites More sharing options...
Bifter Posted July 1, 2008 Author Share Posted July 1, 2008 Thanks for getting back! Upon user requset would be the one, in either pdf or html, or anything that can be accessed as was previously viewed at a later date. Quote Link to comment Share on other sites More sharing options...
Bifter Posted July 1, 2008 Author Share Posted July 1, 2008 Looks like JD* has gone offline - is there anybody else who can pick this up for me? Quote Link to comment Share on other sites More sharing options...
JD* Posted July 1, 2008 Share Posted July 1, 2008 Still here, just went away for a bit... So for the user request, I would have the page have a print.css file that can show/hide elements you do/don't want to show up on the print. This way, when a person chooses "File->Print" it just does what it needs to do. As for the downloading of the page, if you want it to go out to a PDF file, you can look into a class like http://sourceforge.net/projects/pdf-php, which you can use to output content to a PDF file. Quote Link to comment Share on other sites More sharing options...
Bifter Posted July 1, 2008 Author Share Posted July 1, 2008 Excellent your back....! I have got a similar pdf class working, however I cant get the table data from the main script into the pdf one below: pdf.php <?php define('FPDF_FONTPATH','font/'); require('html_table.php'); $pdf=new PDF(); $pdf->AddPage(); $pdf->SetFont('Arial','',12); $html=''; $pdf->WriteHTML($html); $filename = md5(date('r', time())) . ".pdf"; $pdf->Output("../quote/outputs/$filename","F"); ?> html_table.php : <?php require('fpdf.php'); //function hex2dec //returns an associative array (keys: R,G,B) from //a hex html code (e.g. #3FE5AA) function hex2dec($couleur = "#000000"){ $R = substr($couleur, 1, 2); $rouge = hexdec($R); $V = substr($couleur, 3, 2); $vert = hexdec($V); $B = substr($couleur, 5, 2); $bleu = hexdec($B); $tbl_couleur = array(); $tbl_couleur['R']=$rouge; $tbl_couleur['G']=$vert; $tbl_couleur['B']=$bleu; return $tbl_couleur; } //conversion pixel -> millimeter in 72 dpi function px2mm($px){ return $px*25.4/72; } function txtentities($html){ $trans = get_html_translation_table(HTML_ENTITIES); $trans = array_flip($trans); return strtr($html, $trans); } //////////////////////////////////// class PDF extends FPDF { //variables of html parser var $B; var $I; var $U; var $HREF; var $fontList; var $issetfont; var $issetcolor; function PDF($orientation='P',$unit='mm',$format='A4') { //Call parent constructor $this->FPDF($orientation,$unit,$format); //Initialization $this->B=0; $this->I=0; $this->U=0; $this->HREF=''; $this->tableborder=0; $this->tdbegin=false; $this->tdwidth=0; $this->tdheight=0; $this->tdalign="L"; $this->tdbgcolor=false; $this->oldx=0; $this->oldy=0; $this->fontlist=array("arial","times","courier","helvetica","symbol"); $this->issetfont=false; $this->issetcolor=false; } ////////////////////////////////////// //html parser function WriteHTML($html) { $html=strip_tags($html,"<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><hr><td><tr><table><sup>"); //remove all unsupported tags $html=str_replace("\n",'',$html); //replace carriage returns by spaces $html=str_replace("\t",'',$html); //replace carriage returns by spaces $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); //explodes the string foreach($a as $i=>$e) { if($i%2==0) { //Text if($this->HREF) $this->PutLink($this->HREF,$e); elseif($this->tdbegin) { if(trim($e)!='' and $e!=" ") { $this->Cell($this->tdwidth,$this->tdheight,$e,$this->tableborder,'',$this->tdalign,$this->tdbgcolor); } elseif($e==" ") { $this->Cell($this->tdwidth,$this->tdheight,'',$this->tableborder,'',$this->tdalign,$this->tdbgcolor); } } else $this->Write(5,stripslashes(txtentities($e))); } else { //Tag if($e{0}=='/') $this->CloseTag(strtoupper(substr($e,1))); else { //Extract attributes $a2=explode(' ',$e); $tag=strtoupper(array_shift($a2)); $attr=array(); foreach($a2 as $v) if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3)) $attr[strtoupper($a3[1])]=$a3[2]; $this->OpenTag($tag,$attr); } } } } function OpenTag($tag,$attr) { //Opening tag switch($tag){ case 'SUP': if($attr['SUP'] != '') { //Set current font to: Bold, 6pt $this->SetFont('','',6); //Start 125cm plus width of cell to the right of left margin //Superscript "1" $this->Cell(2,2,$attr['SUP'],0,0,'L'); } break; case 'TABLE': // TABLE-BEGIN if( $attr['BORDER'] != '' ) $this->tableborder=$attr['BORDER']; else $this->tableborder=0; break; case 'TR': //TR-BEGIN break; case 'TD': // TD-BEGIN if( $attr['WIDTH'] != '' ) $this->tdwidth=($attr['WIDTH']/4); else $this->tdwidth=40; // SET to your own width if you need bigger fixed cells if( $attr['HEIGHT'] != '') $this->tdheight=($attr['HEIGHT']/6); else $this->tdheight=6; // SET to your own height if you need bigger fixed cells if( $attr['ALIGN'] != '' ) { $align=$attr['ALIGN']; if($align=="LEFT") $this->tdalign="L"; if($align=="CENTER") $this->tdalign="C"; if($align=="RIGHT") $this->tdalign="R"; } else $this->tdalign="L"; // SET to your own if( $attr['BGCOLOR'] != '' ) { $coul=hex2dec($attr['BGCOLOR']); $this->SetFillColor($coul['R'],$coul['G'],$coul['B']); $this->tdbgcolor=true; } $this->tdbegin=true; break; case 'HR': if( $attr['WIDTH'] != '' ) $Width = $attr['WIDTH']; else $Width = $this->w - $this->lMargin-$this->rMargin; $x = $this->GetX(); $y = $this->GetY(); $this->SetLineWidth(0.2); $this->Line($x,$y,$x+$Width,$y); $this->SetLineWidth(0.2); $this->Ln(1); break; case 'STRONG': $this->SetStyle('B',true); break; case 'EM': $this->SetStyle('I',true); break; case 'B': case 'I': case 'U': $this->SetStyle($tag,true); break; case 'A': $this->HREF=$attr['HREF']; break; case 'IMG': if(isset($attr['SRC']) and (isset($attr['WIDTH']) or isset($attr['HEIGHT']))) { if(!isset($attr['WIDTH'])) $attr['WIDTH'] = 0; if(!isset($attr['HEIGHT'])) $attr['HEIGHT'] = 0; $this->Image($attr['SRC'], $this->GetX(), $this->GetY(), px2mm($attr['WIDTH']), px2mm($attr['HEIGHT'])); } break; //case 'TR': case 'BLOCKQUOTE': case 'BR': $this->Ln(5); break; case 'P': $this->Ln(10); break; case 'FONT': if (isset($attr['COLOR']) and $attr['COLOR']!='') { $coul=hex2dec($attr['COLOR']); $this->SetTextColor($coul['R'],$coul['G'],$coul['B']); $this->issetcolor=true; } if (isset($attr['FACE']) and in_array(strtolower($attr['FACE']), $this->fontlist)) { $this->SetFont(strtolower($attr['FACE'])); $this->issetfont=true; } if (isset($attr['FACE']) and in_array(strtolower($attr['FACE']), $this->fontlist) and isset($attr['SIZE']) and $attr['SIZE']!='') { $this->SetFont(strtolower($attr['FACE']),'',$attr['SIZE']); $this->issetfont=true; } break; } } function CloseTag($tag) { //Closing tag if($tag=='SUP') { } if($tag=='TD') { // TD-END $this->tdbegin=false; $this->tdwidth=0; $this->tdheight=0; $this->tdalign="L"; $this->tdbgcolor=false; } if($tag=='TR') { // TR-END $this->Ln(); } if($tag=='TABLE') { // TABLE-END //$this->Ln(); $this->tableborder=0; } if($tag=='STRONG') $tag='B'; if($tag=='EM') $tag='I'; if($tag=='B' or $tag=='I' or $tag=='U') $this->SetStyle($tag,false); if($tag=='A') $this->HREF=''; if($tag=='FONT'){ if ($this->issetcolor==true) { $this->SetTextColor(0); } if ($this->issetfont) { $this->SetFont('arial'); $this->issetfont=false; } } } function SetStyle($tag,$enable) { //Modify style and select corresponding font $this->$tag+=($enable ? 1 : -1); $style=''; foreach(array('B','I','U') as $s) if($this->$s>0) $style.=$s; $this->SetFont('',$style); } function PutLink($URL,$txt) { //Put a hyperlink $this->SetTextColor(0,0,255); $this->SetStyle('U',true); $this->Write(5,$txt,$URL); $this->SetStyle('U',false); $this->SetTextColor(0); } }//end of class ?> Basicly getting $html to the correct format pdf.php is expecting - is the problem. Quote Link to comment Share on other sites More sharing options...
Bifter Posted July 2, 2008 Author Share Posted July 2, 2008 Please can anybody help me with this? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.