You are here

function uc_shipping_package_view in Ubercart 7.3

Same name and namespace in other branches
  1. 5 shipping/uc_shipping/uc_shipping.module \uc_shipping_package_view()
  2. 6.2 shipping/uc_shipping/uc_shipping.module \uc_shipping_package_view()

Displays the details of a package.

1 call to uc_shipping_package_view()
uc_shipping_shipment_view in shipping/uc_shipping/uc_shipping.admin.inc
Displays shipment details.

File

shipping/uc_shipping/uc_shipping.module, line 340
Organizes ordered products into packages and sets them up for shipment. Shipping method modules may add functionality to generate shipping labels and tracking numbers.

Code

function uc_shipping_package_view($package) {
  $shipment = uc_shipping_shipment_load($package->sid);
  $build = array(
    '#prefix' => '<div class="order-pane pos-left">',
    '#suffix' => '</div>',
  );
  $rows = array();
  $build['title'] = array(
    '#markup' => t('Package %id:', array(
      '%id' => $package->package_id,
    )),
    '#prefix' => '<div class="order-pane-title">',
    '#suffix' => '</div>',
  );
  $rows[] = array(
    t('Contents:'),
    filter_xss_admin($package->description),
  );
  if ($shipment) {
    $methods = module_invoke_all('uc_shipping_method');
    if (isset($methods[$shipment->shipping_method])) {
      $pkg_type = $methods[$shipment->shipping_method]['ship']['pkg_types'][$package->pkg_type];
    }
  }
  $rows[] = array(
    t('Package type:'),
    isset($pkg_type) ? $pkg_type : check_plain($package->pkg_type),
  );
  if ($package->length && $package->width && $package->height) {
    $rows[] = array(
      t('Dimensions:'),
      t('!l x !w x !h', array(
        '!l' => uc_length_format($package->length),
        '!w' => uc_length_format($package->width),
        '!h' => uc_length_format($package->height),
      )),
    );
  }
  $rows[] = array(
    t('Insured value:'),
    array(
      'data' => array(
        '#theme' => 'uc_price',
        '#price' => $package->value,
      ),
    ),
  );
  if ($package->tracking_number) {
    $rows[] = array(
      t('Tracking number:'),
      check_plain($package->tracking_number),
    );
  }
  if ($shipment && isset($package->label_image) && file_exists($package->label_image->uri)) {
    $rows[] = array(
      t('Label:'),
      l(t('Click to view.'), 'admin/store/orders/' . $package->order_id . '/shipments/labels/' . $shipment->shipping_method . '/' . $package->label_image->uri),
    );
  }
  else {
    $rows[] = array(
      t('Label:'),
      t('n/a'),
    );
  }
  $build['package'] = array(
    '#theme' => 'table',
    '#rows' => $rows,
    'attributes' => array(
      'style' => 'width:auto;',
    ),
  );
  return $build;
}