Finished Quick Search
This commit is contained in:
parent
2eb2d5f293
commit
3cf7d230ea
|
|
@ -6,8 +6,14 @@ class EmailAttachmentsController extends AppController {
|
||||||
|
|
||||||
|
|
||||||
function download($id) {
|
function download($id) {
|
||||||
Configure::write('debug', 0);
|
|
||||||
$file = $this->EmailAttachment->findById($id);
|
$file = $this->EmailAttachment->findById($id);
|
||||||
|
if(file_exists($file['EmailAttachment']['filename'])) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Configure::write('debug', 0);
|
||||||
|
|
||||||
header('Content-type: ' . $file['EmailAttachment']['type']);
|
header('Content-type: ' . $file['EmailAttachment']['type']);
|
||||||
header('Content-length: ' . $file['EmailAttachment']['size']);
|
header('Content-length: ' . $file['EmailAttachment']['size']);
|
||||||
header('Content-Disposition: attachment; filename='.$file['EmailAttachment']['name']);
|
header('Content-Disposition: attachment; filename='.$file['EmailAttachment']['name']);
|
||||||
|
|
@ -18,5 +24,10 @@ class EmailAttachmentsController extends AppController {
|
||||||
// echo $file['EmailAttachment']['filename']
|
// echo $file['EmailAttachment']['filename']
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
echo "ERROR!! : File Not Found";
|
||||||
|
echo $file['EmailAttachment']['filename'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -429,11 +429,56 @@ class EnquiriesController extends AppController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the search query form
|
||||||
|
*/
|
||||||
function search() {
|
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';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
49
vendors/shells/vault.php
vendored
49
vendors/shells/vault.php
vendored
|
|
@ -14,7 +14,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 */
|
||||||
|
|
@ -61,8 +61,11 @@ class VaultShell extends Shell {
|
||||||
$discardArray = array();
|
$discardArray = array();
|
||||||
|
|
||||||
|
|
||||||
|
//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++) {
|
||||||
$this_header = imap_headerinfo($mbox, $i);
|
$this_header = imap_headerinfo($mbox, $i);
|
||||||
$message = $this->getMessage($mbox, $i, $this_header);
|
$message = $this->getMessage($mbox, $i, $this_header);
|
||||||
|
|
@ -185,20 +188,42 @@ class VaultShell extends Shell {
|
||||||
|
|
||||||
/* Finished working with the IMAP server. Make the changes and close the connection */
|
/* 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($discardArray);
|
||||||
reset($storedArray);
|
reset($storedArray);
|
||||||
|
|
||||||
|
$numberToStore = count($storedArray);
|
||||||
|
$numberToDiscard= count($discardArray);
|
||||||
|
|
||||||
|
|
||||||
|
if($numberToStore > 0) {
|
||||||
|
echo "Got $numberToStore messages to store\n";
|
||||||
$storeSet = implode(",", $storedArray);
|
$storeSet = implode(",", $storedArray);
|
||||||
|
imap_mail_move($mbox, $storeSet, 'INBOX/Stored');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($numberToDiscard > 0) {
|
||||||
|
echo "Going to discard $numberToDiscard messages\n";
|
||||||
$discardSet = implode(",",$discardArray);
|
$discardSet = implode(",",$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');
|
imap_mail_move($mbox, $discardSet, 'INBOX/Discarded');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
imap_expunge($mbox);
|
imap_expunge($mbox);
|
||||||
imap_close($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">
|
<table cellpadding="0" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo $paginator->sort('customer_id');?></th>
|
<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('first_name');?></th>
|
||||||
<th><?php echo $paginator->sort('last_name');?></th>
|
<th><?php echo $paginator->sort('last_name');?></th>
|
||||||
<th><?php echo $paginator->sort('email');?></th>
|
<th><?php echo $paginator->sort('email');?></th>
|
||||||
|
|
@ -30,9 +29,7 @@ foreach ($contacts as $contact):
|
||||||
<td>
|
<td>
|
||||||
<?php echo $html->link($contact['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $contact['Customer']['id'])); ?>
|
<?php echo $html->link($contact['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $contact['Customer']['id'])); ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
<?php echo $contact['Contact']['id']; ?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<?php echo $contact['Contact']['first_name']; ?>
|
<?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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li><?php echo $html->link('Users', '/users/index'); ?>
|
<?php /*<li> echo $html->link('Users', '/users/index'); ?>
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo $html->link('Users Index', '/users/index'); ?></li>
|
<li> echo $html->link('Users Index', '/users/index'); </li>
|
||||||
<li class="last"><?php echo $html->link('Add User', '/users/add'); ?></li>
|
<li class="last"><?php echo $html->link('Add User', '/users/add'); </li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</li>*/
|
||||||
|
?>
|
||||||
|
|
||||||
|
<li><?php echo $html->link('Search', '/enquiries/search'); ?>
|
||||||
</li>
|
</li>
|
||||||
<li><?php echo $html->link('Help', '/pages/help'); ?>
|
<li><?php echo $html->link('Help', '/pages/help'); ?>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ echo $paginator->counter(array(
|
||||||
?></p>
|
?></p>
|
||||||
<table cellpadding="0" cellspacing="0">
|
<table cellpadding="0" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo $paginator->sort('id');?></th>
|
|
||||||
<th><?php echo $paginator->sort('name');?></th>
|
<th><?php echo $paginator->sort('name');?></th>
|
||||||
<th><?php echo $paginator->sort('code');?></th>
|
<th><?php echo $paginator->sort('code');?></th>
|
||||||
<th><?php echo $paginator->sort('country_id');?></th>
|
<th><?php echo $paginator->sort('country_id');?></th>
|
||||||
|
|
@ -24,9 +24,7 @@ foreach ($principles as $principle):
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr<?php echo $class;?>>
|
<tr<?php echo $class;?>>
|
||||||
<td>
|
|
||||||
<?php echo $principle['Principle']['id']; ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<?php echo $principle['Principle']['name']; ?>
|
<?php echo $principle['Principle']['name']; ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ table {
|
||||||
clear: both;
|
clear: both;
|
||||||
color: #333;
|
color: #333;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
width: 100%;
|
width: auto;
|
||||||
}
|
}
|
||||||
th {
|
th {
|
||||||
background: #f2f2f2;
|
background: #f2f2f2;
|
||||||
|
|
@ -603,6 +603,7 @@ table.productTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Paging */
|
/* Paging */
|
||||||
div.paging {
|
div.paging {
|
||||||
background:#fff;
|
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