/** * Return an HTML code containing selected objects. * @param $dcn_id (int) Datacenter ID. * @param $sts_id (int) Suite ID. * @param $rck_id (int) Rack ID. * @param $obt_id (int) Object ID. * @param $obj_owner_id (int) Owner ID. * @param $obj_tenant_id (int) Tenant ID. * @param $keywords (string) Keywords. * @param $list (boolean) If true output an unordered list instead of checkboxes list. * @return html code */ function F_getSelectedObject($dcn_id = 0, $sts_id = 0, $rck_id = 0, $obt_id = 0, $obj_owner_id = 0, $obj_tenant_id = 0, $keywords = 0, $list = false) { global $l, $db; require_once '../config/tce_config.php'; require_once 'tce_functions_user_select.php'; $user_id = intval($_SESSION['session_user_id']); $dcn_id = intval($dcn_id); $sts_id = intval($sts_id); $rck_id = intval($rck_id); $obt_id = intval($obt_id); $obj_owner_id = intval($obj_owner_id); $obj_tenant_id = intval($obj_tenant_id); $out = ''; $out .= '<fieldset class="subset" style="text-align:left;">' . K_NEWLINE; echo '<legend>' . $l['w_objects'] . '</legend>' . K_NEWLINE; // basic selection query $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ' WHERE obj_id>0'; // basic object filtering if ($obt_id > 0) { $sql .= ' AND obj_obt_id=' . $obt_id; } if ($obj_owner_id > 0) { $sql .= ' AND obj_owner_id=' . $obj_owner_id; } if ($obj_tenant_id > 0) { $sql .= ' AND obj_tenant_id=' . $obj_tenant_id; } if (!empty($keywords)) { // get all the words into an array $terms = preg_split("/[\\s]+/i", $keywords); $wheresearch = ''; foreach ($terms as $word) { $word = F_escape_sql($word); $wheresearch .= ' AND ((obj_name LIKE \'%' . $word . '%\')'; $wheresearch .= ' OR (obj_label LIKE \'%' . $word . '%\')'; $wheresearch .= ' OR (obj_tag LIKE \'%' . $word . '%\'))'; } $sql .= ' AND' . substr($wheresearch, 5); } if ($r = F_db_query($sql, $db)) { $out .= '<div class="rowl">' . K_NEWLINE; if ($list) { $out .= '<ul>' . K_NEWLINE; } while ($m = F_db_fetch_array($r)) { $odcn_id = 0; $osts_id = 0; $orck_id = 0; $object_name = F_get_object_path($m['obj_id'], true, $odcn_id, $osts_id, $orck_id); // check if the current object ID respect other filtering options: $include = true; if ($dcn_id > 0) { $include = $dcn_id == $odcn_id; if ($sts_id > 0) { $include = $sts_id == $osts_id; if ($rck_id > 0) { $include = $rck_id == $orck_id; } } } if ($include) { if ($list) { $out .= '<li>' . $object_name . '</li>' . K_NEWLINE; } else { $varname = 'so_' . $m['obj_id']; $out .= '<input type="checkbox" name="' . $varname . '" id="' . $varname . '" value="1" title="' . $m['obj_id'] . '"'; if (isset($_REQUEST['checkall']) and $_REQUEST['checkall'] == 1 or isset($_REQUEST[$varname]) and !isset($_REQUEST['checkall'])) { $out .= ' checked="checked"'; } $out .= ' />'; $out .= ' <label for="' . $varname . '">' . $object_name . '</label><br />' . K_NEWLINE; } } } if ($list) { $out .= '</ul>' . K_NEWLINE; } else { // check/uncheck all options $out .= '<br /><span>'; $out .= '<input type="radio" name="checkall" id="checkall1" value="1" onclick="document.getElementById(\'form_editor\').submit()" />'; $out .= '<label for="checkall1">' . $l['w_check_all'] . '</label> '; $out .= '<input type="radio" name="checkall" id="checkall0" value="0" onclick="document.getElementById(\'form_editor\').submit()" />'; $out .= '<label for="checkall0">' . $l['w_uncheck_all'] . '</label>'; $out .= '</span>' . K_NEWLINE; } $out .= '</div>' . K_NEWLINE; } else { F_display_db_error(); } $out .= '</fieldset>' . K_NEWLINE; return $out; }
} } else { $cbt_name = ''; $cab_color = 'd3d3d3'; } } } echo '<div class="container">' . K_NEWLINE; echo '<div class="tceformbox">' . K_NEWLINE; echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_editor">' . K_NEWLINE; echo F_connection_selector($sel_a_obj_id, $sel_b_obj_id, $sel_cbt_id); echo getFormNoscriptSelect('selectrecord'); echo '<div class="row"><hr /></div>' . K_NEWLINE; if (isset($cab_ids) and !empty($cab_ids)) { echo getFormDescriptionLine($l['w_object'] . ' (A)', '', F_get_object_path($cab_a_obj_id, true)); echo getFormDescriptionLine($l['w_object'] . ' (B)', '', F_get_object_path($cab_b_obj_id, true)); echo getFormDescriptionLine($l['w_connection_type'], '', $cbt_name); } else { echo F_object_selector($cab_a_obj_id, 'cab_a_obj_id', $l['w_object'] . ' (A)', false, false); echo F_object_selector($cab_b_obj_id, 'cab_b_obj_id', $l['w_object'] . ' (B)', false, false); echo F_select_connection_type($cab_cbt_id); } echo F_select_color($cab_color, 'cab_color', $l['w_color'], $l['h_cable_color']); echo '<div class="row">' . K_NEWLINE; // show buttons by case if (isset($cab_ids) and !empty($cab_ids)) { echo '<span style="background-color:#999999;">'; echo '<input type="checkbox" name="confirmupdate" id="confirmupdate" value="1" title="confirm → update" />'; F_submit_button('update', $l['w_update'], $l['h_update']); echo '</span>'; F_submit_button('delete', $l['w_delete'], $l['h_delete']);
} else { F_display_db_error(); } } } } echo '<div class="container">' . K_NEWLINE; echo '<div class="tceformbox">' . K_NEWLINE; echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_editor">' . K_NEWLINE; echo F_object_selector($obj_id, 'obj_id', $l['w_object'], true, true, empty($omp_parent_obj_id), false); echo getFormNoscriptSelect('selectrecord'); if ($obj_id > 0) { // display a cliccable path echo '<div class="row">' . K_NEWLINE; echo '<span class="formw">' . K_NEWLINE; echo F_get_object_path($obj_id, true); echo '</span>' . K_NEWLINE; echo '</div>' . K_NEWLINE; } echo '<div class="row"><hr /></div>' . K_NEWLINE; // object type $virtual = false; echo '<div class="row">' . K_NEWLINE; echo '<span class="label">' . K_NEWLINE; echo '<label for="obj_obt_id">' . $l['w_object_type'] . '</label>' . K_NEWLINE; echo '</span>' . K_NEWLINE; echo '<span class="formw">' . K_NEWLINE; echo '<select name="obj_obt_id" id="obj_obt_id" size="0" onchange="document.getElementById(\'form_editor\').submit()">' . K_NEWLINE; $sql = 'SELECT * FROM ' . K_TABLE_OBJECT_TYPES . ' WHERE 1 ORDER BY obt_name ASC'; if ($r = F_db_query($sql, $db)) { while ($m = F_db_fetch_array($r)) {