LoanReturnSummary.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 Loan                        |
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 // | Authors: Greg Gilbert <ggilbert@codejanitor.com>                     |
00021 // +----------------------------------------------------------------------+
00022 
00023 // }}}
00024 // {{{ requires
00025 
00026 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action.php';
00027 
00028 // }}}
00029 // {{{ class FF_Action_Display_LoanReturnSummary 
00030 
00042 // }}}
00043 class FF_Action_LoanReturnSummary extends FF_Action {
00044     // {{{ run()
00045 
00052     function run()
00053     {
00054         $o_tableWidget =& new FF_Smarty('twoColumnTable');
00055         $o_tableWidget->assign(array('S_table_columns' => 1, 
00056                     'T_table_header' => $this->getTableHeaderText(), 'has_table_header' => true));
00057         $this->renderSummaryTable($o_tableWidget);
00058         $this->o_output->o_tpl->append('content_middle', $o_tableWidget->fetch());
00059         $this->o_output->setPageName($this->getPageName());
00060         return $this->o_nextAction;
00061     }
00062 
00063     // }}}
00064     // {{{ renderSummaryTable()
00065 
00074     function renderSummaryTable(&$in_tableWidget)
00075     {
00076         $a_borrowers = $this->o_model->getReturnBorrowers();
00077         if (count($a_borrowers) == 0) {
00078             $in_tableWidget->append('rows', array('has_content_cell' => true,
00079                         'T_table_content_cell' => _('No items were marked as returned'),
00080                         'S_table_content_cell' => 'style="font-style: italic; text-align: center;"')); 
00081             return;
00082         }
00083 
00084         require_once dirname(__FILE__) . '/../Output/Checkout.php';
00085         $o_chkoutOutput =& new FF_Output_Checkout();
00086         $b_haveAlerted = false;
00087         foreach ($a_borrowers as $s_borrowerId => $s_numItemsReturned) {
00088             $this->o_model->setBorrowerId($s_borrowerId);
00089             $tmp_data = $o_chkoutOutput->getLinkedBorrower($s_borrowerId) . 
00090                         ': ' . sprintf(_('%s Item(s) Returned'), $s_numItemsReturned) . ' (' . 
00091                         $this->o_output->popupLink(
00092                             'receiptWin', _('Receipt For this Borrower'), 
00093                             array('actionId' => ACTION_RETURN_RECEIPT, 
00094                                 'returnTimestamp' => time(), 
00095                                 'isPopup' => 1, 'borrowerId' => $s_borrowerId)) .
00096                         ')';
00097 
00098             $o_result =& $this->o_model->getOpenLoansForBorrower();
00099             $in_tableWidget->append('rows', array('has_field_cell' => true,
00100                     'T_table_field_cell' => $tmp_data));
00101             if ($o_result->numRows() == 0) {
00102                 $in_tableWidget->append('rows', array('has_content_cell' => true,
00103                         'T_table_content_cell' => _('Borrower has no open loans.'),
00104                         'S_table_content_cell' => 'style="font-style: italic;"'));
00105             }
00106             else {
00107                 if (!$b_haveAlerted) {
00108                     $this->o_output->setMessage(_('At least one borrower who returned items still has an open loan.'), FASTFRAME_WARNING_MESSAGE);
00109                     $b_haveAlerted = true;
00110                 }
00111 
00112                 $tmp_data = '<div style="font-weight: bold;">' . 
00113                     $this->o_output->imgTag('exclamation.gif', 'mini') . ' ' .
00114                     _('Open Loans') . ':</div>';
00115                 while ($a_row = $o_result->fetchRow()) {
00116                     $this->o_model->reset();
00117                     $this->o_model->importFromArray($a_row);
00118                     $tmp_data .= '<div style="padding-left: 15px; margin-top: 5px;">' .
00119                                  $this->o_output->popupLink(
00120                                          'receiptWin',
00121                                          $this->o_output->imgTag('view.gif', 'actions'), 
00122                                          array('actionId' => ACTION_DISPLAY, 
00123                                              'objectId' => $this->o_model->getId(),
00124                                              'isPopup' => 1,
00125                                              'returnActionId' => ACTION_DISPLAY_SUMMARY),
00126                                          array('title' => _('Display Loan'))) .
00127                                  ' ' . $this->o_model->getFormattedStartDate() . ' - ' .
00128                                  $this->o_model->getFormattedDueDate() . 
00129                                  '</div>';
00130                 }
00131 
00132                 $in_tableWidget->append('rows', array('has_content_cell' => true,
00133                             'T_table_content_cell' => $tmp_data));
00134             }
00135         }
00136     }
00137 
00138     // }}}
00139     // {{{ getPageName()
00140 
00147     function getPageName()
00148     {
00149         return _('Loan Return Summary');
00150     }
00151 
00152     // }}}
00153     // {{{ getTableHeaderText()
00154 
00161     function getTableHeaderText()
00162     {
00163         return $this->getPageName();
00164     }
00165 
00166     // }}}
00167 }
00168 ?>

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