00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/Form.php';
00027
00028
00029
00030
00041
00042 class FF_Action_Form_DemoAddToBorrower extends FF_Action_Form {
00043
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
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
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
00103
00110 function setSubmitActionId()
00111 {
00112 $this->formActionId = ACTION_ADD_BORROWER_DEMO_SUBMIT;
00113 }
00114
00115
00116
00117
00124 function getSingularText()
00125 {
00126 return _('Demo');
00127 }
00128
00129
00130
00131
00139 function getPluralText()
00140 {
00141 return _('Demos');
00142 }
00143
00144
00145
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
00172
00179 function getTableHeaderText()
00180 {
00181 return sprintf(_('Add Demo "%s" to Borrower(s)'), $this->o_model->getName());
00182 }
00183
00184
00185
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
00205
00212 function isUpdate()
00213 {
00214 return true;
00215 }
00216
00217
00218
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 ?>