DemoAddToBorrower.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_DemoAddToBorrower
00030 
00041 // }}}
00042 class FF_Action_Form_DemoAddToBorrower extends FF_Action_Form {
00043     // {{{ renderAdditionalLinks()
00044 
00051     function renderAdditionalLinks()
00052     {
00053         $this->o_output->o_tpl->append('page_links', $this->o_output->link(
00054                     FastFrame::selfURL(array('actionId' => ACTION_LIST)),
00055                     sprintf(_('Return to %s List'), $this->getSingularText())));
00056     }
00057 
00058     // }}}
00059     // {{{ createFormElements()
00060 
00068     function createFormElements()
00069     {
00070         $this->o_form->addElement('hidden', 'actionId');
00071         $this->o_form->addElement('hidden', 'objectId');
00072         $this->o_form->addElement('hidden', 'name');
00073         $this->o_form->addElement('image', 'selectBorrower', $this->o_output->imgTag('view.gif', 'actions', array('onlyUrl' => true)), array('style' => 'vertical-align: middle;'));
00074         $this->o_form->addElement('textarea', 'borrowers', null, array('cols' => 35, 'rows' => 7));
00075         $this->o_form->addElement('submit', 'submitbutton');
00076     }
00077 
00078     // }}}
00079     // {{{ fillModelWithData()
00080 
00088     function fillModelWithData()
00089     {
00090         if (($tmp_model = FF_Request::getParam('selectedModel', 'g', false))) {
00091             $this->currentActionId = FF_Request::getParam('returnActionId', 's');
00092             $this->o_model->importFromArray(FF_Request::getParam('returnModel', 's'));
00093             $this->o_model->setBorrowersToAdd(FF_Request::getParam('selectedId', 'g'), true);
00094             return true;
00095         }
00096         else {
00097             return parent::fillModelWithData();
00098         }
00099     }
00100 
00101     // }}}
00102     // {{{ setSubmitActionId()
00103 
00110     function setSubmitActionId()
00111     {
00112         $this->formActionId = ACTION_ADD_BORROWER_DEMO_SUBMIT;
00113     }
00114 
00115     // }}}
00116     // {{{ getSingularText()
00117 
00124     function getSingularText()
00125     {
00126         return _('Demo');
00127     }
00128 
00129     // }}}
00130     // {{{ getPluralText()
00131 
00139     function getPluralText()
00140     {
00141         return _('Demos');
00142     }
00143 
00144     // }}}
00145     // {{{ getTableData()
00146 
00155     function getTableData()
00156     {
00157         $a_headers = array();
00158         $a_headers[] = array(
00159                 'title' => _('Select Borrower'),
00160                 'data' => _('Select Borrower') . ' ' .  $this->o_renderer->elementToHtml('selectBorrower'),
00161                 );
00162         $tmp_help = _('Use this textarea to add this demo to several borrowers at once.  Enter the barcode of the borrowers, separated by spaces or each on a new line.');
00163         $a_headers[] = array(
00164                 'title' => sprintf(_('List of Borrowers %s'), $this->o_output->getHelpLink($tmp_help)),
00165                 'data' => $this->o_renderer->elementToHtml('borrowers'),
00166                 );
00167         return $a_headers;
00168     }
00169 
00170     // }}}
00171     // {{{ getTableHeaderText()
00172 
00179     function getTableHeaderText()
00180     {
00181         return sprintf(_('Add Demo "%s" to Borrower(s)'), $this->o_model->getName());
00182     }
00183 
00184     // }}}
00185     // {{{ getFormDefaults()
00186 
00194     function getFormDefaults()
00195     {
00196         $a_fields = array();
00197         $a_fields['objectId'] = $this->o_model->getId();
00198         $a_fields['name'] = $this->o_model->getName();
00199         $a_fields['borrowers'] = $this->o_model->getBorrowersToAdd();
00200         return $a_fields;
00201     }
00202 
00203     // }}}
00204     // {{{ isUpdate()
00205 
00212     function isUpdate()
00213     {
00214         return true; 
00215     }
00216 
00217     // }}}
00218     // {{{ checkPerms()
00219 
00226     function checkPerms()
00227     {
00228         if ($this->o_perms->hasPerm('can_add_borrower_demo')) {
00229             return true;
00230         }
00231         else {
00232             $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00233             $this->o_output->setMessage(_('You do not have permission to add demos'), FASTFRAME_ERROR_MESSAGE);
00234             return false;
00235         }
00236     }
00237 
00238     // }}}
00239 }
00240 ?>

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