/** * Return last storage location as an ca_objects_x_storage_locations instance */ public function getLastLocation($pa_options = null) { $pn_object = caGetOption('object_id', $pa_options, null); if (!($vn_object_id = $pn_object_id > 0 ? $pn_object_id : $this->getPrimaryKey())) { return null; } $va_current_date = caDateToHistoricTimestamps(_t('now')); $vn_current_date = $va_current_date['start']; $o_db = $this->getDb(); $qr_res = $o_db->query("\n \t\t\tSELECT csl.relation_id\n \t\t\tFROM ca_objects_x_storage_locations csl\n \t\t\tINNER JOIN ca_storage_locations AS sl ON sl.location_id = csl.location_id\n \t\t\tWHERE\n \t\t\t\t(csl.object_id = ?) AND \n \t\t\t\t(sl.deleted = 0) AND (csl.sdatetime <= ?)\n \t\t\tORDER BY\n \t\t\t\tcsl.sdatetime DESC, csl.relation_id DESC\n \t\t\tLIMIT 1\n \t\t", array($vn_object_id, $vn_current_date)); if ($qr_res->nextRow()) { $t_loc = new ca_objects_x_storage_locations($qr_res->get('relation_id')); if ($this->inTransaction()) { $t_loc->setTransaction($this->getTransaction()); } return $t_loc; } return false; }
/** * Returns HTML editor form bundle for ca_objects_history (object use history bundle) * * @param HTTPRequest $po_request The current request * @param string $ps_form_name * @param string $ps_placement_code * @param array $pa_bundle_settings * @param array $pa_options Array of options. Options include: * noCache = Don't use any cached history data. [Default is false] * currentOnly = Only return history entries dates before or on the current date. [Default is false] * limit = Only return a maximum number of history entries. [Default is null; no limit] * * @return string Rendered HTML bundle * * @uses ca_objects::getObjectHistory() */ public function getObjectHistoryHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_bundle_settings = null, $pa_options = null) { global $g_ui_locale; $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/'); if (!is_array($pa_options)) { $pa_options = array(); } $vs_display_template = caGetOption('display_template', $pa_bundle_settings, _t('No template defined')); $vs_history_template = caGetOption('history_template', $pa_bundle_settings, $vs_display_template); $o_view->setVar('id_prefix', $ps_form_name); $o_view->setVar('placement_code', $ps_placement_code); // pass placement code $o_view->setVar('settings', $pa_bundle_settings); $o_view->setVar('add_label', isset($pa_bundle_settings['add_label'][$g_ui_locale]) ? $pa_bundle_settings['add_label'][$g_ui_locale] : null); $o_view->setVar('t_subject', $this); // // Loan update // $t_loan_rel = new ca_loans_x_objects(); $o_view->setVar('loan_relationship_types', $t_loan_rel->getRelationshipTypes(null, null, array_merge($pa_options, $pa_bundle_settings))); $o_view->setVar('loan_relationship_types_by_sub_type', $t_loan_rel->getRelationshipTypesBySubtype($this->tableName(), $this->get('type_id'), array_merge($pa_options, $pa_bundle_settings))); $t_location_rel = new ca_objects_x_storage_locations(); $o_view->setVar('location_relationship_types', $t_location_rel->getRelationshipTypes(null, null, array_merge($pa_options, $pa_bundle_settings))); $o_view->setVar('location_relationship_types_by_sub_type', $t_location_rel->getRelationshipTypesBySubtype($this->tableName(), $this->get('type_id'), array_merge($pa_options, $pa_bundle_settings))); // // Location update // $o_view->setVar('mode', 'ca_storage_locations'); //$vs_mode = caGetOption('locationTrackingMode', $pa_bundle_settings, 'ca_movements')); switch ($vs_mode) { case 'ca_storage_locations': $t_last_location = $this->getLastLocation(array()); $o_view->setVar('current_location', $t_last_location ? $t_last_location->getWithTemplate($vs_display_template) : null); $o_view->setVar('location_relationship_type', is_array($pa_bundle_settings['ca_storage_locations_relationshipType']) ? addslashes($pa_bundle_settings['ca_storage_locations_relationshipType'][0]) : ''); $o_view->setVar('location_change_url', null); break; case 'ca_movements': default: $t_last_movement = $this->getLastMovement(array('dateElement' => caGetOption('ca_movements_dateElement', $pa_bundle_settings, null))); $o_view->setVar('current_location', $t_last_movement ? $t_last_movement->getWithTemplate($vs_display_template) : null); $o_view->setVar('location_relationship_type', is_array($pa_bundle_settings['ca_movements_relationshipType']) ? addslashes($pa_bundle_settings['ca_movements_relationshipType'][0]) : ''); $o_view->setVar('location_change_url', caNavUrl($po_request, 'editor/movements', 'MovementQuickAdd', 'Form', array('movement_id' => 0))); break; } $va_history = $this->getObjectHistory($pa_bundle_settings, $pa_options); $o_view->setVar('history', $va_history); return $o_view->render('ca_objects_history.php'); }
} if ($vs_theme_display) { print "<H6>" . _t("Themes") . "</H6>"; print $vs_theme_display; } } if ($vs_style_display || $vs_theme_display || sizeof($va_collections)) { print "<HR/>"; } ?> {{{<ifdef code="ca_objects.idno"><H6>Steelcase Number</H6>^ca_objects.idno</ifdef>}}} <?php $va_storage_locations = $t_object->get("ca_storage_locations", array("returnAsArray" => true, "checkAccess" => $va_access_values)); if (sizeof($va_storage_locations)) { $t_location = new ca_storage_locations(); $t_relationship = new ca_objects_x_storage_locations(); $vn_now = date("Y.md"); $va_location_display = array(); foreach ($va_storage_locations as $va_storage_location) { $t_relationship->load($va_storage_location["relation_id"]); $va_daterange = $t_relationship->get("effective_daterange", array("rawDate" => true, "returnAsArray" => true)); if (is_array($va_daterange) && sizeof($va_daterange)) { foreach ($va_daterange as $va_date) { break; } #print $vn_now." - ".$va_date["effective_daterange"]["start"]." - ".$va_date["effective_daterange"]["end"]; if (is_array($va_date)) { if ($vn_now > $va_date["effective_daterange"]["start"] && $vn_now < $va_date["effective_daterange"]["end"]) { # --- only display the top level from the hierarchy $va_hierarchy_ancestors = array_reverse(caExtractValuesByUserLocale($t_location->getHierarchyAncestors($va_storage_location["location_id"], array("includeSelf" => 1, "additionalTableToJoin" => "ca_storage_location_labels", "additionalTableSelectFields" => array("name"))))); foreach ($va_hierarchy_ancestors as $va_ancestor) {