Bulk Actions - Check in and Check out

Created on 16 November 2011, about 13 years ago
Updated 28 October 2024, 3 months ago

Does anyone have the skill to create a bulk check in and check out feature to work with bulk operations ... or Core Actions?

I can see that it would involve creating some further code in library.actions.inc.

Line 63

),
    'library_checkout_action' => array(
      'description' => t('Checkout Library Item(s)'),
      'type' => 'library',
      'configurable' => FALSE,
      'hooks' => array(
        'library' => $hooks,
      )
    ),

And then creating the actual function ...

function library_checkout_action(&$object, $context = array()) {

I am not sure how to do this part. Other than to use some parts of: (from library.pages.inc)

function library_transaction_form_submit($form, &$form_state) {
  $now = time();
  $duedate = NULL;
  $clean = library_clean_action_name($form_state['values']['action_name']);
  if ($form_state['values']['action_status_change'] == LIBRARY_ACTION_TYPE_UNAVAILABLE) {
    $type = $form_state['values']['node_type'];
    $period = variable_get('library_period_for_'. $type .'_'. $clean, 0);
    if ($period > 0) {
      $duedate = library_get_due_date($now, $clean, $type);
    }
    $new_status = LIBRARY_ITEM_UNAVAILABLE;
  }
  elseif ($form_state['values']['action_status_change'] == LIBRARY_ACTION_TYPE_AVAILABLE) {
    $new_status = LIBRARY_ITEM_AVAILABLE;   
  }
  db_query("INSERT {library_transactions} (nid, item_id, uid, action_aid, duedate, notes, created) VALUES (%d, %d, %d, %d, %d, '%s', %d)", $form_state['values']['nid'], $form_state['values']['item_id'], $form_state['values']['patron_uid'], $form_state['values']['action_aid'], $duedate, check_plain($form_state['values']['notes']), $now);
  if ($form_state['values']['action_status_change'] > LIBRARY_ACTION_NO_CHANGE) {
    db_query("UPDATE {library} set library_status = %d WHERE id = %d", $new_status, $form_state['values']['item_id']);
  }

  drupal_set_message(t('The '. $form_state['values']['action_name'] .' was successful.'));
  if (module_exists('trigger')) {
    $transaction_id = db_last_insert_id('library_transactions', 'tid');
    $context = array();
    $object = (object) $context;
    $context['item'] = array(
      'id' => $form_state['values']['item_id'], 'nid' => $form_state['values']['nid'], 'title' => $form_state['values']['item_name'], 'barcode' => $form_state['values']['barcode'], 'node_type' => $form_state['values']['node_type']
    );
    $context['transaction'] = array('id' => $transaction_id, 'action_name' => $form_state['values']['action_name'], 'aid' => $form_state['values']['action_aid'], 'notes' => check_plain($form_state['values']['notes']), 'duedate' => $duedate, 'created' => $now);
    $context['patron'] = array('name' => $form_state['values']['patron_name'], 'mail' => $form_state['values']['patron_email'], 'uid' => $form_state['values']['patron_uid']);
    $actions = _library_get_hook_aids('library', 'after_'. $clean);
    if (!empty($actions)) {
      actions_do($actions, $object, $context);
    }
  }
  $form_state['redirect'] = 'node/'. $form_state['values']['nid'];
  return;
}

Any help would be much appreciated. Can you call that function directly from the action?
I want to be able to check in a number of items at a time.

And then also to be able to check out a number of items at a time to one patron, but I think that this is much more complex than the first.

Feature request
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024