当前位置: 首页>>代码示例>>PHP>>正文


PHP ca_objects::getCheckoutReservations方法代码示例

本文整理汇总了PHP中ca_objects::getCheckoutReservations方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::getCheckoutReservations方法的具体用法?PHP ca_objects::getCheckoutReservations怎么用?PHP ca_objects::getCheckoutReservations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_objects的用法示例。


在下文中一共展示了ca_objects::getCheckoutReservations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetObjectInfo

 /**
  * Return info via ajax on selected object
  */
 public function GetObjectInfo()
 {
     $pn_user_id = $this->request->getParameter('user_id', pInteger);
     $pn_object_id = $this->request->getParameter('object_id', pInteger);
     $t_object = new ca_objects($pn_object_id);
     $vn_current_user_id = $vs_current_user = $vs_current_user_checkout_date = $vs_reservation_list = null;
     // user_id of current holder of item
     $vb_is_reserved_by_current_user = false;
     switch ($vn_status = $t_object->getCheckoutStatus()) {
         case __CA_OBJECTS_CHECKOUT_STATUS_AVAILABLE__:
             $vs_status_display = _t('Available');
             break;
         case __CA_OBJECTS_CHECKOUT_STATUS_OUT__:
             $t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
             $vn_current_user_id = $t_checkout->get('user_id');
             $vs_status_display = $vn_current_user_id == $pn_user_id ? _t('Out with this user') : _t('Out');
             $vs_current_user_checkout_date = $t_checkout->get('checkout_date', array('timeOmit' => true));
             break;
         case __CA_OBJECTS_CHECKOUT_STATUS_OUT_WITH_RESERVATIONS__:
             $t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
             $vn_current_user_id = $t_checkout->get('user_id');
             $va_reservations = $t_object->getCheckoutReservations();
             $vn_num_reservations = sizeof($va_reservations);
             $vs_current_user_checkout_date = $t_checkout->get('checkout_date', array('timeOmit' => true));
             $vs_status_display = $vn_num_reservations == 1 ? _t('Out with %1 reservation', $vn_num_reservations) : _t('Out with %1 reservations', $vn_num_reservations);
             break;
         case __CA_OBJECTS_CHECKOUT_STATUS_RESERVED__:
             // get reservations list
             $va_reservations = $t_object->getCheckoutReservations();
             $vn_num_reservations = sizeof($va_reservations);
             $t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
             $vs_current_user_checkout_date = $t_checkout->get('created_on', array('timeOmit' => true));
             $vs_status_display = $vn_num_reservations == 1 ? _t('Reserved') : _t('Available with %1 reservations', $vn_num_reservations);
             break;
     }
     $vb_is_held_by_current_user = $pn_user_id == $vn_current_user_id;
     if (is_array($va_reservations)) {
         $va_tmp = array();
         foreach ($va_reservations as $va_reservation) {
             $vb_is_reserved_by_current_user = $va_reservation['user_id'] == $pn_user_id;
             $t_user = new ca_users($va_reservation['user_id']);
             $va_tmp[] = $t_user->get('fname') . ' ' . $t_user->get('lname') . (($vs_email = $t_user->get('email')) ? " ({$vs_email})" : "");
         }
         $vs_reservation_list = join(", ", $va_tmp);
     }
     if ($vn_current_user_id) {
         $t_user = new ca_users($vn_current_user_id);
         $vs_current_user = $t_user->get('fname') . ' ' . $t_user->get('lname');
     }
     $va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
     $vs_holder_display_label = '';
     if ($vb_is_held_by_current_user) {
         $vs_status_display = _t('The user currently has this item');
     } elseif ($vb_is_reserved_by_current_user) {
         $vs_status_display = _t('The user has reserved this item');
     } else {
         $vs_reserve_display_label = $vn_status == 3 ? _t('Currently reserved by %1', $vs_reservation_list) : _t('Will reserve');
         if (in_array($vn_status, array(1, 2))) {
             $vs_holder_display_label = _t('held by %1 since %2', $vs_current_user, $vs_current_user_checkout_date);
         }
     }
     $va_info = array('object_id' => $t_object->getPrimaryKey(), 'idno' => $t_object->get('idno'), 'name' => $t_object->get('ca_objects.preferred_labels.name'), 'media' => $t_object->getWithTemplate('^ca_object_representations.media.icon'), 'status' => $vn_status, 'status_display' => $vs_status_display, 'numReservations' => sizeof($va_reservations), 'reservations' => $va_reservations, 'config' => $va_checkout_config, 'current_user_id' => $vn_current_user_id, 'current_user' => $vs_current_user, 'current_user_checkout_date' => $vs_current_user_checkout_date, 'isOutWithCurrentUser' => $pn_user_id == $vn_current_user_id, 'isReservedByCurrentUser' => $vb_is_reserved_by_current_user, 'reserve_display_label' => $vs_reserve_display_label, 'due_on_display_label' => _t('Due on'), 'notes_display_label' => _t('Notes'), 'holder_display_label' => $vs_holder_display_label);
     $va_info['title'] = $va_info['name'] . " (" . $va_info['idno'] . ")";
     $va_info['storage_location'] = $t_object->getWithTemplate($va_checkout_config['show_storage_location_template']);
     $this->view->setVar('data', $va_info);
     $this->render('checkout/ajax_data_json.php');
 }
开发者ID:samrahman,项目名称:providence,代码行数:70,代码来源:CheckOutController.php


注:本文中的ca_objects::getCheckoutReservations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。