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 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/FormSubmit.php';
00026
00027
00028
00029
00040
00041 class FF_Action_FormSubmit_Borrower extends FF_Action_FormSubmit {
00042
00043
00051 function doMultiPageForm()
00052 {
00053 if (FF_Request::getParam('selectProfile_x', 'p', false) !== false) {
00054 $s_nextModule = 'Profile';
00055 }
00056 else {
00057 $s_nextModule = false;
00058 }
00059
00060 if ($s_nextModule) {
00061 FF_Request::setParam('returnModel', $this->o_model->exportToArray(), 's');
00062 if ($this->currentActionId == ACTION_EDIT_SUBMIT) {
00063 FF_Request::setParam('returnActionId', ACTION_EDIT, 's');
00064 }
00065 else {
00066 FF_Request::setParam('returnActionId', ACTION_ADD, 's');
00067 }
00068
00069 FF_Request::setParam('returnObjectId', $this->o_model->getId(), 's');
00070 FF_Request::setParam('returnModule', 'Borrower', 's');
00071 FF_Request::setParam('returnApp', $this->o_registry->getCurrentApp(), 's');
00072 $this->o_nextAction->setNextActionId(ACTION_SELECT);
00073 $this->o_nextAction->setNextModuleId($s_nextModule);
00074 $this->o_nextAction->setNextAppId('profile');
00075 return true;
00076 }
00077 else {
00078 return false;
00079 }
00080 }
00081
00082
00083
00084
00091 function fillModelWithSubmitData()
00092 {
00093 $this->o_model->setId(FF_Request::getParam('objectId', 'p'));
00094 $this->o_model->setFirstName(FF_Request::getParam('first_name', 'p'));
00095 $this->o_model->setLastName(FF_Request::getParam('last_name', 'p'));
00096 $this->o_model->setBarcode(FF_Request::getParam('barcode', 'p'));
00097 $this->o_model->setType(FF_Request::getParam('type', 'p'));
00098 $this->o_model->setEmail(FF_Request::getParam('email', 'p'));
00099 $this->o_model->setProfileId(FF_Request::getParam('profile_id', 'p'));
00100 $this->o_model->setNewComment(FF_Request::getParam('comment', 'p'));
00101 $a_remove = FF_Request::getParam('toRemove', 'p');
00102 $a_remove['comments'] = isset($a_remove['comments']) ? $a_remove['comments'] : array();
00103 $this->o_model->setCommentsToRemove($a_remove['comments']);
00104 foreach (FF_Request::getParam('attributes', 'p', array()) as $s_key => $s_val) {
00105 $s_perm = "can_view_borrower_attrib_$s_key";
00106 if ($this->o_perms->hasPerm($s_perm)) {
00107 $this->o_model->setAttribute($s_key, $s_val);
00108 }
00109 }
00110 }
00111
00112
00113
00114
00121 function save()
00122 {
00123 $o_result =& $this->o_model->save($this->isUpdate());
00124 if ($o_result->isSuccess()) {
00125 $o_fileCache =& FF_FileCache::singleton();
00126 if (FF_Request::getParam('imageRemove', 'p', false)) {
00127 FF_Request::setParam('imageRemove', null, 'p');
00128 $o_fileCache->remove(array('subdir' => 'borrower_images', 'name' => $this->o_model->getId()), true);
00129 }
00130
00131 $tmp_result =& $o_fileCache->saveUploadedFile(FF_Request::getParam('image', 'f'),
00132 array('subdir' => 'borrower_images', 'name' => $this->o_model->getId()),
00133 $this->o_registry->getConfigParam('borrower/max_image_size'),
00134 array('image/png', 'image/gif', 'image/jpeg', 'image/pjpeg'), true);
00135 if (!$tmp_result->isSuccess()) {
00136
00137 $o_result->addMessage($tmp_result->getMessages());
00138 }
00139
00140 $o_fileCache->makeViewableFromWeb(array('subdir' => 'borrower_images', 'name' => $this->o_model->getId()), true);
00141 }
00142
00143 return $o_result;
00144 }
00145
00146
00147
00148
00155 function validateInput()
00156 {
00157 require_once dirname(__FILE__) . '/../Validate/Borrower.php';
00158 $o_validate =& new FF_Validate_Borrower($this->o_model, $this->isUpdate());
00159 return $o_validate->validate();
00160 }
00161
00162
00163
00164
00171 function getSingularText()
00172 {
00173 return _('borrower');
00174 }
00175
00176
00177
00178
00185 function checkPerms()
00186 {
00187 switch ($this->currentActionId) {
00188 case ACTION_EDIT_SUBMIT:
00189 if (($this->o_perms->hasPerm('can_edit_borrower'))) {
00190 return true;
00191 }
00192 else {
00193 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00194 $this->o_output->setMessage(_('You do not have permission to edit borrowers'), FASTFRAME_ERROR_MESSAGE);
00195 return false;
00196 }
00197 break;
00198 case ACTION_ADD_SUBMIT:
00199 if (($this->o_perms->hasPerm('can_add_borrower'))) {
00200 return true;
00201 }
00202 else {
00203 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00204 $this->o_output->setMessage(_('You do not have permission to add borrowers'), FASTFRAME_ERROR_MESSAGE);
00205 return false;
00206 }
00207 break;
00208 default:
00209 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00210 $this->o_output->setMessage(_('Could not determine the intended action'), FASTFRAME_ERROR_MESSAGE);
00211 return false;
00212 break;
00213 }
00214 }
00215
00216
00217 }
00218 ?>