BorrowerDownloadForm.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/Form.php';
00027 
00028 // }}}
00029 // {{{ class FF_Action_Form_BorrowerDownload
00030 
00040 // }}}
00041 class FF_Action_Form_BorrowerDownload extends FF_Action_Form {
00042     // {{{ renderAdditionalLinks()
00043 
00050     function renderAdditionalLinks()
00051     {
00052         $this->o_output->o_tpl->append('page_links', $this->o_output->link(
00053                     FastFrame::selfURL(array('actionId' => ACTION_LIST)),
00054                     sprintf(_('Return to %s List'), $this->getSingularText())));
00055     }
00056 
00057     // }}}
00058     // {{{ createFormElements()
00059 
00067     function createFormElements()
00068     {
00069         $this->o_form->addElement('hidden', 'actionId');
00070         $this->o_form->addElement('submit', 'submitbutton');
00071         $this->o_form->addElement('select', 'download_fields', null, 
00072             $this->o_model->getFields(), array('multiple' => true, 'size' => 5));
00073         $this->o_form->addElement('radio', 'download_limit', null, _('All Borrowers'), 'all',
00074                 array('id' => 'all', 'onclick' => 'document.getElementById("limitFields").style.display = "none";'));
00075         $this->o_form->addElement('radio', 'download_limit', null, _('Limit Borrowers'), 'limited',
00076                 array('id' => 'limited', 'onclick' => 'document.getElementById("limitFields").style.display = "block";'));
00077         $a_letters = array();
00078         foreach (range('A', 'Z') as $s_letter) {
00079             $a_letters[] = $s_letter;
00080         }
00081 
00082         $this->o_form->addElement('select', 'barcode_field', null, $a_letters);
00083         $this->o_form->addElement('file', 'borrower_barcodes');
00084     }
00085 
00086     // }}}
00087     // {{{ getSingularText()
00088 
00095     function getSingularText()
00096     {
00097         return _('Borrower');
00098     }
00099 
00100     // }}}
00101     // {{{ getPluralText()
00102 
00110     function getPluralText()
00111     {
00112         return _('Borrowers');
00113     }
00114 
00115     // }}}
00116     // {{{ setSubmitActionId()
00117 
00124     function setSubmitActionId()
00125     {
00126         $this->formActionId = ACTION_DOWNLOAD;
00127     }
00128 
00129     // }}}
00130     // {{{ getTableData()
00131 
00140     function getTableData()
00141     {
00142         $a_headers = array();
00143         $a_headers[] = array(
00144             'title' => _('Which Borrowers to Download'),
00145             'data' => $this->o_renderer->elementToHtml('download_limit', 'all') . '<br />' .
00146                       $this->o_renderer->elementToHtml('download_limit', 'limited') .
00147                       '<div id="limitFields" style="display: none;">' .
00148                       $this->o_renderer->elementToHtml('borrower_barcodes') . ' <i>' . _('Borrower Barcode File (CSV)') . '</i><br />' .
00149                       $this->o_renderer->elementToHtml('barcode_field') . ' <i>' . _('Barcode Field in the File') . '</i>' .
00150                       '</div>'
00151         );
00152         $a_headers[] = array(
00153             'title' => _('Which Fields to Download'),
00154             'data' => $this->o_renderer->elementToHtml('download_fields'),
00155         );
00156         return $a_headers;
00157     }
00158 
00159     // }}}
00160     // {{{ getTableHeaderText()
00161 
00168     function getTableHeaderText()
00169     {
00170         return _('Download Borrower Info');
00171     }
00172 
00173     // }}}
00174     // {{{ getFormConstants()
00175 
00182     function getFormConstants()
00183     {
00184         return array_merge(parent::getFormConstants(), array('download_limit' => 'all'));
00185     }
00186 
00187     // }}}
00188     // {{{ checkPerms()
00189 
00196     function checkPerms()
00197     {
00198         if ($this->o_perms->hasPerm('can_download_borrowers')) {
00199             return true;
00200         }
00201         else {
00202             $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00203             $this->o_output->setMessage(_('You do not have permission to download borrower info'), FASTFRAME_ERROR_MESSAGE);
00204             return false;
00205         }
00206     }
00207 
00208     // }}}
00209 }
00210 ?>

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