User import completed. Removing the contact Class
This commit is contained in:
parent
643d5c1a1d
commit
fae95d8065
|
|
@ -6,7 +6,7 @@ class AppController extends Controller {
|
|||
|
||||
var $components = array('Auth', 'RequestHandler');
|
||||
|
||||
var $helpers = array('Javascript', 'Time', 'Html', 'Form', 'Ajax');
|
||||
var $helpers = array('Javascript', 'Time', 'Html', 'Form');
|
||||
function beforeFilter() {
|
||||
$this->set('currentuser', $this->Auth->user());
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
class ContactsController extends AppController {
|
||||
|
||||
var $name = 'Contacts';
|
||||
var $helpers = array('Html', 'Form', 'Ajax');
|
||||
var $helpers = array('Html', 'Form');
|
||||
var $components = array('RequestHandler');
|
||||
var $paginate = array(
|
||||
'Contact' => array('order' => array('Contact.customer_id' => 'asc')),
|
||||
|
|
|
|||
9
controllers/email_recipients_controller.php
Executable file
9
controllers/email_recipients_controller.php
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
class EmailRecipientsController extends AppController {
|
||||
|
||||
var $name = 'EmailRecipients';
|
||||
var $helpers = array('Html', 'Form', 'Number');
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -15,7 +15,7 @@ class EnquiriesController extends AppController {
|
|||
|
||||
var $components = array('RequestHandler', 'Email');
|
||||
|
||||
var $cacheAction = "1 hour";
|
||||
//var $cacheAction = "1 hour";
|
||||
|
||||
|
||||
function index() {
|
||||
|
|
@ -58,6 +58,8 @@ class EnquiriesController extends AppController {
|
|||
|
||||
/* 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
|
||||
*
|
||||
* WTF was I thinking. Binary data in the database. Fucking oath.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
|
@ -76,7 +78,7 @@ class EnquiriesController extends AppController {
|
|||
*/
|
||||
|
||||
|
||||
$this->set('emails', $this->Enquiry->Email->find('all', 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))));
|
||||
//$this->set('number_of_files', $this->Enquiry->EnquiryFile->find('count', array('conditions' => array('EnquiryFile.enquiry_id'=>$id))));
|
||||
$this->set('principle_emails', $this->Enquiry->Principle->PrincipleContact->findAllByPrincipleId($enquiry['Enquiry']['principle_id']));
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ class UsersController extends AppController {
|
|||
var $helpers = array('Html', 'Form');
|
||||
var $components = array('Acl','Auth', 'Cookie');
|
||||
var $paginate = array(
|
||||
'Users' => array('order' => array('User.name' => 'asc'),
|
||||
'limit' => 20
|
||||
'Users' => array('order' => array('User.id' => 'desc'),
|
||||
'limit' => 200
|
||||
),
|
||||
'Enquiry' => array('order' => array('Enquiry.id' => 'desc'), 'limit' => 250)
|
||||
);
|
||||
|
|
@ -14,11 +14,13 @@ class UsersController extends AppController {
|
|||
function beforeFilter() {
|
||||
$this->Auth->allow('add');
|
||||
$this->set('currentuser', $this->Auth->user());
|
||||
$this->Auth->autoRedirect = false;
|
||||
//$this->login();
|
||||
}
|
||||
|
||||
function login() { //Provided by the authComponent
|
||||
$this->pageTitle = ': Login';
|
||||
$this->Session->setFlash(__('Please enter your Username and Password to continue', true));
|
||||
//$this->Session->setFlash(__('Please enter your Username and Password to continue', true));
|
||||
|
||||
|
||||
/* Auth Cookie code from http://www.webdevelopment2.com/cakephp-auth-component-tutorial-3/ */
|
||||
|
|
@ -39,7 +41,7 @@ class UsersController extends AppController {
|
|||
if ($this->Auth->login($cookie)) {
|
||||
// Clear auth message, just in case we use it.
|
||||
|
||||
$this->Session->setFlash(__('Welcome back '.$cookie['username']), true);
|
||||
// $this->Session->setFlash(__('Welcome back '.$cookie['username']), true);
|
||||
$this->Session->del('Message.auth');
|
||||
$this->redirect($this->Auth->redirect());
|
||||
} else { // Delete invalid Cookie
|
||||
|
|
@ -48,7 +50,6 @@ class UsersController extends AppController {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,15 +63,36 @@ class UsersController extends AppController {
|
|||
$this->User->recursive = 0;
|
||||
$this->set('users', $this->paginate());
|
||||
}
|
||||
|
||||
/**
|
||||
* View a User.
|
||||
*
|
||||
* Depending on the type of user. Fetch the appropriate data and render the appropriate template.
|
||||
*
|
||||
* @param int $id
|
||||
*/
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid User.', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->set('user', $this->User->read(null, $id));
|
||||
|
||||
$user = $this->User->read(null, $id);
|
||||
$this->set('user', $user);
|
||||
|
||||
switch($user['User']['type']) {
|
||||
case 'contact':
|
||||
$this->render('viewContact');
|
||||
break;
|
||||
|
||||
case 'principle':
|
||||
|
||||
$this->render('viewPrinciple');
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.user_id' => $id)));
|
||||
|
||||
|
||||
$statuses = $this->User->Enquiry->Status->find('all', array('recursive'=>0));
|
||||
$status_list = array();
|
||||
foreach ($statuses as $status) {
|
||||
|
|
@ -79,11 +101,42 @@ class UsersController extends AppController {
|
|||
}
|
||||
$this->set('status_list', $status_list);
|
||||
|
||||
$this->render('viewUser');
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function add_contact() {
|
||||
if (!empty($this->data)) {
|
||||
$this->User->create();
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash(__('The User has been saved', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* the default generated add() method. Used for system users, rather than contacts & principle contacts.
|
||||
*/
|
||||
function add() {
|
||||
|
||||
$this->set('groups', $this->User->Group->find('list'));
|
||||
if (!empty($this->data)) {
|
||||
$this->User->create();
|
||||
if ($this->User->save($this->data)) {
|
||||
|
|
@ -125,32 +178,8 @@ class UsersController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
function initpermissions() {
|
||||
|
||||
$group = $this->User->Group;
|
||||
//Allow admins to everything
|
||||
$group->id = 6;
|
||||
$this->Acl->allow($group, 'controllers');
|
||||
|
||||
//Manager Permission
|
||||
$group->id = 5;
|
||||
$this->Acl->allow($group, 'controllers');
|
||||
|
||||
//User Permission
|
||||
$group->id = 4;
|
||||
$this->Acl->deny($group, 'controllers');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/add');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/edit');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/view');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/add');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/edit');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/view');
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/add');
|
||||
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/edit');
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/view');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
16704
emails/.eml
Executable file
16704
emails/.eml
Executable file
File diff suppressed because it is too large
Load diff
|
|
@ -47,7 +47,7 @@ class Customer extends AppModel {
|
|||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
'Contact' => array('className' => 'Contact',
|
||||
'Contact' => array('className' => 'Contact', //Change this back to Contact for user_import.php
|
||||
'foreignKey' => 'customer_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
|
|
|
|||
|
|
@ -7,10 +7,22 @@ class Email extends AppModel {
|
|||
var $hasMany = array(
|
||||
'EmailAttachment' => array('className' => 'EmailAttachment',
|
||||
'foreignKey' => 'email_id',
|
||||
'dependent' => false)
|
||||
'dependent' => false),
|
||||
|
||||
'EmailRecipient' => array('className' => 'EmailRecipient',
|
||||
'foreignKey' => 'email_id',
|
||||
'dependent'=>true)
|
||||
|
||||
);
|
||||
|
||||
|
||||
var $hasOne = array(
|
||||
'FromUser' => array('className' => 'User',
|
||||
'foreign_key'=>'from_user_id')
|
||||
);
|
||||
|
||||
|
||||
|
||||
var $hasAndBelongsToMany = array (
|
||||
'Enquiry' => array('className' => 'Enquiry',
|
||||
'joinTable' => 'emails_enquiries'
|
||||
|
|
@ -21,8 +33,7 @@ class Email extends AppModel {
|
|||
|
||||
'PurchaseOrder' => array('className' => 'PurchaseOrder',
|
||||
'joinTable' => 'emails_purchase_orders'
|
||||
),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
|||
15
models/email_recipient.php
Executable file
15
models/email_recipient.php
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
class EmailRecipient extends AppModel {
|
||||
|
||||
var $name = 'EmailRecipient';
|
||||
|
||||
var $hasOne = array (
|
||||
'User' => array('className' => 'User',
|
||||
'foreign_key' =>'user_id' )
|
||||
);
|
||||
|
||||
var $belongsTo = array(
|
||||
'Email' => array('className'=>'Email', 'foreign_key'=>'email_id')
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
|
@ -112,12 +112,19 @@ class Enquiry extends AppModel {
|
|||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
'Contact' => array('className' => 'Contact',
|
||||
/* 'Contact' => array('className' => 'Contact',
|
||||
'foreignKey' => 'contact_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),*/
|
||||
'Contact' => array('className' => 'User',
|
||||
'foreignKey' => 'contact_user_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
|
||||
'State' => array('className' => 'State',
|
||||
'foreignKey' => 'state_id',
|
||||
'conditions' => '',
|
||||
|
|
|
|||
|
|
@ -48,7 +48,5 @@ class User extends AppModel {
|
|||
);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
106
vendors/shells/firstpass.php
vendored
106
vendors/shells/firstpass.php
vendored
|
|
@ -31,7 +31,7 @@ class FirstpassShell extends Shell {
|
|||
$mbox = imap_open("{192.168.0.8:143}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
|
||||
}
|
||||
else {
|
||||
$mbox = imap_open("{mail.cmctechnologies.com.au: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());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ class FirstpassShell extends Shell {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
$enquiries = $this->Enquiry->find('all', array('recursive'=>0,'fields' => array('Enquiry.title', 'Enquiry.id')));
|
||||
/* $enquiries = $this->Enquiry->find('all', array('recursive'=>0,'fields' => array('Enquiry.title', 'Enquiry.id')));
|
||||
|
||||
|
||||
|
||||
|
|
@ -55,33 +55,53 @@ class FirstpassShell extends Shell {
|
|||
$id = $enq['Enquiry']['id'];
|
||||
$enquiryList[$enqNumber] = $id;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//while($number_of_messages > 0) {
|
||||
|
||||
$encodingValues = array();
|
||||
for($i=0; $i <=10; $i++) {
|
||||
$encodingValues[$i] = 0;
|
||||
}
|
||||
|
||||
// for($i=1; $i <= $number_of_messages; $i++) {
|
||||
for($i=$number_of_messages; $i > 0; $i--) {
|
||||
$this_header = imap_headerinfo($mbox, $i);
|
||||
$message = $this->getMessage($mbox, $i, $this_header);
|
||||
|
||||
echo "Checking msg number: $i\tSubject: ".$message['subject']."\n";
|
||||
// $this_header = imap_headerinfo($mbox, $i);
|
||||
// $message = $this->getMessage($mbox, $i, $this_header);
|
||||
$structure = imap_fetchstructure($mbox, $i);
|
||||
//echo "Checking msg number: $i\tSubject: ".$message['subject']."\n";
|
||||
//echo "Checking msg number: $i\n";
|
||||
|
||||
$enqID = $this->checkIfValidEnquiry($message['subject'], $enquiryList);
|
||||
$encoding = $this->extract_encoding($mbox, $structure, $i);
|
||||
|
||||
if(is_numeric($encoding)) {
|
||||
$encodingValues[$encoding]++;
|
||||
echo "message $i has encoding: $encoding\t total # for this encoding=".$encodingValues[$encoding]."\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
//echo "Message: $i / $number_of_messages\n";
|
||||
|
||||
|
||||
/**$enqID = $this->checkIfValidEnquiry($message['subject'], $enquiryList);
|
||||
|
||||
if($enqID == false) {
|
||||
echo "Deleting msg number: $i\tSubject: ".$message['subject']."\n";
|
||||
// imap_delete($mbox, $i);
|
||||
//$discardArray[] = $i;
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
foreach($encodingValues as $encoding => $count) {
|
||||
echo "Encoding: $encoding\t Count: $count\n";
|
||||
}
|
||||
|
||||
echo "Tidying up now.\n";
|
||||
|
||||
//echo "Tidying up now.\n";
|
||||
|
||||
|
||||
// reset($discardArray);
|
||||
|
|
@ -112,7 +132,7 @@ class FirstpassShell extends Shell {
|
|||
|
||||
|
||||
|
||||
imap_expunge($mbox);
|
||||
/* imap_expunge($mbox);
|
||||
|
||||
echo "Messages before delete: ".$number_of_messages."\n";
|
||||
|
||||
|
|
@ -122,7 +142,7 @@ class FirstpassShell extends Shell {
|
|||
$number_of_messages = $check->Nmsgs;
|
||||
|
||||
echo "Messages after delete: ".$number_of_messages."\n";
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
@ -183,6 +203,68 @@ class FirstpassShell extends Shell {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapted from
|
||||
* http://www.electrictoolbox.com/function-extract-email-attachments-php-imap/
|
||||
* @param <type> $connection
|
||||
* @param <type> $message_number
|
||||
* @return <type>
|
||||
*/
|
||||
function extract_encoding($connection, $structure, $message_number) {
|
||||
$encoding = false;
|
||||
$attachments = array();
|
||||
//$structure = imap_fetchstructure($connection, $message_number);
|
||||
|
||||
if(isset($structure->parts)) {
|
||||
$numberOfParts = count($structure->parts);
|
||||
}
|
||||
if(isset($structure->parts) && $numberOfParts) {
|
||||
|
||||
for($i = 0; $i < $numberOfParts; $i++) {
|
||||
|
||||
$attachments[$i] = array(
|
||||
'is_attachment' => false,
|
||||
'filename' => '',
|
||||
'name' => '',
|
||||
'attachment' => ''
|
||||
);
|
||||
|
||||
if($structure->parts[$i]->ifdparameters) {
|
||||
foreach($structure->parts[$i]->dparameters as $object) {
|
||||
if(strtolower($object->attribute) == 'filename') {
|
||||
$attachments[$i]['is_attachment'] = true;
|
||||
$attachments[$i]['filename'] = $object->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($structure->parts[$i]->ifparameters) {
|
||||
foreach($structure->parts[$i]->parameters as $object) {
|
||||
if(strtolower($object->attribute) == 'name') {
|
||||
$attachments[$i]['is_attachment'] = true;
|
||||
$attachments[$i]['name'] = $object->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($attachments[$i]['is_attachment']) {
|
||||
//echo "Encoding is".$structure->parts[$i]->encoding."\n";
|
||||
/*$attachments[$i]['attachment'] = imap_fetchbody($connection, $message_number, $i+1);
|
||||
//if($structure->parts[$i]->encoding == 3) { // 3 = BASE64
|
||||
$attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']);
|
||||
}
|
||||
elseif($structure->parts[$i]->encoding == 4) { // 4 = QUOTED-PRINTABLE
|
||||
$attachments[$i]['attachment'] = quoted_printable_decode($attachments[$i]['attachment']);
|
||||
}*/
|
||||
$encoding = $structure->parts[$i]->encoding;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $encoding;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
43
vendors/shells/users_migrate.php
vendored
43
vendors/shells/users_migrate.php
vendored
|
|
@ -1,22 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* file: vault_two.php
|
||||
* file: users_migrate.php
|
||||
*
|
||||
* Major re-working of the vault idea.
|
||||
|
||||
* Move Contacts to a User.
|
||||
*/
|
||||
|
||||
class UsersMigrateShell extends Shell {
|
||||
|
||||
|
||||
var $uses = array('User', 'Contact', 'PrincipleContact', 'PurchaseOrder');
|
||||
var $uses = array('User', 'Contact', 'PrincipleContact', 'PurchaseOrder', 'Enquiry');
|
||||
|
||||
|
||||
function main() {
|
||||
|
||||
$principleContactsCount = $this->PrincipleContact->find('count');
|
||||
$contactsCount = $this->Contact->find('count');
|
||||
$contacts = $this->Contact->find('all');
|
||||
|
||||
$usersCount = $this->User->find('count');
|
||||
|
||||
$this->printCountLine($principleContactsCount, 'Principle Contact');
|
||||
|
|
@ -25,7 +26,6 @@ class UsersMigrateShell extends Shell {
|
|||
|
||||
$totalCount = $principleContactsCount + $contactsCount + $usersCount;
|
||||
$this->printCountLine($totalCount, 'Total Users we should have after migration');
|
||||
|
||||
$principleContacts = $this->PrincipleContact->find('all');
|
||||
$newPrincipleUsers = array();
|
||||
foreach($principleContacts as $contact) {
|
||||
|
|
@ -33,7 +33,7 @@ class UsersMigrateShell extends Shell {
|
|||
|
||||
$newUser['User']['principle_id'] = $contact['PrincipleContact']['principle_id'];
|
||||
$newUser['User']['type'] = 'principle';
|
||||
$newUser['User']['username'] = trim($contact['PrincipleContact']['first_name']).' '.trim($contact['PrincipleContact']['last_name']);
|
||||
// $newUser['User']['username'] = trim($contact['PrincipleContact']['first_name']).trim($contact['PrincipleContact']['last_name']);
|
||||
$newUser['User']['first_name'] = $contact['PrincipleContact']['first_name'];
|
||||
$newUser['User']['last_name'] = $contact['PrincipleContact']['last_name'];
|
||||
$newUser['User']['email'] = $contact['PrincipleContact']['email'];
|
||||
|
|
@ -44,6 +44,10 @@ class UsersMigrateShell extends Shell {
|
|||
$this->User->create();
|
||||
//$newPrincipleUsers[] = $newUser;
|
||||
$this->User->save($newUser);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$customerContacts = $this->Contact->find('all');
|
||||
|
|
@ -51,9 +55,11 @@ class UsersMigrateShell extends Shell {
|
|||
foreach($customerContacts as $contact) {
|
||||
$newUser = array();
|
||||
|
||||
$oldID = $contact['Contact']['id'];
|
||||
|
||||
$newUser['User']['customer_id'] = $contact['Contact']['customer_id'];
|
||||
$newUser['User']['type'] = 'contact';
|
||||
$newUser['User']['username'] = trim($contact['Contact']['first_name']).' '.trim($contact['Contact']['last_name']);
|
||||
// $newUser['User']['username'] = trim($contact['Contact']['first_name']).' '.trim($contact['Contact']['last_name']);
|
||||
$newUser['User']['first_name'] = $contact['Contact']['first_name'];
|
||||
$newUser['User']['last_name'] = $contact['Contact']['last_name'];
|
||||
$newUser['User']['email'] = $contact['Contact']['email'];
|
||||
|
|
@ -63,13 +69,32 @@ class UsersMigrateShell extends Shell {
|
|||
$newUser['User']['job_title'] = $contact['Contact']['job_title'];
|
||||
$newUser['User']['phone_extension'] = $contact['Contact']['phone_extension'];
|
||||
$newUser['User']['direct_phone'] = $contact['Contact']['direct_phone'];
|
||||
$this->User->create();
|
||||
$newUser['User']['mobile'] = $contact['Contact']['mobile'];
|
||||
$this->User->create($newUser);
|
||||
//$newPrincipleUsers[] = $newUser;
|
||||
$this->User->save($newUser);
|
||||
if($this->User->save($newUser)) {
|
||||
$newID = $this->User->getLastInsertID();
|
||||
$sql = "UPDATE enquiries SET contact_user_id = {$newID} WHERE contact_id = {$oldID}";
|
||||
$this->Enquiry->query($sql);
|
||||
echo $sql."\n";
|
||||
}
|
||||
else {
|
||||
echo "Unable to create new user. {$newUser['User']['email']}\n";
|
||||
}
|
||||
|
||||
}
|
||||
$newCount = $this->User->find('count');
|
||||
$this->printCountLine($newCount, 'Now have Total Users after migration');
|
||||
|
||||
if($newCount != $totalCount) {
|
||||
echo "Error! We expected to have {$totalCount}. We have {$newCount} \n";
|
||||
}
|
||||
else {
|
||||
echo "Yay! Sucessfully imported the contacts.\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
//print_r($newPrincipleUsers);
|
||||
|
||||
//$this->User->save($newPrincipleUsers);
|
||||
|
|
|
|||
141
vendors/shells/vault.php
vendored
141
vendors/shells/vault.php
vendored
|
|
@ -19,15 +19,10 @@ class VaultShell extends Shell {
|
|||
$password = 'xjdYOsmJWc37'; /* The password for the account to be checked */
|
||||
$email_dir = '/var/www/cakephp/app/emails';
|
||||
|
||||
|
||||
|
||||
$ripmime_path = '/usr/local/bin/ripmime';
|
||||
|
||||
|
||||
if($testing == 1) {
|
||||
$email_dir = '/Users/karlcordes/Sites/quotenik/app/emails';
|
||||
$ripmime_path = '/opt/local/bin/ripmime';
|
||||
$mbox = imap_open("{192.168.0.8:143}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());
|
||||
}
|
||||
else {
|
||||
$mbox = imap_open("{192.168.0.8:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
|
||||
|
|
@ -40,6 +35,7 @@ class VaultShell extends Shell {
|
|||
|
||||
echo "Number of messages to Process ".$number_of_messages."\n";
|
||||
|
||||
|
||||
if($number_of_messages == 0) {
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -64,13 +60,11 @@ class VaultShell extends Shell {
|
|||
/* 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++) {
|
||||
for($i=$number_of_messages; $i > 0; $i--) {
|
||||
$this_header = imap_headerinfo($mbox, $i);
|
||||
$message = $this->getMessage($mbox, $i, $this_header);
|
||||
|
||||
//echo "Checking msg number: $i\tSubject: ".$message['subject']."\n";
|
||||
echo "Checking msg number: $i\n";
|
||||
|
||||
$enqID = $this->checkIfValidEnquiry($message['subject'], $enquiryList);
|
||||
|
||||
|
||||
|
|
@ -81,7 +75,7 @@ class VaultShell extends Shell {
|
|||
//Generate a Uniqid for this email.
|
||||
// $uniqid = $this->getUniqId($email_dir);
|
||||
|
||||
$this->Email->create();
|
||||
/*$this->Email->create();
|
||||
$this->data['Email']['enquiry_id'] = $enqID;
|
||||
$this->data['Email']['to'] = $message['to'];
|
||||
$this->data['Email']['cc'] = $message['cc'];
|
||||
|
|
@ -89,11 +83,55 @@ class VaultShell extends Shell {
|
|||
$this->data['Email']['date'] = $message['date'];
|
||||
$this->data['Email']['subject'] = $message['subject'];
|
||||
$this->data['Email']['body'] = "";
|
||||
$this->data['Email']['plainbody'] = "";
|
||||
$this->data['Email']['plainbody'] = "";*/
|
||||
|
||||
$structure = imap_fetchstructure($mbox, $i);
|
||||
$attachments = 1;
|
||||
if (empty($structure->parts)) { /* A single part message. No attachments and is plain text */
|
||||
|
||||
$attachments = $this->extract_attachments($mbox,$structure, $i);
|
||||
echo "Msg number: $i\tSubject: ".$message['subject']."\n";
|
||||
foreach($attachments as $attachment) {
|
||||
if(isset($attachment['is_attachment'])) {
|
||||
$name = false;
|
||||
$result = false;
|
||||
|
||||
if(!empty($attachment['filename'])) {
|
||||
echo "filename: ".$attachment['filename']."\n";
|
||||
$name = $attachment['filename'];
|
||||
|
||||
}
|
||||
if(!empty($attachment['name'])) {
|
||||
echo "name: ".$attachment['name']."\n";
|
||||
$name = $attachment['name'];
|
||||
|
||||
}
|
||||
if($name != false) {
|
||||
echo $email_dir."/".$name."\n";
|
||||
|
||||
$result = file_put_contents($email_dir."/".$name, $attachment['attachment']);
|
||||
if($result === false) {
|
||||
echo "Failed to write $name\n";
|
||||
}
|
||||
else {
|
||||
$kb_result = $result / 1024;
|
||||
echo "Wrote $result kilobytes for $name\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $attachments = 1;
|
||||
|
||||
if (empty($structure->parts)) { /* A single part message. No attachments and is plain text
|
||||
$this->data['Email']['body'] = imap_body($mbox, $i);
|
||||
}
|
||||
else {
|
||||
|
|
@ -120,8 +158,9 @@ class VaultShell extends Shell {
|
|||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
if( ($this->data['Email']['body'] != "") || ($this->data['Email']['plainbody'] != "") || ($attachments != 1) ) {
|
||||
|
||||
if($this->Email->save($this->data)) {
|
||||
|
|
@ -235,7 +274,7 @@ class VaultShell extends Shell {
|
|||
*
|
||||
*/
|
||||
|
||||
function fetchBodyAttachments($mailbox, $msg_number, $email_dir, $uniqid, $ripmime_path) {
|
||||
/* function fetchBodyAttachments($mailbox, $msg_number, $email_dir, $uniqid, $ripmime_path) {
|
||||
|
||||
|
||||
|
||||
|
|
@ -247,7 +286,7 @@ class VaultShell extends Shell {
|
|||
exec($command, $output, $status);
|
||||
|
||||
/* Check the $output array and find the filenames of the attachments */
|
||||
|
||||
/*
|
||||
if($status == 0) {
|
||||
$attachments = array();
|
||||
|
||||
|
|
@ -272,7 +311,7 @@ class VaultShell extends Shell {
|
|||
unlink($email_file);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
function getMessage($mbox, $msgnumber, $headers) {
|
||||
|
|
@ -293,7 +332,10 @@ class VaultShell extends Shell {
|
|||
return $message;
|
||||
|
||||
}
|
||||
/* get Recipients from the headers of an email */
|
||||
/* get Recipients from the headers of an email
|
||||
*
|
||||
* Will need to rework this 2011
|
||||
*/
|
||||
function getRecipients($headers) {
|
||||
|
||||
$recipients = array();
|
||||
|
|
@ -344,7 +386,7 @@ class VaultShell extends Shell {
|
|||
}
|
||||
|
||||
function checkIfValidEnquiry($subject, &$enqList) {
|
||||
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
|
||||
//$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
|
||||
|
||||
$output = array();
|
||||
// $decoded_subject = iconv_mime_decode($subject, 2, "ISO-8859-1");
|
||||
|
|
@ -377,14 +419,17 @@ class VaultShell extends Shell {
|
|||
* @param <type> $message_number
|
||||
* @return <type>
|
||||
*/
|
||||
function extract_attachments($connection, $message_number) {
|
||||
function extract_attachments($connection, $structure, $message_number) {
|
||||
|
||||
$attachments = array();
|
||||
$structure = imap_fetchstructure($connection, $message_number);
|
||||
//$structure = imap_fetchstructure($connection, $message_number);
|
||||
|
||||
if(isset($structure->parts) && count($structure->parts)) {
|
||||
if(isset($structure->parts)) {
|
||||
$numberOfParts = count($structure->parts);
|
||||
}
|
||||
if(isset($structure->parts) && $numberOfParts) {
|
||||
|
||||
for($i = 0; $i < count($structure->parts); $i++) {
|
||||
for($i = 0; $i < $numberOfParts; $i++) {
|
||||
|
||||
$attachments[$i] = array(
|
||||
'is_attachment' => false,
|
||||
|
|
@ -393,7 +438,7 @@ class VaultShell extends Shell {
|
|||
'attachment' => ''
|
||||
);
|
||||
|
||||
if($structure->parts[$i]->ifparameters) {
|
||||
if($structure->parts[$i]->ifdparameters) {
|
||||
foreach($structure->parts[$i]->dparameters as $object) {
|
||||
if(strtolower($object->attribute) == 'filename') {
|
||||
$attachments[$i]['is_attachment'] = true;
|
||||
|
|
@ -412,6 +457,7 @@ class VaultShell extends Shell {
|
|||
}
|
||||
|
||||
if($attachments[$i]['is_attachment']) {
|
||||
echo "Encoding is".$structure->parts[$i]->encoding."\n";
|
||||
$attachments[$i]['attachment'] = imap_fetchbody($connection, $message_number, $i+1);
|
||||
if($structure->parts[$i]->encoding == 3) { // 3 = BASE64
|
||||
$attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']);
|
||||
|
|
@ -431,5 +477,50 @@ class VaultShell extends Shell {
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Fetches the body and attachments from a MIME encoded email. Uses ripmime to do the decoding
|
||||
*
|
||||
*/
|
||||
|
||||
function fetchBodyAttachments($mailbox, $msg_number, $email_dir, $ripmime_path) {
|
||||
|
||||
|
||||
|
||||
$email_file = $email_dir.'/'.$uniqid.'.eml';
|
||||
imap_savebody($mailbox, $email_file, $msg_number);
|
||||
$command = "$ripmime_path -i $email_file -d $email_dir --prefix --paranoid -v --verbose-contenttype";
|
||||
|
||||
$output = array();
|
||||
exec($command, $output, $status);
|
||||
|
||||
/* Check the $output array and find the filenames of the attachments */
|
||||
|
||||
if($status == 0) {
|
||||
$attachments = array();
|
||||
|
||||
for($i=0, $j=0; $i< count($output); $i++, $j++) {
|
||||
$words = explode(' ', $output[$i]);
|
||||
$type = explode('=', $words[1]);
|
||||
$name = explode('=', $words[2]);
|
||||
|
||||
if($type[1] == "" || $name[1] == "") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$attachments[$j]['type'] = $type[1];
|
||||
$attachments[$j]['name'] = $name[1];
|
||||
//echo "in message number $msg_number ($uniqid): found attachment ".$attachments[$j]['name'].' '.$attachments[$j]['type']."\n";
|
||||
}
|
||||
unlink($email_file);
|
||||
return $attachments;
|
||||
|
||||
}
|
||||
else {
|
||||
unlink($email_file);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
501
vendors/shells/vault_two.php
vendored
501
vendors/shells/vault_two.php
vendored
|
|
@ -10,12 +10,11 @@
|
|||
class VaultTwoShell extends Shell {
|
||||
|
||||
|
||||
var $uses = array('Enquiry', 'Contact', 'Invoice', 'PurchaseOrder');
|
||||
var $uses = array('Enquiry', 'Contact', 'Invoice', 'PurchaseOrder', 'User', 'Email', 'EmailRecipient', 'Job');
|
||||
|
||||
|
||||
function main() {
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Config Variables
|
||||
* *****************************************************/
|
||||
|
|
@ -25,18 +24,12 @@ class VaultTwoShell extends Shell {
|
|||
$password = 'xjdYOsmJWc37'; /* The password for the account to be checked */
|
||||
$email_dir = '/var/www/cakephp/app/emails';
|
||||
|
||||
|
||||
|
||||
$ripmime_path = '/usr/local/bin/ripmime';
|
||||
|
||||
|
||||
if($testing == 0) {
|
||||
|
||||
//$username = 'karl';
|
||||
//$password = '72seng89';
|
||||
|
||||
$email_dir = '/Users/karlcordes/Sites/quotenik/app/emails';
|
||||
$ripmime_path = '/opt/local/bin/ripmime';
|
||||
$mbox = imap_open("{mail.cmctechnologies.com.au:143}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
|
||||
}
|
||||
else {
|
||||
|
|
@ -47,9 +40,19 @@ class VaultTwoShell extends Shell {
|
|||
$MC = imap_check($mbox);
|
||||
$number_of_messages = $MC->Nmsgs;
|
||||
|
||||
echo $username."\n";
|
||||
echo "Number of messages to Process ".$number_of_messages."\n";
|
||||
|
||||
|
||||
for($i=0;$i<20;$i++) {
|
||||
|
||||
$uuid = String::uuid();
|
||||
$length = strlen($uuid);
|
||||
|
||||
echo "{$uuid} is $length \n";
|
||||
|
||||
}
|
||||
die();
|
||||
|
||||
if($number_of_messages == 0) {
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -58,107 +61,291 @@ class VaultTwoShell extends Shell {
|
|||
/* Find the strings we want to look for in the subjects. Build arrays
|
||||
* using the string as the keys, IDs as the value
|
||||
*/
|
||||
$enquiries = $this->Enquiry->find('all', array('recursive'=>0,'fields' => array('Enquiry.title', 'Enquiry.id')));
|
||||
//$contacts = $this->Contact->find('all', array('recursive'=>0, 'fields'=>array('Contact.id', 'Contact.email')));
|
||||
$invoices = $this->Invoice->find('all', array('recursive'=>0, 'fields'=>array('Invoice.id', 'Invoice.title')));
|
||||
$purchaseOrders = $this->PurchaseOrder->find('all', array('recursive'=>0, 'fields'=>array('PurchaseOrder.id', 'PurchaseOrder.title')));
|
||||
|
||||
|
||||
foreach ($enquiries as $enq) {
|
||||
$enqNumber = $enq['Enquiry']['title'];
|
||||
$id = $enq['Enquiry']['id'];
|
||||
$enquiryList[$enqNumber] = $id;
|
||||
}
|
||||
$enquiries = $this->Enquiry->find('all', array('recursive'=>0,
|
||||
'fields' => array('Enquiry.title', 'Enquiry.id')));
|
||||
|
||||
foreach ($invoices as $inv) {
|
||||
$invNumber = $inv['Invoice']['title'];
|
||||
$id = $inv['Invoice']['id'];
|
||||
$invoiceList[$invNumber] = $id;
|
||||
//echo $invNumber."\n";
|
||||
}
|
||||
$invoices = $this->Invoice->find('all', array('recursive'=>0, '
|
||||
fields'=>array('Invoice.id', 'Invoice.title')));
|
||||
|
||||
foreach ($purchaseOrders as $po) {
|
||||
$poNumber = $po['PurchaseOrder']['title'];
|
||||
$id = $po['PurchaseOrder']['id'];
|
||||
$poList[$poNumber] = $id;
|
||||
//echo $poNumber."\n";
|
||||
}
|
||||
$purchaseOrders = $this->PurchaseOrder->find('all',
|
||||
array('recursive'=>0,
|
||||
'fields'=>array('PurchaseOrder.id', 'PurchaseOrder.title')));
|
||||
|
||||
foreach($contacts as $contact) {
|
||||
$email = strtolower($contact['Contact']['email']);
|
||||
$id = $contact['Contact']['id'];
|
||||
$emailList[$email] = $id;
|
||||
//echo $email."\n";
|
||||
}
|
||||
$users = $this->User->find('all', array('recursive'=>0,
|
||||
'fields'=>array('User.id', 'User.email')));
|
||||
|
||||
$jobs = $this->Job->find('all', array('recursive'=>0, 'fields'=>array('Job.id', 'Job.title')));
|
||||
|
||||
$enquiryMap = $this->makeMap($enquiries,'Enquiry', 'title');
|
||||
$invoiceMap = $this->makeMap($invoices, 'Invoice', 'title');
|
||||
$poMap = $this->makeMap($purchaseOrders, 'PurchaseOrder', 'title');
|
||||
$userMap = $this->makeMap($users, 'User', 'email');
|
||||
$jobMap = $this->makeMap($jobs, 'Job', 'title');
|
||||
|
||||
/**
|
||||
* Loop through the messages.
|
||||
*
|
||||
* Procedure:
|
||||
*
|
||||
* 1. Check to see if the recipients (CC, or to), or Sender is in the $userMap.
|
||||
* 1a. If one of these is true, we need to capture this email. Else, delete it.
|
||||
*
|
||||
* 2. This email is either to/from/CC a user in the system.
|
||||
* We need to associate it with the right PO/Invoice/Enquiries etc.
|
||||
* Check the subject for patterns that match Identifiers.
|
||||
*
|
||||
*/
|
||||
for($i=$number_of_messages; $i > 0; $i--) {
|
||||
if(!imap_ping($mbox)) {
|
||||
echo "Connection to Mailserver dropped. Attempting to reconnect";
|
||||
$mbox = imap_open("{mail.cmctechnologies.com.au:143}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
|
||||
}
|
||||
|
||||
|
||||
$this_header = imap_headerinfo($mbox, $i);
|
||||
$message = $this->getMessage($mbox, $i, $this_header);
|
||||
//$message = $this->getMessage($mbox, $i, $this_header);
|
||||
$recipients = $this->getRecipients($this_header, true);
|
||||
|
||||
|
||||
|
||||
// echo "Checking msg number: $i\tSubject: ".$message['subject']."\n";
|
||||
//echo "Checking msg number: $i\n";
|
||||
|
||||
$enqID = $this->checkIfValidEnquiry($message['subject'], $enquiryList);
|
||||
// continue;
|
||||
//die();
|
||||
$saveThis = false; //Set to true, if To,From,CC is a Known User.
|
||||
$fromKnownUser = false;
|
||||
|
||||
|
||||
if($enqID == false && $contactID == false) {
|
||||
$uid = imap_uid($mbox, $i);
|
||||
echo "Deleting msg number: $i\tSubject: ".$message['subject']."[{$uid}]"."\n";
|
||||
imap_delete($mbox, $uid, 1);
|
||||
//$discardArray[] = $i;
|
||||
foreach($recipients['to'] as $email) {
|
||||
$saveThis = $this->userExists($email, $userMap);
|
||||
}
|
||||
foreach($recipients['from'] as $email) {
|
||||
$saveThis = $this->userExists($email, $userMap);
|
||||
$fromKnownUser = $saveThis;
|
||||
}
|
||||
|
||||
foreach($recipients['cc'] as $email) {
|
||||
$saveThis = $this->userExists($email, $userMap);
|
||||
}
|
||||
|
||||
|
||||
//print_r($recipients);
|
||||
|
||||
$subjDecoded = imap_mime_header_decode($this_header->subject);
|
||||
|
||||
$foundIdent = false;
|
||||
|
||||
|
||||
foreach($subjDecoded as $sub) {
|
||||
|
||||
$found_enquiries = $this->checkValidIdentifier($sub->text, $enquiryMap, 'enquiry');
|
||||
$foundIdent = $this->foundIdentifier($found_enquiries);
|
||||
|
||||
$found_invoices = $this->checkValidIdentifier($sub->text, $invoiceMap, 'invoice');
|
||||
$foundIdent = $this->foundIdentifier($found_invoices);
|
||||
|
||||
$found_pos = $this->checkValidIdentifier($sub->text, $poMap, 'purchaseorder');
|
||||
$foundIdent = $this->foundIdentifier($found_pos);
|
||||
|
||||
$found_jobs = $this->checkValidIdentifier($sub->text, $jobMap, 'job');
|
||||
$foundIdent = $this->foundIdentifier($found_jobs);
|
||||
|
||||
//echo "["$sub->.$sub->text;
|
||||
}
|
||||
|
||||
|
||||
//We're going to save this Email.
|
||||
//Lets grab the attachments (if any) then create the appropiate Objects.
|
||||
|
||||
|
||||
if($fromKnownUser == true || $saveThis == true || $foundIdent == true) {
|
||||
|
||||
$recipientsIDs['to'] = array();
|
||||
$recipientsIDs['from'] = array();
|
||||
$recipientsIDs['cc'] = array();
|
||||
|
||||
/**
|
||||
* Loop over each recipient email found. Build an array containing the User IDs of that user.
|
||||
*
|
||||
* If that email doesn't have a corresponding User ID. We need to create a new User for this email address.
|
||||
*
|
||||
*
|
||||
*/
|
||||
foreach($recipients as $type => $recipientArray) {
|
||||
foreach($recipientArray as $recEmail) {
|
||||
if(isset($userMap[$recEmail])) {
|
||||
$recipientsIDs[$type][] = $userMap[$recEmail]; //Existing User ID.
|
||||
}
|
||||
else {
|
||||
$message['subject']." from ".$message['from']." will be saved";
|
||||
//$recipientsIDs[$type][] = "NEW User: $recEmail"; //Need to make a new user ID.
|
||||
echo "Making a new User for: '{$recEmail}'\n";
|
||||
$newUser['User'] = array(
|
||||
'type' => 'contact',
|
||||
'email' => $recEmail,
|
||||
'by_vault' => 1
|
||||
);
|
||||
|
||||
$this->User->create();
|
||||
if($this->User->save($newUser)) {
|
||||
$newID = $this->User->id;
|
||||
echo "New User '{$recEmail}' Added with ID: {$newID}\n";
|
||||
$recipientsIDs[$type][] = $newID;
|
||||
|
||||
//Add it to the userMap
|
||||
$userMap[$recEmail] = $newID;
|
||||
}
|
||||
else {
|
||||
echo "Fatal Error: Unable to create user for email '{$recEmail}'\n";
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "--------------------------\n";
|
||||
echo "Email No: $i\n";
|
||||
echo "Subject: ".$subjDecoded[0]->text."\n";
|
||||
|
||||
if(count($found_jobs) > 0) {
|
||||
echo "Found Job IDs: \n";
|
||||
print_r($found_jobs);
|
||||
}
|
||||
|
||||
|
||||
if(count($found_pos) > 0) {
|
||||
echo "Found PO IDs: \n";
|
||||
print_r($found_pos);
|
||||
}
|
||||
|
||||
if(count($found_enquiries) > 0) {
|
||||
echo "Found enquiry IDs: \n";
|
||||
print_r($found_enquiries);
|
||||
}
|
||||
|
||||
if(count($found_invoices) > 0) {
|
||||
echo "Found Invoice IDs: \n";
|
||||
print_r($found_invoices);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$newEmail = array();
|
||||
|
||||
|
||||
$structure = imap_fetchstructure($mbox, $i);
|
||||
print_r($recipients);
|
||||
print_r($recipientsIDs);
|
||||
|
||||
//print_r($structure);
|
||||
// continue;
|
||||
|
||||
|
||||
|
||||
$attachments = $this->extract_attachments($mbox,$structure, $i);
|
||||
|
||||
foreach($attachments as $attachment) {
|
||||
if(isset($attachment['is_attachment'])) {
|
||||
$name = false;
|
||||
$result = false;
|
||||
|
||||
if(!empty($attachment['filename'])) {
|
||||
echo "\tfilename: ".$attachment['filename']."\n";
|
||||
$name = $attachment['filename'];
|
||||
}
|
||||
if(!empty($attachment['name'])) {
|
||||
echo "\tname: ".$attachment['name']."\n";
|
||||
$name = $attachment['name'];
|
||||
}
|
||||
if($name != false) {
|
||||
echo "\t".$email_dir."/".$name."\n";
|
||||
|
||||
/*$result = file_put_contents($email_dir."/".$name, $attachment['attachment']);
|
||||
if($result === false) {
|
||||
echo "Failed to write $name\n";
|
||||
}
|
||||
else {
|
||||
$kb_result = $result / 1024;
|
||||
echo "Wrote $result kilobytes for $name\n";
|
||||
}*/
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "--------\n";
|
||||
}
|
||||
else {
|
||||
echo "email {$i} will not be saved. Subject: ".$subjDecoded[0]->text."\n";
|
||||
}
|
||||
// print_r($recipients);
|
||||
// echo "----------------------\n";
|
||||
}
|
||||
|
||||
imap_expunge($mbox);
|
||||
|
||||
imap_close($mbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a 'HashMap' (array) in the format.
|
||||
* $newMap[$key] = $obj[$modelName]['id'];
|
||||
*
|
||||
* @param array $objects
|
||||
* @param string $modelName
|
||||
* @param string $keyName
|
||||
* @return array
|
||||
*/
|
||||
function makeMap($objects,$modelName, $keyName) {
|
||||
$newMap = array();
|
||||
foreach ($objects as $obj) {
|
||||
|
||||
$key = $obj[$modelName][$keyName];
|
||||
if($modelName == 'User') {
|
||||
strtolower($key);
|
||||
}
|
||||
|
||||
$newMap[$key] = $obj[$modelName]['id'];
|
||||
|
||||
}
|
||||
return $newMap;
|
||||
}
|
||||
|
||||
|
||||
function checkIfValidEnquiry($subject, &$enqList) {
|
||||
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
|
||||
|
||||
$output = array();
|
||||
// $decoded_subject = iconv_mime_decode($subject, 2, "ISO-8859-1");
|
||||
|
||||
preg_match("/CMC\d+([NVQWSOT]|ACT|NT)E\d+-\d+/", $subject, $output);
|
||||
|
||||
|
||||
if(isset($output[0])) { //Found a valid-looking Enquiry Number
|
||||
$fetched_enquirynumber = $output[0];
|
||||
|
||||
echo "'$fetched_enquirynumber'\n";
|
||||
|
||||
if(array_key_exists($fetched_enquirynumber, $enqList)) { //check if it actually exists.
|
||||
$enqid = $enqList[$fetched_enquirynumber];
|
||||
|
||||
return $enqid;
|
||||
/**
|
||||
*
|
||||
* @param <type> $recipient
|
||||
* @param <type> $emailMap
|
||||
* @return <type>
|
||||
*/
|
||||
function userExists($recipient, &$emailMap) {
|
||||
if(isset($emailMap[$recipient])) {
|
||||
//echo "$recipient is a user in the system. Will be saved\n";
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
//echo "$recipient is not a user in the system.\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkIfValidIdentifier($subject, &$list, $type) {
|
||||
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
|
||||
/**
|
||||
*
|
||||
* @param <type> $subject
|
||||
* @param <type> $list
|
||||
* @param <type> $type
|
||||
*/
|
||||
function checkValidIdentifier($subject, &$list, $type) {
|
||||
|
||||
$output = array();
|
||||
// $decoded_subject = iconv_mime_decode($subject, 2, "ISO-8859-1");
|
||||
$returnArray = array();
|
||||
|
||||
if($type == 'enquiry') {
|
||||
preg_match("/CMC\d+([NVQWSOT]|ACT|NT)E\d+-\d+/", $subject, $output);
|
||||
|
|
@ -169,47 +356,49 @@ class VaultTwoShell extends Shell {
|
|||
else if ($type == 'purchaseorder') {
|
||||
preg_match("/CMCPO\d+/", $subject, $output);
|
||||
}
|
||||
else if($type == 'job') {
|
||||
preg_match("/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\d+(N|V|W|S|T|NT|ACT)J\d+/", $subject, $output);
|
||||
}
|
||||
|
||||
if(isset($output[0])) { //Found a valid-looking Enquiry Number
|
||||
$fetched_enquirynumber = $output[0];
|
||||
foreach($output as $match) {
|
||||
if(isset($list[$match])) { //check if it actually exists.
|
||||
$returnArray[] = $list[$match];
|
||||
}
|
||||
}
|
||||
|
||||
echo "'$fetched_enquirynumber'\n";
|
||||
return $returnArray;
|
||||
|
||||
if(array_key_exists($fetched_enquirynumber, $enqList)) { //check if it actually exists.
|
||||
$enqid = $enqList[$fetched_enquirynumber];
|
||||
}
|
||||
|
||||
return $enqid;
|
||||
/**
|
||||
*
|
||||
* @param <type> $found_identifier
|
||||
* @return <type>
|
||||
*/
|
||||
function foundIdentifier(&$found_identifier) {
|
||||
if(count($found_identifier) > 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function getMessage($mbox, $msgnumber, $headers) {
|
||||
|
||||
$subject = $headers->subject;
|
||||
//$subject = $headers->subject;
|
||||
//$subject = iconv_mime_decode($subject, 0, "ISO-8859-1//IGNORE");
|
||||
// $subject = mb_convert_encoding($subject, "ISO-8859-1");
|
||||
// $subject = mb_convert_encoding($subject, "UTF-8");
|
||||
$subject = mb_decode_mimeheader($subject);
|
||||
//$subject = mb_decode_mimeheader($subject);
|
||||
|
||||
$date = $headers->date;
|
||||
$recipients = $this->getRecipients($headers, false);
|
||||
|
||||
$message['subject'] = $subject;
|
||||
$message['date'] = $date;
|
||||
$message['to'] = $recipients['to'];
|
||||
$message['from'] = $recipients['from'];
|
||||
$message['cc'] = $recipients['cc'];
|
||||
|
||||
|
||||
return $message;
|
||||
|
||||
|
|
@ -218,69 +407,105 @@ class VaultTwoShell extends Shell {
|
|||
/**
|
||||
* get Recipients from the headers of an email
|
||||
*
|
||||
* if $returnArray is true, return an array rather than a string.
|
||||
* NOT USED DUE TO AWFUL WAY CONTACTS ARE SETUP. 3 different classes of people? WTF was I thinking.
|
||||
*/
|
||||
function getRecipients($headers, $returnArray = false) {
|
||||
function getRecipients($headers) {
|
||||
|
||||
$recipients = array();
|
||||
if($returnArray == false) {
|
||||
$recipients['to'] = "";
|
||||
$recipients['from'] = "";
|
||||
$recipients['cc'] = "";
|
||||
}
|
||||
else {
|
||||
$recipients['to'] = array();
|
||||
$recipients['from'] = array();
|
||||
$recipients['cc'] = array();
|
||||
}
|
||||
|
||||
if(isset($headers->to)) {
|
||||
$to = $headers->to;
|
||||
if(count($to) > 0) {
|
||||
foreach ($to as $id => $object) {
|
||||
if($returnArray == false) {
|
||||
$recipients['to'] .= "$object->mailbox@$object->host ";
|
||||
}
|
||||
else {
|
||||
$recipients['to'][] = strtolower($object->mailbox."@".$object->host);
|
||||
}
|
||||
}
|
||||
}
|
||||
$recipients['to'] = $this->buildEmailArray($headers->to);
|
||||
}
|
||||
if(isset($headers->cc)) {
|
||||
$cc = $headers->cc;
|
||||
if(count($cc) > 0) {
|
||||
foreach ($cc as $id => $object) {
|
||||
if($returnArray == false) {
|
||||
$recipients['cc'] .= "$object->mailbox@$object->host ";
|
||||
$recipients['cc'] = $this->buildEmailArray($headers->cc);
|
||||
}
|
||||
else {
|
||||
$recipients['cc'][] = strtolower($object->mailbox."@".$object->host);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($headers->from)) {
|
||||
$from = $headers->from;
|
||||
if(count($from) > 0) {
|
||||
foreach ($from as $id => $object) {
|
||||
if($returnArray == false) {
|
||||
$recipients['from'] .= "$object->mailbox@$object->host";
|
||||
}
|
||||
else {
|
||||
$recipients['from'][] = strtolower($object->mailbox."@".$object->host);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$recipients['from'] = $this->buildEmailArray($headers->from);
|
||||
}
|
||||
|
||||
return $recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an array containing email addresses from the header object
|
||||
* passed to it.
|
||||
*
|
||||
* @param Object $recipientObj
|
||||
* @return Array
|
||||
*/
|
||||
function buildEmailArray($recipientObj) {
|
||||
$recipientList = array();
|
||||
if(count($recipientObj) > 0) {
|
||||
foreach($recipientObj as $id=> $object) {
|
||||
$recipientList[] = strtolower($object->mailbox."@".$object->host);
|
||||
}
|
||||
return $recipientList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adapted from
|
||||
* http://www.electrictoolbox.com/function-extract-email-attachments-php-imap/
|
||||
* @param <type> $connection
|
||||
* @param <type> $message_number
|
||||
* @return <type>
|
||||
*/
|
||||
function extract_attachments($connection, $structure, $message_number) {
|
||||
|
||||
$attachments = array();
|
||||
|
||||
if(isset($structure->parts)) {
|
||||
$numberOfParts = count($structure->parts);
|
||||
}
|
||||
if(isset($structure->parts) && $numberOfParts) {
|
||||
|
||||
for($i = 0; $i < $numberOfParts; $i++) {
|
||||
|
||||
$attachments[$i] = array(
|
||||
'is_attachment' => false,
|
||||
'filename' => '',
|
||||
'name' => '',
|
||||
'attachment' => ''
|
||||
);
|
||||
|
||||
if($structure->parts[$i]->ifdparameters) {
|
||||
foreach($structure->parts[$i]->dparameters as $object) {
|
||||
if(strtolower($object->attribute) == 'filename') {
|
||||
$attachments[$i]['is_attachment'] = true;
|
||||
$attachments[$i]['filename'] = $object->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($structure->parts[$i]->ifparameters) {
|
||||
foreach($structure->parts[$i]->parameters as $object) {
|
||||
if(strtolower($object->attribute) == 'name') {
|
||||
$attachments[$i]['is_attachment'] = true;
|
||||
$attachments[$i]['name'] = $object->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($attachments[$i]['is_attachment']) {
|
||||
$attachments[$i]['attachment'] = imap_fetchbody($connection, $message_number, $i+1);
|
||||
if($structure->parts[$i]->encoding == 3) { // 3 = BASE64
|
||||
$attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']);
|
||||
}
|
||||
elseif($structure->parts[$i]->encoding == 4) { // 4 = QUOTED-PRINTABLE
|
||||
$attachments[$i]['attachment'] = quoted_printable_decode($attachments[$i]['attachment']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $attachments;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,25 @@
|
|||
<div class="customers view">
|
||||
<h2><?php __('Customer: '.$customer['Customer']['name']);?></h2>
|
||||
<dl><?php $i = 0; $class = ' class="altrow"';?>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Full Company Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $customer['Customer']['name']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Trading Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $customer['Customer']['trading_name']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('ABN'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $html->link($this->element('abn', array('abn'=>$customer['Customer']['abn'])), 'http://www.abr.business.gov.au/abnDetails.aspx?ABN='.$customer['Customer']['abn'],
|
||||
array('target'=>'_blank')); ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Record Created'); ?></dt>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Date Added'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $time->nice($customer['Customer']['created']); ?>
|
||||
|
||||
|
|
@ -95,7 +102,6 @@ echo "<div class=\"actions\">".$html->link("Tag Industries for this Customer", a
|
|||
<th><?php __('Phone Number'); ?></th>
|
||||
<th><?php __('Direct Phone'); ?></th>
|
||||
<th><?php __('Fax Number'); ?></th>
|
||||
<th><?php __('Department'); ?></th>
|
||||
<th><?php __('Notes'); ?></th>
|
||||
<th class="actions"><?php __('Actions');?></th>
|
||||
</tr>
|
||||
|
|
@ -115,11 +121,10 @@ echo "<div class=\"actions\">".$html->link("Tag Industries for this Customer", a
|
|||
?></td>
|
||||
<td><?php echo $contact['Contact']['direct_phone'];?></td>
|
||||
<td><?php echo $contact['Contact']['fax'];?></td>
|
||||
<td><?php echo $contact['ContactCategory']['name']; ?></td>
|
||||
<td><?php echo $contact['Contact']['notes'];?></td>
|
||||
<td class="actions">
|
||||
<?php echo $html->link(__('View', true), array('controller'=> 'contacts', 'action'=>'view', $contact['Contact']['id'])); ?>
|
||||
<?php echo $html->link(__('Edit', true), array('controller'=> 'contacts', 'action'=>'edit', $contact['Contact']['id'])); ?>
|
||||
<?php echo $html->link(__('View', true), array('controller'=> 'users', 'action'=>'view', $contact['Contact']['id'])); ?>
|
||||
<?php echo $html->link(__('Edit', true), array('controller'=> 'users', 'action'=>'edit', $contact['Contact']['id'])); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ echo $paginator->counter(array(
|
|||
|
||||
|
||||
<th><?php echo $paginator->sort('status_id');?></th>
|
||||
<th><?php echo $paginator->sort('comments');?></th>
|
||||
<th class="actions"><?php __('Actions');?></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
@ -33,7 +32,11 @@ echo $paginator->counter(array(
|
|||
//if ($i++ % 2 == 0) {
|
||||
// $class = ' class="altrow"';
|
||||
//}
|
||||
/* Set Row colour to Yellow if the Job has been won and turned into an order */
|
||||
/* Set Row colour to Yellow if the Job has been won and turned into an order.
|
||||
*
|
||||
* re-do this as a switch statement. -Feb 2011.
|
||||
*
|
||||
* */
|
||||
if($enquiry['Status']['id'] == 3) {
|
||||
$class = ' class="jobwon"';
|
||||
}
|
||||
|
|
@ -72,8 +75,8 @@ echo $paginator->counter(array(
|
|||
else {
|
||||
$nameclass = 'class="notposted"';
|
||||
}
|
||||
echo "<td $nameclass>";
|
||||
?>
|
||||
<td <?=$nameclass?>>
|
||||
<?php
|
||||
/* Take the First Letter from First/Last Names to make the initials. Could be a problem if Users have the Same Initials */
|
||||
$firstname = $enquiry['User']['first_name'];
|
||||
|
|
@ -127,7 +130,7 @@ echo $paginator->counter(array(
|
|||
<?php echo $html->link($enquiry['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $enquiry['Customer']['id'])); ?>
|
||||
</td>
|
||||
<td class="contactname">
|
||||
<?php echo $html->link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?>
|
||||
<?php echo $html->link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'users', 'action'=>'view', $enquiry['Contact']['id'])); ?>
|
||||
</td>
|
||||
<td class="contactemail">
|
||||
<? //BCC address to Con is hardcoded in here. ?>
|
||||
|
|
@ -228,18 +231,7 @@ ENDJS;
|
|||
echo $javascript->codeBlock($jsblock);
|
||||
?>
|
||||
</td>
|
||||
<td class="comments">
|
||||
<div id="comment_<?php echo $i; ?>">
|
||||
<?php
|
||||
|
||||
$displayedComment = substr($enquiry['Enquiry']['comments'], 0, 60);
|
||||
echo $displayedComment;
|
||||
if(strlen($enquiry['Enquiry']['comments']) > strlen($displayedComment) ) {
|
||||
echo '.... '.$html->link('view all', array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id']));
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="viewedit">
|
||||
<?php echo $html->link(__('View', true), array('controller'=>'enquiries','action'=>'view', $enquiry['Enquiry']['id'])); ?>
|
||||
<?php echo $html->link(__('Edit', true), array('controller'=>'enquiries','action'=>'edit', $enquiry['Enquiry']['id'])); ?>
|
||||
|
|
@ -256,3 +248,5 @@ ENDJS;
|
|||
| <?php echo $paginator->numbers();?>
|
||||
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
|
||||
</div>
|
||||
|
||||
<?=debug($enquiries);?>
|
||||
|
|
@ -1,55 +1,263 @@
|
|||
<?php echo $javascript->link('jquery.jeditable.mini'); ?>
|
||||
|
||||
|
||||
<?php echo $paginator->options(array('url'=>$this->passedArgs)); ?>
|
||||
|
||||
<?php
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
|
||||
));
|
||||
?>
|
||||
|
||||
<table cellpadding="0" cellspacing="0" class="mer">
|
||||
<tr>
|
||||
<th><?php echo $paginator->sort('user_id');?></th>
|
||||
<th><?php echo $paginator->sort('Date', 'created');?></th>
|
||||
<?php /* <th> echo $paginator->sort('Date Submitted', 'submitted'); </th> */ ?>
|
||||
<th><?php echo $paginator->sort('principle_id');?></th>
|
||||
<th><?php echo $paginator->sort('Enquiry Number', 'title');?></th>
|
||||
<th><?php echo $paginator->sort('customer_id');?></th>
|
||||
<th><?php echo $paginator->sort('contact_id');?></th>
|
||||
<th><?php __('Email'); ?></th>
|
||||
<th><?php __('Phone No'); ?></th>
|
||||
|
||||
<th><?php __('Assigned to'); ?></th>
|
||||
<th><?php __('Date'); ?></th>
|
||||
<th><?php __('Enquiry Number'); ?></th>
|
||||
<th><?php __('Customer'); ?></th>
|
||||
<th><?php __('Contact'); ?></th>
|
||||
<th><?php __('State'); ?></th>
|
||||
<th><?php __('Country'); ?></th>
|
||||
<th><?php __('Principle'); ?></th>
|
||||
<th><?php __('Status'); ?></th>
|
||||
<th><?php __('Comments'); ?></th>
|
||||
|
||||
<th><?php echo $paginator->sort('status_id');?></th>
|
||||
<th><?php echo $paginator->sort('comments');?></th>
|
||||
<th class="actions"><?php __('Actions');?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($enquiries as $enquiry):
|
||||
$class = null;
|
||||
/* Set Row colour to Yellow if the Job has been won and turned into an order */
|
||||
//if ($i++ % 2 == 0) {
|
||||
// $class = ' class="altrow"';
|
||||
//}
|
||||
/* Set Row colour to Yellow if the Job has been won and turned into an order.
|
||||
*
|
||||
* re-do this as a switch statement. -Feb 2011.
|
||||
*
|
||||
* */
|
||||
if($enquiry['Status']['id'] == 3) {
|
||||
$class = ' class="jobwon"';
|
||||
}
|
||||
else if($enquiry['Status']['id'] == 4) {
|
||||
$class = ' class="joblost"';
|
||||
}
|
||||
else if($enquiry['Status']['id'] == 8) {
|
||||
$class = ' class="joblost"';
|
||||
}
|
||||
else if($enquiry['Status']['id'] == 9) {
|
||||
$class = ' class="joblost"';
|
||||
}
|
||||
else if($enquiry['Status']['id'] == 10) {
|
||||
$class = ' class="joblost"';
|
||||
}
|
||||
else if($enquiry['Status']['id'] == 6) {
|
||||
$class = ' class="information"';
|
||||
}
|
||||
else if($enquiry['Status']['id'] == 11) {
|
||||
$class = ' class="informationsent"';
|
||||
}
|
||||
else if($enquiry['Status']['id'] == 5) {
|
||||
$class = ' class="quoteissued"';
|
||||
$class = ' class="quoted"';
|
||||
}
|
||||
else if($enquiry['Status']['id'] == 1) {
|
||||
$class = ' class="requestforquote"';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<tr<?php echo $class;?>>
|
||||
<td>
|
||||
<? $firstname = $enquiry['User']['first_name'];
|
||||
$lastname = $enquiry['User']['last_name'];
|
||||
echo $html->link($firstname[0].$lastname[0], array('controller'=> 'users', 'action'=>'view', $enquiry['User']['id'])); ?>
|
||||
<tr<?php echo $class;?> id="row<?php echo $enquiry['Enquiry']['id']; ?>">
|
||||
<?php $nameclass = null;
|
||||
if($enquiry['Enquiry']['posted'] == 1) {
|
||||
$nameclass = ' class="posted"';
|
||||
}
|
||||
else {
|
||||
$nameclass = 'class="notposted"';
|
||||
}
|
||||
?>
|
||||
<td <?=$nameclass?>>
|
||||
<?php
|
||||
/* Take the First Letter from First/Last Names to make the initials. Could be a problem if Users have the Same Initials */
|
||||
$firstname = $enquiry['User']['first_name'];
|
||||
$lastname = $enquiry['User']['last_name']; ?>
|
||||
<?php echo $html->link($firstname[0].$lastname[0], array('controller'=> 'users', 'action'=>'view', $enquiry['User']['id'])); ?>
|
||||
</td>
|
||||
<td><?php echo date('j M Y',$time->toUnix($enquiry['Enquiry']['created'])); ?></td>
|
||||
<td><?php echo $enquiry['Enquiry']['title'];?></td>
|
||||
<td><?php echo $enquiry['Customer']['name'];?></td>
|
||||
<td><?php echo $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'];?></td>
|
||||
<td><?php echo $enquiry['State']['name'];?></td>
|
||||
<td><?php echo $enquiry['Country']['name'];?></td>
|
||||
<td><?php echo $enquiry['Principle']['name'];?></td>
|
||||
<td><?php echo $enquiry['Status']['name'];?></td>
|
||||
<td><?php echo $enquiry['Enquiry']['comments'];?></td>
|
||||
<td class="actions">
|
||||
|
||||
<td class="enqdate">
|
||||
<?php
|
||||
/* Change the date from MySQL DATETIME to a D M Y format */
|
||||
echo date('j M Y',$time->toUnix($enquiry['Enquiry']['created'])); ?>
|
||||
</td>
|
||||
|
||||
|
||||
<?php
|
||||
/* <td class="enqdate">
|
||||
|
||||
Change the date from MySQL DATETIME to a D M Y format
|
||||
if($enquiry['Enquiry']['submitted']) {
|
||||
echo date('j M Y',$time->toUnix($enquiry['Enquiry']['submitted']));
|
||||
}
|
||||
else {
|
||||
/* Maybe should make this so only the assigned user can mark it as submitted.
|
||||
|
||||
echo $html->link('Not Submitted', array('controller'=>'enquiries', 'action'=>'mark_submitted', $enquiry['Enquiry']['id']));
|
||||
}
|
||||
|
||||
</td>
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<td class="principlename">
|
||||
<?php
|
||||
if($enquiry['Principle']['short_name']) {
|
||||
echo $html->link($enquiry['Principle']['short_name'], array('controller'=> 'principles', 'action'=>'view', $enquiry['Principle']['id']));
|
||||
}
|
||||
else {
|
||||
echo $html->link($enquiry['Principle']['name'], array('controller'=> 'principles', 'action'=>'view', $enquiry['Principle']['id']));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $html->link($enquiry['Enquiry']['title'], array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id'])); ?>
|
||||
</td>
|
||||
|
||||
<td class="customername">
|
||||
<?php echo $html->link($enquiry['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $enquiry['Customer']['id'])); ?>
|
||||
</td>
|
||||
<td class="contactname">
|
||||
<?php echo $html->link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'users', 'action'=>'view', $enquiry['Contact']['id'])); ?>
|
||||
</td>
|
||||
<td class="contactemail">
|
||||
<? //BCC address to Con is hardcoded in here. ?>
|
||||
<?php echo $html->link($enquiry['Contact']['email'], 'mailto:'.$enquiry['Contact']['email'].'?subject='.$enquiry['Enquiry']['title'].'&bcc=carpis@cmctechnologies.com.au'); ?>
|
||||
</td>
|
||||
<td class="contactemail">
|
||||
<?php
|
||||
if($enquiry['Contact']['mobile']) {
|
||||
echo $enquiry['Contact']['mobile'];
|
||||
}
|
||||
else if($enquiry['Contact']['direct_phone']) {
|
||||
echo $enquiry['Contact']['direct_phone'];
|
||||
}
|
||||
else {
|
||||
echo $enquiry['Contact']['phone'];
|
||||
if($enquiry['Contact']['phone_extension']) {
|
||||
echo ' ext:'.$enquiry['Contact']['phone_extension'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td class="status"><div id="<? echo $enquiry['Enquiry']['id']; ?>"><?php echo $enquiry['Status']['name']; ?></div>
|
||||
<?php
|
||||
$enqid = $enquiry['Enquiry']['id'];
|
||||
|
||||
$statusList = $status_list;
|
||||
|
||||
$statusList['selected'] = $enquiry['Enquiry']['status_id'];
|
||||
|
||||
$jsonList = json_encode($statusList);
|
||||
|
||||
$jsblock = <<<ENDJS
|
||||
|
||||
|
||||
\$('#$enqid').editable('/enquiries/update_status', {
|
||||
id : 'data[Enquiry][id]',
|
||||
name: 'data[Enquiry][status_id]',
|
||||
|
||||
data : '$jsonList',
|
||||
type : 'select',
|
||||
indicator : 'Saving...',
|
||||
submit : 'Update Status',
|
||||
cssclass: 'MER-inplace-select',
|
||||
callback : function(value, settings) {
|
||||
|
||||
var match = /won/i.test(value);
|
||||
|
||||
if(match == true) {
|
||||
\$('#row$enqid').removeClass().addClass('jobwon');
|
||||
return;
|
||||
}
|
||||
|
||||
match = /lost/i.test(value);
|
||||
|
||||
if(match == true) {
|
||||
\$('#row$enqid').removeClass().addClass('joblost');
|
||||
return;
|
||||
}
|
||||
|
||||
match = /cancelled/i.test(value);
|
||||
|
||||
if(match == true) {
|
||||
\$('#row$enqid').removeClass().addClass('joblost');
|
||||
return;
|
||||
}
|
||||
|
||||
match = /information sent/i.test(value);
|
||||
if(match == true) {
|
||||
\$('#row$enqid').removeClass().addClass('informationsent');
|
||||
return;
|
||||
}
|
||||
|
||||
match = /issued/i.test(value);
|
||||
if(match == true) {
|
||||
\$('#row$enqid').removeClass().addClass('quoted');
|
||||
return;
|
||||
}
|
||||
|
||||
match = /request for quotation/i.test(value);
|
||||
if(match == true) {
|
||||
\$('#row$enqid').removeClass().addClass('requestforquote');
|
||||
return;
|
||||
}
|
||||
|
||||
match = /assigned/i.test(value);
|
||||
if(match == true) {
|
||||
\$('#row$enqid').removeClass();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ENDJS;
|
||||
|
||||
echo $javascript->codeBlock($jsblock);
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td class="comments">
|
||||
<div id="comment_<?php echo $i; ?>">
|
||||
<?php
|
||||
|
||||
$displayedComment = substr($enquiry['Enquiry']['comments'], 0, 60);
|
||||
echo $displayedComment;
|
||||
if(strlen($enquiry['Enquiry']['comments']) > strlen($displayedComment) ) {
|
||||
echo '.... '.$html->link('view all', array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id']));
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="viewedit">
|
||||
<?php echo $html->link(__('View', true), array('controller'=>'enquiries','action'=>'view', $enquiry['Enquiry']['id'])); ?>
|
||||
<?php echo $html->link(__('Edit', true), array('controller'=>'enquiries','action'=>'edit', $enquiry['Enquiry']['id'])); ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php $i++; ?>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<div class="paging">
|
||||
|
||||
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
|
||||
| <?php echo $paginator->numbers();?>
|
||||
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
|
||||
</div>
|
||||
|
|
|
|||
5
views/elements/short_enquiry_number.ctp
Executable file
5
views/elements/short_enquiry_number.ctp
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
<?
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
<?php echo $html->link($invoice['Enquiry']['title'], array('controller' => 'enquiries', 'action' => 'view', $invoice['Enquiry']['id'])); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $invoice['Customer']['name']; ?>
|
||||
<?php echo $html->link($invoice['Customer']['name'], array('controller'=>'customers', 'action'=>'view', $invoice['Customer']['id'])); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
|
|
|
|||
237
views/jobs/index-big.ctp
Executable file
237
views/jobs/index-big.ctp
Executable file
|
|
@ -0,0 +1,237 @@
|
|||
<?php echo $javascript->link('jobindex');
|
||||
echo $javascript->link('addjob');
|
||||
?>
|
||||
|
||||
|
||||
<h2><?php __('Jobs');?></h2>
|
||||
<p>
|
||||
<?php
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
|
||||
));
|
||||
?></p>
|
||||
<table cellpadding="0" cellspacing="0" class="mer">
|
||||
<tr>
|
||||
|
||||
<th><?php echo $paginator->sort('created');?></th>
|
||||
<th><?php echo $paginator->sort('Job Number');?></th>
|
||||
<th><?php echo $paginator->sort('enquiry_id');?></th>
|
||||
<th><?php echo $paginator->sort('Customer');?></th>
|
||||
<th><?php echo $paginator->sort('customer_order_number');?></th>
|
||||
<th><?php echo $paginator->sort('supplier_reference');?></th>
|
||||
|
||||
|
||||
<th><?php echo $paginator->sort('date_order_received');?></th>
|
||||
<th><?php echo $paginator->sort('date_order_placed_on_principle');?></th>
|
||||
<th><?php echo $paginator->sort('date_scheduled_ex_works');?></th>
|
||||
<th><?php echo $paginator->sort('date_order_sent_to_customer');?></th>
|
||||
|
||||
<th><?php echo $paginator->sort('domestic_freight_paid_by');?></th>
|
||||
<th><?php echo $paginator->sort('sale_category');?></th>
|
||||
<th><?php echo $paginator->sort('shipment_category');?></th>
|
||||
<th><?php echo $paginator->sort('comments');?></th>
|
||||
|
||||
<th><?php echo $paginator->sort('company_gross_sales_aud');?></th>
|
||||
<th><?php echo $paginator->sort('net_sales_aud');?></th>
|
||||
<th><?php echo $paginator->sort('gross_profit_aud');?></th>
|
||||
<th><?php echo $paginator->sort('ato_exchange_rate');?></th>
|
||||
<th><?php echo $paginator->sort('gst');?></th>
|
||||
<th><?php echo $paginator->sort('currency_id');?></th>
|
||||
<th><?php echo $paginator->sort('gst_amount');?></th>
|
||||
<th><?php echo $paginator->sort('gross_commisions');?></th>
|
||||
<th><?php echo $paginator->sort('invoiced_amount_inc_gst');?></th>
|
||||
<th><?php echo $paginator->sort('net_export_sales_aud');?></th>
|
||||
<th><?php echo $paginator->sort('gross_profit_exports_aud');?></th>
|
||||
|
||||
<th><?php echo $paginator->sort('gp_percent');?></th>
|
||||
<th><?php echo $paginator->sort('gross_australian_sales_foreign_currency');?></th>
|
||||
<th><?php echo $paginator->sort('net_australian_sales_foreign_currency');?></th>
|
||||
<th><?php echo $paginator->sort('gross_profit_value_australian_sales_foreign_currency');?></th>
|
||||
<th><?php echo $paginator->sort('gross_export_sales_foreign_currency');?></th>
|
||||
<th><?php echo $paginator->sort('net_export_sales_foreign_currency');?></th>
|
||||
<th><?php echo $paginator->sort('gross_profit_value_after_discount_exports_foreign_currency');?></th>
|
||||
<th><?php echo $paginator->sort('gross_commissions');?></th>
|
||||
<th><?php echo $paginator->sort('net_commissions');?></th>
|
||||
|
||||
|
||||
<th class="actions"><?php __('Actions');?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($jobs as $job):
|
||||
|
||||
?>
|
||||
<tr class="jobRow">
|
||||
|
||||
|
||||
|
||||
<td class="enqdate">
|
||||
<?php
|
||||
/* Change the date from MySQL DATETIME to a D M Y format */
|
||||
echo date('j M Y',$time->toUnix($job['Job']['created'])); ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $html->link(__($job['Job']['title'], true), array('action' => 'view', $job['Job']['id'])); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $html->link($job['Enquiry']['title'], array('controller' => 'enquiries', 'action' => 'view', $job['Enquiry']['id'])); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $html->link($customers[$job['Enquiry']['customer_id']], array('controller'=>'customers',
|
||||
'action'=>'view', $job['Enquiry']['customer_id'])); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $job['Job']['customer_order_number']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['supplier_reference']; ?>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<?php echo $job['Job']['date_order_received']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo isEmptyDate($job['Job']['date_order_placed_on_principle']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo isEmptyDate($job['Job']['date_scheduled_ex_works']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo isEmptyDate($job['Job']['date_order_sent_to_customer']); ?>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['domestic_freight_paid_by']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $job['Job']['sale_category']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $job['Job']['shipment_category']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $job['Job']['comments']; ?>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['company_gross_sales_aud']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['net_sales_aud']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gross_profit_aud']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['ato_exchange_rate']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gst']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['currency_id']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gst_amount']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gross_commisions']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['invoiced_amount_inc_gst']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['net_export_sales_aud']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gross_profit_exports_aud']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gp_percent']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gross_australian_sales_foreign_currency']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['net_australian_sales_foreign_currency']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gross_profit_value_australian_sales_foreign_currency']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gross_export_sales_foreign_currency']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['net_export_sales_foreign_currency']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gross_profit_value_after_discount_exports_foreign_currency']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['gross_commissions']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $job['Job']['net_commissions']; ?>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="actions">
|
||||
<?php //echo $html->link(__('View', true), array('action' => 'view', $job['Job']['id'])); ?>
|
||||
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $job['Job']['id']), array('class'=>'editWindow', 'name'=>$job['Job']['id'])); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<div class="paging">
|
||||
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
|
||||
| <?php echo $paginator->numbers();?>
|
||||
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
|
||||
</div>
|
||||
|
||||
<div id="editDiv">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
function isEmptyDate($date) {
|
||||
if($date == "0000-00-00") {
|
||||
return "-";
|
||||
}
|
||||
else {
|
||||
return $date;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php // debug($customers); ?>
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
echo $javascript->link('jquery.form');
|
||||
echo $javascript->link('jquery.validate.min');
|
||||
echo $javascript->link('menu');
|
||||
echo $javascript->link('global');
|
||||
echo $javascript->link('search');
|
||||
//echo $javascript->link('ajaxLoader');
|
||||
echo $javascript->link('ckeditor/adapters/jquery');
|
||||
|
|
|
|||
|
|
@ -9,15 +9,7 @@
|
|||
echo $form->input('last_name');
|
||||
echo $form->input('email');
|
||||
echo $form->input('job_title');
|
||||
echo $form->input('group_id');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $form->end('Submit');?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('List Users', true), array('action'=>'index'));?></li>
|
||||
<li><?php echo $html->link(__('List Enquiries', true), array('controller'=> 'enquiries', 'action'=>'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Enquiry', true), array('controller'=> 'enquiries', 'action'=>'add')); ?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -51,3 +51,10 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(!empty($user['Principle']['id'])) {
|
||||
echo "Principle Contact!!";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php debug($user); ?>
|
||||
65
views/users/view_contact.ctp
Normal file
65
views/users/view_contact.ctp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<div class="users view">
|
||||
<h2><?php __('Contact: '.$user['User']['username'] );?></h2>
|
||||
<h3>Customer: <?=$html->link($user['Customer']['name'], '/customers/view/'.$user['Customer']['id']);?></h3>
|
||||
<dl><?php $i = 0; $class = ' class="altrow"';?>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Username'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['username']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('First Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['first_name']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Last Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['last_name']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Email'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $html->link($user['User']['email'], 'mailto:'.$user['User']['email']); ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Phone'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['phone']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Mobile'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['mobile']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Fax'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['fax']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Direct Phone'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['direct_phone']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Phone Extension'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['phone_extension']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Notes'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['notes']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<?php // debug($user);?>
|
||||
65
views/users/view_principle.ctp
Normal file
65
views/users/view_principle.ctp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<div class="users view">
|
||||
<h2><?php __('Principle Contact: '.$user['User']['username'] );?></h2>
|
||||
<h3>Customer: <?=$html->link($user['Customer']['name'], '/customers/view/'.$user['Customer']['id']);?></h3>
|
||||
<dl><?php $i = 0; $class = ' class="altrow"';?>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Username'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['username']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('First Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['first_name']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Last Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['last_name']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Email'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $html->link($user['User']['email'], 'mailto:'.$user['User']['email']); ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Phone'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['phone']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Mobile'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['mobile']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Fax'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['fax']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Direct Phone'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['direct_phone']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Phone Extension'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['phone_extension']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Notes'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['notes']; ?>
|
||||
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<?php // debug($user);?>
|
||||
48
views/users/view_user.ctp
Normal file
48
views/users/view_user.ctp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<div class="users view">
|
||||
<h2><?php __('User: '.$user['User']['username'] );?></h2>
|
||||
<dl><?php $i = 0; $class = ' class="altrow"';?>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Username'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['username']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('First Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['first_name']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Last Name'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['last_name']; ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Email'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $html->link($user['User']['email'], 'mailto:'.$user['User']['email']); ?>
|
||||
|
||||
</dd>
|
||||
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Job Title'); ?></dt>
|
||||
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
|
||||
<?php echo $user['User']['job_title']; ?>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="related">
|
||||
<h3><?php __('Enquiries Assigned to this User');?></h3>
|
||||
<? /* If there are enquiries for this user, render the enquiries table passing the $enquiries array */ ?>
|
||||
<?php if (!empty($user['Enquiry'])) {
|
||||
echo $this->element('enquiry_table', $enquiries);
|
||||
}
|
||||
else {
|
||||
echo "No Enquiries for this User";
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('New Enquiry', true), array('controller'=> 'enquiries', 'action'=>'add'));?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -635,7 +635,7 @@ div.paging span a {
|
|||
dl {
|
||||
line-height: 2em;
|
||||
margin: 0em 0em;
|
||||
width: 60%;
|
||||
|
||||
}
|
||||
|
||||
dl.mailheaders {
|
||||
|
|
@ -682,7 +682,7 @@ form {
|
|||
clear: left;
|
||||
margin-right: 20px;
|
||||
padding: 0;
|
||||
width: 60%;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
9
webroot/js/global.js
Normal file
9
webroot/js/global.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Javascript that applies to the whole site.
|
||||
*
|
||||
* Apply button() to buttons and submit buttons for jQuery UI styling.
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
$("button, input:submit").button();
|
||||
});
|
||||
Loading…
Reference in a new issue