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


PHP ca_objects::getCheckoutStatus方法代码示例

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


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

示例1: GetObjectInfo

 /**
  * Return info via ajax on selected object
  */
 public function GetObjectInfo()
 {
     $pn_checkout_id = $this->request->getParameter('checkout_id', pInteger);
     $t_checkout = new ca_object_checkouts($pn_checkout_id);
     $t_user = new ca_users($t_checkout->get('user_id'));
     $t_object = new ca_objects($t_checkout->get('object_id'));
     $va_status = $t_object->getCheckoutStatus();
     $va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
     $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' => $t_object->getCheckoutStatus(), 'status_display' => $t_object->getCheckoutStatus(array('returnAsText' => true)), 'checkout_date' => $t_checkout->get('ca_object_checkouts.checkout_date', array('timeOmit' => true)), 'user_name' => $t_user->get('ca_users.fname') . ' ' . $t_user->get('ca_users.lname'), 'config' => $va_checkout_config);
     $va_info['title'] = $va_info['name'] . ' (' . $va_info['idno'] . ')';
     $va_info['borrower'] = _t('Borrowed by %1 on %2', $va_info['user_name'], $va_info['checkout_date']);
     $this->view->setVar('data', $va_info);
     $this->render('checkin/ajax_data_json.php');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:17,代码来源:CheckInController.php

示例2: 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

示例3: reserve

 /**
  *
  */
 public function reserve($pn_object_id, $pn_user_id, $ps_note, $pa_options = null)
 {
     global $g_ui_locale_id;
     $vb_we_set_transaction = false;
     if ($this->inTransaction()) {
         $o_trans = $this->getTransaction();
     } else {
         $vb_we_set_transaction = true;
         $this->setTransaction($o_trans = new Transaction());
     }
     $o_request = caGetOption('request', $pa_options, null);
     $t_object = new ca_objects($pn_object_id);
     $t_object->setTransaction($o_trans);
     if (!$t_object->getPrimaryKey()) {
         return null;
     }
     if ($o_request && !$t_object->isReadable($o_request)) {
         return null;
     }
     // is object out?
     if ($t_object->getCheckoutStatus() === __CA_OBJECTS_CHECKOUT_STATUS_AVAILABLE__) {
         throw new Exception(_t('Item is not out'));
     }
     $va_reservations = $this->objectHasReservations($pn_object_id);
     // is object already reserved by this user?
     if (is_array($va_reservations)) {
         foreach ($va_reservations as $va_reservation) {
             if ($va_reservation['user_id'] == $pn_user_id) {
                 throw new Exception(_t('Item is already reserved by this user'));
             }
         }
     }
     $vs_uuid = $this->getTransactionUUID();
     $va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
     $this->setMode(ACCESS_WRITE);
     $this->set(array('group_uuid' => $vs_uuid, 'object_id' => $pn_object_id, 'user_id' => $pn_user_id, 'checkout_notes' => $ps_notes));
     // Do we need to set values?
     if (is_array($va_checkout_config['set_values']) && sizeof($va_checkout_config['set_values'])) {
         $t_object->setMode(ACCESS_WRITE);
         foreach ($va_checkout_config['set_values'] as $vs_attr => $va_attr_values_by_event) {
             if (!is_array($va_attr_values_by_event['reserve'])) {
                 if ($t_object->hasField($vs_attr)) {
                     // Intrinsic
                     $t_object->set($vs_attr, $va_attr_values_by_event['reserve']);
                 }
             } else {
                 $va_attr_values['locale_id'] = $g_ui_locale_id;
                 $t_object->replaceAttribute($va_attr_values_by_event['reserve'], $vs_attr);
             }
             $t_object->update();
             if ($t_object->numErrors()) {
                 $this->errors = $t_object->errors;
                 if ($vb_we_set_transaction) {
                     $o_trans->rollback();
                 }
                 return false;
             }
         }
     }
     $vn_rc = $this->insert();
     if ($vb_we_set_transaction) {
         $vn_rc ? $o_trans->commit() : $o_trans->rollback();
     }
     return $vn_rc;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:68,代码来源:ca_object_checkouts.php


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