Going into the vault to fix it up

This commit is contained in:
Karl Cordes 2010-03-19 09:30:29 +11:00
parent 11e240238c
commit 5622d8b94c
7 changed files with 497 additions and 397 deletions

View file

@ -198,7 +198,93 @@ class QuotesController extends AppController {
} }
function ajaxpdf() { function ajaxpdf($id = null) {
//Configure::write('debug',0);
if(empty($this->data)) {
$this->Session->setFlash(__('Invalid Quote', true));
$this->redirect(array('controller'=>'enquiries', 'action'=>'index'));
}
else {
$id = $this->data['Quote']['id'];
$quote = $this->Quote->findById($id);
//$customer = $this->Quote->Enquiry->Customer->read(null, $quote['Enquiry']['customer_id']);
$enquiry = $this->Quote->Enquiry->find('first', array('conditions' => array('Enquiry.id' => $quote['Quote']['enquiry_id'])));
$quoteProducts = $this->Quote->LineItem->find('all', array('recursive' => 0, 'conditions' => array('LineItem.quote_id' => $id),
'order' => array('LineItem.item_number ASC'))
);
$user = $this->Quote->Enquiry->User->find('first', array('conditions' => array('User.id' => $enquiry['Enquiry']['user_id'])));
/**
* Call the commercial Comments. Need to have already figured out what page to do this on..
*
* * Passing a data structure in the following format.
*
* $details = array(
* 'deliveryTime' => (String) eg. 2-3
* 'paymentTerms => (String) eg. 100% PAYMENT WITH ORDER || NET 30 DAYS FOR APPROVED ACCOUNTS
* 'dateIssued' => (String) eg. 2009-05-20
* 'daysValid' => (Int) eg. 30
* 'deliveryPoint' => (String) eg. EX-CMC Technologies, NSW. || EX-SUPPLIER NAME
* 'exchangeRate' => (String) eg. FIXED
* 'customsDuty' => (String) eg. NIL || 5%
* 'gst' => (String) eg. 10% EXTRA || Not Applicable for Export
* 'salesEngineer' => (String) eg. Karl Cordes || Con Carpis || Kenan Fernandes etc
* );
*
*
*/
if($enquiry['Enquiry']['gst'] == 1) {
$gstPhrase = "10% EXTRA";
}
else {
$gstPhrase = "Not Applicable for Export";
}
$commercialDetails = array (
'deliveryTime' => strtoupper($quote['Quote']['delivery_time']),
'paymentTerms' => strtoupper($quote['Quote']['payment_terms']),
'dateIssued' => $quote['Quote']['date_issued'],
'validFor' => $quote['Quote']['days_valid'],
'deliveryPoint' => strtoupper($quote['Quote']['delivery_point']),
'exchangeRate' => strtoupper($quote['Quote']['exchange_rate']),
'customsDuty' => strtoupper($quote['Quote']['customs_duty']),
'gst' => strtoupper($gstPhrase),
'salesEngineer' => strtoupper($user['User']['first_name'].' '.$user['User']['last_name'])
);
$this->set('commercialDetails', $commercialDetails);
//debug($quote);
//debug($commercialDetails);
$this->set('quote', $quote);
$this->set('enquiry', $enquiry);
$this->set('products', $quoteProducts);
}
}
function BROKENajaxpdf() {
Configure::write('debug',0); Configure::write('debug',0);
if($this->RequestHandler->isAjax()) { if($this->RequestHandler->isAjax()) {

View file

@ -13,7 +13,7 @@ class VaultShell extends Shell {
/****************************************************** /******************************************************
* Config Variables * Config Variables
* *****************************************************/ * *****************************************************/
$testing = 0; //Whether to actually move the emails. 1=test, 0=production $testing = 1; //Whether to actually move the emails. 1=test, 0=production
/* Setup Connection to the IMAP server */ /* Setup Connection to the IMAP server */
$username = 'vault'; $username = 'vault';
$password = 'xjdYOsmJWc37'; /* The password for the account to be checked */ $password = 'xjdYOsmJWc37'; /* The password for the account to be checked */
@ -21,10 +21,10 @@ class VaultShell extends Shell {
$temp_filename = 'temp.eml'; $temp_filename = 'temp.eml';
if($testing == 1) { if($testing == 1) {
$email_dir = '/var/www/quotenik1.2/app/emails/working'; $email_dir = '/Users/karlcordes/Sites/app/emails/working';
} }
$mbox = imap_open("{neptune:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error()); $mbox = imap_open("{mail.cmctechnologies.com.au:143}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
$MC = imap_check($mbox); $MC = imap_check($mbox);
$number_of_messages = $MC->Nmsgs; $number_of_messages = $MC->Nmsgs;
@ -33,7 +33,7 @@ class VaultShell extends Shell {
if($number_of_messages == 0) { if($number_of_messages == 0) {
exit(0); exit(0);
} }
exit(0);
/* Loop through the messages and sort them into ones to be processed or discarded */ /* Loop through the messages and sort them into ones to be processed or discarded */
for ($i=1; $i <= $number_of_messages; $i++) { for ($i=1; $i <= $number_of_messages; $i++) {
@ -43,6 +43,7 @@ class VaultShell extends Shell {
echo "Checking msg number: $i \tSubject: ".$message['subject']."\n"; echo "Checking msg number: $i \tSubject: ".$message['subject']."\n";
$enquiry = $this->checkIfValidEnquiry($message['subject'], $testing); $enquiry = $this->checkIfValidEnquiry($message['subject'], $testing);
if($enquiry) { if($enquiry) {
//Process it and store the message and its attachments. //Process it and store the message and its attachments.
$this->Email->create(); $this->Email->create();
@ -331,8 +332,7 @@ function checkIfValidEnquiry($subject, $testing) {
* @param string $dirname Directory to delete * @param string $dirname Directory to delete
* @return bool Returns TRUE on success, FALSE on failure * @return bool Returns TRUE on success, FALSE on failure
*/ */
function rmdirr($dirname) function rmdirr($dirname) {
{
// Sanity check // Sanity check
if (!file_exists($dirname)) { if (!file_exists($dirname)) {
return false; return false;

6
vendors/xtcpdf.php vendored
View file

@ -421,12 +421,12 @@ ENDPRODUCT;
$heightNeeded = $this->getLastH(); $heightNeeded = $this->getLastH();
$this->MultiCell($qtyColwidth, $heightNeeded, "", 1, "C", 1, 0); $this->MultiCell($qtyColwidth, $heightNeeded, "", 1, "C", 1, 0);
$this->MultiCell($descColwidth, $heightNeeded, $principleName, 1, "C", 1, 0); $this->MultiCell($descColwidth, $heightNeeded, "", 1, "C", 1, 0); //Principle Name used to go here.
$this->MultiCell($unitpriceColwidth, $heightNeeded, $currency['iso4217'], 1, "C", 1, 0); $this->MultiCell($unitpriceColwidth, $heightNeeded, $currency['iso4217'], 1, "C", 1, 0);
$this->MultiCell($totalPricColwidth, $heightNeeded, $currency['iso4217'], 1, "C", 1, 1); $this->MultiCell($totalPricColwidth, $heightNeeded, $currency['iso4217'], 1, "C", 1, 1);
echo "<h2>$pageNo</h2>"; // echo "<h2>$pageNo</h2>";
// print_r($page); // print_r($page);
//Start Printing Product cells, until we run out of room. Then continue on the next page //Start Printing Product cells, until we run out of room. Then continue on the next page
@ -471,7 +471,7 @@ ENDPRODUCT;
debug($products); //debug($products);

View file

@ -1,3 +1,4 @@
<h3><?php __($quote['Quote']['line_item_count'].' Items in this Quote');?></h3>
<table cellpadding = "0" cellspacing = "0" id= "quoteTable" class="quoteproducts" "> <table cellpadding = "0" cellspacing = "0" id= "quoteTable" class="quoteproducts" ">
<thead> <thead>
<tr> <tr>

View file

@ -120,6 +120,21 @@ $tcpdf->Output($output_dir.$filename, 'F');
echo "<br> Wrote: ".$output_dir.$filename; echo "<br> Wrote: ".$output_dir.$filename;
App::import('Vendor', 'xfpdi');
//$newpdf = new concat_pdf();
$newpdf = new XFPDI();
$newpdf->SetMargins(2, 2);
$newpdf->setPrintHeader(false);
$newpdf->setPrintFooter(false);
$newpdf->setFiles(array($output_dir.$filename, $output_dir.'CMC_terms_and_conditions2006_A4.pdf'));
$newpdf->concat();
$newpdf->Output($output_dir.$filename, "F");
//$tcpdf->Output('cmcquote.pdf', 'D'); //$tcpdf->Output('cmcquote.pdf', 'D');

View file

@ -57,7 +57,7 @@ foreach ($quote['QuotePage'] as $quotePage):
<div class="quoteproducts"> <div class="quoteproducts">
<h3><?php __($quote['Quote']['line_item_count'].' Items in this Quote');?></h3>
<div id="productTable"></div> <div id="productTable"></div>
@ -66,7 +66,7 @@ foreach ($quote['QuotePage'] as $quotePage):
<button id="addLineItem">Add a Product to this Quote</button> <button id="addLineItem">Add a Product to this Quote</button>
<button id="generatePDF">Generate a PDF of this Quote</button> <button id="generatePDF">Generate a PDF of this Quote</button>
<li><?php echo $html->link(__('Generate PDF from this Quote', true), array('controller'=>'quotes', 'action'=>'pdf', $quote['Quote']['id'])); ?></li>
</ul> </ul>
</div> </div>

View file

@ -85,8 +85,6 @@ $(function() {
function getPrincipleProducts() { function getPrincipleProducts() {
$.post("/products/getPrincipleProducts", $("#LineItemPrincipleId").serialize(), function(data) { $.post("/products/getPrincipleProducts", $("#LineItemPrincipleId").serialize(), function(data) {
$('#productBox').html(data); $('#productBox').html(data);
$("#LineItemProductId").change(getProductOptions); $("#LineItemProductId").change(getProductOptions);
}); });