public function Index()
 {
     $this->view->setVar('order_items', is_array($va_items = $this->opt_order->getItems()) ? $va_items : array());
     //
     // Set default dates for order items
     //
     $t_order_item = new ca_commerce_order_items();
     $t_order_item->set('loan_checkout_date', time(), array('SET_DIRECT_DATE' => true));
     if (($vn_loan_period_in_days = $this->opo_client_services_config->get('default_library_loan_period')) <= 0) {
         $vn_loan_period_in_days = 7;
     }
     $t_order_item->set('loan_due_date', time() + $vn_loan_period_in_days * 24 * 60 * 60, array('SET_DIRECT_DATE' => true));
     $va_default_values = array('loan_checkout_date' => $t_order_item->get('loan_checkout_date', array('dateFormat' => 'delimited', 'timeOmit' => true)), 'loan_due_date' => $t_order_item->get('loan_due_date', array('dateFormat' => 'delimited', 'timeOmit' => true)));
     $this->view->setVar('t_order_item', $t_order_item);
     //$this->view->setVar('default_item_prices', $va_default_prices);
     //
     // Additional fees
     //
     $this->view->setVar('additional_fees', $t_order_item->getAdditionalFeesHTMLFormBundle($this->request, array('config' => $this->opo_client_services_config, 'currency_symbol' => $this->opo_client_services_config->get('currency_symbol'), 'type' => 'L')));
     $this->view->setVar('additional_fees_for_new_items', $t_order_item->getAdditionalFeesHTMLFormBundle($this->request, array('config' => $this->opo_client_services_config, 'currency_symbol' => $this->opo_client_services_config->get('currency_symbol'), 'use_defaults' => true, 'type' => 'L')));
     $this->view->setVar('additional_fee_codes', $va_additional_fee_codes = $this->opo_client_services_config->getAssoc('additional_loan_fees'));
     foreach ($va_additional_fee_codes as $vs_code => $va_info) {
         $va_default_values['ADDITIONAL_FEE_' . $vs_code] = $va_info['default_cost'];
     }
     $this->view->setVar('default_values', $va_default_values);
     //
     // Functional options
     //
     $this->view->setVar('loan_use_item_fee_and_tax', (bool) $this->opo_client_services_config->get('loan_use_item_fee_and_tax'));
     $this->view->setVar('loan_use_notes_and_restrictions', (bool) $this->opo_client_services_config->get('loan_use_notes_and_restrictions'));
     $this->view->setVar('loan_use_additional_fees', (bool) $this->opo_client_services_config->get('loan_use_additional_fees'));
     $this->render('checkout_html.php');
 }
 public function ItemList()
 {
     if (!$this->opt_order->getPrimaryKey()) {
         $this->Edit();
         return;
     }
     $va_items = $this->opt_order->getItems();
     foreach ($va_items as $vn_item_id => $va_item) {
         $va_items[$vn_item_id]['loan_checkout_date'] = $va_items[$vn_item_id]['loan_checkout_date'] ? caGetLocalizedDate($va_items[$vn_item_id]['loan_checkout_date'], array('dateFormat' => 'delimited')) : '';
         $va_items[$vn_item_id]['loan_due_date'] = $va_items[$vn_item_id]['loan_due_date'] ? caGetLocalizedDate($va_items[$vn_item_id]['loan_due_date'], array('dateFormat' => 'delimited')) : '';
         $va_items[$vn_item_id]['loan_return_date'] = $va_items[$vn_item_id]['loan_return_date'] ? caGetLocalizedDate($va_items[$vn_item_id]['loan_return_date'], array('dateFormat' => 'delimited')) : '';
     }
     $this->view->setVar('order_items', $va_items);
     $va_service_groups = $this->opo_client_services_config->getAssoc('service_groups');
     $va_default_prices = array();
     foreach ($va_service_groups as $vs_group => $va_group_info) {
         foreach ($va_group_info['services'] as $vs_service => $va_service_info) {
             $va_default_prices[$vs_service] = $va_service_info;
         }
     }
     $this->view->setVar('default_item_prices', $va_default_prices);
     if (($vn_loan_period_in_days = $this->opo_client_services_config->get('default_library_loan_period')) <= 0) {
         $vn_loan_period_in_days = 7;
     }
     $t_order_item = new ca_commerce_order_items();
     $t_order_item->set('loan_checkout_date', time(), array('SET_DIRECT_DATE' => true));
     $t_order_item->set('loan_due_date', time() + $vn_loan_period_in_days * 24 * 60 * 60, array('SET_DIRECT_DATE' => true));
     $va_default_values = array('loan_checkout_date' => $t_order_item->get('loan_checkout_date', array('dateFormat' => 'delimited', 'timeOmit' => true)), 'loan_due_date' => $t_order_item->get('loan_due_date', array('dateFormat' => 'delimited', 'timeOmit' => true)));
     $this->view->setVar('t_order_item', $t_order_item);
     $this->view->setVar('additional_fees', $t_order_item->getAdditionalFeesHTMLFormBundle($this->request, array('config' => $this->opo_client_services_config, 'currency_symbol' => $this->opo_client_services_config->get('currency_symbol'), 'type' => 'L')));
     $this->view->setVar('additional_fees_for_new_items', $t_order_item->getAdditionalFeesHTMLFormBundle($this->request, array('config' => $this->opo_client_services_config, 'currency_symbol' => $this->opo_client_services_config->get('currency_symbol'), 'type' => 'L')));
     $this->view->setVar('additional_fee_codes', $va_additional_fee_codes = $this->opo_client_services_config->getAssoc('additional_loan_fees'));
     foreach ($va_additional_fee_codes as $vs_code => $va_info) {
         $va_default_values['ADDITIONAL_FEE_' . $vs_code] = $va_info['default_cost'];
     }
     $this->view->setVar('default_values', $va_default_values);
     $this->render('order_item_list_html.php');
 }
Ejemplo n.º 3
0
 public function Save()
 {
     $vn_checkin_count = 0;
     foreach ($_REQUEST as $vs_k => $vs_v) {
         if (preg_match('!^caClientLibraryCheckin_item_id_([\\d]+)$!', $vs_k, $va_matches)) {
             if (isset($_REQUEST['caClientLibraryCheckin_' . $va_matches[1] . '_delete'])) {
                 continue;
             }
             $vn_item_id = $va_matches[1];
             $t_order_item = new ca_commerce_order_items($vn_item_id);
             if ($t_order_item->getPrimaryKey()) {
                 $t_order_item->setMode(ACCESS_WRITE);
                 $t_order_item->set('loan_return_date', time(), array('SET_DIRECT_DATE' => true));
                 $t_order_item->set('notes', $this->request->getParameter('caClientLibraryCheckin_notes_' . $vn_item_id, pString));
                 $t_order_item->update();
                 if ($t_order_item->numErrors()) {
                     $this->notification->addNotification(_t('Could not check in item %1: %2', $vn_item_id, join("; ", $t_order_item->getErrors())), __NOTIFICATION_TYPE_ERROR__);
                     continue;
                 }
                 $vn_checkin_count++;
             }
         }
     }
     $this->notification->addNotification($vn_checkin_count == 1 ? _t('Checked in %1 item', $vn_checkin_count) : _t('Checked in %1 items', $vn_checkin_count), __NOTIFICATION_TYPE_INFO__);
     $this->Index();
 }
Ejemplo n.º 4
0
 /**
  * Sets order of items in the currently loaded order to the order of item_ids as set in $pa_item_ids
  *
  * @param array $pa_item_ids A list of item_ids in the order, in the order in which they should be displayed in the order
  * @param array $pa_options An optional array of options. Supported options include:
  *			NONE
  * @return array An array of errors. If the array is empty then no errors occurred
  */
 public function reorderItems($pa_item_ids, $pa_options = null)
 {
     if (!($vn_order_id = $this->getPrimaryKey())) {
         return null;
     }
     $va_item_ranks = $this->getItemIDRanks($pa_options);
     // get current ranks
     $vn_i = 0;
     $o_trans = new Transaction();
     $t_item = new ca_commerce_order_items();
     $t_item->setTransaction($o_trans);
     $t_item->setMode(ACCESS_WRITE);
     $va_errors = array();
     // rewrite ranks
     foreach ($pa_item_ids as $vn_rank => $vn_item_id) {
         if (isset($va_item_ranks[$vn_item_id]) && $t_item->load(array('order_id' => $vn_order_id, 'item_id' => $vn_item_id))) {
             if ($va_item_ranks[$vn_item_id] != $vn_rank) {
                 $t_item->set('rank', $vn_rank);
                 $t_item->update();
                 if ($t_item->numErrors()) {
                     $va_errors[$vn_item_id] = _t('Could not reorder item %1: %2', $vn_item_id, join('; ', $t_item->getErrors()));
                 }
             }
         }
     }
     if (sizeof($va_errors)) {
         $o_trans->rollback();
     } else {
         $o_trans->commit();
     }
     return $va_errors;
 }