BorrowerDisplay.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // +----------------------------------------------------------------------+
00021 
00022 // }}}
00023 // {{{ requires
00024 
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/Display.php';
00026 
00027 // }}}
00028 // {{{ class FF_Action_Display_Borrower 
00029 
00039 // }}}
00040 class FF_Action_Display_Borrower extends FF_Action_Display {
00041     // {{{ fillModelWithData()
00042 
00050     function fillModelWithData()
00051     {
00052         if ( $this->currentActionId != ACTION_BORROWER_INFO ) {
00053             $b_result = $this->o_model->fillById(FF_Request::getParam('objectId', 'gp'));
00054         }
00055         else {
00056            $b_result = $this->o_model->fillById(FF_Request::getParam('borrowerId', 's'));
00057            FF_Request::setParam('borrowerId',null,'s');
00058         }
00059         if (!$b_result) {
00060             $this->o_output->setMessage(
00061                 sprintf(_('Could not find the specified %s'), $this->getSingularText()), 
00062                 FASTFRAME_ERROR_MESSAGE
00063             );
00064             $this->o_nextAction->setNextActionId(ACTION_LIST);
00065             return false; 
00066         }
00067 
00068         return true;
00069     }
00070 
00071     // }}}
00072     // {{{ renderDisplay()
00073 
00080     function renderDisplay()
00081     {
00082         require_once FASTFRAME_ROOT . '/lib/FastFrame/Output/Table.php';
00083         $o_table =& new FF_Output_Table('twoColumn');
00084         $o_table->setTableHeaderText($this->getPageName());
00085         $o_table->setTableHeaders($this->getTableData());
00086         $o_table->setAlternateRowColors(true);
00087         $o_table->render();
00088         $o_tableWidget =& $o_table->getWidgetObject();
00089         $this->o_output->o_tpl->append('content_middle', $o_tableWidget->fetch());
00090         $this->renderAdditionalLinks();
00091     }
00092     // }}}
00093     // {{{ renderSearchBox()
00094 
00103     function renderSearchBox($in_focusSearch = true)
00104     {
00105         // Hide the searchbox from the  borrower info module
00106         if ($this->currentActionId == ACTION_BORROWER_INFO) {
00107             return false;
00108         }
00109         else {
00110             return parent::renderSearchBox($in_focusSearch);
00111         }
00112     }
00113 
00114     // }}}
00115     // {{{ renderAdditionalLinks()
00116 
00123     function renderAdditionalLinks()
00124     {
00125         if (FF_Request::getParam('isPopup', 'g', false)) {
00126             if ($this->o_perms->hasPerm('can_edit_borrower')) {
00127                 $this->o_output->o_tpl->append('page_links', 
00128                         $this->o_output->link(FastFrame::selfURL(array(
00129                                     'actionId' => ACTION_EDIT, 'objectId' => $this->o_model->getId())), 
00130                             _('Edit this Borrower')));
00131             }
00132 
00133             $this->o_output->o_tpl->append('page_links', 
00134                     $this->o_output->link('#', _('Close Window'), 
00135                         array('onclick' => 'self.close();')));
00136         }
00137         else if ( $this->currentActionId != ACTION_BORROWER_INFO)  {
00138             if (FF_Request::getParam('returnActionId', 'g', false) !== false) {
00139                 // Store it into session in case they leave the display page
00140                 FF_Request::setParam('borrower_returnActionId', FF_Request::getParam('returnActionId', 'g'), 's');
00141             }
00142 
00143             $this->o_output->o_tpl->append('page_links', 
00144                     $this->o_output->link(FastFrame::selfURL(array(
00145                                 'actionId' => FF_Request::getParam('borrower_returnActionId', 's'))),
00146                         sprintf(_('Return to %s List'), $this->getSingularText())));
00147         } 
00148         else {
00149             $this->o_output->o_tpl->append('page_links', 
00150                 $this->o_output->link(FastFrame::selfURL(array(
00151                     'actionId' => ACTION_BORROWER_LOOKUP)),
00152                     _('Show Another Borrower')));
00153         
00154         }
00155     }
00156 
00157     // }}}
00158     // {{{ getTableData()
00159 
00166     function getTableData()
00167     {
00168         $a_headers = array();
00169         $a_headers[] = array(
00170             'title' => _('First Name:'),
00171             'data' => $this->o_model->getFirstName(),
00172         );
00173         $a_headers[] = array(
00174             'title' => _('Last Name:'),
00175             'data' => $this->o_model->getLastName(),
00176         );
00177         $o_fileCache =& FF_FileCache::singleton();
00178         $tmp_path = $o_fileCache->exists(array('subdir' => 'borrower_images', 'name' => $this->o_model->getId()), true) ? 
00179             $o_fileCache->getPath(array('subdir' => 'borrower_images', 'name' => $this->o_model->getId()), true, FASTFRAME_WEBPATH) :
00180             $this->o_registry->getRootFile('general/no_image.gif', 'graphics', FASTFRAME_WEBPATH);
00181         $a_headers[] = array(
00182             'title' => _('Image:'),
00183             'data' => $this->o_output->imgTag($tmp_path, null, array('style' => 'vertical-align: top;')),
00184             'dataIsSafe' => true,
00185         );
00186         $a_headers[] = array(
00187             'title' => _('Barcode:'),
00188             'data' => $this->o_model->getBarcode(),
00189         );
00190         $a_headers[] = array(
00191             'title' => _('Email Address:'),
00192             'data' => $this->o_model->getEmail(), 
00193         );
00194         $a_headers[] = array(
00195             'title' => _('Type:'),
00196             'data' => $this->o_model->getFormattedType(),
00197         );
00198         $a_headers[] = array(
00199             'title' => _('Associated Profile:'),
00200             'data' => $this->o_model->getProfileUsername(),
00201         );
00202 
00203         // create extra attribute fields
00204         foreach ($this->o_registry->getConfigParam('borrower/attributes') as $s_key => $s_desc) {
00205             $s_perm = "can_view_borrower_attrib_$s_key";
00206             if ($this->o_perms->hasPerm($s_perm)) {
00207                 $a_headers[] = array(
00208                     'title' => $s_desc . ':',
00209                     'data' => $this->o_model->getAttribute($s_key),
00210                 );
00211             }
00212         }
00213 
00214         FF_Request::setParam('objectId', $this->o_model->getId(), 's');
00215         FF_Request::setParam('objectDesc', $this->o_model->getFirstName() . ' ' . $this->o_model->getLastName(), 's');
00216         if ($this->o_perms->hasPerm('can_view_loan_history')) {
00217             FF_Request::setParam('returnObjectId', $this->o_model->getId(), 's');
00218             FF_Request::setParam('returnModuleId', 'Borrower', 's');
00219             $a_headers[] = array(
00220                 'title' => _('Borrower\'s Loan History:'),
00221                 'data' => $this->o_output->link(
00222                     FastFrame::selfURL(array('module' => 'Loan', 'actionId' => ACTION_LIST_BORROWER_LOANS)), 
00223                     _('Click Here To View')),
00224                 'dataIsSafe' => true,
00225             );
00226         }
00227 
00228         if ($this->o_perms->hasPerm(array('can_use_demo', 'can_view_borrower_demos'))) {
00229             $a_headers[] = array(
00230                 'title' => _('Borrower\'s Demos:'),
00231                 'data' => $this->o_output->link(
00232                     FastFrame::selfURL(array('module' => 'Demo', 
00233                             'actionId' => ACTION_LIST_BORROWER_DEMOS, 
00234                             'returnObjectId'=> $this->o_model->getId())), 
00235                     _('Click Here To View')),
00236                 'dataIsSafe' => true,
00237             );
00238         }
00239 
00240         if ($this->o_perms->hasPerm('can_use_reddot')) {
00241             require_once dirname(__FILE__) . '/../Model/Reddot.php';
00242             $o_reddotModel =& new FF_Model_Reddot();
00243             $s_reddotCount = $o_reddotModel->getReddotCountForBorrower($this->o_model->getId());
00244             $s_penalty = $o_reddotModel->getProblemReddotCountForBorrower($this->o_model->getId());
00245             $s_block = $o_reddotModel->getBlockingReddotCountForBorrower($this->o_model->getId());
00246             $s_message = sprintf(_('Borrower has <b>%s</b> red dots in the last %s days (<b>%s</b> penalty and <b>%s</b> blocking).'), $s_reddotCount, 
00247                     $this->o_registry->getConfigParam('reddot/active_cutoff'), $s_penalty, $s_block);
00248             
00249             if ($s_penalty >= 1 &&
00250                 $s_reddotCount >= $this->o_registry->getConfigParam('reddot/max_active')) {
00251                 $s_message .= _(' <b>The borrower is currently in a red dot penalty period.</b>');
00252             }
00253 
00254             $a_headers[] = array(
00255                 'title' => _('Borrower\'s Reddots:'),
00256                 'data' => '<div>' . $s_message . '</div>'. $this->o_output->link(  
00257                     FastFrame::selfURL(array('module' => 'Reddot', 'actionId' => ACTION_LIST, 
00258                             'returnObjectId'=> $this->o_model->getId())), 
00259                     _('Click Here To View')),
00260                 'dataIsSafe' => true,
00261             );
00262         }
00263 
00264         // Show comments
00265         require_once dirname(__FILE__) . '/../Output/Checkout.php';
00266         require_once dirname(__FILE__) . '/../Model/Comment.php';
00267         $o_chkoutOutput =& new FF_Output_Checkout();
00268         $o_commentModel =& new FF_Model_Comment();
00269         foreach ($o_commentModel->getCommentsByTransactionId($this->o_model->getId()) as $a_data) {
00270             $o_commentModel->reset();
00271             $o_commentModel->importFromArray($a_data);
00272             $a_headers[] = array(
00273                 'title' => _('Comment:'),
00274                 'data' => $o_chkoutOutput->getCommentTable(array('o_comment' => &$o_commentModel), false),
00275                 'dataIsSafe' => true,
00276                 );
00277         }
00278 
00279         return $a_headers;
00280     }
00281 
00282     // }}}
00283     // {{{ getSingularText()
00284 
00291     function getSingularText()
00292     {
00293         return _('Borrower');
00294     }
00295 
00296     // }}}
00297     // {{{ getPluralText()
00298 
00306     function getPluralText()
00307     {
00308         return _('Borrowers');
00309     }
00310 
00311     // }}}
00312 }
00313 ?>

Generated on Fri Jun 23 11:38:15 2006 for FastFrame by  doxygen 1.4.4