LoanForm.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_Loan
00030 
00042 // }}}
00043 class FF_Action_Form_Loan extends FF_Action_Form {
00044     // {{{ properties
00045 
00050     var $origActionId;
00051 
00052     // }}}
00053     // {{{ constructor
00054 
00063     function FF_Action_Form_Loan(&$in_model)
00064     {
00065         FF_Action_Form::FF_Action_Form($in_model);
00066         $this->origActionId = $this->currentActionId;
00067         if ($this->currentActionId == ACTION_SHOP_EDIT_RESERVE ||
00068             FF_Request::getParam('editingReservation', 's', false)) {
00069             FF_Request::setParam('editingReservation', true, 's');
00070             // Editing a reservation is largely the same as reserving, so this makes the logic easier
00071             $this->currentActionId = ACTION_SHOP_RESERVE;
00072         }
00073 
00074         if ($this->currentActionId == ACTION_ADD_CART) {
00075             $this->editActionId = ACTION_EDIT_CART;
00076         }
00077         else {
00078             $this->editActionId = $this->currentActionId;
00079         }
00080     }
00081 
00082     // }}}
00083     // {{{ run()
00084 
00088     function run()
00089     {
00090         if ($this->currentActionId == ACTION_SHOP_RESERVE) {
00091             $o_result =& $this->o_model->setupStoreVars();
00092             if (!$o_result->isSuccess()) {
00093                 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00094                 $this->o_output->setMessage($o_result->getMessages(), FASTFRAME_ERROR_MESSAGE);
00095                 return $this->o_nextAction;
00096             }
00097         }
00098 
00099         return parent::run();
00100     }
00101 
00102     // }}}
00103     // {{{ renderAdditionalLinks()
00104 
00111     function renderAdditionalLinks()
00112     {
00113         if ($this->currentActionId == ACTION_SHOP_RESERVE) {
00114             $s_link = $this->o_output->link(
00115                     FastFrame::selfURL(array('actionId' => ACTION_SHOP, 'module' => 'Item',
00116                             'storeId' => FF_Request::getParam('chkoutStoreId', 's'))),
00117                     $this->o_output->imgTag('continue_browsing.gif', 'general', 
00118                         array('app' => 'checkout', 'height' => 18, 'width' => 117)),
00119                     array('class' => 'img', 'title' => _('Continue Browsing')));
00120         }
00121         else {
00122             $s_actionId = FF_Request::getParam('returnActionId', 'g', false);
00123             if ($s_actionId !== false) {
00124                 $s_link = $this->o_output->link(
00125                         FastFrame::selfURL(array('actionId' => $s_actionId, 'module' => 'Loan')),
00126                         _('Return'));
00127             }
00128         }
00129 
00130         if (!empty($s_link)) {
00131             $this->o_output->o_tpl->append('page_links', $s_link);
00132         }
00133     }
00134 
00135     // }}}
00136     // {{{ createFormElements()
00137 
00145     function createFormElements()
00146     {
00147         $this->o_form->addElement('hidden', 'actionId');
00148         $this->o_form->addElement('hidden', 'objectId');
00149         $this->o_form->addElement('hidden', 'borrower_id');
00150         $this->o_form->addElement('hidden', 'newItemsHidden');
00151         if ($this->o_perms->hasPerm('can_add_transaction_comment')) {
00152             $this->o_form->addElement('textarea', 'comment', null, array('cols' => 55, 'rows' => 4));
00153         }
00154 
00155         // For loans and shopping reservations, the borrower is read only
00156         if ($this->currentActionId != ACTION_EDIT_LOAN &&
00157             $this->currentActionId != ACTION_CREATE_LOAN &&
00158             $this->currentActionId != ACTION_SHOP_RESERVE) {
00159             $this->o_form->addElement('text', 'inputBorrower', null, array('maxlength' => 20, 'size' => 15));
00160         }
00161 
00162         if ($this->o_registry->getConfigParam('checkout/use_is_complete') &&
00163             ($this->currentActionId == ACTION_EDIT_CART ||
00164              $this->currentActionId == ACTION_ADD_CART ||
00165              $this->currentActionId == ACTION_EDIT_RESERVATION ||
00166              $this->currentActionId == ACTION_CREATE_RESERVATION)) {
00167             $this->o_form->addElement('checkbox', 'is_complete');
00168         }
00169         else {
00170             $this->o_form->addElement('hidden', 'is_complete');
00171         }
00172 
00173         if ($this->currentActionId != ACTION_SHOP_RESERVE) {
00174             $this->o_form->addElement('textarea', 'newItems', null, array('cols' => 55, 'rows' => 4));
00175         }
00176 
00177         $this->o_form->addElement('submit', 'submitbutton');
00178 
00179         // Only carts can proceed to creating a loan or reservation
00180         if ($this->currentActionId == ACTION_ADD_CART ||
00181             $this->currentActionId == ACTION_EDIT_CART) {
00182             $this->o_form->addElement('radio', 'successActionId', null, _('Save Cart'), ACTION_EDIT_CART,
00183                     array('id' => ACTION_EDIT_CART));
00184             if ($this->o_perms->hasPerm('can_add_loan')) {
00185                 $this->o_form->addElement('radio', 'successActionId', null, _('Proceed to Loan'), ACTION_CREATE_LOAN,
00186                         array('id' => ACTION_CREATE_LOAN));
00187             }
00188 
00189             if ($this->o_perms->hasPerm('can_add_reservation')) {
00190                 $this->o_form->addElement('radio', 'successActionId', null, _('Proceed to Reservation'), ACTION_CREATE_RESERVATION,
00191                         array('id' => ACTION_CREATE_RESERVATION));
00192             }
00193         }
00194         else {
00195             $this->o_form->addElement('hidden', 'successActionId');
00196         }
00197 
00198         if ($this->currentActionId == ACTION_EDIT_RESERVATION ||
00199             $this->currentActionId == ACTION_CREATE_RESERVATION ||
00200             $this->currentActionId == ACTION_SHOP_RESERVE ||
00201             $this->currentActionId == ACTION_EDIT_CART ||
00202             $this->currentActionId == ACTION_ADD_CART) {
00203             if ($this->currentActionId == ACTION_EDIT_CART ||
00204                 $this->currentActionId == ACTION_ADD_CART) {
00205                 // We don't show the hour and minute because it is
00206                 // constantly changing based on what is in the cart
00207                 $tmp_format = 'd M Y';
00208                 $this->o_form->addElement('hidden', 'start_date[H]');
00209                 $this->o_form->addElement('hidden', 'start_date[i]');
00210             }
00211             else {
00212                 $tmp_format = 'd M Y H : i';
00213             }
00214 
00215             $this->o_form->addElement('date', 'start_date', null, 
00216                     array('format' => $tmp_format,
00217                           'minYear' => date('Y') - 1, 
00218                           'maxYear' => date('Y') + $this->o_registry->getConfigParam('checkout/years_in_future'),
00219                          ),
00220                     array('onchange' => 'updateDueDate()'));
00221         }
00222         // Loans need the start date for the duration javascript to work
00223         else {
00224             $this->o_form->addElement('hidden', 'start_date[d]');
00225             $this->o_form->addElement('hidden', 'start_date[M]');
00226             $this->o_form->addElement('hidden', 'start_date[Y]');
00227             $this->o_form->addElement('hidden', 'start_date[H]');
00228             $this->o_form->addElement('hidden', 'start_date[i]');
00229         }
00230 
00231         // Don't show due date to carts or to shoppers when the due date is locked
00232         if ($this->currentActionId != ACTION_ADD_CART &&
00233             $this->currentActionId != ACTION_EDIT_CART &&
00234             !($this->currentActionId == ACTION_SHOP_RESERVE && $this->o_model->isDueDateLocked())) {
00235             $this->renderDurationJavascript(false);
00236             $this->o_form->addElement('date', 'due_date', null, 
00237                     array(
00238                         'format' => 'd M Y H : i', 
00239                         'minYear' => date('Y') - 1,
00240                         'maxYear' => date('Y') + $this->o_registry->getConfigParam('checkout/years_in_future'),
00241                        ),
00242                     array('onchange' => 'updateDuration()'));
00243         }
00244         else {
00245             $this->renderDurationJavascript(true);
00246             $this->o_form->addElement('hidden', 'due_date[d]');
00247             $this->o_form->addElement('hidden', 'due_date[M]');
00248             $this->o_form->addElement('hidden', 'due_date[Y]');
00249             $this->o_form->addElement('hidden', 'due_date[H]');
00250             $this->o_form->addElement('hidden', 'due_date[i]');
00251         }
00252 
00253         // Duration is hidden if it is a cart or the due date is locked (since it
00254         // is just confusing to have a duration when the due date time must stay
00255         // the same)
00256         if ($this->currentActionId == ACTION_EDIT_CART ||
00257             $this->currentActionId == ACTION_ADD_CART ||
00258             $this->o_model->isDueDateLocked()) {
00259             $this->o_form->addElement('hidden', 'duration[d]');
00260             $this->o_form->addElement('hidden', 'duration[h]');
00261             $this->o_form->addElement('hidden', 'duration[i]');
00262         }
00263         else {
00264             require_once FASTFRAME_ROOT . 'lib/FastFrame/Util.php';
00265             $this->o_form->addElement('select', 'duration[d]', null, 
00266                     FF_Util::createNumericOptionList(0, 30, 1, '%d'), array('onchange' => 'updateDueDate()'));
00267             $this->o_form->addElement('select', 'duration[h]', null, 
00268                     FF_Util::createNumericOptionList(0, 23, 1, '%d'), array('onchange' => 'updateDueDate()')); 
00269             $this->o_form->addElement('select', 'duration[i]', null, 
00270                     FF_Util::createNumericOptionList(0, 60), array('onchange' => 'updateDueDate()')); 
00271         }
00272 
00273         // Carts don't have override codes
00274         if ($this->currentActionId != ACTION_EDIT_CART && 
00275             $this->currentActionId != ACTION_ADD_CART) {
00276             $this->o_form->addElement('text', 'overrideCode', null, array('maxlength' => 25, 'size' => 15));
00277             if ($this->o_perms->hasPerm('can_force_override')) {
00278                 $this->o_form->addElement('checkbox', 'forceOverride');
00279             }
00280         }
00281     }
00282 
00283     // }}}
00284     // {{{ fillModelWithData()
00285 
00293     function fillModelWithData()
00294     {
00295         if (($tmp_model = FF_Request::getParam('selectedModel', 'g', false))) {
00296             $this->currentActionId = FF_Request::getParam('returnActionId', 's');
00297             $this->o_model->importFromArray(FF_Request::getParam('returnModel', 's'));
00298             if ($tmp_model == 'Borrower') {
00299                 $this->o_model->setBorrowerId(FF_Request::getParam('selectedId', 'g'));
00300             }
00301             elseif ($tmp_model == 'Item') {
00302                 // get the barcode
00303                 require_once dirname(__FILE__) . '/../Model/Item.php';
00304                 $o_itemModel =& new FF_Model_Item();
00305                 if ($o_itemModel->fillById(FF_Request::getParam('selectedId', 'g'))) {
00306                     $this->o_model->setItem($o_itemModel->getId(), $o_itemModel->getBarcode());
00307                     $this->o_output->setMessage(_('Item was successfully added to the list of items to add.'));
00308                 }
00309                 else {
00310                     $this->o_output->setMessage(_('There was an error in adding the item to the list of items to add.'), FASTFRAME_ERROR_MESSAGE);
00311                 }
00312             }
00313             elseif ($tmp_model == 'Group') {
00314                 // get the barcode
00315                 require_once dirname(__FILE__) . '/../Model/Group.php';
00316                 $o_groupModel =& new FF_Model_Group();
00317                 if ($o_groupModel->fillById(FF_Request::getParam('selectedId', 'g'))) {
00318                     $this->o_model->setItem($o_groupModel->getId(), null, true);
00319                     $this->o_output->setMessage(_('Group was successfully added to the list of items to add.'));
00320                 }
00321                 else {
00322                     $this->o_output->setMessage(_('There was an error in adding the group to the list of items to add.'), FASTFRAME_ERROR_MESSAGE);
00323                 }
00324             }
00325 
00326             $b_result = true;
00327         } 
00328         else {
00329             // If this is a shopping reservation, then need to get id of cart
00330             if ($this->currentActionId == ACTION_SHOP_RESERVE && $this->origActionId != ACTION_SHOP_EDIT_RESERVE) {
00331                 $this->o_model->setType(LOANS_TYPE_SHOP_CART);
00332                 $b_result = true;
00333             }
00334             else {
00335                 $b_result = parent::fillModelWithData();
00336                 // Setup session loan model so they can go browse for more items
00337                 if ($b_result && $this->origActionId == ACTION_SHOP_EDIT_RESERVE) {
00338                     FF_Request::setParam('chkoutStoreId', $this->o_model->getStoreId(), 's');
00339                     $_SESSION['chkoutShopLoanModel'][$_SESSION['chkoutStoreId']] = $this->o_model->exportToArray();
00340                 }
00341             }
00342 
00343             // Expand kits, but only once
00344             if ($this->currentActionId == ACTION_CREATE_LOAN &&
00345                 FF_Request::getParam('submitWasSuccess', 'g', true)) {
00346                 require_once dirname(__FILE__) . '/../Model/Group.php';
00347                 $o_groupModel =& new FF_Model_Group();
00348                 foreach ($this->o_model->getAllItems() as $s_key => $tmp_item) {
00349                     if ($tmp_item['is_kit']) {
00350                         $o_groupModel->setId($tmp_item['item_id']);
00351                         foreach ($o_groupModel->getAllItems() as $tmp_item2) {
00352                             $this->o_model->setItem($tmp_item2['item_id'], $tmp_item2['barcode']);
00353                         }
00354 
00355                         $_POST['toRemove']['groups'][$tmp_item['item_id']][$s_key] = 1;
00356                     }
00357                 }
00358             }
00359 
00360             if (!FF_Request::getParam('submitWasSuccess', 'g', false) ||
00361                 FF_Request::getParam('successActionId', 'p') == ACTION_CREATE_LOAN) {
00362                 $this->o_model->setItemsToRemove(FF_Request::getParam('toRemove', 'p'));
00363                 // For shopping don't need to load items from post since they are in session
00364                 if ($this->currentActionId != ACTION_SHOP_RESERVE && 
00365                     $this->currentActionId != ACTION_SHOP_EDIT_RESERVE) {
00366                     $this->o_model->setItemsFromString(FF_Request::getParam('newItems', 'p'));
00367                     $this->o_model->setItemsFromString(FF_Request::getParam('newItemsHidden', 'p'));
00368                 }
00369             }
00370 
00371             // If it's a loan or we're adding items to the cart then dates
00372             // may need to be changed based on rules
00373             if ($this->currentActionId == ACTION_CREATE_LOAN ||
00374                 $this->currentActionId == ACTION_CREATE_RESERVATION ||
00375                 $this->currentActionId == ACTION_SHOP_RESERVE) {
00376                 // Only reset the due date for loans if it would be
00377                 // different from the reservation because of rules
00378                 if ($this->currentActionId == ACTION_CREATE_LOAN && 
00379                     $this->o_model->getType() == LOANS_TYPE_RESERVATION) {
00380                     // Duration rules need to know it will be a loan
00381                     $this->o_model->setType(LOANS_TYPE_LOAN);
00382                     $tmp_dur = $this->o_model->getDefaultDuration(true, false);
00383                     if ((!empty($tmp_dur) && 
00384                         ($this->o_model->getStartDate() + $tmp_dur) < $this->o_model->getDueDate()) ||
00385                         $this->o_model->getDueDate() < time()) {
00386                         $this->o_model->setDueDate(null);
00387                     }
00388                 }
00389                 else {
00390                     $this->o_model->setDueDate(null);
00391                 }
00392 
00393                 // For loans the start date should always be now, but for reservations
00394                 // we see if we need to set the time.
00395                 if ($this->currentActionId == ACTION_CREATE_LOAN) {
00396                     $this->o_model->setStartDate(null);
00397                 }
00398                 elseif ($this->currentActionId == ACTION_CREATE_RESERVATION ||
00399                         FF_Request::getParam('editingReservation', 's', false)) {
00400                     // Setting start date from rules needs to know what the type will be
00401                     $this->o_model->setType(LOANS_TYPE_RESERVATION);
00402                     $this->o_model->setStartDateUsingRules();
00403                 }
00404                 elseif ($this->currentActionId == ACTION_SHOP_RESERVE &&
00405                         FF_Request::getParam('submitWasSuccess', 'g', true)) {
00406                     $this->o_model->setType(LOANS_TYPE_RESERVATION);
00407                     $this->o_model->setStartDateUsingRules();
00408                 }
00409                 // Otherwise set start date based on what they selected
00410                 else {
00411                     $tmp_date = FF_Request::getParam('start_date', 'p');
00412                     $this->o_model->setStartDate(mktime($tmp_date['H'], $tmp_date['i'], 0, $tmp_date['M'], $tmp_date['d'], $tmp_date['Y']));
00413                 }
00414             }
00415         }
00416 
00417         // Because the due date isn't shown and we want the item
00418         // availability to be reflective of the most likely due date we can
00419         // reset it every time
00420         if ($this->currentActionId == ACTION_EDIT_CART ||
00421             $this->currentActionId == ACTION_ADD_CART) {
00422             $this->o_model->setStartDateUsingRules(false);
00423             $this->o_model->setDueDate(null);
00424         }
00425 
00426         if (!is_null($this->o_model->getBorrowerId()) && 
00427             ($this->currentActionId == ACTION_CREATE_RESERVATION ||
00428              $this->currentActionId == ACTION_EDIT_RESERVATION ||
00429              $this->currentActionId == ACTION_CREATE_LOAN ||
00430              $this->currentActionId == ACTION_EDIT_LOAN)) {
00431             $a_totals = $this->o_model->getNumOpen();
00432             if ($a_totals[0] > 0 || $a_totals[1] > 0) {
00433                 $s_other1 = $this->currentActionId == ACTION_CREATE_RESERVATION || 
00434                     $this->currentActionId == ACTION_EDIT_RESERVATION ? _('other') : '';
00435                 $s_other2 = $this->currentActionId == ACTION_CREATE_LOAN || 
00436                     $this->currentActionId == ACTION_EDIT_LOAN ? _('other') : '';
00437                 $this->o_output->setMessage(sprintf(_('NOTE: This borrower currently has %s %s open reservation(s) and %s %s open loan(s).'), $a_totals[1], $s_other1, $a_totals[0], $s_other2));
00438             }
00439         }
00440 
00441         return $b_result;
00442     }
00443 
00444     // }}}
00445     // {{{ renderDurationJavascript()
00446     
00459     function renderDurationJavascript($in_readOnly)
00460     {
00461         ob_start();
00462         ?>
00463         <script language="JavaScript" type="text/javascript">
00464         <!--
00465         // {{{ addZero()
00466 
00468         function addZero(vNumber)
00469         {
00470             return ((vNumber < 10) ? "0" : "") + vNumber 
00471         } 
00472 
00473         // }}}
00474         // {{{ formatDate()
00475                 
00477         function formatDate(date, format)
00478         { 
00479             var wDays      = ['<?php echo implode('\',\'', array(_('Sun'), _('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'))); ?>'];
00480             var dayName    = addZero(wDays[date.getUTCDay()]); 
00481             var day        = addZero(date.getUTCDate()); 
00482             var month      = addZero(date.getUTCMonth() + 1); 
00483             var yearLong   = addZero(date.getUTCFullYear()); 
00484             var yearShort  = addZero(date.getUTCFullYear().toString().substring(3,4)); 
00485             var year       = (format.indexOf("yyyy") > -1 ? yearLong : yearShort) 
00486             var hour24     = date.getUTCHours(); 
00487             var amPm       = hour24 < 12 ? 'am' : 'pm';
00488             var hour       = addZero(convertTo12Hour(hour24, ''));
00489             var hour24     = addZero(hour24);
00490             var minute     = addZero(date.getUTCMinutes()); 
00491             var second     = addZero(date.getUTCSeconds()); 
00492             var dateString = format.replace(/dd/g, day).replace(/MM/g, month).replace(/y{1,4}/g, year);
00493             dateString     = dateString.replace(/hh/g, hour).replace(/HH/g, hour24).replace(/mm/g, minute);
00494             dateString     = dateString.replace(/ss/g, second).replace(/a/g, amPm).replace(/DD/g, dayName);
00495             return dateString 
00496         } 
00497 
00498         // }}}
00499         // {{{ convertTo12Hour()
00500 
00502         function convertTo12Hour(in_hour)
00503         {
00504             if (in_hour < 12) {
00505                 if (in_hour == 0) {
00506                     in_hour = 12;
00507                 }
00508             } else {
00509                 if (in_hour > 12) {
00510                     in_hour -= 12;
00511                 }
00512             }
00513             return in_hour
00514         }
00515 
00516         // }}}
00517         // {{{ getDateFromFields()
00518 
00520         function getDateFromFields(in_elementName)
00521         {
00522             var thisForm = document.<?php echo $this->formName; ?>;
00523             var hour = parseInt(thisForm[in_elementName + '[H]'].value, 10);
00524             // We use UTC dates to prevent timezone problems.
00525             // We use the UTC() function because the setUTC*() methods are jacked in Safari
00526             var dateObj = new Date();
00527             dateObj.setTime(Date.UTC(thisForm[in_elementName + '[Y]'].value,
00528                         thisForm[in_elementName + '[M]'].value - 1,
00529                         thisForm[in_elementName + '[d]'].value,
00530                         hour,
00531                         thisForm[in_elementName + '[i]'].value));
00532             return dateObj;
00533         }
00534 
00535         // }}}
00536         // {{{ updateDuration()
00537 
00539         function updateDuration()
00540         {
00541             var thisForm = document.<?php echo $this->formName; ?>;
00542             var failed = false;
00543             var startDate = getDateFromFields('start_date');
00544             var endDate = getDateFromFields('due_date');
00545             if (endDate.getTime() < startDate.getTime()) {
00546                 alert('<?php echo addslashes(_('The due date must be later than the start date.')) ?>');
00547                 endDate.setTime(startDate.getTime() + (<?php echo $this->o_model->getDefaultDuration(); ?> * 1000));
00548                 failed = true;
00549             }
00550 
00551             var duration = (endDate.getTime() - startDate.getTime()) / 1000;
00552             var durDay = Math.floor(duration / 86400);
00553             duration %= 86400;
00554             var durHour = Math.floor(duration / 3600);
00555             duration %= 3600;
00556             var durMin = Math.floor(duration / 60);
00557             if (thisForm['duration[d]'].type == 'hidden') {
00558                 thisForm['duration[d]'].value = durDay;
00559                 thisForm['duration[h]'].value = durHour;
00560                 thisForm['duration[i]'].value = durMin;
00561             }
00562             else {
00563                 // Handle case where duration is out of range
00564                 if (durDay < thisForm['duration[d]'].options.length) {
00565                     thisForm['duration[d]'].selectedIndex = durDay;
00566                 }
00567                 else {
00568                     thisForm['duration[d]'].selectedIndex = thisForm['duration[d]'].options.length - 1;
00569                 }
00570                 thisForm['duration[h]'].selectedIndex = durHour;
00571                 thisForm['duration[i]'].selectedIndex = durMin;
00572             }
00573 
00574             if (failed) updateDueDate(true);
00575         }
00576 
00577         // }}}
00578         // {{{ updateDueDate()
00579 
00581         function updateDueDate(in_isFromFailure)
00582         {
00583             var thisForm = document.<?php echo $this->formName; ?>;
00584             var startDate = getDateFromFields('start_date');
00585             var endDate = new Date();
00586             var minutes = thisForm['duration[d]'].value * 1440;
00587             minutes += thisForm['duration[h]'].value * 60;
00588             minutes += thisForm['duration[i]'].value * 1;
00589             var msecs = minutes * 60000;
00590             endDate.setTime(startDate.getTime() + msecs);
00591             <?php if ($in_readOnly): ?>
00592             var currentEndDate = getDateFromFields('due_date');
00593             // In read only mode the time is locked, so if start time changes then we want
00594             // to keep due date the same and just update the duration
00595             if ((currentEndDate.getUTCHours() != endDate.getUTCHours() ||
00596                  currentEndDate.getUTCMinutes() != endDate.getUTCMinutes())) {
00597                 // Don't want an infinite loop
00598                 if (!in_isFromFailure) {
00599                     updateDuration();
00600                 }
00601             }
00602             else {
00603                 // Otherwise, if date has changed then change due date div (if it exists) to reflect the change
00604                 if (document.getElementById && document.getElementById('dueDate') != null) {
00605                     document.getElementById('dueDate').firstChild.nodeValue = formatDate(endDate, 'MM/dd/yyyy hh:mm a (DD.)');
00606                 }
00607                 thisForm['due_date[Y]'].value = endDate.getUTCFullYear();
00608                 thisForm['due_date[M]'].value = endDate.getUTCMonth() + 1;
00609                 thisForm['due_date[d]'].value = endDate.getUTCDate();
00610                 thisForm['due_date[H]'].value = endDate.getUTCHours();
00611                 thisForm['due_date[i]'].value = endDate.getUTCMinutes(); 
00612             }
00613             <?php else: ?>
00614             // Handle case where year goes out or range
00615             var yearDiff = <?php echo date('Y') - 1 ?>;
00616             var yearIndex = endDate.getUTCFullYear() - yearDiff;
00617             if (yearIndex < thisForm['due_date[Y]'].options.length) {
00618                 thisForm['due_date[Y]'].selectedIndex = yearIndex; 
00619             }
00620             else {
00621                 thisForm['due_date[Y]'].selectedIndex = thisForm['due_date[Y]'].length - 1;
00622                 updateDuration();
00623             }
00624             thisForm['due_date[M]'].selectedIndex = endDate.getUTCMonth();
00625             thisForm['due_date[d]'].selectedIndex = endDate.getUTCDate() - 1;
00626             thisForm['due_date[H]'].selectedIndex = endDate.getUTCHours(); 
00627             thisForm['due_date[i]'].selectedIndex = endDate.getUTCMinutes(); 
00628             <?php endif; ?>
00629             updateWdays();
00630         }
00631 
00632         // }}}
00633         // {{{ updateWdays()
00634 
00636         function updateWdays()
00637         {
00638             if (document.getElementById && document.getElementById('startWday') != null) {
00639                 var date = getDateFromFields('start_date');
00640                 document.getElementById('startWday').firstChild.nodeValue = formatDate(date, ' (DD.)');
00641             }
00642 
00643             if (document.getElementById && document.getElementById('dueWday') != null) {
00644                 var date = getDateFromFields('due_date');
00645                 document.getElementById('dueWday').firstChild.nodeValue = formatDate(date, ' (DD.)');
00646             }
00647         }
00648 
00649         // }}}
00650         Event.observe(window, 'load', updateDuration, false);
00651         Event.observe(window, 'load', updateWdays, false);
00652         //-->
00653         </script>
00654         <?php
00655         $this->o_output->o_tpl->append('javascript', ob_get_contents());
00656         ob_end_clean();
00657     }
00658     
00659     // }}}
00660     // {{{ renderSearchBox()
00661 
00668     function renderSearchBox()
00669     {
00670         return;
00671     }
00672 
00673     // }}}
00674     // {{{ getSingularText()
00675 
00682     function getSingularText()
00683     {
00684         if ($this->currentActionId == ACTION_EDIT_RESERVATION ||
00685             $this->currentActionId == ACTION_CREATE_RESERVATION ||
00686             $this->currentActionId == ACTION_SHOP_RESERVE) {
00687             return _('Reservation');
00688         }
00689         elseif ($this->currentActionId == ACTION_EDIT_LOAN ||
00690                 $this->currentActionId == ACTION_CREATE_LOAN) {
00691             return _('Loan');
00692         }
00693         else {
00694             return _('Cart');
00695         }
00696     }
00697 
00698     // }}}
00699     // {{{ getTableData()
00700 
00709     function getTableData()
00710     {
00711         require_once dirname(__FILE__) . '/../Output/Checkout.php';
00712         $o_chkoutOutput =& new FF_Output_Checkout();
00713         $o_chkoutOutput->setFormObject($this->o_form);
00714         $a_headers = array();
00715         if ($this->currentActionId == ACTION_EDIT_LOAN ||
00716             $this->currentActionId == ACTION_CREATE_LOAN) {
00717             $a_headers[] = array(
00718                 'title' => _('Borrower'),
00719                 'data' => $o_chkoutOutput->getLinkedBorrower($this->o_model->getBorrowerId(), true,
00720                     $this->o_model->getBorrowerName()),
00721                 );
00722         }
00723         elseif ($this->currentActionId != ACTION_SHOP_RESERVE) {
00724             $a_headers[] = array(
00725                 'title' => _('Borrower'),
00726                 'data' => '<div style="margin-bottom: 3px;">' . 
00727                           $o_chkoutOutput->getLinkedBorrower($this->o_model->getBorrowerId(), true,
00728                               $this->o_model->getBorrowerName()) . '</div>' . 
00729                           '<div>' . _('Select Borrower: ') . 
00730                           $this->o_output->imgTag('view.gif', 'actions', 
00731                               array('title' => _('Select a Borrower'), 'name' => 'selectBorrower', 
00732                                   'type' => 'input')) . '</div>' .
00733                           '<div>' . _('Or Enter Borrower Barcode: ') . 
00734                           $this->o_renderer->elementToHtml('inputBorrower') . '</div>',
00735                 );
00736         }
00737 
00738         if ($this->currentActionId != ACTION_CREATE_LOAN &&
00739             $this->currentActionId != ACTION_EDIT_LOAN) {
00740             $tmp_data = $this->o_renderer->elementToHtml('start_date') .
00741                 '<span id="startWday"> </span>';
00742         }
00743         else {
00744             $tmp_data = $this->o_model->getFormattedStartDate();
00745         }
00746 
00747         // Try and make that, for reservations, the start date is checked
00748         if ($this->currentActionId == ACTION_SHOP_RESERVE ||
00749             $this->currentActionId == ACTION_EDIT_RESERVATION ||
00750             $this->currentActionId == ACTION_CREATE_RESERVATION) {
00751             $tmp_data = '<div class="attentionBox">' . $tmp_data . '</div>';
00752         }
00753 
00754         $a_headers[] = array(
00755                 'title' => _('Start Date'),
00756                 'data' => $tmp_data,
00757                 );
00758 
00759         if ($this->currentActionId != ACTION_EDIT_CART &&
00760             $this->currentActionId != ACTION_ADD_CART) {
00761             if (!($this->currentActionId == ACTION_SHOP_RESERVE && $this->o_model->isDueDateLocked())) {
00762                 $tmp_data = $this->o_renderer->elementToHtml('due_date') . 
00763                     '<span id="dueWday"> </span>';
00764             }
00765             else {
00766                 $tmp_data = '<div id="dueDate">' . $this->o_model->getFormattedDueDate() . '</div>';
00767             }
00768 
00769             $a_headers[] = array(
00770                     'title' => _('Due Date'),
00771                     'data' => $tmp_data,
00772                     );
00773 
00774             if (!$this->o_model->isDueDateLocked()) {
00775                 $a_headers[] = array(
00776                         'title' => _('Duration'),
00777                         'data' => $this->o_renderer->elementToHtml('duration[d]') . _('Days(s) ') . 
00778                                   $this->o_renderer->elementToHtml('duration[h]') . _('Hour(s) ') .
00779                                   $this->o_renderer->elementToHtml('duration[i]') . _('Minutes '),
00780                         );
00781             }
00782         }
00783 
00784         if (!count($a_items = $this->o_model->getAllItems(false, true, false))) {
00785             $tmp_data = sprintf(_('No Items Are In This %s'), $this->getSingularText());
00786             $tmp_dataStyle = 'style="font-style: italic;"';
00787         }
00788         else {
00789             $tmp_dataStyle = '';
00790             $tmp_data = '';
00791             $a_removed = array();
00792             $a_returned = array();
00793             $a_dups = array();
00794             // Cannot remove items from a loan that has been made
00795             $b_hideDetails = $this->currentActionId == ACTION_SHOP_RESERVE;
00796             foreach ($a_items as $s_key => $a_item) {
00797                 $b_canRemove = ($this->currentActionId != ACTION_EDIT_LOAN || !empty($a_item['notSaved']));
00798                 $a_item['groupId'] = $s_key;
00799                 // Put removed items at the bottom
00800                 if (!empty($a_item['remove'])) {
00801                     $a_item['returnDate'] = 0;
00802                     $a_removed[] = $a_item;
00803                     continue;
00804                 }
00805 
00806                 if ($b_canRemove) {
00807                     $a_item['returnDate'] = false;
00808                 }
00809                 elseif ($a_item['return_date'] == 0) {
00810                     $a_item['returnDate'] = _('Not Returned');
00811                 }
00812                 else {
00813                     // Put returned items at the bottom
00814                     $a_item['returnDate'] = $this->o_model->formatTimestamp($a_item['return_date']); 
00815                     $a_returned[] = $a_item;
00816                     continue;
00817                 }
00818 
00819                 $tmp_data .= $o_chkoutOutput->getItemTable($a_item, $b_canRemove, $b_hideDetails);
00820             }
00821 
00822             if (count($a_removed)) {
00823                 $tmp_data .= '<div style="cursor: pointer; margin-top: 5px;" class="info color6" onclick="Element.toggle(\'removedItems\')">' .  _('Click to Show Items Marked for Removal') .  '</div><div style="display: none;" id="removedItems">';
00824                 foreach ($a_removed as $a_item) {
00825                     $b_canRemove = ($this->currentActionId != ACTION_EDIT_LOAN || !empty($a_item['notSaved']));
00826                     $tmp_data .= $o_chkoutOutput->getItemTable($a_item, $b_canRemove, $b_hideDetails);
00827                 }
00828 
00829                 $tmp_data .= '</div>';
00830             }
00831 
00832             if (count($a_returned)) {
00833                 $tmp_data .= '<div style="cursor: pointer; margin-top: 5px;" class="info color6" onclick="Element.toggle(\'returnedItems\');">' .  _('Click to Show Returned Items') .  '</div><div style="display: none;" id="returnedItems">';
00834                 foreach ($a_returned as $a_item) {
00835                     $tmp_data .= $o_chkoutOutput->getItemTable($a_item, false, $b_hideDetails);
00836                 }
00837 
00838                 $tmp_data .= '</div>';
00839             }
00840         }
00841 
00842         $a_headers[] = array(
00843                 'title' => _('Items'),
00844                 'data' => $tmp_data, 
00845                 'dataStyle' => $tmp_dataStyle, 
00846                 );
00847 
00848         if ($this->currentActionId != ACTION_SHOP_RESERVE) {
00849             // Loans can only add items, or if they don't have access to groups
00850             if ($this->currentActionId == ACTION_CREATE_LOAN ||
00851                 $this->currentActionId == ACTION_EDIT_LOAN ||
00852                 !$this->o_perms->hasPerm('can_use_group')) {
00853                 $a_headers[] = array(
00854                         'title' => _('Add New Item'),
00855                         'data' => _('Select New Item To Add') . ' ' .
00856                             $this->o_output->imgTag('view.gif', 'actions', 
00857                                 array('title' => _('Select an Item'), 
00858                                     'name' => 'selectItem', 'type' => 'input')),
00859                         );
00860             }
00861             else {
00862                 $a_headers[] = array(
00863                         'title' => _('Add New Item/Group'),
00864                         'data' => _('Select New Item/Group To Add') . ' ' .
00865                             $this->o_output->imgTag('view.gif', 'actions', 
00866                                 array('title' => _('Select an Item'), 
00867                                     'name' => 'selectItem', 'type' => 'input')) . ' ' .
00868                             $this->o_output->imgTag('view_multiple.gif', 'actions', 
00869                                 array('title' => _('Select a Group'), 
00870                                     'name' => 'selectGroup', 'type' => 'input')),
00871                         );
00872             }
00873 
00874             $tmp_help = _('Use this textarea to add several items to the loan at once.  Enter the barcode of the items, separated by spaces or each on a new line.');
00875             $a_headers[] = array(
00876                     'title' => sprintf(_('Add New Items %s'), $this->o_output->getHelpLink($tmp_help)),
00877                     'data' => $this->o_renderer->elementToHtml('newItems'),
00878                     );
00879         }
00880 
00881         if ($this->o_perms->hasPerm('can_view_transaction_comments')) {
00882             require_once dirname(__FILE__) . '/../Model/Comment.php';
00883             $o_commentModel =& new FF_Model_Comment();
00884             foreach ($o_commentModel->getCommentsByTransactionId($this->o_model->getId()) as $a_data) {
00885                 $o_commentModel->reset();
00886                 $o_commentModel->importFromArray($a_data);
00887                 $a_headers[] = array(
00888                     'title' => _('Comment'),
00889                     'data' => $o_chkoutOutput->getCommentTable(array('o_comment' => &$o_commentModel), true)
00890                     );
00891             }
00892         }
00893 
00894         if ($this->o_perms->hasPerm('can_add_transaction_comment')) {
00895             $a_headers[] = array(
00896                     'title' => _('Add a New Comment'),
00897                     'data' => $this->o_renderer->elementToHtml('comment'), 
00898                     );
00899         }
00900 
00901         if ($this->currentActionId != ACTION_EDIT_CART &&
00902             $this->currentActionId != ACTION_ADD_CART) {
00903             $tmp_help = _('If your loan or reservation is blocked due to red dots, insufficient demos, an invalid borrower type, or a conflict with other items on reservation you can enter an override code here to override the block.'); 
00904             $a_headers[] = array(
00905                     'title' => sprintf(_('Override Code %s'), $this->o_output->getHelpLink($tmp_help)),
00906                     'data' => $this->o_renderer->elementToHtml('overrideCode'),
00907                     );
00908             if ($this->o_perms->hasPerm('can_force_override')) {
00909                 $tmp_help = _('By checking this box you can force an override, even if no override code has been entered.');
00910                 $a_headers[] = array(
00911                         'title' => sprintf(_('Force Override %s'), $this->o_output->getHelpLink($tmp_help)),
00912                         'data' => $this->o_renderer->elementToHtml('forceOverride'),
00913                         );
00914             }
00915         }
00916 
00917         if ($this->o_registry->getConfigParam('checkout/use_is_complete') &&
00918             ($this->currentActionId == ACTION_EDIT_CART ||
00919              $this->currentActionId == ACTION_ADD_CART ||
00920              $this->currentActionId == ACTION_EDIT_RESERVATION ||
00921              $this->currentActionId == ACTION_CREATE_RESERVATION)) {
00922             $tmp_help = sprintf(_('You may mark this %s as complete to indicate that it is complete and ready for the next action.'),
00923                     $this->getSingularText()); 
00924             $a_headers[] = array(
00925                     'title' => sprintf(_('Is Complete %s'), $this->o_output->getHelpLink($tmp_help)),
00926                     'data' => $this->o_renderer->elementToHtml('is_complete'),
00927                     );
00928         }
00929 
00930         if ($this->currentActionId == ACTION_ADD_CART ||
00931             $this->currentActionId == ACTION_EDIT_CART) {
00932             $tmp_data =  $this->o_renderer->elementToHtml('successActionId', ACTION_EDIT_CART) . '<br />';
00933             if ($this->o_perms->hasPerm('can_add_reservation')) {
00934                 $tmp_data .= $this->o_renderer->elementToHtml('successActionId', ACTION_CREATE_RESERVATION) . '<br />';
00935             }
00936 
00937             if ($this->o_perms->hasPerm('can_add_loan')) {
00938                 $tmp_data .= $this->o_renderer->elementToHtml('successActionId', ACTION_CREATE_LOAN) . '<br />';
00939             }
00940 
00941             $a_headers[] = array(
00942                     'title' => _('Next Action'),
00943                     'data' => $tmp_data,
00944                     );
00945         }
00946 
00947         return $a_headers;
00948     }
00949 
00950     // }}}
00951     // {{{ getTableHeaderText()
00952 
00959     function getTableHeaderText()
00960     {
00961         if ($this->currentActionId == ACTION_SHOP_RESERVE &&
00962             !FastFrame::isEmpty(FF_Request::getParam('chkoutStoreDesc', 's'))) {
00963             if (FF_Request::getParam('editingReservation', 's', false)) {
00964                 return sprintf(_('Edit %s (%s)'), 
00965                     $this->getSingularText(), FF_Request::getParam('chkoutStoreDesc', 's'));
00966             }
00967             else {
00968                 return sprintf(_('Create %s (%s)'), 
00969                     $this->getSingularText(), FF_Request::getParam('chkoutStoreDesc', 's'));
00970             }
00971         }
00972         elseif (FF_Request::getParam('editingReservation', 's', false)) {
00973             return sprintf(_('Edit %s'), $this->getSingularText());
00974         }
00975         elseif ($this->currentActionId == ACTION_CREATE_RESERVATION ||
00976                 $this->currentActionId == ACTION_CREATE_LOAN ||
00977                 $this->currentActionId == ACTION_SHOP_RESERVE) {
00978             return sprintf(_('Create %s'), $this->getSingularText());
00979         }
00980         else {
00981             return parent::getTableHeaderText();
00982         }
00983     }
00984 
00985     // }}}
00986     // {{{ getFormConstants()
00987 
00994     function getFormConstants()
00995     {
00996         $a_constants = array();
00997         // Borrower id needs to be a constant so it overrides the empty value on add
00998         $a_constants['borrower_id'] = $this->o_model->getBorrowerId();
00999         $tmp_model = FF_Request::getParam('selectedModel', 'g', false);
01000         // Not yet saved items need to be set, and since they go into
01001         // newItemsHidden we can reset newItems
01002         $a_constants += array('newItemsHidden' => $this->o_model->getItemList(), 'newItems' => '');
01003         // Borrower text should be set specially when coming from another form
01004         if ($tmp_model) {
01005             $a_constants += array('inputBorrower' => '');
01006         }
01007         // On creation of loan/reservation the start/due date must be the default
01008         // But don't do try and change the dates back if it was a faulty submit
01009         // since that means they probably changed it on purpose.
01010         elseif (FF_Request::getParam('submitWasSuccess', 'g', true) &&
01011                 ($this->currentActionId == ACTION_CREATE_LOAN ||
01012                  $this->currentActionId == ACTION_CREATE_RESERVATION ||
01013                  $this->currentActionId == ACTION_SHOP_RESERVE)) {
01014             $a_constants['start_date'] = $this->_timestampToDateSelect($this->o_model->getStartDate());
01015             $a_constants['due_date'] = $this->_timestampToDateSelect($this->o_model->getDueDate());
01016         }
01017         // If shopping and due date is hidden it needs to be updated in case they remove items
01018         elseif ($this->currentActionId == ACTION_SHOP_RESERVE && $this->o_model->isDueDateLocked()) {
01019             $a_constants['due_date'] = $this->_timestampToDateSelect($this->o_model->getDueDate());
01020         }
01021 
01022         // Set comment when coming from another page
01023         if (FF_Request::getParam('selectedModel', 'g', false)) {
01024             $a_constants['comment'] = $this->o_model->getNewComment();
01025         }
01026 
01027         // On successful submit these should be cleared
01028         if (FF_Request::getParam('submitWasSuccess', 'g', false) &&
01029             FF_Request::getParam('successActionId', 'p') != ACTION_CREATE_LOAN) {
01030             $a_constants = array_merge($a_constants, 
01031                     array('newItemsHidden' => '', 'inputBorrower' => '', 'overrideCode' => '', 'comment' => ''));
01032         }
01033 
01034         return array_merge(parent::getFormConstants(), $a_constants); 
01035     }
01036 
01037     // }}}
01038     // {{{ getFormDefaults()
01039 
01047     function getFormDefaults()
01048     {
01049         $a_fields = array();
01050         $a_fields['objectId'] = $this->o_model->getId();
01051         $a_fields['start_date'] = $this->_timestampToDateSelect($this->o_model->getStartDate());
01052         $a_fields['due_date'] = $this->_timestampToDateSelect($this->o_model->getDueDate());
01053         $a_fields['is_complete'] = $this->o_model->getIsComplete();
01054         $a_fields['toRemove'] = $this->o_model->getItemsToRemove();
01055         $a_fields['overrideCode'] = $this->o_model->getOverrideCode();
01056         $a_fields['forceOverride'] = $this->o_model->getForceOverride();
01057         if ($this->currentActionId == ACTION_ADD_CART) {
01058             $a_fields['successActionId'] = ACTION_EDIT_CART;
01059         }
01060         else {
01061             $a_fields['successActionId'] = $this->currentActionId; 
01062         }
01063 
01064         return $a_fields;
01065     }
01066 
01067     // }}}
01068     // {{{ setSubmitActionId()
01069 
01076     function setSubmitActionId()
01077     {
01078         if ($this->currentActionId == ACTION_EDIT_RESERVATION) {
01079             $this->formActionId = ACTION_EDIT_RESERVATION_SUBMIT;
01080         }
01081         elseif ($this->currentActionId == ACTION_CREATE_RESERVATION) {
01082             $this->formActionId = ACTION_CREATE_RESERVATION_SUBMIT;
01083         }
01084         elseif ($this->currentActionId == ACTION_SHOP_RESERVE) {
01085             $this->formActionId = ACTION_SHOP_RESERVE_SUBMIT;
01086         }
01087         elseif ($this->currentActionId == ACTION_EDIT_LOAN) {
01088             $this->formActionId = ACTION_EDIT_LOAN_SUBMIT;
01089         }
01090         elseif ($this->currentActionId == ACTION_CREATE_LOAN) {
01091             $this->formActionId = ACTION_CREATE_LOAN_SUBMIT;
01092         }
01093         elseif ($this->currentActionId == ACTION_EDIT_CART) {
01094             $this->formActionId = ACTION_EDIT_CART_SUBMIT;
01095         }
01096         else {
01097             $this->formActionId = ACTION_ADD_CART_SUBMIT;
01098         }
01099     }
01100 
01101     // }}}
01102     // {{{ checkPerms()
01103 
01110     function checkPerms()
01111     {
01112         switch ($this->currentActionId) {
01113             case ACTION_CREATE_LOAN:
01114                 if (($this->o_perms->hasPerm('can_add_loan'))) {
01115                     return true;
01116                 }
01117                 else {
01118                     $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01119                     $this->o_output->setMessage(_('You do not have permission to add loans'), FASTFRAME_ERROR_MESSAGE);
01120                     return false;
01121                 }
01122             break;
01123             case ACTION_CREATE_RESERVATION:
01124                 if (($this->o_perms->hasPerm('can_add_reservation'))) {
01125                     return true;
01126                 }
01127                 else {
01128                     $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01129                     $this->o_output->setMessage(_('You do not have permission to add reservations'), FASTFRAME_ERROR_MESSAGE);
01130                     return false;
01131                 }
01132             break;
01133             case ACTION_SHOP_RESERVE:
01134                 if (!$this->o_perms->hasPerm(array('can_borrower_shop_items', 'can_borrower_shop_groups', '||'))) {
01135                     $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01136                     $this->o_output->setMessage(_('You do not have permission to use the shopping module.'), FASTFRAME_ERROR_MESSAGE);
01137                     return false;
01138                 }
01139                 elseif (FF_Request::getParam('editingReservation', 's', false) &&
01140                         !$this->o_perms->hasPerm('can_borrower_edit_reservation') &&
01141                         $this->o_model->getBorrowerId() != FF_Request::getParam('chkoutBorrowerId', 's')) {
01142                     $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01143                     $this->o_output->setMessage(_('You do not have permission to edit this reservation'), FASTFRAME_ERROR_MESSAGE);
01144                     return false;
01145                 }
01146                 else {
01147                     return true;
01148                 }
01149             break;
01150             case ACTION_ADD_CART:
01151                 if (($this->o_perms->hasPerm('can_add_cart'))) {
01152                     return true;
01153                 }
01154                 else {
01155                     $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01156                     $this->o_output->setMessage(_('You do not have permission to add carts'), FASTFRAME_ERROR_MESSAGE);
01157                     return false;
01158                 }
01159 
01160             break;
01161             case ACTION_EDIT_LOAN:
01162                 if (($this->o_perms->hasPerm('can_edit_loan'))) {
01163                     return true;
01164                 }
01165                 else {
01166                     $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01167                     $this->o_output->setMessage(_('You do not have permission to edit loans'), FASTFRAME_ERROR_MESSAGE);
01168                     return false;
01169                 }
01170             break;
01171             case ACTION_EDIT_RESERVATION:
01172                 if ($this->o_perms->hasPerm('can_edit_reservation')) {
01173                     return true;
01174                 }
01175                 else {
01176                     $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01177                     $this->o_output->setMessage(_('You do not have permission to edit reservations'), FASTFRAME_ERROR_MESSAGE);
01178                     return false;
01179                 }
01180             break;
01181             case ACTION_EDIT_CART:
01182                 if (($this->o_perms->hasPerm('can_edit_cart'))) {
01183                     return true;
01184                 }
01185                 else {
01186                     $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01187                     $this->o_output->setMessage(_('You do not have permission to edit carts'), FASTFRAME_ERROR_MESSAGE);
01188                     return false;
01189                 }
01190             break;
01191             default:
01192                 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
01193                 $this->o_output->setMessage(_('Could not determine the intended action'), FASTFRAME_ERROR_MESSAGE);
01194                 return false;
01195             break;
01196         }
01197     }
01198 
01199     // }}}
01200     // {{{ _timestampToDateSelect()
01201 
01211     function _timestampToDateSelect($in_timestamp)
01212     {
01213         $a_tmp = explode('-', date('d-n-Y-H-i', (int) $in_timestamp));
01214         $a_select = array('d' => $a_tmp[0], 'M' => $a_tmp[1], 'Y' => $a_tmp[2],
01215                           'H' => $a_tmp[3], 'i' => $a_tmp[4]);
01216         return $a_select;
01217     }
01218 
01219     // }}}
01220 }
01221 ?>

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