function check_alarm_calendar($count = true, $id = false) { global $config; $now = strtotime(date('Y-m-d H:i:s')); if ($count) { $sql = "SELECT count(`id`) as num_alarms FROM tagenda \n\t\t\tWHERE id_user='******'id_user'] . "'\n\t\t\tAND alarm <> 0\n\t\t\tAND ((UNIX_TIMESTAMP(`timestamp`) - {$now}) > 0)\n\t\t\tAND ((UNIX_TIMESTAMP(`timestamp`) - (`alarm` * 60)) <= {$now})"; $alarms = get_db_value_sql($sql); } else { if (!$count && !$id) { $sql = "SELECT * FROM tagenda \n\t\t\tWHERE id_user='******'id_user'] . "'\n\t\t\tAND alarm <> 0\n\t\t\tAND ((UNIX_TIMESTAMP(`timestamp`) - {$now}) > 0)\n\t\t\tAND ((UNIX_TIMESTAMP(`timestamp`) - (`alarm` * 60)) <= {$now})"; $alarms = get_db_all_rows_sql($sql); } else { $sql = "SELECT * FROM tagenda \n\t\t\tWHERE id_user='******'id_user'] . "'\n\t\t\tAND alarm <> 0\n\t\t\tAND id={$id}\n\t\t\tAND ((UNIX_TIMESTAMP(`timestamp`) - {$now}) > 0)\n\t\t\tAND ((UNIX_TIMESTAMP(`timestamp`) - (`alarm` * 60)) <= {$now})"; $alarms = get_db_row_sql($sql); } } return $alarms; }
function show_workunit_user($id_workunit, $full = 0, $show_multiple = true, $back_to_wu = false, $user = "", $timestamp_h = "", $timestamp_l = "") { global $config; $sql = "SELECT * FROM tworkunit WHERE id = {$id_workunit}"; if ($res = mysql_query($sql)) { $row = mysql_fetch_array($res); } else { return; } $timestamp = $row["timestamp"]; $duration = $row["duration"]; $id_user = $row["id_user"]; $avatar = get_db_value("avatar", "tusuario", "id_usuario", $id_user); $nota = $row["description"]; $have_cost = $row["have_cost"]; $profile = $row["id_profile"]; $public = $row["public"]; $locked = $row["locked"]; $work_home = $row["work_home"]; $id_task = get_db_value("id_task", "tworkunit_task", "id_workunit", $row["id"]); if (!$id_task) { $id_incident = get_db_value("id_incident", "tworkunit_incident", "id_workunit", $row["id"]); } $id_project = get_db_value("id_project", "ttask", "id", $id_task); $id_profile = get_db_value("id_profile", "tworkunit", "id", $id_workunit); $task_title = get_db_value("name", "ttask", "id", $id_task); if (!$id_task) { $incident_title = get_db_value("titulo", "tincidencia", "id_incidencia", $id_incident); } $project_title = get_db_value("name", "tproject", "id", $id_project); // ACL Check for visibility if (!$public && $id_user != $config["id_user"]) { if ($id_task) { $task_access = get_project_access($config["id_user"], false, $id_task, false, true); if (!$task_access["manage"]) { return; } } elseif (!give_acl($config["id_user"], 0, "TM")) { return; } } echo "<div id='wu_{$id_workunit}'>"; echo "<form method='post' action='index.php?sec=projects&sec2=operation/projects/task_workunit'>"; // Show data echo "<div class='notetitle'>"; // titulo echo "<table class='' width='100%' style='margin: 0px; background: transparent;'>"; echo "<tr><td rowspan=4 width='2%'>"; print_user_avatar($id_user, true); echo "<td width='20%'><b>"; if ($id_task) { echo __('Task') . " </b> : "; echo "<a href='index.php?sec=projects&sec2=operation/projects/task_detail&id_task={$id_task}&operation=view'>{$task_title}</A>"; } else { echo __('Ticket') . " </b> : "; echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id={$id_incident}'>{$incident_title}</A>"; } echo "</td>"; echo "<td><b>"; if ($id_task) { echo __('Project') . " </b> : "; echo "<a href='index.php?sec=projects&sec2=operation/projects/task&id_project={$id_project}'>{$project_title}</A>"; } else { echo __('Group') . "</b> : "; echo dame_nombre_grupo(get_db_sql("SELECT id_grupo FROM tincidencia WHERE id_incidencia = {$id_incident}")); } echo "</td>"; echo "<td width='13%'>"; echo "<b>" . __('Duration') . "</b>"; echo " : " . format_numeric($duration); echo "</td>"; echo "<td>"; // Public WU ? echo "<span style='margin-bottom:0px; padding-right:10px;'>"; if ($public == 1) { echo "<img src='images/group.png' title='" . __('Public Workunit') . "' />"; } else { echo "<img src='images/delete.png' title='" . __('Non public Workunit') . "' />"; } echo "</span>"; echo "</td></tr>"; echo "<tr>"; echo "<td><b>"; if ($have_cost != 0) { $profile_cost = get_db_value("cost", "trole", "id", $profile); $cost = format_numeric($duration * $profile_cost); $cost = $cost . " €"; } else { $cost = __('N/A'); } echo __('Cost'); echo "</b>"; echo " : " . $cost; echo "</td>"; echo "<td><b>"; echo __('Work from home'); echo "</b>"; if ($work_home == 0) { $wfh = __('No'); } else { $wfh = __('Yes'); } echo " : " . $wfh; echo "</td>"; echo "<td><b>"; echo __('Profile'); echo "</b>"; $profile_name = get_db_value("name", "trole", "id", $profile); echo " : "; echo $profile_name == false ? "N/A" : $profile_name; echo "</td>"; if ($show_multiple) { echo "<td>"; echo print_checkbox_extended('op_multiple[]', $id_workunit, false, false, '', '', true); echo "</td>"; } echo "</tr>"; echo "</table>"; echo "</div>"; // Body //echo "<div class='notebody'>"; $output = "<div class='notebody' id='wu_{$id_workunit}'>"; $output .= "<table width='100%' class=''>"; $output .= "<tr><td valign='top'>"; if (strlen($nota) > 1024 and $full == 0) { $output .= topi_richtext(clean_output_breaks(substr($nota, 0, 1024))); $output .= "<a href='index.php?sec=users&sec2=operation/users/user_workunit_report&id_workunit=" . $id_workunit . "&title={$task_title}'>"; $output .= __('Read more...'); $output .= "</a>"; } else { $output .= topi_richtext(clean_output_breaks($nota)); } $output .= "<td valign='top'>"; $output .= "<table width='100%' class=''>"; if ($_GET["sec2"] == "operation/users/user_workunit_report") { $myurl = "index.php?sec=users&sec2=operation/users/user_workunit_report&id={$id_user}"; } else { if ($id_project > 0) { $myurl = "index.php?sec=projects&sec2=operation/users/user_spare_workunit&id_project={$id_project}&id_task={$id_task}"; } else { $myurl = "index.php?sec=users&sec2=operation/users/user_workunit_report&id={$id_user}"; } } $belong_to_ticket = get_db_value_sql("SELECT * FROM tworkunit_incident WHERE id_workunit = " . $id_workunit); if ((project_manager_check($id_project) == 1 or $id_user == $config["id_user"] or give_acl($config["id_user"], 0, "TM")) && !$belong_to_ticket) { $output .= "<tr><td align='right'>"; $output .= "<a class='delete-workunit' id='delete-{$id_workunit}' href='{$myurl}&id_workunit={$id_workunit}&operation=delete' onclick='if (!confirm(\"" . __('Are you sure?') . "\")) return false;'><img src='images/cross.png' title='" . __('Delete workunit') . "'/></a>"; } // Edit workunit if (((project_manager_check($id_project) == 1 or give_acl($config["id_user"], 0, "TM") or $id_user == $config["id_user"]) and ($locked == "" or give_acl($config["id_user"], 0, "UM"))) && !$belong_to_ticket) { $output .= "<tr><td align='right'>"; $output .= "<a class='edit-workunit' id='edit-{$id_workunit}' href='index.php?sec=projects&sec2=operation/users/user_spare_workunit&id_project={$id_project}&id_task={$id_task}&id_workunit={$id_workunit}&id_profile={$id_profile}&back_to_wu={$back_to_wu}&user={$user}×tamp_l={$timestamp_l}×tamp_h={$timestamp_h}'><img border=0 src='images/page_white_text.png' title='" . __('Edit workunit') . "'></a>"; $output .= "</td>"; } // Lock workunit if (!$belong_to_ticket) { if ((project_manager_check($id_project) == 1 or give_acl($config["id_user"], 0, "TM") or $id_user == $config["id_user"]) and $locked == "") { $output .= "<tr><td align='right'>"; $output .= "<a class='lock_workunit' id='lock-{$id_workunit}' href='{$myurl}&id_workunit={$id_workunit}&operation=lock'><img src='images/lock.png' title='" . __('Lock workunit') . "'></a>"; $output .= "</td>"; } else { $output .= "<tr><td align='right'>"; $output .= "<img src='images/rosette.png' title='" . __('Locked by') . " {$locked}'"; $output .= "</td>"; } } $output .= "</tr></table>"; $output .= "</tr></table>"; $output .= "</div>"; $title = "<a href='index.php?sec=users&sec2=operation/users/user_edit&id={$id_user}'>"; $title .= "<b>" . $id_user . "</b>"; $title .= "</a>"; $title .= " " . __('said on') . ' ' . $timestamp; print_container_div("dest-" . $id_workunit, $title, $output, 'closed', false, false, '', '', 1, '', "margin-top:0px;"); echo "</form>"; echo "</div>"; }
foreach ($rows as $r) { $aux = array(); $aux["id"] = $r["id"]; $aux["name"] = $r["name"]; $aux["id_object_type"] = $r["id_object_type"]; $aux["object_type_name"] = ""; if ($aux["id_object_type"]) { $aux["object_type_name"] = get_db_value("name", "tobject_type", "id", $r["id_object_type"]); $sql = "SELECT * FROM tobject_type_field WHERE id_object_type=" . $aux["id_object_type"]; $all_fields = get_db_all_rows_sql($sql); if ($all_fields == false) { $all_fields = array(); } foreach ($all_fields as $key => $field) { $sql = "SELECT data FROM tobject_field_data WHERE id_object_type_field=" . $field['id'] . " AND id_inventory=" . $aux["id"]; $data = get_db_value_sql($sql); $aux[safe_output($field['label'])] = $data; } } $aux["description"] = $r["description"]; $aux["id_contract"] = $r["id_contract"]; $aux["contract_name"] = ""; if ($aux["id_contract"]) { $aux["contract_name"] = get_db_value("name", "tcontract", "id", $r["id_contract"]); } $aux["id_manufacturer"] = $r["id_manufacturer"]; $aux["manufacturer_name"] = ""; if ($aux["id_manufacturer"]) { $aux["manufacturer_name"] = get_db_value("name", "tmanufacturer", "id", $r["id_manufacturer"]); } $aux["id_parent"] = $r["id_parent"];
echo "<tr align='left'>"; echo "<td>"; echo $child['id_incidencia'] . ' - ' . $child['titulo']; echo "</td>"; } echo "</table>"; } else { return false; } return; } if ($check_custom_search) { $sql = sprintf('SELECT COUNT(id) FROM tcustom_search WHERE id_user = "******" AND section = "incidents" ORDER BY name', $config['id_user']); $count_search = get_db_value_sql($sql); if (!$count_search) { $result = __("Ticket reports are based on custom searches. In order to elaborate a report, first you will need to define a custom search on which the report will be based."); $result .= integria_help("custom_search", true); $result .= '<br><br><a href="index.php?sec=incidents&sec2=operation/incidents/incident_search">' . __('Go to Custom search') . '</a>'; } else { $result = false; } echo json_encode($result); return; } if ($set_params) { $id_ticket = get_parameter('id_ticket'); $values = array(); $values['prioridad'] = get_parameter('id_priority'); $values['resolution'] = get_parameter('id_resolution');
return; } if ($printTableMoreInfo) { $id_inventory = get_parameter('id_inventory'); $id_object_type = get_db_value_sql('SELECT id_object_type FROM tinventory WHERE id=' . $id_inventory); if ($id_object_type) { $object_fields = get_db_all_rows_sql("SELECT * FROM tobject_type_field WHERE id_object_type=" . $id_object_type); if ($object_fields == false) { $object_fields = array(); } $table_info->class = 'list'; $table_info->width = '98%'; $table_info->data = array(); $i = 0; foreach ($object_fields as $field) { $value = get_db_value_sql("SELECT data FROM tobject_field_data WHERE id_inventory=" . $id_inventory . " AND id_object_type_field=" . $field['id']); if ($value == "") { $value = "--"; } $table_info->data[$i][0] = print_label($field['label'], '', '', true); $table_info->data[$i][1] = $value; $i++; } print_table($table_info); return; } else { echo "<b>" . __('No data to show') . "</b>"; return; } } if ($change_owner) {
// http://www.artica.es <*****@*****.**> // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; version 2 // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. global $config; check_login (); // Get start date of first incident to use it on filters $first_start = get_db_value_sql ("SELECT UNIX_TIMESTAMP(inicio) FROM tincidencia ORDER BY inicio ASC"); if (!empty($first_start)) { $first_start = date ("Y-m-d", $first_start); } echo "<h1>"; echo __("Tickets overview"); echo "</h1>"; /* Users affected by the incident */ $table->width = '100%'; $table->class = "none"; $table->size = array (); $table->size[0] = '50%'; $table->size[1] = '50%';
check_login(); if (!give_acl($config["id_user"], 0, "CN")) { audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access company section"); require "general/noaccess.php"; exit; } if (defined('AJAX')) { $calculate_total = get_parameter('calculate_total', 0); $create_queue = get_parameter('create_queue', 0); $add_address = get_parameter('add_address', 0); if ($calculate_total) { $id_newsletter_content = get_parameter('id_newsletter_content'); $issue = get_db_row("tnewsletter_content", "id", $id_newsletter_content); $newsletter = get_db_row("tnewsletter", "id", $issue["id_newsletter"]); $sql = "SELECT COUNT(id) FROM tnewsletter_address WHERE status = 0 AND id_newsletter = " . $newsletter["id"]; $total = get_db_value_sql($sql); echo json_encode($total); return; } if ($create_queue) { $id_newsletter_content = get_parameter('id_newsletter_content'); $datetime = date("Y-m-d H:i:s"); $issue = get_db_row("tnewsletter_content", "id", $id_newsletter_content); $newsletter = get_db_row("tnewsletter", "id", $issue["id_newsletter"]); //Create the queue $sql = sprintf('INSERT INTO tnewsletter_queue (id_newsletter_content, datetime, status) VALUES (%d, "%s", %d)', $issue["id"], $datetime, 0); $id_queue = process_sql($sql, 'insert_id'); echo json_encode($id_queue); return; } if ($add_address) {
function inventories_show_list($sql_search, $sql_count, $params = '', $last_update = 0, $modal = 0) { global $config; $is_enterprise = false; if (file_exists("enterprise/include/functions_inventory.php")) { require_once "enterprise/include/functions_inventory.php"; $is_enterprise = true; } $write_permission = enterprise_hook('inventory_check_acl', array($config['id_user'], $id, true)); $params['mode'] = 'list'; if (!$sql_search) { $sql_search = "SELECT * FROM tinventory"; } $pure = get_parameter("pure"); if ($pure) { $block_limit = 5000; } else { $block_limit = $config["block_size"]; } $sql_search .= " LIMIT " . $block_limit; $offset = get_parameter("offset", 0); $sql_search .= " OFFSET {$offset}"; $inventories_aux = get_db_all_rows_sql($sql_search); $count_inv = get_db_value_sql($sql_count); if ($is_enterprise) { $inventories = inventory_get_user_inventories($config['id_user'], $inventories_aux); } else { $inventories = $inventories_aux; } if ($inventories === false) { echo ui_print_error_message(__("Empty inventory"), '', true, 'h3', true); } else { $result_check = inventories_check_same_object_type_list($inventories); $table->id = 'inventory_list'; $table->class = 'listing'; $table->width = '100%'; $table->data = array(); $table->head = array(); $table->colspan = array(); $table->head[0] = __('Id'); $table->head[1] = __('Name'); $table->head[2] = __('Owner'); $table->head[3] = __("Parent object"); $table->head[4] = __('Object type'); $table->head[5] = __('Manufacturer'); $table->head[6] = __('Contract'); $table->head[7] = __('Status'); $table->head[8] = __('Receipt date'); if ($result_check) { $res_object_fields = inventories_get_all_type_field($result_check, false, true); $i = 9; foreach ($res_object_fields as $key => $object_field) { if (isset($object_field["label"])) { $table->head[$i] = $object_field['label']; $i++; } } if (!$pure) { if (!$modal) { $table->head[$i] = __('Actions'); if ($write_permission) { $i = $i + 1; $table->head[$i] = print_checkbox('inventorycb-all', "", false, true); } } } } else { if (!$pure) { if (!$modal) { $table->head[9] = __('Actions'); if ($write_permission) { $table->head[10] = print_checkbox('inventorycb-all', "", false, true); } } } } $count = $count_inv; $params = json_encode($params); $params = base64_encode($params); $url_pag = "index.php?sec=inventory&sec2=operation/inventories/inventory¶ms=" . $params; $offset = get_parameter("offset"); if (!$pure) { pagination($count, $url_pag, $offset, false, '', 0, true); } $idx = 0; foreach ($inventories as $key => $inventory) { $data = array(); if ($modal) { $url = "javascript:loadInventory(" . $inventory['id'] . ");"; } else { $url = 'index.php?sec=inventory&sec2=operation/inventories/inventory_detail&id=' . $inventory['id']; } $data[0] = "<a href=" . $url . ">" . $inventory['id'] . "</a>"; $data[1] = "<a href=" . $url . ">" . $inventory['name'] . '</a>'; if ($inventory['owner'] != '') { $name_owner = get_db_value('nombre_real', 'tusuario', 'id_usuario', $inventory['owner']); } else { $name_owner = '--'; } $data[2] = "<a href=" . 'index.php?sec=users&sec2=operation/users/user_edit&id=' . $inventory['owner'] . ">" . $name_owner . '</a>'; if ($inventory["id_parent"] != 0) { $name_parent = get_db_value('name', 'tinventory', 'id', $inventory['id_parent']); $data[3] = "<a href=" . 'index.php?sec=inventory&sec2=operation/inventories/inventory_detail&id=' . $inventory['id_parent'] . ">" . $name_parent . '</a>'; } else { $name_parent = '--'; $data[3] = $name_parent; } if ($inventory['id_object_type'] != 0) { $name_object = get_db_value('name', 'tobject_type', 'id', $inventory['id_object_type']); $data[4] = "<a href=" . 'index.php?sec=inventory&sec2=operation/inventories/manage_objects&id=' . $inventory['id_object_type'] . ">" . $name_object . '</a>'; } else { $name_object = '--'; $data[4] = $name_object; } if ($inventory['id_manufacturer'] != 0) { $name_manufacturer = get_db_value('name', 'tmanufacturer', 'id', $inventory['id_manufacturer']); $data[5] = "<a href=" . 'index.php?sec=inventory&sec2=operation/manufacturers/manufacturer_detail&id=' . $inventory['id_manufacturer'] . ">" . $name_manufacturer . '</a>'; } else { $name_manufacturer = '--'; $data[5] = $name_manufacturer; } if ($inventory['id_contract'] != 0) { $name_contract = get_db_value('name', 'tcontract', 'id', $inventory['id_contract']); $data[6] = "<a href=" . 'index.php?sec=customers&sec2=operation/contracts/contract_detail&id_contract=' . $inventory['id_contract'] . ">" . $name_contract . '</a>'; } else { $name_contract = '--'; $data[6] = $name_contract; } if ($inventory['status'] != "") { $data[7] = __($inventory['status']); } else { $status_none = '--'; $data[7] = $status_none; } if ($inventory['receipt_date'] != "") { $data[8] = $inventory['receipt_date']; } else { $receipt_date = '--'; $data[8] = $receipt_date; } if ($result_check) { $result_object_fields = inventories_get_all_type_field($result_check, $inventory['id'], true); $i = 9; foreach ($result_object_fields as $k => $ob_field) { if (isset($ob_field["label"])) { $data[$i] = $ob_field['data']; $i++; } } if (!$pure) { if (!$modal) { if ($write_permission) { $data[$i] .= '<a href="index.php?sec=inventory&sec2=operation/inventories/inventory&quick_delete=' . $inventory["id"] . '¶ms=' . $params . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) return false;"><img src="images/cross.png"></a>'; } } } if (!$pure) { if (!$modal) { if ($write_permission) { $i = $i + 1; $data[$i] = print_checkbox_extended('inventorycb-' . $inventory['id'], $inventory['id'], false, '', '', 'class="cb_inventory"', true); } } } } else { if (!$pure) { if (!$modal) { if ($write_permission) { $data[9] .= '<a href="index.php?sec=inventory&sec2=operation/inventories/inventory&quick_delete=' . $inventory["id"] . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) return false;"><img src="images/cross.png"></a>'; } } } if (!$pure) { if (!$modal) { if ($write_permission) { $data[10] = print_checkbox_extended('inventorycb-' . $inventory['id'], $inventory['id'], false, '', '', 'class="cb_inventory"', true); } } } } $table->rowclass[$idx] = 'inventory_info_' . $inventory["id"]; $idx++; array_push($table->data, $data); } echo '<div id= "inventory_only_table">'; print_table($table); echo '</div>'; if (!$pure) { pagination($count, $url_pag, $offset, true, '', 0, true); if (!$modal) { if ($write_permission) { echo '<div class="button-form">'; echo print_button(__('Delete All'), '', false, 'javascript: delete_massive_inventory()', 'class="sub"', true); echo '</div>'; } } } } }
function inventories_show_list($sql_search, $sql_count, $params = '', $last_update = 0) { global $config; $is_enterprise = false; if (file_exists("enterprise/include/functions_inventory.php")) { require_once "enterprise/include/functions_inventory.php"; $is_enterprise = true; } $write_permission = enterprise_hook('inventory_check_acl', array($config['id_user'], $id, true)); $params .= "&mode=list"; if (!$sql_search) { $sql_search = "SELECT * FROM tinventory"; } if ($last_update) { $sql_search .= " ORDER BY last_update DESC"; } else { $sql_search .= " ORDER BY name ASC"; } $clean_output = get_parameter("clean_output"); if ($clean_output) { $block_limit = 5000; } else { $block_limit = $config["block_size"]; } $sql_search .= " LIMIT " . $block_limit; $offset = get_parameter("offset", 0); $sql_search .= " OFFSET {$offset}"; $inventories_aux = get_db_all_rows_sql($sql_search); $count_inv = get_db_value_sql($sql_count); if ($is_enterprise) { $inventories = inventory_get_user_inventories($config['id_user'], $inventories_aux); } else { $inventories = $inventories_aux; } if ($inventories === false) { echo "<h3 class='error'>" . __("Empty inventory") . "</h3>"; } else { $result_check = inventories_check_same_object_type_list($inventories); $table->id = 'inventory_list'; $table->class = 'listing'; $table->width = '100%'; $table->data = array(); $table->head = array(); $table->colspan = array(); $table->head[0] = __('Id'); $table->head[1] = __('Name'); $table->head[2] = __('Owner'); $table->head[3] = __("Parent object"); $table->head[4] = __('Object type'); $table->head[5] = __('Manufacturer'); $table->head[6] = __('Contract'); if ($result_check) { $res_object_fields = inventories_get_all_type_field($result_check, false, true); $i = 6; foreach ($res_object_fields as $key => $object_field) { if (isset($object_field["label"])) { $table->head[$i] = $object_field['label']; $i++; } } $table->head[$i] = __('Actions'); if ($write_permission) { $table->head[$i] = print_checkbox('inventorycb-all', "", false, true); } } else { if (!$clean_output) { $table->head[7] = __('Actions'); } if ($write_permission) { $table->head[8] = print_checkbox('inventorycb-all', "", false, true); } } $count = $count_inv; $url_pag = "index.php?sec=inventory&sec2=operation/inventories/inventory" . $params; $offset = get_parameter("offset"); if (!$clean_output) { pagination($count, $url_pag, $offset); } $idx = 0; foreach ($inventories as $key => $inventory) { $data = array(); if (defined('AJAX')) { $url = "javascript:loadInventory(" . $inventory['id'] . ");"; } else { $url = 'index.php?sec=inventory&sec2=operation/inventories/inventory_detail&id=' . $inventory['id']; } $data[0] = "<a href=" . $url . ">" . $inventory['id'] . "</a>"; $data[1] = "<a href=" . $url . ">" . $inventory['name'] . '</a>'; if ($inventory['owner'] != '') { $name_owner = get_db_value('nombre_real', 'tusuario', 'id_usuario', $inventory['owner']); } else { $name_owner = '--'; } $data[2] = "<a href=" . 'index.php?sec=inventory&sec2=users&sec2=operation/users/user_edit&id=' . $inventory['owner'] . ">" . $name_owner . '</a>'; if ($inventory["id_parent"] != 0) { $name_parent = get_db_value('name', 'tinventory', 'id', $inventory['id_parent']); $data[3] = "<a href=" . 'index.php?sec=inventory&sec2=operation/inventories/inventory_detail&id=' . $inventory['id_parent'] . ">" . $name_parent . '</a>'; } else { $name_parent = '--'; $data[3] = $name_parent; } if ($inventory['id_object_type'] != 0) { $name_object = get_db_value('name', 'tobject_type', 'id', $inventory['id_object_type']); $data[4] = "<a href=" . 'index.php?sec=inventory&sec2=operation/inventories/manage_objects&id=' . $inventory['id_object_type'] . ">" . $name_object . '</a>'; } else { $name_object = '--'; $data[4] = $name_object; } if ($inventory['id_manufacturer'] != 0) { $name_manufacturer = get_db_value('name', 'tmanufacturer', 'id', $inventory['id_manufacturer']); $data[5] = "<a href=" . 'index.php?sec=inventory&sec2=operation/manufacturers/manufacturer_detail&id=' . $inventory['id_manufacturer'] . ">" . $name_manufacturer . '</a>'; } else { $name_manufacturer = '--'; $data[5] = $name_manufacturer; } if ($inventory['id_contract'] != 0) { $name_contract = get_db_value('name', 'tcontract', 'id', $inventory['id_contract']); $data[6] = "<a href=" . 'index.php?sec=inventory&sec2=customers&sec2=operation/contracts/contract_detail&id_contract=' . $inventory['id_contract'] . ">" . $name_contract . '</a>'; } else { $name_contract = '--'; $data[6] = $name_contract; } if ($result_check) { $result_object_fields = inventories_get_all_type_field($result_check, $inventory['id'], true); $i = 6; foreach ($result_object_fields as $k => $ob_field) { if (isset($ob_field["label"])) { $data[$i] = $ob_field['data']; $i++; } } if (!$clean_output) { $data[$i] = '<a href="javascript: toggleInventoryInfo(' . $inventory['id'] . ')" id="show_info-' . $inventory["id"] . '">'; $data[$i] .= print_image("images/information.png", true, array("title" => __('Show object type fields'))); $data[$i] .= '</a> '; if ($write_permission) { $data[$i] .= '<a href="index.php?sec=inventory&sec2=operation/inventories/inventory&quick_delete=' . $inventory["id"] . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) return false;"><img src="images/cross.png"></a>'; } } if ($write_permission) { $data[$i] = print_checkbox_extended('inventorycb-' . $inventory['id'], $inventory['id'], false, '', '', 'class="cb_inventory"', true); } } else { if (!$clean_output) { $data[7] = '<a href="javascript: toggleInventoryInfo(' . $inventory['id'] . ')" id="show_info-' . $inventory["id"] . '">'; $data[7] .= print_image("images/information.png", true, array("title" => __('Show object type fields'))); $data[7] .= '</a> '; if ($write_permission) { $data[7] .= '<a href="index.php?sec=inventory&sec2=operation/inventories/inventory&quick_delete=' . $inventory["id"] . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) return false;"><img src="images/cross.png"></a>'; } } if ($write_permission) { $data[8] = print_checkbox_extended('inventorycb-' . $inventory['id'], $inventory['id'], false, '', '', 'class="cb_inventory"', true); } } $table->rowclass[$idx] = 'inventory_info_' . $inventory["id"]; $idx++; array_push($table->data, $data); if (!$clean_output) { $data_info = array(); $table_info->width = '98%'; $table_info->class = 'databox_color_without_line'; $table_info->size = array(); $table_info->style = array(); $table_info->data = array(); $res_obj_fields = inventories_get_all_type_field($inventory['id_object_type'], $inventory['id'], false); if (empty($res_obj_fields)) { $table_info->data[0][0] = '<b>' . __('No data to show') . '</b>'; } else { $j = 0; foreach ($res_obj_fields as $k => $ob_field) { if (isset($ob_field['label']) && $ob_field['label'] != "") { if ($ob_field['type'] == 'external') { $table_info->align[$j] = 'left;'; $table_info->data[$j][$j] = '<b>' . $ob_field['label']; $table_info->data[$j][$j] .= ' : ' . '</b>'; $table_info->data[$j][$j] .= $ob_field['data']; $j++; if (isset($ob_field['external_label']) && $ob_field['external_label'] != '') { $label_value = get_db_value_sql("SELECT " . $ob_field['external_label'] . " FROM " . $ob_field['external_table_name'] . " WHERE " . $ob_field['external_reference_field'] . " = " . $ob_field['data']); $table_info->align[$j] = 'left;'; $table_info->data[$j][$j] = '<b>' . $ob_field['external_label']; $table_info->data[$j][$j] .= ' : ' . '</b>'; $table_info->data[$j][$j] .= $label_value; $j++; } } else { $table_info->align[$j] = 'left;'; $table_info->data[$j][$j] = '<b>' . $ob_field['label']; $table_info->data[$j][$j] .= ' : ' . '</b>'; $table_info->data[$j][$j] .= $ob_field['data']; $j++; } } } } $data_info['row_info'] = print_table($table_info, true); $table_info->colspan[0][0] = 6; $table->rowclass[$idx] = 'inventory_more_info_' . $inventory["id"]; $table->rowstyle[$idx] = 'display: none;'; if ($write_permission) { $table->colspan[$idx]["row_info"] = 8; } else { $table->colspan[$idx]["row_info"] = 7; } array_push($table->data, $data_info); $idx++; } } print_table($table); if (!$clean_output) { pagination($count, $url_pag, $offset, true); } } }
$options = array(); foreach ($aux as $a) { $options[$a] = $a; } $table->data[$column][$row] = print_select ($options, 'custom_'.$comp["id"], $data, '', '', '0', true, false, false, $comp["label"]); break; case "linked": $linked_values = explode(",", $comp['linked_value']); if ($id) { $has_parent = get_db_value_sql("SELECT parent FROM tcompany_field WHERE id=".$comp['id']); if ($has_parent) { $parent_value = get_db_value_sql("SELECT `data` FROM tcompany_field_data WHERE id_company =".$id." AND id_company_field =".$has_parent); $values = array(); foreach ($linked_values as $value) { $parent_found = preg_match("/^".$parent_value."\|/", $value); if ($parent_found) { $value_without_parent = preg_replace("/^.*\|/","", $value); $values[$value_without_parent] = $value_without_parent; } } } else { foreach ($linked_values as $value) { $values[$value] = $value; } }
$blocked = login_check_blocked($nick); else $blocked = false; } if (!$blocked) { if ($is_enterprise){ login_check_failed($nick); //Checks failed attempts } $first = substr ($pass, 0, 1); $last = substr ($pass, strlen ($pass) - 1, 1); $pass = $first . "****" . $last; if ($expired_pass == false) { $enable_login = get_db_value_sql("SELECT enable_login FROM tusuario WHERE id_usuario='".$nick."'"); if ($enable_login == 0) { $disable_login = true; } else { $login_failed = true; unset($disable_login); } } else { unset($login_failed); } echo '<body class="login">'; require_once ('general/login_page.php'); exit ("</html>"); } else { echo '<body class="login">';
$sql = "DELETE FROM tagenda WHERE timestamp = '$old_alarm' AND description = '$old_description'"; $res = process_sql ($sql); } else if (!empty($date_alarm) && $date_alarm != '0000-00-00') { if ($time_alarm == '') { $time_alarm = date ('H:i'); $datetime_alarm = $date_alarm ." ". $time_alarm; } if (!empty($old_alarm) && !empty($old_name) && $old_alarm != '0000-00-00 00:00:00') { $old_description = "ALARM: LEAD ".$old_name; $description = "ALARM: LEAD ".$fullname; $id_agenda = get_db_value_sql("SELECT id FROM tagenda WHERE timestamp = '$old_alarm' AND description = '$old_description'"); $values = array( 'timestamp' => $datetime_alarm, 'id_user' => $config['id_user'], 'description' => $description ); process_sql_update('tagenda', $values, array('id' => $id_agenda)); } else if (empty($old_alarm) || $old_alarm == '0000-00-00 00:00:00') { $public = 0; $alarm = 60; $date = $date_alarm; if ($time_alarm != '') { $time = $time_alarm; } else {
function incidents_get_filter_tickets_tree($filters, $mode = false, $id_task = false) { global $config; // TODO: Refactor to use the function 'filter_incidents' /* Set default values if none is set */ $filters['inverse_filter'] = isset($filters['inverse_filter']) ? $filters['inverse_filter'] : false; $filters['string'] = isset($filters['string']) ? $filters['string'] : ''; $filters['status'] = isset($filters['status']) ? $filters['status'] : 0; $filters['priority'] = isset($filters['priority']) ? $filters['priority'] : -1; $filters['id_group'] = isset($filters['id_group']) ? $filters['id_group'] : -1; $filters['id_company'] = isset($filters['id_company']) ? $filters['id_company'] : 0; $filters['id_inventory'] = isset($filters['id_inventory']) ? $filters['id_inventory'] : 0; $filters['id_incident_type'] = isset($filters['id_incident_type']) ? $filters['id_incident_type'] : 0; $filters['id_user'] = isset($filters['id_user']) ? $filters['id_user'] : ''; $filters['id_user_or_creator'] = isset($filters['id_user_or_creator']) ? $filters['id_user_or_creator'] : ''; $filters['from_date'] = isset($filters['from_date']) ? $filters['from_date'] : 0; $filters['first_date'] = isset($filters['first_date']) ? $filters['first_date'] : ''; $filters['last_date'] = isset($filters['last_date']) ? $filters['last_date'] : ''; $filters['id_creator'] = isset($filters['id_creator']) ? $filters['id_creator'] : ''; $filters['editor'] = isset($filters['editor']) ? $filters['editor'] : ''; $filters['closed_by'] = isset($filters['closed_by']) ? $filters['closed_by'] : ''; $filters['resolution'] = isset($filters['resolution']) ? $filters['resolution'] : ''; $filters["offset"] = isset($filters['offset']) ? $filters['offset'] : 0; $filters["group_by_project"] = isset($filters['group_by_project']) ? $filters['group_by_project'] : 0; $filters["id_task"] = isset($filters['id_task']) ? $filters['id_task'] : -1; $filters["sla_state"] = isset($filters['sla_state']) ? $filters['sla_state'] : 0; $filters["left_sla"] = isset($filters['left_sla']) ? $filters['left_sla'] : 0; $filters["right_sla"] = isset($filters['right_sla']) ? $filters['right_sla'] : 0; $filters["show_hierarchy"] = isset($filters['show_hierarchy']) ? $filters['show_hierarchy'] : 0; $filters["medals"] = isset($filters['medals']) ? $filters['medals'] : 0; $filters["parent_name"] = isset($filters['parent_name']) ? $filters['parent_name'] : ''; ///// IMPORTANT: Write an inverse filter for every new filter ///// $is_inverse = $filters['inverse_filter']; $sql_clause = ''; // Status if (!empty($filters['status'])) { // Not closed if ($filters['status'] == -10) { if (!$is_inverse) { $sql_clause .= sprintf(' AND estado <> %d', STATUS_CLOSED); } else { $sql_clause .= sprintf(' AND estado = %d', STATUS_CLOSED); } } else { if (!$is_inverse) { $sql_clause .= sprintf(' AND estado = %d', $filters['status']); } else { $sql_clause .= sprintf(' AND estado <> %d', $filters['status']); } } } // Priority if ($filters['priority'] != -1) { if (!$is_inverse) { $sql_clause .= sprintf(' AND prioridad = %d', $filters['priority']); } else { $sql_clause .= sprintf(' AND prioridad <> %d', $filters['priority']); } } // Group if ($filters['id_group'] != 1) { if ($filters['show_hierarchy']) { $children = groups_get_childrens($filters['id_group']); $ids = $filters['id_group']; foreach ($children as $child) { $ids .= "," . $child['id_grupo']; } if (!$is_inverse) { $sql_clause .= sprintf(' AND id_grupo IN (%s)', $ids); } else { $sql_clause .= sprintf(' AND id_grupo NOT IN (%s)', $ids); } } else { if (!$is_inverse) { $sql_clause .= sprintf(' AND id_grupo = %d', $filters['id_group']); } else { $sql_clause .= sprintf(' AND id_grupo <> %d', $filters['id_group']); } } } // User if (!empty($filters['id_user'])) { if (!$is_inverse) { $sql_clause .= sprintf(' AND id_usuario = "%s"', $filters['id_user']); } else { $sql_clause .= sprintf(' AND id_usuario <> "%s"', $filters['id_user']); } } // User or creator if (!empty($filters['id_user_or_creator'])) { if (!$is_inverse) { $sql_clause .= sprintf(' AND (id_usuario = "%s" OR id_creator = "%s")', $filters['id_user_or_creator'], $filters['id_user_or_creator']); } else { $sql_clause .= sprintf(' AND (id_usuario <> "%s" AND id_creator <> "%s")', $filters['id_user_or_creator'], $filters['id_user_or_creator']); } } // Resolution if (!empty($filters['resolution']) && $filters['resolution'] > -1) { if (!$is_inverse) { $sql_clause .= sprintf(' AND resolution = %d', $filters['resolution']); } else { $sql_clause .= sprintf(' AND resolution <> %d', $filters['resolution']); } } // Task if ($id_task !== false) { // Don't apply the task inverse filter $sql_clause .= sprintf(' AND id_task = %d', $id_task); } else { if ($filters['id_task'] > 0) { if (!$is_inverse) { $sql_clause .= sprintf(' AND id_task = %d', $filters['id_task']); } else { $sql_clause .= sprintf(' AND id_task <> %d', $filters['id_task']); } } } // Incidents if (!empty($filters['id_incident_type']) && $filters['id_incident_type'] != -1) { if (!$is_inverse) { $sql_clause .= sprintf(' AND id_incident_type = %d', $filters['id_incident_type']); } else { $sql_clause .= sprintf(' AND id_incident_type <> %d', $filters['id_incident_type']); } // Incident fields $incident_fields = array(); foreach ($filters as $key => $value) { // If matchs an incident field, ad an element to the array with their real id and its data if (preg_match('/^type_field_/', $key)) { $incident_fields[preg_replace('/^type_field_/', '', $key)] = $value; } } foreach ($incident_fields as $id => $data) { if (!empty($data)) { if (!$is_inverse) { $sql_clause .= sprintf(' AND id_incidencia IN (SELECT id_incident FROM tincident_field_data WHERE id_incident_field = "%s" AND data LIKE "%%%s%%")', $id, $data); } else { $sql_clause .= sprintf(' AND id_incidencia NOT IN (SELECT id_incident FROM tincident_field_data WHERE id_incident_field = "%s" AND data LIKE "%%%s%%")', $id, $data); } } } } // Date if (!empty($filters['from_date']) && $filters['from_date'] > 0) { $last_date_seconds = $filters['from_date'] * 24 * 60 * 60; $filters['first_date'] = date('Y-m-d H:i:s', time() - $last_date_seconds); if (!$is_inverse) { $sql_clause .= sprintf(' AND inicio >= "%s"', $filters['first_date']); } else { $sql_clause .= sprintf(' AND inicio < "%s"', $filters['first_date']); } } else { if (!empty($filters['first_date']) && !empty($filters['last_date'])) { // 00:00:00 to set date at the beginig of the day $start_time = strtotime($filters['first_date']); $start_date = date('Y-m-d 00:00:00', $start_time); // 23:59:59 to set date at the end of day $end_time = strtotime($filters['last_date']); $end_date = date('Y-m-d 23:59:59', $end_time); if (!$is_inverse) { $sql_clause .= sprintf(' AND inicio >= "%s"', $start_date); $sql_clause .= sprintf(' AND inicio <= "%s"', $end_date); } else { $sql_clause .= sprintf(' AND (inicio < "%s" OR inicio > "%s")', $start_date, $end_date); } } else { if (!empty($filters['first_date'])) { // 00:00:00 to set date at the beginig of the day $start_time = strtotime($filters['first_date']); $start_date = date('Y-m-d 00:00:00', $start_time); if (!$is_inverse) { $sql_clause .= sprintf(' AND inicio >= "%s"', $start_date); } else { $sql_clause .= sprintf(' AND inicio < "%s"', $start_date); } } else { if (!empty($filters['last_date'])) { // 23:59:59 to set date at the end of day $end_time = strtotime($filters['last_date']); $end_date = date('Y-m-d 23:59:59', $end_time); if (!$is_inverse) { $sql_clause .= sprintf(' AND inicio <= "%s"', $end_date); } else { $sql_clause .= sprintf(' AND inicio > "%s"', $end_date); } } } } } // Creator if (!empty($filters['id_creator'])) { if (!$is_inverse) { $sql_clause .= sprintf(' AND id_creator = "%s"', $filters['id_creator']); } else { $sql_clause .= sprintf(' AND id_creator <> "%s"', $filters['id_creator']); } } // Editor if (!empty($filters['editor'])) { if (!$is_inverse) { $sql_clause .= sprintf(' AND editor = "%s"', $filters['editor']); } else { $sql_clause .= sprintf(' AND editor <> "%s"', $filters['editor']); } } // Closed by if (!empty($filters['closed_by'])) { if (!$is_inverse) { $sql_clause .= sprintf(' AND closed_by = "%s"', $filters['closed_by']); } else { $sql_clause .= sprintf(' AND closed_by <> "%s"', $filters['closed_by']); } } // SLA $sla_filter = ''; if (!empty($filters['sla_state'])) { $sla_fired_filter = 'AND (sla_disabled = 0 AND affected_sla_id <> 0)'; $sla_not_fired_filter = 'AND (sla_disabled = 0 AND affected_sla_id = 0)'; if ($filters['sla_state'] == 1) { $sla_filter = !$is_inverse ? $sla_fired_filter : $sla_not_fired_filter; } else { if ($filters['sla_state'] == 2) { $sla_filter = !$is_inverse ? $sla_not_fired_filter : $sla_fired_filter; } } } // Medals $medals_filter = ''; if ($filters['medals']) { if ($filters['medals'] == 1) { if (!$is_inverse) { $medals_filter = 'AND gold_medals <> 0'; } else { $medals_filter = 'AND gold_medals = 0'; } } else { if ($filters['medals'] == 2) { if (!$is_inverse) { $medals_filter = 'AND black_medals <> 0'; } else { $medals_filter = 'AND black_medals = 0'; } } } } if (!empty($filters['parent_name'])) { $inventory_id = get_db_value('id', 'tinventory', 'name', $filters['parent_name']); if ($inventory_id) { if (!$is_inverse) { $sql_clause .= sprintf(' AND id_incidencia IN (SELECT id_incident FROM tincident_inventory WHERE id_inventory = %d)', $inventory_id); } else { $sql_clause .= sprintf(' AND id_incidencia NOT IN (SELECT id_incident FROM tincident_inventory WHERE id_inventory = %d)', $inventory_id); } } } if ($no_parents) { $sql_clause .= ' AND id_incidencia NOT IN (SELECT id_incidencia FROM tincidencia WHERE id_parent <> 0)'; } // Order if ($filters['order_by'] && !is_array($filters['order_by'])) { $order_by_array = json_decode(clean_output($filters['order_by']), true); } else { $order_by_array = $filters['order_by']; } $order_by = ''; if ($order_by_array) { foreach ($order_by_array as $key => $value) { if ($value) { $order_by .= " {$key} {$value}, "; } } } // Use config block size if no other was given if ($limit && !isset($filters['limit'])) { $filters['limit'] = $config['block_size']; } // Text filter $text_filter = ''; if (!empty($filters['string'])) { if (!$is_inverse) { $text_filter = sprintf('AND ( titulo LIKE "%%%s%%" OR descripcion LIKE "%%%s%%" OR id_creator LIKE "%%%s%%" OR id_usuario LIKE "%%%s%%" OR id_incidencia = %d OR id_incidencia IN ( SELECT id_incident FROM tincident_field_data WHERE data LIKE "%%%s%%"))', $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string']); } else { $text_filter = sprintf('AND ( titulo NOT LIKE "%%%s%%" AND descripcion NOT LIKE "%%%s%%" AND id_creator NOT LIKE "%%%s%%" AND id_usuario NOT LIKE "%%%s%%" AND id_incidencia <> %d AND id_incidencia NOT IN ( SELECT id_incident FROM tincident_field_data WHERE data LIKE "%%%s%%"))', $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string']); } } switch ($mode) { case 'count': //Just count items $sql = sprintf('SELECT COUNT(id_incidencia) FROM tincidencia FD WHERE 1=1 %s %s %s %s', $sql_clause, $text_filter, $sla_filter, $medals_filter); return (int) get_db_value_sql($sql); break; case 'tasks': $sql = sprintf('SELECT id_task FROM tincidencia FD WHERE 1=1 %s %s %s %s GROUP BY id_task', $sql_clause, $text_filter, $sla_filter, $medals_filter); return get_db_all_rows_sql($sql); break; case 'tickets': default: //Select all items and return all information $sql = sprintf('SELECT * FROM tincidencia FD WHERE 1=1 %s %s %s %s ORDER BY %s actualizacion DESC', $sql_clause, $text_filter, $sla_filter, $medals_filter, $order_by); $incidents = get_db_all_rows_sql($sql); if ($incidents === false) { return false; } $result = array(); foreach ($incidents as $incident) { //Check external users ACLs $standalone_check = enterprise_hook('manage_standalone', array($incident, 'read')); if ($standalone_check !== ENTERPRISE_NOT_HOOK && !$standalone_check) { continue; } else { // Normal ACL pass if IR for this group or if the user is the incident creator // or if the user is the owner or if the user has workunits $check_acl = enterprise_hook('incidents_check_incident_acl', array($incident)); if (!$check_acl) { continue; } } $inventories = get_inventories_in_incident($incident['id_incidencia'], false); // Inventory if ($filters['id_inventory']) { $found = false; foreach ($inventories as $inventory) { if ($inventory['id'] == $filters['id_inventory']) { $found = true; break; } } if (!$is_inverse && !$found) { continue; } else { if ($is_inverse && $found) { continue; } } } // Company if ($filters['id_company']) { $found = false; $user_creator = $incident['id_creator']; $user_company = get_db_value('id_company', 'tusuario', 'id_usuario', $user_creator); // Don't match, dismiss incident if (!$is_inverse && $filters['id_company'] != $user_company) { continue; } // Match, dismiss incident if ($is_inverse && $filters['id_company'] == $user_company) { continue; } } // SLA if ($filters['left_sla']) { $percent_sla_incident = format_numeric(get_sla_compliance_single_id($incident['id_incidencia'])); // Don't match, dismiss incident if (!$is_inverse && $filters['left_sla'] > $percent_sla_incident) { continue; } // Match, dismiss incident if ($is_inverse && $filters['left_sla'] <= $percent_sla_incident) { continue; } } if ($filters['right_sla']) { $percent_sla_incident = format_numeric(get_sla_compliance_single_id($incident['id_incidencia'])); // Don't match, dismiss incident if (!$is_inverse && $filters['right_sla'] < $percent_sla_incident) { continue; } // Match, dismiss incident if ($is_inverse && $filters['right_sla'] >= $percent_sla_incident) { continue; } } array_push($result, $incident); } return $result; break; } }
function api_attach_file($return_type, $user, $params) { global $config; $id_incident = $params[0]; if (!check_user_incident($user, $id_incident)) { return; } // Insert into database $filename = str_replace(" ", "_", $params[1]); $filesize = $params[2]; $file_description = $params[3]; $file_content = base64_decode(str_replace(" ", "+", $params[4])); //Check if file exists $exists = get_db_value_sql("SELECT id_attachment FROM tattachment WHERE id_incidencia=" . $id_incident . " AND filename='" . $filename . "'"); if ($exists) { $result = '0'; echo $result; return; } $sql = sprintf('INSERT INTO tattachment (id_incidencia, id_usuario, filename, description, size, timestamp) VALUES (%d, "%s", "%s", "%s", %d, "%s")', $id_incident, $user, $filename, $file_description, $filesize, date("Y-m-d H:i:s")); $id_attachment = process_sql($sql, 'insert_id'); $config['id_user'] = $user; incident_tracking($id_incident, INCIDENT_FILE_ADDED); /* // Email notify to all people involved in this incident if ($email_notify == 1) { if ($config["email_on_incident_update"] == 1){ mail_incident ($id_incident, $user, 0, 0, 2); } }*/ include_once "config.php"; $homedir = get_db_value('value', 'tconfig', 'token', $condition = 1); // Copy file to directory and change name $short_filename = $filename; $filename = $config["homedir"] . "/attachment/" . $id_attachment . "_" . $filename; $file_handler = fopen($filename, "w"); fputs($file_handler, $file_content); $close = fclose($file_handler); if (!$file_handler) { $result = '-1'; $sql = sprintf('DELETE FROM tattachment WHERE id_attachment = %d', $id_attachment); process_sql($sql); } else { // Adding a WU noticing about this $link = "<a target='_blank' href='operation/common/download_file.php?type=incident&id_attachment=" . $id_attachment . "'>" . $short_filename . "</a>"; $nota = "Automatic WU: Added a file to this issue. Filename uploaded: " . $link; $public = 1; $timestamp = print_mysql_timestamp(); $timeused = "0.05"; $sql = sprintf('INSERT INTO tworkunit (timestamp, duration, id_user, description, public) VALUES ("%s", %.2f, "%s", "%s", %d)', $timestamp, $timeused, $user, $nota, $public); $id_workunit = process_sql($sql, "insert_id"); $sql = sprintf('INSERT INTO tworkunit_incident (id_incident, id_workunit) VALUES (%d, %d)', $id_incident, $id_workunit); process_sql($sql); $result = '0'; } switch ($return_type) { case "xml": echo xml_node($result); break; case "csv": echo $result; break; } }
"Workunit for ".$config['id_user']); if (defined ('AJAX')) { echo '<img src="images/rosette.png" title="'.__('Locked by').' '.$config['id_user'].'" />'; print_user_avatar ($config['id_user'], true); return; } } if ($id_workunit) { $sql = sprintf ('SELECT * FROM tworkunit WHERE tworkunit.id = %d', $id_workunit); $workunit = get_db_row_sql ($sql); $belong_to_ticket = get_db_value_sql("SELECT * FROM tworkunit_incident WHERE id_workunit = ".$id_workunit); if (($workunit === false) OR $belong_to_ticket) { require ("general/noaccess.php"); return; } // $id_task = $workunit['id_task']; // $id_project = get_db_value ('id_project', 'ttask', 'id', $id_task); $id_user = $workunit['id_user']; $wu_user = $id_user; $duration = $workunit['duration']; $description = $workunit['description']; $have_cost = $workunit['have_cost']; $id_profile = $workunit['id_profile'];
function incidents_get_filter_tickets_tree($filters, $mode = false, $limit = false) { global $config; /* Set default values if none is set */ $filters['string'] = isset($filters['string']) ? $filters['string'] : ''; $filters['status'] = isset($filters['status']) ? $filters['status'] : -10; $filters['priority'] = isset($filters['priority']) ? $filters['priority'] : -1; $filters['id_group'] = isset($filters['id_group']) ? $filters['id_group'] : -1; $filters['id_company'] = isset($filters['id_company']) ? $filters['id_company'] : 0; $filters['id_inventory'] = isset($filters['id_inventory']) ? $filters['id_inventory'] : 0; $filters['id_incident_type'] = isset($filters['id_incident_type']) ? $filters['id_incident_type'] : 0; $filters['id_user'] = isset($filters['id_user']) ? $filters['id_user'] : ''; $filters['id_user_or_creator'] = isset($filters['id_user_or_creator']) ? $filters['id_user_or_creator'] : ''; $filters['from_date'] = isset($filters['from_date']) ? $filters['from_date'] : 0; $filters['first_date'] = isset($filters['first_date']) ? $filters['first_date'] : ''; $filters['last_date'] = isset($filters['last_date']) ? $filters['last_date'] : ''; $filters['id_creator'] = isset($filters['id_creator']) ? $filters['id_creator'] : ''; $filters['editor'] = isset($filters['editor']) ? $filters['editor'] : ''; $filters['closed_by'] = isset($filters['closed_by']) ? $filters['closed_by'] : ''; $filters['resolution'] = isset($filters['resolution']) ? $filters['resolution'] : ''; $filters["offset"] = isset($filters['offset']) ? $filters['offset'] : 0; $filters["group_by_project"] = isset($filters['group_by_project']) ? $filters['group_by_project'] : 0; $filters["id_task"] = isset($filters['id_task']) ? $filters['id_task'] : -1; $filters["sla_state"] = isset($filters['sla_state']) ? $filters['sla_state'] : 0; $filters["left_sla"] = isset($filters['left_sla']) ? $filters['left_sla'] : 0; $filters["right_sla"] = isset($filters['right_sla']) ? $filters['right_sla'] : 0; $filters["show_hierarchy"] = isset($filters['show_hierarchy']) ? $filters['show_hierarchy'] : 0; if (empty($filters['status'])) { $filters['status'] = implode(',', array_keys(get_indicent_status())); } // Not closed if ($filters["status"] == -10) { $filters['status'] = "1,2,3,4,5,6"; } $resolutions = get_incident_resolutions(); $sql_clause = ''; if ($filters['priority'] != -1) { $sql_clause .= sprintf(' AND prioridad = %d', $filters['priority']); } if ($filters['id_group'] != 1) { if ($filters["show_hierarchy"]) { $children = groups_get_childrens($filters['id_group']); $ids = $filters['id_group']; foreach ($children as $child) { $ids .= "," . $child['id_grupo']; } $sql_clause .= " AND id_grupo IN (" . $ids . ")"; } else { $sql_clause .= sprintf(' AND id_grupo = %d', $filters['id_group']); } } if (!empty($filters['id_user'])) { $sql_clause .= sprintf(' AND id_usuario = "%s"', $filters['id_user']); } if (!empty($filters['id_user_or_creator'])) { $sql_clause .= sprintf(' AND (id_usuario = "%s" OR id_creator = "%s")', $filters['id_user_or_creator'], $filters['id_user_or_creator']); } if (!empty($filters['resolution']) && $filters['resolution'] > -1) { $sql_clause .= sprintf(' AND resolution = %d', $filters['resolution']); } if ($filters['id_task'] == 0) { $sql_clause .= sprintf(' AND id_task = 0'); } else { if ($filters['id_task'] != -1) { $sql_clause .= sprintf(' AND id_task = %d', $filters['id_task']); } } //Incident type 0 means all and incident type -1 means without type if ($filters["id_incident_type"] != -1) { if ($filters["id_incident_type"]) { $sql_clause .= sprintf(' AND id_incident_type = %d', $filters['id_incident_type']); } $incident_fields = array(); foreach ($filters as $key => $value) { // If matchs an incident field, ad an element to the array with their real id and its data if (preg_match("/^type_field_/", $key)) { $incident_fields[preg_replace("/^type_field_/", "", $key)] = $value; } } foreach ($incident_fields as $id => $data) { if ($data !== "") { $sql_clause .= sprintf(' AND id_incidencia = ANY (SELECT id_incident FROM tincident_field_data WHERE id_incident_field = "%s" AND data LIKE "%%%s%%")', $id, $data); } } } if (!empty($filters['from_date']) && $filters['from_date'] > 0) { $last_date_seconds = $filters['from_date'] * 24 * 60 * 60; $filters['first_date'] = date('Y-m-d H:i:s', time() - $last_date_seconds); $sql_clause .= sprintf(' AND inicio >= "%s"', $filters['first_date']); $filters['last_date'] = ""; } else { if (!empty($filters['first_date'])) { $time = strtotime($filters['first_date']); //00:00:00 to set date at the beginig of the day $sql_clause .= sprintf(' AND inicio >= "%s"', date("Y-m-d 00:00:00", $time)); } if (!empty($filters['last_date'])) { $time = strtotime($filters['last_date']); if (!empty($filters['first_date'])) { //23:59:59 to set date at the end of day $sql_clause .= sprintf(' AND inicio <= "%s"', date("Y-m-d 23:59:59", $time)); } else { $time_from = strtotime($filters['first_date']); if ($time_from < $time) { $sql_clause .= sprintf(' AND inicio <= "%s"', date("Y-m-d", $time)); } } } } if (!empty($filters['id_creator'])) { $sql_clause .= sprintf(' AND id_creator = "%s"', $filters['id_creator']); } if (!empty($filters['editor'])) { $sql_clause .= sprintf(' AND editor = "%s"', $filters['editor']); } if (!empty($filters['closed_by'])) { $sql_clause .= sprintf(' AND closed_by = "%s"', $filters['closed_by']); } if (!empty($filters['sla_state'])) { switch ($filters['sla_state']) { case 0: $sla_filter = ' '; break; case 1: $sla_filter = "AND (sla_disabled = 0 AND affected_sla_id <> 0)"; break; case 2: $sla_filter = "AND (sla_disabled = 0 AND affected_sla_id = 0)"; break; } } if ($filters['order_by'] && !is_array($filters['order_by'])) { $order_by_array = json_decode(clean_output($filters["order_by"]), true); } else { $order_by_array = $filters['order_by']; } //Use config block size if no other was given if ($limit) { if (!isset($filters["limit"])) { $filters["limit"] = $config["block_size"]; } } $order_by = ""; if ($order_by_array) { foreach ($order_by_array as $key => $value) { if ($value) { $order_by .= " {$key} {$value}, "; } } } switch ($mode) { case 'count': //Just count items $sql = sprintf('SELECT COUNT(id_incidencia) FROM tincidencia FD WHERE estado IN (%s) %s AND (titulo LIKE "%%%s%%" OR descripcion LIKE "%%%s%%" OR id_creator LIKE "%%%s%%" OR id_usuario LIKE "%%%s%%" OR id_incidencia IN (SELECT id_incident FROM tincident_field_data WHERE data LIKE "%%%s%%")) %s', $filters['status'], $sql_clause, $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string'], $sla_filter); $count = get_db_value_sql($sql); if ($count === false) { return 0; } return $count; break; case 'tasks': $sql = sprintf('SELECT id_task FROM tincidencia FD WHERE estado IN (%s) %s AND (titulo LIKE "%%%s%%" OR descripcion LIKE "%%%s%%" OR id_creator LIKE "%%%s%%" OR id_usuario LIKE "%%%s%%" OR id_incidencia IN (SELECT id_incident FROM tincident_field_data WHERE data LIKE "%%%s%%")) %s GROUP BY id_task', $filters['status'], $sql_clause, $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string'], $sla_filter); $tasks = get_db_all_rows_sql($sql); if ($tasks === false) { return false; } return $tasks; break; case 'tickets': default: //Select all items and return all information $sql = sprintf('SELECT * FROM tincidencia FD WHERE estado IN (%s) %s AND (titulo LIKE "%%%s%%" OR descripcion LIKE "%%%s%%" OR id_creator LIKE "%%%s%%" OR id_usuario LIKE "%%%s%%" OR id_incidencia IN (SELECT id_incident FROM tincident_field_data WHERE data LIKE "%%%s%%")) %s ORDER BY %s actualizacion DESC', $filters['status'], $sql_clause, $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string'], $sla_filter, $order_by); $incidents = get_db_all_rows_sql($sql); if ($incidents === false) { return false; } $result = array(); foreach ($incidents as $incident) { //Check external users ACLs $external_check = enterprise_hook("manage_external", array($incident)); if ($external_check !== ENTERPRISE_NOT_HOOK && !$external_check) { continue; } else { //Normal ACL pass if IR for this group or if the user is the incident creator //or if the user is the owner or if the user has workunits $check_acl = enterprise_hook("incidents_check_incident_acl", array($incident)); if (!$check_acl) { continue; } } $inventories = get_inventories_in_incident($incident['id_incidencia'], false); if ($filters['id_inventory']) { $found = false; foreach ($inventories as $inventory) { if ($inventory['id'] == $filters['id_inventory']) { $found = true; break; } } if (!$found) { continue; } } if ($filters['id_company']) { $found = false; $user_creator = $incident['id_creator']; $user_company = get_db_value('id_company', 'tusuario', 'id_usuario', $user_creator); //If company do no match, dismiss incident if ($filters['id_company'] != $user_company) { continue; } } if ($filters['left_sla']) { $percent_sla_incident = format_numeric(get_sla_compliance_single_id($incident['id_incidencia'])); //If sla do not match, dismiss incident if ($filters['left_sla'] > $percent_sla_incident) { continue; } } if ($filters['right_sla']) { $percent_sla_incident = format_numeric(get_sla_compliance_single_id($incident['id_incidencia'])); //If sla do not match, dismiss incident if ($filters['right_sla'] < $percent_sla_incident) { continue; } } array_push($result, $incident); } return $result; break; } }
$email_copy = get_parameter("email_copy", ""); $creation_date = get_parameter("creation_date", ""); $creation_time = get_parameter("creation_time", ""); $upfiles = (string) get_parameter('upfiles'); $old_status = $estado; $old_resolution = $resolution; //Get notify flag from group if the user doesn't has IM flag if (give_acl($config['id_user'], $id_grupo, "IW")) { $email_notify = get_db_value("forced_email", "tgrupo", "id_grupo", $grupo); } // If user is not provided, is the currently logged user or user group by default //~ $usuario = get_parameter ("id_user", $config['id_user']); $usuario = get_parameter('id_user', ''); if ($usuario == '') { $sql = 'SELECT id_user_default FROM tgrupo WHERE id_grupo = ' . $grupo; $default_user = get_db_value_sql($sql); if ($default_user == '' || !$default_user) { $usuario = $config['id_user']; } else { $usuario = $default_user; } } $closed_by = get_parameter("closed_by", ''); $blocked = get_parameter("blocked", 0); // Redactor user is ALWAYS the currently logged user entering the incident. Cannot change. Never. $editor = $config["id_user"]; $id_group_creator = get_parameter("id_group_creator", $grupo); $creator_exists = get_user($id_creator); $user_exists = get_user($usuario); if ($creator_exists === false) { $result_msg = '<h3 class="error">' . __('Creator user does not exist') . '</h3>';
$show_fields = false; //show fields of incident type $add_field = (int) get_parameter('add_field', 0); $delete_field = (int) get_parameter('delete_field', 0); $update_field = (int) get_parameter('update_field', 0); if ($add_field) { //add field to incident type $global = get_parameter("global"); $value['id_incident_type'] = (int) get_parameter('id', 0); $value['label'] = get_parameter('label', ''); $value['type'] = get_parameter('type'); $value['combo_value'] = get_parameter('combo_value', ''); $value['show_in_list'] = (int) get_parameter('show_in_list'); $value['linked_value'] = get_parameter('linked_value', ''); $value['parent'] = get_parameter('parent', ''); $last_order = get_db_value_sql("SELECT MAX(`order`) FROM tincident_type_field WHERE id_incident_type = " . $value['id_incident_type']); $value['order'] = $last_order + 1; $error_combo = false; $error_linked = false; if ($value['type'] == 'combo') { if ($value['combo_value'] == '') { $error_combo = true; } } if ($value['type'] == 'linked') { if ($value['linked_value'] == '') { $error_linked = true; } } if ($value['label'] == '') { echo '<h3 class="error">' . __('Empty field name') . '</h3>';
$table->width = '99%'; if ($objects !== false) { $table->class = 'listing'; $table->data = array(); $table->head = array(); $table->head[0] = __('ID'); $table->head[1] = __('Name'); $table->head[2] = __('Description'); $table->head[3] = __('Items'); $table->head[4] = __('Actions'); $table->style = array(); $table->style[1] = 'font-weight: bold'; $table->align = array(); echo '<table width="90%" class="listing">'; foreach ($objects as $object) { $has_external_fields = get_db_value_sql("SELECT COUNT(id) FROM tobject_type_field WHERE type='external' AND id_object_type=" . $object['id']); $data = array(); $data[0] = ' <a href="index.php?sec=inventory&sec2=operation/inventories/manage_objects&id=' . $object['id'] . '">' . $object['id'] . '</a>'; $data[1] = objects_get_icon($object['id'], true); $data[1] .= ' <a href="index.php?sec=inventory&sec2=operation/inventories/manage_objects&id=' . $object['id'] . '">' . $object['name'] . '</a>'; $data[2] = substr($object["description"], 0, 200); $data[3] = objects_count_fields($object['id']); if ($has_external_fields) { $data[4] = '<a title=' . __("Edit external tables") . ' href=index.php?sec=inventory&sec2=operation/inventories/manage_external_tables&id=' . $object["id"] . '><img src="images/resolution.png"></a>'; } else { $data[4] = '<img src="images/resolution_disabled.png">'; } $data[4] .= '<a title=' . __("Fields") . ' href=index.php?sec=inventory&sec2=operation/inventories/manage_objects_types_list&id=' . $object["id"] . '><img src="images/page_white_text.png"></a>'; $data[4] .= '<form style="display:inline;" method="post" onsubmit="if (!confirm(\'' . __('Are you sure?') . '\')) return false;">'; $data[4] .= print_input_hidden('delete_object', 1, true);
SELECT twi.id_workunit, ti.id_incidencia, ti.titulo, tis.name AS estado FROM tworkunit_incident twi INNER JOIN tincidencia ti ON twi.id_incident = ti.id_incidencia AND ti.id_task = %d INNER JOIN tincident_status tis ON ti.estado = tis.id ) twin ON tw2.id = twin.id_workunit ) final ORDER BY final.id_user, final.timestamp limit %d offset %d', $id_task, $id_task, $block_size, $offset); $all_wu = get_db_all_rows_sql($sql); $count = get_db_value_sql($sql_count); if (!empty($all_wu)) { $table_wu = new StdClass(); $table_wu->class = 'listing'; $table_wu->head = array(); $table_wu->head['person'] = __('Person'); $table_wu->head['date'] = __('Date'); $table_wu->head['duration'] = __('Duration (' . __('In hours') . ')'); $table_wu->head['ticket_id'] = __('Ticket id'); $table_wu->head['ticket_title'] = __('Ticket title'); $table_wu->head['ticket_status'] = __('Ticket status'); if (!$pdf_output) { $table_wu->head['content'] = __('Content'); } $table_wu->data = array(); foreach ($all_wu as $wu) {