Going into the vault to fix it up
This commit is contained in:
parent
11e240238c
commit
5622d8b94c
|
|
@ -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()) {
|
||||||
|
|
@ -260,7 +346,7 @@ class QuotesController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revise an existing quote.
|
* Revise an existing quote.
|
||||||
*
|
*
|
||||||
* Might make this AJAXy in the future. For now, I just want to make it work
|
* Might make this AJAXy in the future. For now, I just want to make it work
|
||||||
|
|
|
||||||
52
vendors/shells/vault.php
vendored
52
vendors/shells/vault.php
vendored
|
|
@ -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();
|
||||||
|
|
@ -181,16 +182,16 @@ class VaultShell extends Shell {
|
||||||
imap_expunge($mbox);
|
imap_expunge($mbox);
|
||||||
imap_close($mbox);
|
imap_close($mbox);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetches the body and attachments from a MIME encoded email. Uses ripmime to do the decoding
|
* Fetches the body and attachments from a MIME encoded email. Uses ripmime to do the decoding
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function fetchBodyAttachments($mailbox, $msg_number, $filename, $email_dir) {
|
function fetchBodyAttachments($mailbox, $msg_number, $filename, $email_dir) {
|
||||||
|
|
||||||
$email_file = $email_dir.'/'.$filename;
|
$email_file = $email_dir.'/'.$filename;
|
||||||
imap_savebody($mailbox, $email_file, $msg_number);
|
imap_savebody($mailbox, $email_file, $msg_number);
|
||||||
|
|
@ -217,23 +218,23 @@ function fetchBodyAttachments($mailbox, $msg_number, $filename, $email_dir) {
|
||||||
else {
|
else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* clearEmailyAttachmentDirs($email_dir, $filename, $attachment_dir, $attachments)
|
/* clearEmailyAttachmentDirs($email_dir, $filename, $attachment_dir, $attachments)
|
||||||
*
|
*
|
||||||
* Deletes $email_dir/$filename.eml and the attachments specified by $attachments
|
* Deletes $email_dir/$filename.eml and the attachments specified by $attachments
|
||||||
* */
|
* */
|
||||||
function clearEmailAttachmentDirs($email_dir, $filename, $attachments) {
|
function clearEmailAttachmentDirs($email_dir, $filename, $attachments) {
|
||||||
unlink("$email_dir/$filename");
|
unlink("$email_dir/$filename");
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
unlink($email_dir.'/'.$attachment['name']);
|
unlink($email_dir.'/'.$attachment['name']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getMessage($mbox, $msgnumber, $headers) {
|
function getMessage($mbox, $msgnumber, $headers) {
|
||||||
|
|
||||||
$subject = $headers->subject;
|
$subject = $headers->subject;
|
||||||
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
|
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
|
||||||
|
|
@ -246,9 +247,9 @@ function getMessage($mbox, $msgnumber, $headers) {
|
||||||
$message['cc'] = $recipients['cc'];
|
$message['cc'] = $recipients['cc'];
|
||||||
return $message;
|
return $message;
|
||||||
|
|
||||||
}
|
}
|
||||||
/* get Recipients from the headers of an email */
|
/* get Recipients from the headers of an email */
|
||||||
function getRecipients($headers) {
|
function getRecipients($headers) {
|
||||||
|
|
||||||
$recipients = array();
|
$recipients = array();
|
||||||
$recipients['to'] = "";
|
$recipients['to'] = "";
|
||||||
|
|
@ -282,11 +283,11 @@ function getRecipients($headers) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $recipients;
|
return $recipients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getBody($mbox, $msgnumber) {
|
function getBody($mbox, $msgnumber) {
|
||||||
$structure = imap_fetchstructure($mbox, $msgnumber);
|
$structure = imap_fetchstructure($mbox, $msgnumber);
|
||||||
if (!empty($structure->parts)) {
|
if (!empty($structure->parts)) {
|
||||||
$body = $this->getParts($structure->parts, $mbox, $msgnumber);
|
$body = $this->getParts($structure->parts, $mbox, $msgnumber);
|
||||||
|
|
@ -295,9 +296,9 @@ function getBody($mbox, $msgnumber) {
|
||||||
$body = imap_body($mbox, $msgnumber); /* Or get the plaintext */
|
$body = imap_body($mbox, $msgnumber); /* Or get the plaintext */
|
||||||
}
|
}
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIfValidEnquiry($subject, $testing) {
|
function checkIfValidEnquiry($subject, $testing) {
|
||||||
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
|
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
|
||||||
|
|
||||||
$output = array();
|
$output = array();
|
||||||
|
|
@ -319,10 +320,10 @@ function checkIfValidEnquiry($subject, $testing) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a file, or a folder and its contents (recursive algorithm)
|
* Delete a file, or a folder and its contents (recursive algorithm)
|
||||||
*
|
*
|
||||||
* @author Aidan Lister <aidan@php.net>
|
* @author Aidan Lister <aidan@php.net>
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -357,7 +357,7 @@ function rmdirr($dirname)
|
||||||
$dir->close();
|
$dir->close();
|
||||||
return; //removing the last recursion - should remove the deletion of the last directory I hope. Lazy hack using this but should work
|
return; //removing the last recursion - should remove the deletion of the last directory I hope. Lazy hack using this but should work
|
||||||
//rmdir($dirname);
|
//rmdir($dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
6
vendors/xtcpdf.php
vendored
6
vendors/xtcpdf.php
vendored
|
|
@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue