From b233ead647ba4b2366113ed51aa45b9f295f926c Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Thu, 17 Mar 2011 12:48:27 +1100 Subject: [PATCH] Changed user view to load enquiry table by default --- controllers/emails_controller.php | 31 ++++++++++++++++++++--------- webroot/js/view_user.js | 33 ++++++++++++++----------------- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/controllers/emails_controller.php b/controllers/emails_controller.php index b43f74f1..4286ca1e 100755 --- a/controllers/emails_controller.php +++ b/controllers/emails_controller.php @@ -80,7 +80,27 @@ class EmailsController extends AppController { $this->set('email', $email); } - + + + /** + * Fetch all the Emails that are from, to, cc a User ID + * + * @param $id + * @return + */ + function view_user_emails($id) { + if(!$id) { + return; + } + else { + $fromEmails = $this->Email->find('list', array('fields'=>array('Email.id'), 'recursive'=>0, 'conditions'=>array('Email.user_id'=>$id))); + $recEmails = $this->Email->EmailRecipient->find('all', array('fields'=>array('Email.id'),'recursive'=>0, 'conditions'=>array('EmailRecipient.user_id'=>$id))); + + $this->set('emails', $fromEmails); + $this->set('recEmails', $recEmails); + } + } + @@ -100,14 +120,7 @@ class EmailsController extends AppController { } - /** - * View Emails to, from or CC a particular user ID. - * - * - */ - function view_user_emails($id) { - - } + } ?> diff --git a/webroot/js/view_user.js b/webroot/js/view_user.js index 91ad62fe..9e135011 100644 --- a/webroot/js/view_user.js +++ b/webroot/js/view_user.js @@ -1,6 +1,6 @@ $(function() { - $('#hide').hide(); + $('#show').hide(); $('#enquiryTable').hide(); $("#ajaxLoad").hide(); @@ -14,31 +14,28 @@ $(function() { var userID = $('#userID').text(); - var alreadyFetched = false; + $.get('/enquiries/view_user_enquiries/'+userID, function(data) { + $('#enquiryTable').html(data); + $('#enquiryTable').slideDown('fast'); + + }); + + + $('#hide').click(function() { + $(this).hide(); + $('#show').show(); + + $('#enquiryTable').slideUp('fast'); + }); + $('#show').click(function() { $(this).hide(); $('#hide').show(); - if(alreadyFetched == false) { - - alreadyFetched = true; - } - $.get('/enquiries/view_user_enquiries/'+userID, function(data) { - $('#enquiryTable').html(data); - }); $('#enquiryTable').slideDown('fast'); }); - $('#hide').click(function() { - $(this).hide(); - $('#show').show(); - - $('#enquiryTable').slideUp('fast'); - - }); - - }); \ No newline at end of file