Finished Quick Search
This commit is contained in:
parent
2eb2d5f293
commit
3cf7d230ea
|
|
@ -6,8 +6,14 @@ class EmailAttachmentsController extends AppController {
|
|||
|
||||
|
||||
function download($id) {
|
||||
Configure::write('debug', 0);
|
||||
|
||||
$file = $this->EmailAttachment->findById($id);
|
||||
if(file_exists($file['EmailAttachment']['filename'])) {
|
||||
|
||||
|
||||
|
||||
Configure::write('debug', 0);
|
||||
|
||||
header('Content-type: ' . $file['EmailAttachment']['type']);
|
||||
header('Content-length: ' . $file['EmailAttachment']['size']);
|
||||
header('Content-Disposition: attachment; filename='.$file['EmailAttachment']['name']);
|
||||
|
|
@ -17,6 +23,11 @@ class EmailAttachmentsController extends AppController {
|
|||
readfile($file['EmailAttachment']['filename']);
|
||||
// echo $file['EmailAttachment']['filename']
|
||||
exit();
|
||||
}
|
||||
else {
|
||||
echo "ERROR!! : File Not Found";
|
||||
echo $file['EmailAttachment']['filename'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ class EnquiriesController extends AppController {
|
|||
|
||||
var $paginate = array(
|
||||
|
||||
'contain' => false,
|
||||
'limit' => 150,
|
||||
'order'=>array('Enquiry.id' => 'desc')
|
||||
'contain' => false,
|
||||
'limit' => 150,
|
||||
'order'=>array('Enquiry.id' => 'desc')
|
||||
|
||||
);
|
||||
|
||||
|
|
@ -29,8 +29,8 @@ class EnquiriesController extends AppController {
|
|||
}
|
||||
$this->set('status_list', $status_list);
|
||||
|
||||
//debug($this->paginate());
|
||||
// $this->set('status_list', $this->Enquiry->Status->find('list'));
|
||||
//debug($this->paginate());
|
||||
// $this->set('status_list', $this->Enquiry->Status->find('list'));
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
|
|
@ -50,11 +50,11 @@ class EnquiriesController extends AppController {
|
|||
|
||||
//$this->set('files', $this->Enquiry->EnquiryFile->find('all', array('conditions' => array('EnquiryFile.enquiry_id'=>$id), 'order' => 'EnquiryFile.created ASC')));
|
||||
|
||||
/* Trying to optimise the queries for this part of the view - it's currently getting bogged down checking Email Attachments.
|
||||
/* Trying to optimise the queries for this part of the view - it's currently getting bogged down checking Email Attachments.
|
||||
* Going to create an array describing whether a particular email ID has an attachment. Trying to avoid checking binary data in a find('all') call
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
$emails = $this->Enquiry->Email->find('all', array(
|
||||
'recursive' => 0,
|
||||
'contain' => 'EmailAttachment.id', 'EmailAttachment.email_id',
|
||||
|
|
@ -67,7 +67,7 @@ class EnquiriesController extends AppController {
|
|||
TO DO:
|
||||
* Fix up Email Attachment icon on email box. Currently broken -KC 6/8/09
|
||||
$this->set('number_of_emails', $this->Enquiry->Email->find('count', array('conditions'=>array('Email.enquiry_id'=>$id))));
|
||||
*/
|
||||
*/
|
||||
|
||||
$this->set('emails', $this->Enquiry->Email->find('all', array('conditions'=>array('Email.enquiry_id' => $id))));
|
||||
$this->set('number_of_quotes', $this->Enquiry->Quote->find('count', array('conditions'=>array('Quote.enquiry_id'=>$id))));
|
||||
|
|
@ -100,7 +100,7 @@ class EnquiriesController extends AppController {
|
|||
}
|
||||
|
||||
if(isset($customer)) {
|
||||
/* Check if the customer exists in the database - otherwise send the user back to step 1*/
|
||||
/* Check if the customer exists in the database - otherwise send the user back to step 1*/
|
||||
if(!$customer) {
|
||||
$this->Session->setFlash(__('The customer must already exist in the database. Please try again', true));
|
||||
$this->redirect(array('action'=>'add'));
|
||||
|
|
@ -155,12 +155,12 @@ class EnquiriesController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
/* Internal function to display page 2 of the Add Enquiry Form Wizard
|
||||
/* Internal function to display page 2 of the Add Enquiry Form Wizard
|
||||
* to help make the flow-control logic of the add function clearer.
|
||||
* */
|
||||
function __showPage2($customer) {
|
||||
|
||||
/* Combine the first_name and last_name for the Contact Drop Down Box */
|
||||
/* Combine the first_name and last_name for the Contact Drop Down Box */
|
||||
$contacts = $this->Enquiry->Contact->find('all', array('conditions' => array('Contact.customer_id' => $customer['Customer']['id'])));
|
||||
$contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0} {1}', '{n}.Contact.first_name', '{n}.Contact.last_name'));
|
||||
$states = $this->Enquiry->State->find('list');
|
||||
|
|
@ -173,7 +173,7 @@ class EnquiriesController extends AppController {
|
|||
$this->set('billing_addresses', $customerAddresses);
|
||||
$this->set('shipping_addresses', $customerAddresses);
|
||||
$this->set('errors', $this->Enquiry->invalidFields());
|
||||
/* Feels like an ugly hack. But it gets the desired effect and it will do for now */
|
||||
/* Feels like an ugly hack. But it gets the desired effect and it will do for now */
|
||||
|
||||
if(isset($customerAddresses[0]['BillingAddress'])) {
|
||||
$billing_address_list[0] = "No Address Selected";
|
||||
|
|
@ -192,7 +192,7 @@ class EnquiriesController extends AppController {
|
|||
|
||||
|
||||
|
||||
/* Add enquiry_id to the Email Queue */
|
||||
/* Add enquiry_id to the Email Queue */
|
||||
|
||||
function __addToQueue($id) {
|
||||
$enquiry = $this->Enquiry->read(null, $id);
|
||||
|
|
@ -209,13 +209,13 @@ class EnquiriesController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
/* Generate Enquiry number and return it as a string */
|
||||
/* Generate Enquiry number and return it as a string */
|
||||
|
||||
function __generateEnquiryNumber($data) {
|
||||
$state = $this->Enquiry->State->findById($data['Enquiry']['state_id']);
|
||||
$principle = $this->Enquiry->Principle->findById($data['Enquiry']['principle_id']);
|
||||
/* Generate the enquiry number for this enquiry */
|
||||
/* CMC Enquiry number format is:
|
||||
/* Generate the enquiry number for this enquiry */
|
||||
/* CMC Enquiry number format is:
|
||||
* CMC<INCREMENTAL_NUMBER><STATE_INITIAL>E<PRINCIPLE_CODE><NO_OF_ENQ_FOR_THIS_PRINCIPLE_CODE>-<NO_OF_ENQ_FOR_THIS_PRINCIPLE_CODE_IN_THIS_STATE>
|
||||
* eg. CMC1245NE351234-456 */
|
||||
|
||||
|
|
@ -223,104 +223,104 @@ class EnquiriesController extends AppController {
|
|||
$enquiryoffset = 7882; //What Number Enquiry we were at before using this package.
|
||||
$enquiryid += $enquiryoffset;
|
||||
$enquiryid++;
|
||||
/* Find how many enquiries have been for this principle code */
|
||||
/* Find how many enquiries have been for this principle code */
|
||||
$principleenquiries = $this->Enquiry->findCount('principle_code ='. $principle['Principle']['code']);
|
||||
|
||||
/* Principle Code Offsets - Existing Number of Enquiries for each Principle Code */
|
||||
/* Principle Code Offsets - Existing Number of Enquiries for each Principle Code */
|
||||
$principlecode_offset = array( 15 => 207, //ELMAC, AMAL
|
||||
20 => 51, //T and B Electronic
|
||||
25 => 2062, //ATEX,Brilex,Marston
|
||||
35 => 2067, //Mid-West Instrument, DP
|
||||
36 => 47, //Reading Technologies
|
||||
37 => 2040, //Eldridge, Smart Measurement, Alia
|
||||
65 => 2212, //Papenmeier, Herberts Industrieglas
|
||||
85 => 586, //Analytical Systems, Misc
|
||||
95 => 181); //Comet, T and D.
|
||||
20 => 51, //T and B Electronic
|
||||
25 => 2062, //ATEX,Brilex,Marston
|
||||
35 => 2067, //Mid-West Instrument, DP
|
||||
36 => 47, //Reading Technologies
|
||||
37 => 2040, //Eldridge, Smart Measurement, Alia
|
||||
65 => 2212, //Papenmeier, Herberts Industrieglas
|
||||
85 => 586, //Analytical Systems, Misc
|
||||
95 => 181); //Comet, T and D.
|
||||
$principleenquiries += $principlecode_offset[$principle['Principle']['code']]; //Add the offset.
|
||||
$principleenquiries++;
|
||||
|
||||
|
||||
|
||||
/* Find how many enquiries have been for this principle code in this state */
|
||||
/* This aspect of the enquiry number is not useful anymore. Made redundant thanks to mySQL queries.
|
||||
/* Find how many enquiries have been for this principle code in this state */
|
||||
/* This aspect of the enquiry number is not useful anymore. Made redundant thanks to mySQL queries.
|
||||
* But this has been done for backwards-compatablity with existing enquiry numbers */
|
||||
$principleconditions = array
|
||||
(
|
||||
"Enquiry.principle_code" => $principle['Principle']['code'],
|
||||
"Enquiry.state_id" => $data['Enquiry']['state_id']
|
||||
(
|
||||
"Enquiry.principle_code" => $principle['Principle']['code'],
|
||||
"Enquiry.state_id" => $data['Enquiry']['state_id']
|
||||
);
|
||||
|
||||
$stateprincipleenquiries = $this->Enquiry->findCount($principleconditions);
|
||||
|
||||
/*Add the offsets for the State Principle Enquiries for each Code */
|
||||
/*Add the offsets for the State Principle Enquiries for each Code */
|
||||
$stateprinciple_offset = array(
|
||||
//Elmac, Amal
|
||||
15 => array("NSW" => 39, "VIC" => 38, "TAS" => 58,
|
||||
"ACT" => 0, "QLD" => 30, "NT" => 0,
|
||||
"WA" => 19, "SA" => 8, "Overseas" => 1),
|
||||
//T and B Electronic
|
||||
20 => array("NSW" => 14, "VIC" => 6, "TAS" => 0,
|
||||
"ACT" => 0, "QLD" => 8, "NT" => 0,
|
||||
"WA" => 12, "SA" => 1, "Overseas" => 5),
|
||||
//ATEX,Brilex,Marston
|
||||
25 => array("NSW" => 580, "VIC" => 599, "TAS" => 186,
|
||||
"ACT" => 0, "QLD" => 254, "NT" => 3,
|
||||
"WA" => 541, "SA" => 72, "Overseas" => 625),
|
||||
//Mid-West Instrument, DP
|
||||
35 => array("NSW" => 549, "VIC" => 851, "TAS" => 9,
|
||||
"ACT" => 0, "QLD" => 245, "NT" => 15,
|
||||
"WA" => 470, "SA" => 508, "Overseas" => 154),
|
||||
//Reading Technologies
|
||||
36 => array("NSW" => 1, "VIC" => 3, "TAS" => 0,
|
||||
"ACT" => 0, "QLD" => 7, "NT" => 0,
|
||||
"WA" => 0, "SA" => 4, "Overseas" => 2),
|
||||
//Eldridge, Smart Measurement, Alia
|
||||
37 => array("NSW" => 204, "VIC" => 60, "TAS" => 1,
|
||||
"ACT" => 0, "QLD" => 130, "NT" => 1,
|
||||
"WA" => 44, "SA" => 25, "Overseas" => 18),
|
||||
//Papenmeier, Herberts Industrieglas
|
||||
65 => array("NSW" => 498, "VIC" => 537, "TAS" => 44,
|
||||
"ACT" => 0, "QLD" => 158, "NT" => 12,
|
||||
"WA" => 138, "SA" => 25, "Overseas" => 174),
|
||||
//Analytical Systems, Misc
|
||||
85 => array("NSW" => 3, "VIC" => 6, "TAS" => 0,
|
||||
"ACT" => 0, "QLD" => 1, "NT" => 0,
|
||||
"WA" => 2, "SA" => 2, "Overseas" => 0),
|
||||
//Comet, T and D.
|
||||
95 => array("NSW" => 34, "VIC" => 28, "TAS" => 6,
|
||||
"ACT" => 0, "QLD" => 29, "NT" => 0,
|
||||
"WA" => 9, "SA" => 8, "Overseas" => 31),
|
||||
//Elmac, Amal
|
||||
15 => array("NSW" => 39, "VIC" => 38, "TAS" => 58,
|
||||
"ACT" => 0, "QLD" => 30, "NT" => 0,
|
||||
"WA" => 19, "SA" => 8, "Overseas" => 1),
|
||||
//T and B Electronic
|
||||
20 => array("NSW" => 14, "VIC" => 6, "TAS" => 0,
|
||||
"ACT" => 0, "QLD" => 8, "NT" => 0,
|
||||
"WA" => 12, "SA" => 1, "Overseas" => 5),
|
||||
//ATEX,Brilex,Marston
|
||||
25 => array("NSW" => 580, "VIC" => 599, "TAS" => 186,
|
||||
"ACT" => 0, "QLD" => 254, "NT" => 3,
|
||||
"WA" => 541, "SA" => 72, "Overseas" => 625),
|
||||
//Mid-West Instrument, DP
|
||||
35 => array("NSW" => 549, "VIC" => 851, "TAS" => 9,
|
||||
"ACT" => 0, "QLD" => 245, "NT" => 15,
|
||||
"WA" => 470, "SA" => 508, "Overseas" => 154),
|
||||
//Reading Technologies
|
||||
36 => array("NSW" => 1, "VIC" => 3, "TAS" => 0,
|
||||
"ACT" => 0, "QLD" => 7, "NT" => 0,
|
||||
"WA" => 0, "SA" => 4, "Overseas" => 2),
|
||||
//Eldridge, Smart Measurement, Alia
|
||||
37 => array("NSW" => 204, "VIC" => 60, "TAS" => 1,
|
||||
"ACT" => 0, "QLD" => 130, "NT" => 1,
|
||||
"WA" => 44, "SA" => 25, "Overseas" => 18),
|
||||
//Papenmeier, Herberts Industrieglas
|
||||
65 => array("NSW" => 498, "VIC" => 537, "TAS" => 44,
|
||||
"ACT" => 0, "QLD" => 158, "NT" => 12,
|
||||
"WA" => 138, "SA" => 25, "Overseas" => 174),
|
||||
//Analytical Systems, Misc
|
||||
85 => array("NSW" => 3, "VIC" => 6, "TAS" => 0,
|
||||
"ACT" => 0, "QLD" => 1, "NT" => 0,
|
||||
"WA" => 2, "SA" => 2, "Overseas" => 0),
|
||||
//Comet, T and D.
|
||||
95 => array("NSW" => 34, "VIC" => 28, "TAS" => 6,
|
||||
"ACT" => 0, "QLD" => 29, "NT" => 0,
|
||||
"WA" => 9, "SA" => 8, "Overseas" => 31),
|
||||
);
|
||||
$stateprincipleenquiries += $stateprinciple_offset[$principle['Principle']['code']][$state['State']['shortform']];
|
||||
$stateprincipleenquiries++;
|
||||
/* Generate/set the enquiry number */
|
||||
/* Generate/set the enquiry number */
|
||||
$enquiryno = 'CMC'.$enquiryid.$state['State']['enqform'].'E'.$principle['Principle']['code'].$principleenquiries.
|
||||
'-'.$stateprincipleenquiries;
|
||||
'-'.$stateprincipleenquiries;
|
||||
return $enquiryno;
|
||||
}
|
||||
|
||||
/* Autocomplete the customer name - Used in: add.ctp */
|
||||
/* Autocomplete the customer name - Used in: add.ctp */
|
||||
function completeCustomer() {
|
||||
|
||||
$this->set('customers', $this->Enquiry->Customer->find('all', array(
|
||||
'conditions' => array(
|
||||
'Customer.name LIKE' => '%'.$this->data['Customer']['name'].'%'
|
||||
),'fields' => array('Customer.name')
|
||||
'conditions' => array(
|
||||
'Customer.name LIKE' => '%'.$this->data['Customer']['name'].'%'
|
||||
),'fields' => array('Customer.name')
|
||||
)));
|
||||
$this->layout = 'ajax';
|
||||
|
||||
}
|
||||
|
||||
/* Moving this to the new Enquiry email sender. */
|
||||
/* Moving this to the new Enquiry email sender. */
|
||||
function __sendNewEnquiryEmail($id) {
|
||||
|
||||
//Setup the SMTP Options
|
||||
//Setup the SMTP Options
|
||||
$this->Email->smtpOptions = array(
|
||||
'port' => '25',
|
||||
'timeout' => '30',
|
||||
'host' => '192.168.0.8',
|
||||
'username' => 'sales',
|
||||
'password' => '2seng33+02');
|
||||
'port' => '25',
|
||||
'timeout' => '30',
|
||||
'host' => '192.168.0.8',
|
||||
'username' => 'sales',
|
||||
'password' => '2seng33+02');
|
||||
$this->Email->delivery = 'smtp';
|
||||
|
||||
$enquiry = $this->Enquiry->read(null, $id);
|
||||
|
|
@ -382,7 +382,7 @@ class EnquiriesController extends AppController {
|
|||
$this->set('billing_addresses', $customerAddresses);
|
||||
$this->set('shipping_addresses', $customerAddresses);
|
||||
|
||||
/* Feels like an ugly hack. But it gets the desired effect and it will do for now */
|
||||
/* Feels like an ugly hack. But it gets the desired effect and it will do for now */
|
||||
|
||||
if(isset($customerAddresses[0]['BillingAddress'])) {
|
||||
$billing_address_list[0] = "No Address Selected";
|
||||
|
|
@ -402,7 +402,7 @@ class EnquiriesController extends AppController {
|
|||
$this->set(compact('enquiry', 'users','contacts','principles','statuses', 'addresses'));
|
||||
}
|
||||
|
||||
/* function update_status($enquiryid) {
|
||||
/* function update_status($enquiryid) {
|
||||
$newid = $this->params['form']['value'];
|
||||
|
||||
|
||||
|
|
@ -420,21 +420,66 @@ class EnquiriesController extends AppController {
|
|||
function update_status() {
|
||||
if($this->data) {
|
||||
App::import('Core', 'Sanitize');
|
||||
$new_status = Sanitize::clean($this->data['Enquiry']['status_id']);
|
||||
$this->Enquiry->id = $this->data['Enquiry']['id'];
|
||||
$this->Enquiry->saveField('status_id', $new_status);
|
||||
$this->set('enquiry', $this->Enquiry->findById($this->data['Enquiry']['id']));
|
||||
$new_status = Sanitize::clean($this->data['Enquiry']['status_id']);
|
||||
$this->Enquiry->id = $this->data['Enquiry']['id'];
|
||||
$this->Enquiry->saveField('status_id', $new_status);
|
||||
$this->set('enquiry', $this->Enquiry->findById($this->data['Enquiry']['id']));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For the search query form
|
||||
*/
|
||||
function search() {
|
||||
if(empty($this->data)) {
|
||||
$this->Session->setFlash('Enter part of the Enquiry number you want to find');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually performs the searches
|
||||
*/
|
||||
function doSearch() {
|
||||
if(!empty($this->data)) {
|
||||
$searchQuery = $this->data['Enquiry']['search_string'];
|
||||
|
||||
$custConditions = array('Customer.name LIKE' => "%$searchQuery%");
|
||||
$enqConditions = array('Enquiry.title LIKE' => "%$searchQuery%");
|
||||
|
||||
$words = explode(" ", $searchQuery);
|
||||
|
||||
if(count($words) == 2) {
|
||||
$contactConditions = array('AND'=>array('Contact.first_name LIKE' => "%$words[0]%",
|
||||
'Contact.last_name LIKE' => "%$words[1]"));
|
||||
}
|
||||
else {
|
||||
$contactConditions = array('OR'=>array('Contact.first_name LIKE' => "%$searchQuery%",
|
||||
'Contact.last_name LIKE' => "%$searchQuery"));
|
||||
}
|
||||
|
||||
$customerResults = $this->Enquiry->Customer->find('all', array('conditions' => $custConditions, 'recursive'=>0));
|
||||
$enquiryResults = $this->Enquiry->find('all', array('conditions'=>$enqConditions, 'recursive'=>0));
|
||||
$contactResults = $this->Enquiry->find('all', array('conditions'=>$contactConditions, 'recursive'=>0));
|
||||
|
||||
$searchDone = true;
|
||||
|
||||
$statuses = $this->Enquiry->Status->find('all', array('recursive'=>0));
|
||||
$status_list = array();
|
||||
foreach ($statuses as $status) {
|
||||
$statusid = $status['Status']['id'];
|
||||
$status_list[$statusid] = $status['Status']['name'];
|
||||
}
|
||||
$this->set('status_list', $status_list);
|
||||
|
||||
|
||||
$this->set(compact('customerResults', 'enquiryResults', 'contactResults', 'searchDone', 'status_list'));
|
||||
$this->layout = 'ajax';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function mark_submitted($id = null) {
|
||||
|
|
|
|||
57
vendors/shells/vault.php
vendored
57
vendors/shells/vault.php
vendored
|
|
@ -14,7 +14,7 @@ class VaultShell extends Shell {
|
|||
/******************************************************
|
||||
* 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 */
|
||||
$username = 'vault';
|
||||
$password = 'xjdYOsmJWc37'; /* The password for the account to be checked */
|
||||
|
|
@ -61,9 +61,12 @@ class VaultShell extends Shell {
|
|||
$discardArray = array();
|
||||
|
||||
|
||||
//exit(0);
|
||||
|
||||
|
||||
/* 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++) {
|
||||
$this_header = imap_headerinfo($mbox, $i);
|
||||
$message = $this->getMessage($mbox, $i, $this_header);
|
||||
|
||||
|
|
@ -185,19 +188,41 @@ class VaultShell extends Shell {
|
|||
|
||||
/* Finished working with the IMAP server. Make the changes and close the connection */
|
||||
|
||||
if($testing == 0) {
|
||||
//if($testing == 0) {
|
||||
|
||||
|
||||
|
||||
echo "Tidying up now. Moving messages to Stored or Discarded\n";
|
||||
|
||||
|
||||
reset($discardArray);
|
||||
reset($storedArray);
|
||||
|
||||
$storeSet = implode(",", $storedArray);
|
||||
$discardSet = implode(",",$discardArray);
|
||||
$numberToStore = count($storedArray);
|
||||
$numberToDiscard= count($discardArray);
|
||||
|
||||
echo "Tidying up now. Moving messages to Stored or Discarded\n";
|
||||
|
||||
imap_mail_move($mbox, $storeSet, 'INBOX/Stored');
|
||||
imap_mail_move($mbox, $discardSet, 'INBOX/Discarded');
|
||||
}
|
||||
if($numberToStore > 0) {
|
||||
echo "Got $numberToStore messages to store\n";
|
||||
$storeSet = implode(",", $storedArray);
|
||||
imap_mail_move($mbox, $storeSet, 'INBOX/Stored');
|
||||
}
|
||||
|
||||
if($numberToDiscard > 0) {
|
||||
echo "Going to discard $numberToDiscard messages\n";
|
||||
$discardSet = implode(",",$discardArray);
|
||||
|
||||
imap_mail_move($mbox, $discardSet, 'INBOX/Discarded');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//}
|
||||
|
||||
imap_expunge($mbox);
|
||||
imap_close($mbox);
|
||||
|
|
@ -346,19 +371,5 @@ class VaultShell extends Shell {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate a uniq id.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function getUniqId($email_dir) {
|
||||
$uniqid = uniqid(null,TRUE);
|
||||
|
||||
return $uniqid;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ echo $paginator->counter(array(
|
|||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th><?php echo $paginator->sort('customer_id');?></th>
|
||||
<th><?php echo $paginator->sort('id');?></th>
|
||||
<th><?php echo $paginator->sort('first_name');?></th>
|
||||
<th><?php echo $paginator->sort('last_name');?></th>
|
||||
<th><?php echo $paginator->sort('email');?></th>
|
||||
|
|
@ -30,9 +29,7 @@ foreach ($contacts as $contact):
|
|||
<td>
|
||||
<?php echo $html->link($contact['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $contact['Customer']['id'])); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $contact['Contact']['id']; ?>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<?php echo $contact['Contact']['first_name']; ?>
|
||||
|
|
|
|||
124
views/enquiries/do_search.ctp
Normal file
124
views/enquiries/do_search.ctp
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
|
||||
<?php $enqCount = count($enquiryResults);
|
||||
$custCount = count($customerResults);
|
||||
$contactCount = count($contactResults);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<?php if($enqCount > 0):
|
||||
?>
|
||||
|
||||
<h2><?php echo $enqCount;?> Matching Enquiries</h2>
|
||||
<table class="mer">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Principle</th>
|
||||
<th>Enquiry Number</th>
|
||||
<th>Customer</th>
|
||||
<th>Contact</th>
|
||||
<th class="actions">Actions</th>
|
||||
</tr>
|
||||
<?php foreach ($enquiryResults as $enquiryRes):?>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
/* Set Row colour to Yellow if the Job has been won and turned into an order */
|
||||
if($enquiryRes['Status']['id'] == 3) {
|
||||
$class = ' class="jobwon"';
|
||||
}
|
||||
else if($enquiryRes['Status']['id'] == 4) {
|
||||
$class = ' class="joblost"';
|
||||
}
|
||||
else if($enquiryRes['Status']['id'] == 8) {
|
||||
$class = ' class="joblost"';
|
||||
}
|
||||
else if($enquiryRes['Status']['id'] == 9) {
|
||||
$class = ' class="joblost"';
|
||||
}
|
||||
else if($enquiryRes['Status']['id'] == 10) {
|
||||
$class = ' class="joblost"';
|
||||
}
|
||||
else if($enquiryRes['Status']['id'] == 6) {
|
||||
$class = ' class="information"';
|
||||
}
|
||||
else if($enquiryRes['Status']['id'] == 11) {
|
||||
$class = ' class="informationsent"';
|
||||
}
|
||||
else if($enquiryRes['Status']['id'] == 5) {
|
||||
$class = ' class="quoted"';
|
||||
}
|
||||
else if($enquiryRes['Status']['id'] == 1) {
|
||||
$class = ' class="requestforquote"';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<tr <?php echo $class; ?>>
|
||||
<td><?php echo date('j M Y',$time->toUnix($enquiryRes['Enquiry']['created'])); ?></td>
|
||||
<td> <?php
|
||||
if($enquiryRes['Principle']['short_name']) {
|
||||
echo $html->link($enquiryRes['Principle']['short_name'], array('controller'=> 'principles', 'action'=>'view', $enquiryRes['Principle']['id']));
|
||||
}
|
||||
else {
|
||||
echo $html->link($enquiryRes['Principle']['name'], array('controller'=> 'principles', 'action'=>'view', $enquiryRes['Principle']['id']));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo $html->link($enquiryRes['Enquiry']['title'], array('controller'=>'enquiries', 'action'=>'view', $enquiryRes['Enquiry']['id'])); ?></td>
|
||||
<td> <?php echo $html->link($enquiryRes['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $enquiryRes['Customer']['id'])); ?></td>
|
||||
<td> <?php echo $html->link($enquiryRes['Contact']['first_name'].' '.$enquiryRes['Contact']['last_name'], array('controller'=> 'contacts', 'action'=>'view', $enquiryRes['Contact']['id'])); ?></td>
|
||||
<td><?php echo $html->link('View', array('controller'=>'enquiries', 'action'=>'view', $enquiryRes['Enquiry']['id'])); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</table>
|
||||
|
||||
<?php endif;?>
|
||||
|
||||
|
||||
|
||||
<?php if($custCount > 0):
|
||||
?>
|
||||
<h2><?php echo $custCount; ?> Matching Customers</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
<?php foreach($customerResults as $custRes): ?>
|
||||
<tr>
|
||||
<td><?php echo $custRes['Customer']['name'];?></td>
|
||||
<td><?php echo $html->link(__('View', true), array('action'=>'view', $custRes['Customer']['id'])); ?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
<?php endif;?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php if($contactCount > 0): ?>
|
||||
<h2><?php echo $contactCount; ?> Matching Contacts</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>First Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>Customer</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
<?php foreach($contactResults as $contact): ?>
|
||||
<tr>
|
||||
<td><?php echo $contact['Contact']['first_name'];?></td>
|
||||
<td><?php echo $contact['Contact']['last_name'];?></td>
|
||||
<td><?php echo $html->link($contact['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $contact['Customer']['id'])); ?></td>
|
||||
<td><?php echo $html->link(__('View', true), array('action'=>'view', $contact['Contact']['id'])); ?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
<?php endif;?>
|
||||
26
views/enquiries/search.ctp
Normal file
26
views/enquiries/search.ctp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php echo $javascript->link('search'); ?>
|
||||
|
||||
<div class="customers form">
|
||||
|
||||
<?php echo $form->create('Enquiry', array('default'=>false));
|
||||
echo '<h2>Quick Search';
|
||||
echo $html->image('system-search.png');
|
||||
echo '</h2>';
|
||||
|
||||
echo $form->input('Enquiry.search_string', array('Label'=>'Search for:', 'id'=>'searchString'));
|
||||
|
||||
//echo $form->input('Customer.id', array('type'=>'hidden'));
|
||||
|
||||
//echo $form->end('Search');
|
||||
|
||||
?>
|
||||
|
||||
<div class ="ui-widget">
|
||||
<button id="searchButton">Search</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="results"></div>
|
||||
|
|
@ -98,11 +98,15 @@
|
|||
</ul>
|
||||
</li>
|
||||
|
||||
<li><?php echo $html->link('Users', '/users/index'); ?>
|
||||
<?php /*<li> echo $html->link('Users', '/users/index'); ?>
|
||||
<ul>
|
||||
<li><?php echo $html->link('Users Index', '/users/index'); ?></li>
|
||||
<li class="last"><?php echo $html->link('Add User', '/users/add'); ?></li>
|
||||
<li> echo $html->link('Users Index', '/users/index'); </li>
|
||||
<li class="last"><?php echo $html->link('Add User', '/users/add'); </li>
|
||||
</ul>
|
||||
</li>*/
|
||||
?>
|
||||
|
||||
<li><?php echo $html->link('Search', '/enquiries/search'); ?>
|
||||
</li>
|
||||
<li><?php echo $html->link('Help', '/pages/help'); ?>
|
||||
<ul>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ echo $paginator->counter(array(
|
|||
?></p>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th><?php echo $paginator->sort('id');?></th>
|
||||
|
||||
<th><?php echo $paginator->sort('name');?></th>
|
||||
<th><?php echo $paginator->sort('code');?></th>
|
||||
<th><?php echo $paginator->sort('country_id');?></th>
|
||||
|
|
@ -24,9 +24,7 @@ foreach ($principles as $principle):
|
|||
}
|
||||
?>
|
||||
<tr<?php echo $class;?>>
|
||||
<td>
|
||||
<?php echo $principle['Principle']['id']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $principle['Principle']['name']; ?>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ table {
|
|||
clear: both;
|
||||
color: #333;
|
||||
margin-bottom: 10px;
|
||||
width: 100%;
|
||||
width: auto;
|
||||
}
|
||||
th {
|
||||
background: #f2f2f2;
|
||||
|
|
@ -603,6 +603,7 @@ table.productTable {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* Paging */
|
||||
div.paging {
|
||||
background:#fff;
|
||||
|
|
|
|||
10
webroot/js/globalsearch.js
Normal file
10
webroot/js/globalsearch.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* file: globalsearch.js
|
||||
*
|
||||
* Use the jquery plugin to allow keyboard shortcut search from anywhere
|
||||
*
|
||||
* @TODO this.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
35
webroot/js/search.js
Normal file
35
webroot/js/search.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* file: search.js
|
||||
|
||||
* Powers AJAX search of records in the CMC Sales System.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
|
||||
$("#searchButton").button().click(function() {
|
||||
|
||||
doSearch();
|
||||
return false;
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function doSearch() {
|
||||
$.post("/enquiries/doSearch", $("#searchString").serialize(), function(data) {
|
||||
$("#results").html(data);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in a new issue