Beispiel #1
0
function api_get_resolution_incident($id_incident)
{
    global $config;
    $resolution = get_db_value_filter('resolution', 'tincidencia', array('id_incidencia' => $id_incident));
    return $resolution;
}
Beispiel #2
0
function get_valid_users_num()
{
    clean_cache_db();
    $filter = array('enable_login' => 1, 'disabled' => 0, 'login_blocked' => 0);
    return get_db_value_filter("COUNT(id_usuario)", "tusuario", $filter);
}
/** 
 * Check if a tag is assigned to a lead.
 * 
 * @param int Id of the lead.
 * @param int Id of the tag.
 * 
 * @return bool Wether the tag is assigned or not.
 */
function exists_lead_tag($lead_id, $tag_id)
{
    if (empty($lead_id)) {
        throw new InvalidArgumentException(__('The lead id cannot be empty'));
    }
    if (empty($tag_id)) {
        throw new InvalidArgumentException(__('The tag id cannot be empty'));
    }
    $filter = array(LEADS_TABLE_LEAD_ID_COL => $lead_id, LEADS_TABLE_TAG_ID_COL => $tag_id);
    return (bool) get_db_value_filter(LEADS_TABLE_ID_COL, LEADS_TABLE, $filter);
}
Beispiel #4
0
        $read_permission = check_crm_acl('contract', 'cr');
        if (!$read_permission) {
            audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access Downloads browser");
            require $general_error;
            exit;
        }
        $data = get_db_row("tattachment", "id_attachment", $id_attachment);
        $data["filename"] = safe_output($data["filename"]);
        $fileLocation = $config["homedir"] . "/attachment/" . $data["id_attachment"] . "_" . $data["filename"];
        $last_name = $data["filename"];
        break;
    case "file_sharing":
        $public_key = get_parameter("key");
        if (!empty($public_key)) {
            $filter = array('public_key' => $public_key, 'file_sharing' => 1);
            $id_attachment = get_db_value_filter("id_attachment", "tattachment", $filter);
            if (empty($id_attachment)) {
                audit_db($id_user, $config["REMOTE_ADDR"], "ACL Violation", "Trying to download an invalid file sharing file");
                require $general_error;
                exit;
            }
        } else {
            audit_db($id_user, $config["REMOTE_ADDR"], "ACL Violation", "Trying to download an invalid file sharing file");
            require $general_error;
            exit;
        }
        break;
    default:
}
//Compound file path
if ($type == "release" || $type == "external_release") {
Beispiel #5
0
/**
 * This function creates an inventory object for each agent of pandora with name, address, description 
 * and extra fields if are defined as operating system and url address
 */
function synchronize_pandora_inventory()
{
    global $config;
    if (!isset($config["pandora_url"])) {
        return;
    }
    if ($config["pandora_url"] == "") {
        return;
    }
    $separator = ':;:';
    $url = $config['pandora_url'] . '/include/api.php?op=get&apipass='******'pandora_api_password'] . '&op2=all_agents&return_type=csv&user='******'pandora_user'] . '&pass='******'pandora_pass'];
    $return = call_api($url);
    $agents_csv = explode("\n", $return);
    foreach ($agents_csv as $agent_csv) {
        // Avoiding empty csv lines like latest one
        if ($agent_csv == '') {
            continue;
        }
        $values = array();
        $agent = explode(";", $agent_csv);
        $agent_id = $agent[0];
        $agent_name = $agent[1];
        $agent_name_safe = safe_input($agent_name);
        $address = $agent[2];
        $description = $agent[3];
        $os_name = $agent[4];
        $url_address = $agent[5];
        // Check if exist to avoid the creation
        $inventory_id = get_db_value('id', 'tinventory', 'name', $agent_name_safe);
        if ($inventory_id !== false) {
            process_sql_delete('tinventory', array('id' => $inventory_id));
            process_sql_delete('tobject_field_data', array('id_inventory' => $inventory_id));
        }
        $id_object_type = get_db_value('id', 'tobject_type', 'name', safe_input('Pandora agents'));
        $values['name'] = $agent_name_safe;
        $values['description'] = $description;
        $values['id_object_type'] = $id_object_type;
        $values['id_contract'] = $config['default_contract'];
        $id_inventory = process_sql_insert('tinventory', $values);
        if ($id_inventory) {
            $id_type_field_os = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => safe_input('OS')));
            $id_type_field_ip = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => safe_input('IP Address')));
            if ($id_type_field_ip == false) {
                $id_type_field_ip = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => 'IP Address'));
            }
            $id_type_field_url = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => safe_input('URL Address')));
            if ($id_type_field_url == false) {
                $id_type_field_url = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => 'URL Address'));
            }
            $id_type_field_id = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => safe_input('ID Agent')));
            if ($id_type_field_id == false) {
                $id_type_field_id = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => 'ID Agent'));
            }
            $value_os = array();
            $value_os['id_inventory'] = $id_inventory;
            $value_os['id_object_type_field'] = $id_type_field_os;
            $value_os['data'] = $os_name;
            process_sql_insert('tobject_field_data', $value_os);
            $value_ip = array();
            $value_ip['id_inventory'] = $id_inventory;
            $value_ip['id_object_type_field'] = $id_type_field_ip;
            $value_ip['data'] = $address;
            process_sql_insert('tobject_field_data', $value_ip);
            $value_url = array();
            $value_url['id_inventory'] = $id_inventory;
            $value_url['id_object_type_field'] = $id_type_field_url;
            $value_url['data'] = $url_address;
            process_sql_insert('tobject_field_data', $value_url);
            $value_id = array();
            $value_id['id_inventory'] = $id_inventory;
            $value_id['id_object_type_field'] = $id_type_field_id;
            $value_id['data'] = $agent_id;
            process_sql_insert('tobject_field_data', $value_id);
        }
    }
}
     // Do not send mail in this WU
     create_workunit($id, $wu_text, $editor, $config["iwu_defaultime"], 0, "", 1, 0);
 }
 // Email notify to all people involved in this incident
 if ($email_notify) {
     mail_incident($id, $usuario, "", 0, 1);
 }
 //insert data to incident type fields
 if ($id_incident_type != 0) {
     $sql_label = "SELECT `label` FROM `tincident_type_field` WHERE id_incident_type = {$id_incident_type}";
     $labels = get_db_all_rows_sql($sql_label);
     if ($labels === false) {
         $labels = array();
     }
     foreach ($labels as $label) {
         $id_incident_field = get_db_value_filter('id', 'tincident_type_field', array('id_incident_type' => $id_incident_type, 'label' => $label['label']), 'AND');
         $values_insert['id_incident'] = $id;
         $values_insert['data'] = get_parameter(base64_encode($label['label']));
         //~ $values_insert['data'] = str_replace('
', "",get_parameter (base64_encode($label['label'])));
         $values_insert['id_incident_field'] = $id_incident_field;
         $id_incident_field = get_db_value('id', 'tincident_type_field', 'id_incident_type', $id_incident_type);
         process_sql_insert('tincident_field_data', $values_insert);
     }
 }
 // ATTACH A FILE IF IS PROVIDED
 $upfiles = json_decode(safe_output($upfiles), true);
 if (!empty($upfiles)) {
     include_once 'include/functions_workunits.php';
     foreach ($upfiles as $file) {
         if (is_array($file)) {
             if ($file['description']) {
		}		
		
		if ($count % 4 == 0) {
			$search_by_owner .= "<tr>";
		}

		$incidents = get_incidents("id_usuario = '".$owners["id_usuario"]."' AND estado <> 7", true);
		
		$search_by_owner .= "<td>";
		$search_by_owner .= "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_search&search_first_date=" . $first_start . "&search_id_user="******"id_usuario"]."'>";
		if($owners["avatar"]){
			$search_by_owner .= '<div class="bubble_little">' . print_image('images/avatars/' . $owners["avatar"] . '.png', true) . '</div>';
		} else {
			$search_by_owner .= '<div class="bubble_little"></div>';
		}
		$long_name = get_db_value_filter ("nombre_real", "tusuario", array("id_usuario" => $owners["id_usuario"]));
	
		$search_by_owner .= $long_name." (".count($incidents).")";
		$search_by_owner .= "</a>";
		$search_by_owner .= "</td>";
		
		if ($count % 4 == 3) {
			$search_by_owner .= "</tr>";
		}

		//Increase counter
		$count++;
	}
}

$search_by_owner .= "</table>";
Beispiel #8
0
$user_pass = get_parameter('user_pass', '');
$return_type = get_parameter('return_type', 'csv');
$info = get_parameter('info', false);
if ($info == "version") {
    if ($config["enteprise"] == 1) {
        $enterprise = "Enterprise Edition";
    } else {
        $enterprise = "OpenSource Edition";
    }
    if (!$config["minor_release"]) {
        $config["minor_release"] = 0;
    }
    echo "Integria IMS {$enterprise} " . $config["version"] . " Build " . $config["build_version"] . " MR" . $config["minor_release"];
    exit;
}
$api_password = get_db_value_filter('value', 'tconfig', array('token' => 'api_password'));
$correct_login = false;
if (!empty($api_password)) {
    if ($pass === $api_password) {
        $correct_login = true;
    }
} else {
    if (ip_acl_check($ip_origin)) {
        $correct_login = true;
    }
}
if (!$correct_login) {
    sleep(15);
    exit;
}
switch ($op) {
function inventories_get_info($id_item, $id_father)
{
    global $config;
    $result = array();
    $info_inventory = get_db_row('tinventory', 'id', $id_item);
    $info_fields = get_db_all_rows_filter('tobject_type_field', array('id_object_type' => $id_father));
    if ($info_inventory !== false) {
        $result['name'] = $info_inventory['name'];
        $result['data'] = array();
        if (!empty($info_inventory['owner'])) {
            $owner = $info_inventory['owner'];
            $name_owner = get_db_value('nombre_real', 'tusuario', 'id_usuario', $owner);
            if (empty($name_owner)) {
                $name_owner = '--';
            }
        } else {
            $name_owner = '--';
        }
        $row = array();
        $row['label'] = __('Owner');
        $row['data'] = $name_owner;
        $result['data'][] = $row;
        if (!empty($info_inventory['id_parent'])) {
            $parent = $info_inventory['id_parent'];
            $name_parent = get_db_value('name', 'tinventory', 'id', $parent);
            if (empty($name_parent)) {
                $name_parent = '--';
            }
        } else {
            $name_parent = '--';
        }
        $row = array();
        $row['label'] = __('Parent');
        $row['data'] = $name_parent;
        $result['data'][] = $row;
        if (!empty($info_inventory['id_manufacturer'])) {
            $manufacturer = $info_inventory['id_manufacturer'];
            $name_manufacturer = get_db_value('name', 'tmanufacturer', 'id', $info_inventory['id_manufacturer']);
            if (empty($name_manufacturer)) {
                $name_manufacturer = '--';
            }
        } else {
            $name_manufacturer = '--';
        }
        $row = array();
        $row['label'] = __('Manufacturer');
        $row['data'] = $name_manufacturer;
        $result['data'][] = $row;
        if (!empty($info_inventory['id_contract'])) {
            $contract = $info_inventory['id_contract'];
            $name_contract = get_db_value('name', 'tcontract', 'id', $info_inventory['id_contract']);
            if (empty($name_contract)) {
                $name_contract = '--';
            }
        } else {
            $name_contract = '--';
        }
        $row = array();
        $row['label'] = __('Contract');
        $row['data'] = $name_contract;
        $result['data'][] = $row;
        if ($info_fields !== false) {
            foreach ($info_fields as $info) {
                $filter = array('id_inventory' => $id_item, 'id_object_type_field' => $info['id']);
                $value = get_db_value_filter('data', 'tobject_field_data', $filter);
                $data = '--';
                if (!empty($value)) {
                    $data = $value;
                }
                $info_field = array();
                $info_field['label'] = $info['label'];
                $info_field['data'] = $data;
                $result['data'][] = $info_field;
                if ($info['type'] == 'external' && $value != false) {
                    $all_fields_ext = inventories_get_all_external_field($info['external_table_name'], $info['external_reference_field'], $info['id']);
                    foreach ($all_fields_ext as $field) {
                        $data = '--';
                        if (!empty($field['data'])) {
                            $data = $field['data'];
                        }
                        $info_field_external = array();
                        $info_field['label'] = $field['label'];
                        $info_field['data'] = $data;
                        $result['data'][] = $info_field_external;
                    }
                }
            }
        }
    }
    return $result;
}
Beispiel #10
0
			require_once ('general/login_page.php');
			exit ("</html>");
		}
	}
}
else if (! isset ($_SESSION['id_usuario'])) {

	// There is no user connected
	echo '</head>';
	echo '<body class="login">';
	require ('general/login_page.php');
	exit;
}
else {
	if (isset ($_SESSION['id_usuario'])) {
		$user_in_db = get_db_value_filter('id_usuario', 'tusuario', array('id_usuario'=>$_SESSION['id_usuario']));
		if ($user_in_db == false) {
			//logout
			$_REQUEST = array ();
			$_GET = array ();
			$_POST = array ();
			echo '<body class="login">';
			require ('general/login_page.php');
			$iduser = $_SESSION["id_usuario"];
			logoff_db ($iduser, $config["REMOTE_ADDR"]);
			unset($_SESSION["id_usuario"]);
			exit;
		}
	}
	
	// Create id_user variable in $config hash, of ALL pages.
     $result_sql = process_sql($sql, 'insert_id');
     if ($result_sql !== false) {
         $project = get_db_value('name', 'tproject', 'id', $id_project);
         audit_db($config["id_user"], $config["REMOTE_ADDR"], "User/Role added to project", "User {$id_user} added to project {$project}");
     } else {
         $project = get_db_value('name', 'tproject', 'id', $id_project);
         $result_output = "<h3 class='error'>" . __('Error assigning access to project ' . $project . '.') . "</h3>";
         continue;
         // Does not insert the task
     }
 }
 // User->Task insert
 $filter = array();
 $filter['id_user'] = $id_user;
 $filter['id_task'] = $id_task;
 $result_sql = get_db_value_filter('MIN(id_role)', 'trole_people_task', $filter);
 if ($result_sql == false) {
     $sql = "INSERT INTO trole_people_task\n\t\t\t\t\t(id_task, id_user, id_role) VALUES\n\t\t\t\t\t({$id_task}, '{$id_user}', '{$id_role}')";
     $result_sql = process_sql($sql, 'insert_id');
     if ($result_sql !== false) {
         $project = get_db_value('name', 'tproject', 'id', $id_project);
         audit_db($config["id_user"], $config["REMOTE_ADDR"], "User/Role added to project", "User {$id_user} added to project {$project}");
     } else {
         $task = get_db_value("name", "ttask", "id", $id_task);
         $result_output = "<h3 class='error'>" . __('Error assigning access to task ' . $task . '.') . "</h3>";
     }
 } else {
     $sql = "UPDATE trole_people_task\n\t\t\t\t\tSET id_role={$id_role}\n\t\t\t\t\tWHERE id_user='******'\n\t\t\t\t\t\tAND id_task={$id_task}";
     $result_sql = process_sql($sql);
     if ($result_sql !== false) {
         $role = get_db_value("name", "trole", "id", $id_role);
Beispiel #12
0
 private function getIncidentDetail()
 {
     $system = System::getInstance();
     $ui = Ui::getInstance();
     $incident = get_db_row("tincidencia", "id_incidencia", $this->id_incident);
     if (!$incident) {
         $html = "<h2 class=\"error\">" . __('Ticket not found') . "</h2>";
     } else {
         include_once $system->getConfig('homedir') . "/include/functions_incidents.php";
         // DETAILS
         $resolution = incidents_get_incident_resolution_text($incident['id_incidencia']);
         $priority = incidents_get_incident_priority_text($incident['id_incidencia']);
         $priority_image = print_priority_flag_image($incident['prioridad'], true, "../");
         $group = incidents_get_incident_group_text($incident['id_incidencia']);
         $status = incidents_get_incident_status_text($incident['id_incidencia']);
         $type = incidents_get_incident_type_text($incident['id_incidencia']);
         // Get the status icon
         if ($incident['estado'] < 3) {
             $status_icon = 'status_new';
         } else {
             if ($incident['estado'] < 7) {
                 $status_icon = 'status_pending';
             } else {
                 $status_icon = 'status_closed';
             }
         }
         $ui->contentBeginGrid();
         // $options = array(
         // 	'action' => "index.php?page=incidents",
         // 	'method' => 'POST',
         // 	'data-ajax' => 'false'
         // 	);
         // $ui->beginForm($options);
         // 	// Filter status
         // 	$values = array();
         // 	$values[0] = __('Any');
         // 	$values[-10] = __('Not closed');
         // 	$status_table = process_sql ("select * from tincident_status");
         // 	foreach ($status_table as $status) {
         // 		$values[$status['id']] = __($status['name']);
         // 	}
         // 	$options = array(
         // 		'name' => 'filter_status',
         // 		'title' => __('Status'),
         // 		'items' => $values,
         // 		'selected' => $this->filter_status
         // 		);
         // 	$ui->formAddSelectBox($options);
         // $form_html = $ui->getEndForm();
         $status_cell = "<div class='detail-element'>\n\t\t\t\t\t\t\t\t" . __('Status') . "<br>\n\t\t\t\t\t\t\t\t<img src='../images/{$status_icon}.png'><br>\n\t\t\t\t\t\t\t\t<strong>{$status}</strong>\n\t\t\t\t\t\t\t</div>";
         $ui->contentGridAddCell($status_cell);
         $group_cell = "<div class='detail-element'>\n\t\t\t\t\t\t\t\t" . __('Group') . "<br>\n\t\t\t\t\t\t\t\t<img src='../images/group.png'><br>\n\t\t\t\t\t\t\t\t<strong>{$group}</strong>\n\t\t\t\t\t\t\t</div>";
         $ui->contentGridAddCell($group_cell);
         $priority_cell = "<div class='detail-element'>\n\t\t\t\t\t\t\t\t" . __('Priority') . "<br>\n\t\t\t\t\t\t\t\t{$priority_image}<br>\n\t\t\t\t\t\t\t\t<strong>{$priority}</strong>\n\t\t\t\t\t\t\t</div>";
         $ui->contentGridAddCell($priority_cell);
         $resolution_cell = "<div class='detail-element'>\n\t\t\t\t\t\t\t\t" . __('Resolution') . "<br>\n\t\t\t\t\t\t\t\t<img src='../images/resolution.png'><br>\n\t\t\t\t\t\t\t\t<strong>{$resolution}</strong>\n\t\t\t\t\t\t\t</div>";
         $ui->contentGridAddCell($resolution_cell);
         $type_cell = "<div class='detail-element'>\n\t\t\t\t\t\t\t\t" . __('Type') . "<br>\n\t\t\t\t\t\t\t\t<img src='../images/incident.png'><br>\n\t\t\t\t\t\t\t\t<strong>{$type}</strong>\n\t\t\t\t\t\t\t</div>";
         $ui->contentGridAddCell($type_cell);
         $detail_grid = $ui->getContentEndGrid();
         $ui->contentBeginCollapsible(__('Details'));
         $ui->contentCollapsibleAddItem($detail_grid);
         $detail = $ui->getEndCollapsible("", "b", "c", false);
         $detail = "<div style='padding-left: 2px; padding-right: 2px;'>{$detail}</div>";
         // DESCRIPTION
         if ($incident['descripcion'] != "") {
             $ui->contentBeginCollapsible(__('Description'));
             $ui->contentCollapsibleAddItem($incident['descripcion']);
             $description = $ui->getEndCollapsible("", "b", "c", false);
         }
         // CUSTOM FIELDS
         if ($incident['id_incident_type']) {
             $type_name = get_db_value("name", "tincident_type", "id", $incident['id_incident_type']);
             $fields = incidents_get_all_type_field($incident['id_incident_type'], $incident['id_incidencia']);
             $custom_fields = "";
             $ui->contentBeginCollapsible($type_name);
             foreach ($fields as $field) {
                 $custom_fields = $field["label"] . ":&nbsp;<strong>" . $field["data"] . "</strong>";
                 $ui->contentCollapsibleAddItem($custom_fields);
             }
             $custom_fields = $ui->getEndCollapsible("", "b", "c", false);
         }
         // PEOPLE
         $ui->contentBeginGrid();
         $name_creator = get_db_value_filter("nombre_real", "tusuario", array("id_usuario" => $incident['id_creator']));
         $avatar_creator = get_db_value_filter("avatar", "tusuario", array("id_usuario" => $incident['id_creator']));
         $creator_cell = "<div style='text-align: center;'>\n\t\t\t\t\t\t\t\t\t\t<div class='bubble_little'>\n\t\t\t\t\t\t\t\t\t\t\t<img src='../images/avatars/{$avatar_creator}.png'>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<strong style='color: #FF9933'>" . __('Created by') . ":</strong><br>\n\t\t\t\t\t\t\t\t\t{$name_creator}\n\t\t\t\t\t\t\t\t</div>";
         $ui->contentGridAddCell($creator_cell);
         $name_owner = get_db_value_filter("nombre_real", "tusuario", array("id_usuario" => $incident['id_usuario']));
         $avatar_owner = get_db_value_filter("avatar", "tusuario", array("id_usuario" => $incident['id_usuario']));
         $owner_cell = "<div style='text-align: center;'>\n\t\t\t\t\t\t\t\t\t\t<div class='bubble_little'>\n\t\t\t\t\t\t\t\t\t\t\t<img src='../images/avatars/{$avatar_owner}.png'>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<strong style='color: #FF9933'>" . __('Owned by') . ":</strong><br>\n\t\t\t\t\t\t\t\t\t{$name_owner}\n\t\t\t\t\t\t\t\t</div>";
         $ui->contentGridAddCell($owner_cell);
         if ($incident['estado'] == STATUS_CLOSED) {
             if (empty($incident["closed_by"])) {
                 $name_closer = __('Unknown');
                 $avatar_closer = '../avatar_unknown';
             } else {
                 $name_closer = get_db_value_filter("nombre_real", "tusuario", array("id_usuario" => $incident['closed_by']));
                 $avatar_closer = get_db_value_filter("avatar", "tusuario", array("id_usuario" => $incident['closed_by']));
             }
             $closer_cell = "<div style='text-align: center;'>\n\t\t\t\t\t\t\t\t\t\t<div class='bubble_little'>\n\t\t\t\t\t\t\t\t\t\t\t<img src='../images/avatars/{$avatar_closer}.png'>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<strong style='color: #FF9933'>" . __('Closed by') . ":</strong><br>\n\t\t\t\t\t\t\t\t\t\t{$name_creator}\n\t\t\t\t\t\t\t\t\t</div>";
             $ui->contentGridAddCell($closer_cell);
         }
         $people_grid = $ui->getContentEndGrid();
         $ui->contentBeginCollapsible(__('People'));
         $ui->contentCollapsibleAddItem($people_grid);
         $people = $ui->getEndCollapsible("", "b", "c");
         // DATES
         $ui->contentBeginGrid();
         $created_timestamp = strtotime($incident['inicio']);
         $created_cell .= "<table width='97%' style='text-align: center;' id='incidents_dates_square'>";
         $created_cell .= "<tr>";
         $created_cell .= "<td>" . __('Created on') . ":</td>";
         $created_cell .= "</tr>";
         $created_cell .= "<tr>";
         $created_cell .= "<td id='created_on' class='mini_calendar'>";
         $created_cell .= "<table>";
         $created_cell .= "<tr>";
         $created_cell .= "<th>" . strtoupper(date('M\' y', $created_timestamp)) . "</th>";
         $created_cell .= "</tr>";
         $created_cell .= "<tr>";
         $created_cell .= "<td class='day'>" . date('d', $created_timestamp) . "</td>";
         $created_cell .= "</tr>";
         $created_cell .= "<tr>";
         $created_cell .= "<td class='time'><img src='../images/cal_clock_grey.png'>&nbsp;" . date('H:i:s', $created_timestamp) . "</td>";
         $created_cell .= "</tr>";
         $created_cell .= "</table>";
         $created_cell .= "</td>";
         $created_cell .= "</tr>";
         $created_cell .= "</table>";
         $ui->contentGridAddCell($created_cell);
         $updated_timestamp = strtotime($incident['actualizacion']);
         $updated_cell .= "<table width='97%' style='text-align: center;' id='incidents_dates_square'>";
         $updated_cell .= "<tr>";
         $updated_cell .= "<td>" . __('Updated on') . ":</td>";
         $updated_cell .= "</tr>";
         $updated_cell .= "<tr>";
         $updated_cell .= "<td id='updated_on' class='mini_calendar'>";
         $updated_cell .= "<table>";
         $updated_cell .= "<tr>";
         $updated_cell .= "<th>" . strtoupper(date('M\' y', $updated_timestamp)) . "</th>";
         $updated_cell .= "</tr>";
         $updated_cell .= "<tr>";
         $updated_cell .= "<td class='day'>" . date('d', $updated_timestamp) . "</td>";
         $updated_cell .= "</tr>";
         $updated_cell .= "<tr>";
         $updated_cell .= "<td class='time'><img src='../images/cal_clock_orange.png'>&nbsp;" . date('H:i:s', $updated_timestamp) . "</td>";
         $updated_cell .= "</tr>";
         $updated_cell .= "</table>";
         $updated_cell .= "</td>";
         $updated_cell .= "</tr>";
         $updated_cell .= "</table>";
         $ui->contentGridAddCell($updated_cell);
         if ($incident["estado"] == STATUS_CLOSED) {
             $closed_timestamp = strtotime($incident['cierre']);
             $closed_cell .= "<table width='97%' style='text-align: center;' id='incidents_dates_square'>";
             $closed_cell .= "<tr>";
             $closed_cell .= "<td>" . __('Closed on') . ":</td>";
             $closed_cell .= "</tr>";
             $closed_cell .= "<tr>";
             $closed_cell .= "<td id='closed_on' class='mini_calendar'>";
             $closed_cell .= "<table>";
             $closed_cell .= "<tr>";
             $closed_cell .= "<th>" . strtoupper(date('M\' y', $closed_timestamp)) . "</th>";
             $closed_cell .= "</tr>";
             $closed_cell .= "<tr>";
             $closed_cell .= "<td class='day'>" . date('d', $closed_timestamp) . "</td>";
             $closed_cell .= "</tr>";
             $closed_cell .= "<tr>";
             $closed_cell .= "<td class='time'><img src='../images/cal_clock_darkgrey.png'>&nbsp;" . date('H:i:s', $closed_timestamp) . "</td>";
             $closed_cell .= "</tr>";
             $closed_cell .= "</table>";
             $closed_cell .= "</td>";
             $closed_cell .= "</tr>";
             $closed_cell .= "</table>";
             $ui->contentGridAddCell($closed_cell);
         }
         $dates_grid = $ui->getContentEndGrid();
         $ui->contentBeginCollapsible(__('Dates'));
         $ui->contentCollapsibleAddItem($dates_grid);
         $dates = $ui->getEndCollapsible("", "b", "c");
         if ($system->getConfig('enabled_ticket_editor')) {
             $ui->contentBeginCollapsible(__('Quick edit'));
             $ui->contentCollapsibleAddItem($this->getIncidentQuickForm($incident));
             $quick_edit = $ui->getEndCollapsible("", "b", "c");
         } else {
             $quick_edit = "";
         }
         $html = "<h1 class='title'>" . $incident['titulo'] . "</h1>";
         $html .= $detail;
         if (!$description || !$custom_fields) {
             if ($description) {
                 $html .= $description;
             }
             if ($custom_fields) {
                 $html .= $custom_fields;
             }
         } else {
             $ui->contentBeginGrid();
             $ui->contentGridAddCell($description);
             $ui->contentGridAddCell($custom_fields);
             $html .= $ui->getContentEndGrid();
         }
         $ui->contentBeginGrid();
         $ui->contentGridAddCell($people);
         $ui->contentGridAddCell($dates);
         $html .= $ui->getContentEndGrid();
         $html .= $quick_edit;
     }
     return $html;
 }
    /* Auto fill values */
    $len = count($data);
    if ($len < $nfields) {
        $data = array_pad($data, $nfields, '');
    } elseif ($len > $nfields) {
        $data = array_slice($data, NULL, $nfields);
    }
    $values = array_combine($fields, $data);
    if (empty($values['name'])) {
        continue;
    }
    /* Check parent */
    if (is_int($values['id_parent'])) {
        $id_parent = (int) get_db_value('id', 'tinventory', 'id', $values['id_parent']);
    } else {
        $id_parent = (int) get_db_value('id', 'tinventory', 'name', (string) $values['id_parent']);
    }
    $values['id_parent'] = $id_parent ? $id_parent : NULL;
    /* Check if the inventory item already exists */
    $id_inventory = (int) get_db_value_filter('id', 'tinventory', array('name' => $values['name'], 'id_parent' => $values['id_parent']));
    process_values($values, $id_inventory);
    if ($id_inventory) {
        process_sql_update('tinventory', $values, array('id' => $id_inventory));
        echo 'Updated inventory "' . $values['name'] . '"';
    } else {
        process_sql_insert('tinventory', $values);
        echo 'Inserted inventory "' . $values['name'] . '"';
    }
    echo "\n";
}
fclose($file);
         inventory_tracking($id, INVENTORY_OBJECT_TYPE, $id_object_type);
     }
     //parent
     if ($id_parent != 0) {
         $id_object_type_inherit = get_db_value('id_object_type', 'tinventory', 'id', $id_parent);
         //parent has object
         if ($id_object_type_inherit !== false) {
             $inherit_fields = get_db_all_rows_filter('tobject_type_field', array('id_object_type' => $id_object_type_inherit, 'inherit' => 1));
             if ($inherit_fields === false) {
                 $inherit_fields = array();
             }
             foreach ($inherit_fields as $key => $field) {
                 $values = array();
                 $values['id_object_type_field'] = $field['id'];
                 $values['id_inventory'] = $id;
                 $data = get_db_value_filter('data', 'tobject_field_data', array('id_inventory' => $id_parent, 'id_object_type_field' => $field['id']));
                 $values['data'] = $data;
                 process_sql_insert('tobject_field_data', $values);
             }
         }
         inventory_tracking($id, INVENTORY_PARENT_CREATED, $id_parent);
     }
     $result_companies = enterprise_hook('inventory_update_companies', array($id, get_parameter('companies')));
     $result_users = enterprise_hook('inventory_update_users', array($id, get_parameter('users')));
     $result_msg = '<h3 class="suc">' . __('Successfully created') . '</h3>';
     $result_msg .= "<h3><a href='index.php?sec=inventory&sec2=operation/inventories/inventory_detail&id={$id}'>" . __("Click here to continue working with Object #") . $id . "</a></h3>";
 } else {
     $result_msg = '<h3 class="error">' . $err_message . '</h3>';
 }
 $id = 0;
 $name = "";
$incident_users .= "<td>";
$incident_users .= '<div class="bubble">' . print_image('images/avatars/' . $avatar_asigned . '.png', true, $options) . '</div>';
$incident_users .= '<span>' . __('Owned by') . ':</span><br>' . $long_name_asigned;
$incident_users .= "</td>";
$avatar_closer = get_db_value_filter("avatar", "tusuario", array("id_usuario" => $incident["closed_by"]));
$incident_users .= "<td>";
$incident_users .= '<div class="bubble">';
if ($incident["estado"] != STATUS_CLOSED) {
    $long_name_closer = '<em>' . __('Not closed yet') . '</em>';
    $incident_users .= print_image('images/avatar_notyet.png', true);
} else {
    if (empty($incident["closed_by"])) {
        $long_name_closer = '<em>' . __('Unknown') . '</em>';
        $incident_users .= print_image('images/avatar_unknown.png', true);
    } else {
        $long_name_closer = get_db_value_filter("nombre_real", "tusuario", array("id_usuario" => $incident["closed_by"]));
        $closer = $incident['closed_by'];
        $options["onclick"] = "openUserInfo(\"{$closer}\")";
        $incident_users .= print_image('images/avatars/' . $avatar_closer . '.png', true, $options);
    }
}
$incident_users .= '</div>';
$incident_users .= '<span>' . __('Closed by') . ':</span><br>' . $long_name_closer;
$incident_users .= "</td>";
$incident_users .= "</tr>";
$incident_users .= "</table>";
$right_side = print_container('incident_users', __('People') . print_help_tip(_('Click on icons for more details'), true), $incident_users);
// Quick editor
if ($config['enabled_ticket_editor']) {
    $has_im = give_acl($config['id_user'], $id_grupo, "IM") || $config['id_user'] == $incident['id_creator'];
    $has_iw = give_acl($config['id_user'], $id_grupo, "IW") || $config['id_user'] == $incident['id_usuario'] || $config['id_user'] == $incident['id_creator'];
function incidents_search_result_group_by_project($filter, $ajax = false, $return_incidents = false, $print_result_count = false)
{
    global $config;
    // ----------------------------------------
    // Here we print the result of the search
    // ----------------------------------------
    echo '<table width="99%" cellpadding="0" cellspacing="0" border="0px" class="result_table listing" id="incident_search_result_table">';
    echo '<thead>';
    echo "<tr>";
    echo "<th>";
    echo print_checkbox('incidentcb-all', "", false, true);
    echo "</th>";
    echo "<th>";
    echo __('ID');
    echo "</th>";
    echo "<th>";
    echo __('SLA');
    echo "</th>";
    echo "<th>";
    echo __('Ticket');
    echo "</th>";
    echo "<th>";
    echo __('Group') . "<br><i>" . __('Company') . "</i>";
    echo "</th>";
    echo "<th>";
    echo __('Status') . "<br><i>" . __('Resolution') . "</i>";
    echo "</th>";
    echo "<th>";
    echo __('Priority');
    echo "</th>";
    echo "<th style='width: 70px;'>";
    echo __('Updated') . "<br><i>" . __('Started') . "</i>";
    echo "</th>";
    if ($config["show_creator_incident"] == 1) {
        echo "<th>";
    }
    echo __('Creator');
    echo "</th>";
    if ($config["show_owner_incident"] == 1) {
        echo "<th>";
    }
    echo __('Owner');
    echo "</th>";
    echo "</tr>";
    echo '</thead>';
    echo "<tbody>";
    $tasks_in_tickets = incidents_get_filter_tickets_tree($filter, 'tasks');
    if ($tasks_in_tickets === false) {
        $tasks_in_tickets = array();
    }
    $i = 0;
    $tickets_str = '';
    $add_no_project = false;
    foreach ($tasks_in_tickets as $task_ticket) {
        if ($i == 0) {
            $tickets_str = $task_ticket['id_task'];
        } else {
            $tickets_str .= ',' . $task_ticket['id_task'];
        }
        if ($task_ticket['id_task'] == 0) {
            $add_no_project = true;
        }
        $i++;
    }
    if (!empty($tasks_in_tickets)) {
        $sql = "SELECT t1.name as n_task, t2.name as n_project, t1.id as id_task FROM ttask t1, tproject t2\n\t\t\tWHERE t1.id_project=t2.id AND t1.id IN ({$tickets_str})\n\t\t\tORDER BY t2.name";
        $tickets = get_db_all_rows_sql($sql);
    } else {
        $tickets = false;
    }
    if ($tickets === false) {
        $tickets = array();
    }
    if ($add_no_project) {
        $tickets[$i]['id_task'] = 0;
        $tickets[$i]['n_project'] = __('No associated project');
    }
    foreach ($tickets as $task_ticket) {
        $task = get_db_row('ttask', 'id', $task_ticket['id_task']);
        $img = print_image("images/input_create.png", true, array("style" => 'vertical-align: middle;', "id" => $img_id));
        $img_task = print_image("images/task.png", true, array("style" => 'vertical-align: middle;'));
        //tickets in task
        $filter['id_task'] = $task_ticket['id_task'];
        $tickets_in_task = incidents_get_filter_tickets_tree($filter, 'tickets');
        $count_tickets = count($tickets_in_task);
        //print ticket with task
        if ($task_ticket['id_task'] != 0) {
            $project_name = $task_ticket['n_project'] . ' - ' . $task_ticket['n_task'];
        } else {
            $project_name = $task_ticket['n_project'];
        }
        //print project-task
        echo '<tr><td colspan="10" valign="top">';
        echo "\n\t\t<a onfocus='JavaScript: this.blur()' href='javascript: check_rows(\"" . $task_ticket['id_task'] . "\")'>" . $img . "&nbsp;" . $img_task . "&nbsp;" . safe_output($project_name) . "&nbsp;" . "({$count_tickets})" . "</a>" . "&nbsp;&nbsp;";
        echo '</td></tr>';
        foreach ($tickets_in_task as $incident) {
            $class = $task_ticket['id_task'] . "-task";
            $tr_status = 'class="' . $class . '"';
            if ($incident["estado"] < 3) {
                $tr_status = 'class="red_row ' . $class . '"';
            } elseif ($incident["estado"] < 6) {
                $tr_status = 'class="yellow_row ' . $class . '"';
            } else {
                $tr_status = 'class="green_row ' . $class . '"';
            }
            echo '<tr ' . $tr_status . ' id="incident-' . $incident['id_incidencia'] . '"';
            echo " style='border-bottom: 1px solid #ccc;' >";
            echo '<td>';
            print_checkbox_extended('incidentcb-' . $incident['id_incidencia'], $incident['id_incidencia'], false, '', '', 'class="cb_incident"');
            echo '</td>';
            //Print incident link if not ajax, if ajax link to js funtion to replace parent
            $link = "index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=" . $incident["id_incidencia"];
            if ($ajax) {
                $link = "javascript:update_parent('" . $incident["id_incidencia"] . "')";
            }
            echo '<td>';
            echo '<strong><a href="' . $link . '">#' . $incident['id_incidencia'] . '</a></strong></td>';
            // SLA Fired ??
            if ($incident["affected_sla_id"] != 0) {
                echo '<td width="25"><img src="images/exclamation.png" /></td>';
            } else {
                echo '<td></td>';
            }
            echo '<td>';
            echo '<strong><a href="' . $link . '">' . $incident['titulo'] . '</a></strong><br>';
            echo "<span style='font-size:11px;font-style:italic'>";
            echo incidents_get_incident_type_text($incident["id_incidencia"]);
            // Added by slerena 26Ago2013
            $sql = sprintf("SELECT *\n\t\t\t\t\t\t\tFROM tincident_type_field\n\t\t\t\t\t\t\tWHERE id_incident_type = %d", $incident["id_incident_type"]);
            $config['mysql_result_type'] = MYSQL_ASSOC;
            $type_fields = get_db_all_rows_sql($sql);
            $type_fields_values_text = "";
            if ($type_fields) {
                foreach ($type_fields as $type_field) {
                    if ($type_field["show_in_list"]) {
                        $field_data = get_db_value_filter("data", "tincident_field_data", array("id_incident" => $incident["id_incidencia"], "id_incident_field" => $type_field["id"]));
                        if ($field_data) {
                            if ($type_field["type"] == "textarea") {
                                $field_data = "<div style='display: inline-block;' title='{$field_data}'>" . substr($field_data, 0, 15) . "...</div>";
                            }
                            $type_fields_values_text .= " <div title='" . $type_field["label"] . "' style='display: inline-block;'>[{$field_data}]</div>";
                        }
                    }
                }
            }
            echo "&nbsp;{$type_fields_values_text}";
            echo '</span></td>';
            echo '<td>' . get_db_value("nombre", "tgrupo", "id_grupo", $incident['id_grupo']);
            if ($config["show_creator_incident"] == 1) {
                $id_creator_company = get_db_value("id_company", "tusuario", "id_usuario", $incident["id_creator"]);
                if ($id_creator_company != 0) {
                    $company_name = (string) get_db_value('name', 'tcompany', 'id', $id_creator_company);
                    echo "<br><span style='font-size:11px;font-style:italic'>{$company_name}</span>";
                }
            }
            echo '</td>';
            $resolution = isset($resolutions[$incident['resolution']]) ? $resolutions[$incident['resolution']] : __('None');
            echo '<td class="f9"><strong>' . $statuses[$incident['estado']] . '</strong><br /><em>' . $resolution . '</em></td>';
            // priority
            echo '<td>';
            print_priority_flag_image($incident['prioridad']);
            $last_wu = get_incident_lastworkunit($incident["id_incidencia"]);
            if ($last_wu["id_user"] == $incident["id_creator"]) {
                echo "<br><img src='images/comment.gif' title='" . $last_wu["id_user"] . "'>";
            }
            echo '</td>';
            echo '<td style="font-size:11px;">' . human_time_comparation($incident["actualizacion"]);
            // Show only if it's different
            if ($incident["inicio"] != $incident["actualizacion"]) {
                echo "<br><em>[" . human_time_comparation($incident["inicio"]);
                echo "]</em>";
            }
            echo "<br>";
            echo '<span style="font-size:9px;">';
            if (isset($config["show_user_name"]) && $config["show_user_name"]) {
                $updated_by = get_db_value('nombre_real', 'tusuario', 'id_usuario', $last_wu["id_user"]);
            } else {
                $updated_by = $last_wu["id_user"];
            }
            //~ echo $last_wu["id_user"];
            echo $updated_by;
            echo "</span>";
            echo '</td>';
            if ($config["show_creator_incident"] == 1) {
                echo "<td class='f9'>";
                $incident_creator = $incident["id_creator"];
                echo substr($incident_creator, 0, 12);
                echo "</td>";
            }
            if ($config["show_owner_incident"] == 1) {
                echo "<td class='f9'>";
                $incident_owner = $incident["id_usuario"];
                echo substr($incident_owner, 0, 12);
                echo "</td>";
            }
            echo '</tr>';
        }
    }
    echo '</tbody>';
    echo '</table>';
}
        }
    }
    // Does not exist
    echo json_encode(true);
    return;
} elseif ($search_existing_contract) {
    require_once 'include/functions_db.php';
    $contract_name = get_parameter('contract_name');
    $contract_id = get_parameter('contract_id', 0);
    $id_company = get_parameter('id_company', 0);
    $old_contract_name = "";
    if ($contract_id) {
        $old_contract_name = get_db_value("name", "tcontract", "id", $contract_id);
    }
    // Checks if the contract is in the db
    $query_result = get_db_value_filter('name', 'tcontract', array('name' => $contract_name, 'id_company' => $id_company));
    if ($query_result) {
        if ($contract_name != $old_contract_name) {
            // Exists. Validation error
            echo json_encode(false);
            return;
        }
    }
    // Does not exist
    echo json_encode(true);
    return;
} elseif ($search_existing_contract_number) {
    require_once 'include/functions_db.php';
    $contract_number = get_parameter('contract_number');
    $contract_id = get_parameter('contract_id', 0);
    $old_contract_number = -1;
        echo 'Could not access ' . $file . "\n";
        set_include_path($path);
        return 1;
    }
}
set_include_path($path);
$username = $argv[1];
$password = $argv[2];
$filepath = $argv[3];
$separator = isset($argv[4]) ? $argv[4] : ',';
// Check credentials
if (!dame_admin($username)) {
    echo 'Wrong user/password' . "\n";
    return 1;
}
$user = (bool) get_db_value_filter('COUNT(*)', 'tusuario', array('id_usuario' => $username, 'password' => md5($password)));
if (!$user) {
    echo 'Wrong user/password' . "\n";
    return 1;
}
if ($filepath == "-") {
    $file = fopen('php://stdin', 'r');
    $filepath = 'STDIN';
} else {
    $file = @fopen($filepath, 'r');
}
if (!$file) {
    echo 'Could not open ' . $filepath . "\n";
    return 1;
}
$fields = array("id", "date_entered", "date_modified", "modified_user_id", "created_by", "description", "deleted", "assigned_user_id", "salutation", "first_name", "last_name", "title", "department", "do_not_call", "phone_home", "phone_mobile", "phone_work", "phone_other", "phone_fax", "primary_address_street", "primary_address_city", "primary_address_state", "primary_address_postalcode", "primary_address_country", "alt_address_street", "alt_address_city", "alt_address_state", "alt_address_postalcode", "alt_address_country", "assistant", "assistant_phone", "lead_source", "reports_to_id", "birthdate", "portal_name", "portal_active", "portal_app", "campaign_id", "email_address", "account_name", "assigned_user_name");
function is_holidays($datecalc)
{
    $date_formated = $datecalc;
    $date = $date_formated . ' 00:00:00';
    $id = get_db_value_filter("id", "tholidays", array("day" => $date));
    //If there is in the list is holidays
    if ($id) {
        return 1;
    }
    return 0;
}
Beispiel #20
0
if ($operation == 'insert_all') {
    $all_people = get_parameter('people');
    if (empty($all_people)) {
        $update_mode = 0;
        $create_mode = 1;
        $result_output = "<h3 class='error'>" . __('You must select user/role') . "</h3>";
    } else {
        foreach ($all_people as $person) {
            $result = explode('/', $person);
            $id_user = $result[0];
            $id_role = $result[1];
            $filter['id_role'] = $id_role;
            $filter['id_user'] = $id_user;
            $filter['id_task'] = $id_task;
            $role_name = get_db_value('name', 'trole', 'id', $id_role);
            $result_sql = get_db_value_filter('id_user', 'trole_people_task', $filter);
            if ($result_sql !== false) {
                echo "<h3 class='error'>" . __('Not created. Role already exists: ') . $id_user . ' / ' . $role_name . "</h3>";
            } else {
                $sql = "INSERT INTO trole_people_task\n\t\t\t\t\t(id_task, id_user, id_role) VALUES\n\t\t\t\t\t({$id_task}, '{$id_user}', '{$id_role}')";
                task_tracking($id_task, TASK_MEMBER_ADDED);
                $id_task_inserted = process_sql($sql, 'insert_id');
                if ($id_task_inserted !== false) {
                    $result_output .= "<h3 class='suc'>" . __('Successfully created: ') . $id_user . ' / ' . $role_name . "</h3>";
                    audit_db($config["id_user"], $config["REMOTE_ADDR"], "User/Role added to task", "User {$id_user} added to task " . get_db_value("name", "ttask", "id", $id_task));
                } else {
                    $update_mode = 0;
                    $create_mode = 1;
                    $result_output .= "<h3 class='error'>" . __('Not created. Error inserting data: ') . $id_user . ' / ' . $role_name . "</h3>";
                }
            }
$update = (bool) get_parameter ('update_report');
$name = (string) get_parameter ('name');
$sql = (string) get_parameter ('sql');
$id_group = get_parameter('id_group', 0);
$id = (int) get_parameter ('id');
$pure = get_parameter ("pure", 0);

if ($id) {
	$report = get_db_row ('tinventory_reports', 'id', $id);
	if ($report === false)
		return;
	$name = $report['name'];
	$sql = $report['sql'];
	$id_group = $report['id_group'];
	
	$user_in_group = get_db_value_filter('id_grupo', 'tusuario_perfil', array('id_usuario'=>$config['id_user'],'id_grupo'=>$id_group));	
	if ($id_group == 1) {
		$user_in_group = 1;
	}
}


if ((!dame_admin ($config['id_user'])) && ($user_in_group == false)) {
	// Doesn't have access to this page
	audit_db ($config['id_user'], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access inventory reports");
	include ("general/noaccess.php");
	return;
}

$result_msg = '';
if ($create) {
        $enable_login = $rowdup["enable_login"];
        $location = $rowdup["location"];
    }
}
///////////////////////////////
// UPDATE USER
///////////////////////////////
if ($action == 'update') {
    $enable_login = get_parameter("enable_login");
    $user_to_update = get_parameter("update_user");
    $nivel = get_parameter("nivel", 0);
    enterprise_include('include/functions_license.php', true);
    $users_check = true;
    if ($enable_login) {
        $old_enable_login = get_db_value_filter('enable_login', 'tusuario', array('id_usuario' => $user_to_update));
        $old_nivel = get_db_value_filter('nivel', 'tusuario', array('id_usuario' => $user_to_update));
        if ($old_nivel != $nivel) {
            if ($nivel) {
                $users_check = enterprise_hook('license_check_manager_users_num');
            } else {
                $users_check = enterprise_hook('license_check_regular_users_num');
            }
        } else {
            if ($old_enable_login) {
                $users_check = true;
            } else {
                $is_manager = enterprise_hook('license_check_manager_user', array($user_to_update));
                if ($is_manager) {
                    $users_check = enterprise_hook('license_check_manager_users_num');
                } else {
                    $users_check = enterprise_hook('license_check_regular_users_num');