Esempio n. 1
0
    $id_file = (int) get_parameter("id_attachment");
    $file_description = get_parameter("file_description");
    $result = array();
    $result["status"] = false;
    $result["message"] = "";
    $result['status'] = (bool) process_sql_update('tattachment', array('description' => $file_description), array('id_attachment' => $id_file));
    if (!$result['status']) {
        $result['message'] = __('Description not updated');
    }
    echo json_encode($result);
    return;
}
if ($get_file_row) {
    $id_file = (int) get_parameter("id_attachment");
    $id_company = (int) get_parameter("id");
    $file = get_db_row_filter('tattachment', array('id_company' => $id_company, 'id_attachment' => $id_file));
    $html = "";
    if ($file) {
        $link = "operation/common/download_file.php?id_attachment=" . $file["id_attachment"] . "&type=company";
        $real_filename = $config["homedir"] . "/attachment/" . $file["id_attachment"] . "_" . rawurlencode($file["filename"]);
        $html .= "<tr>";
        $html .= "<td valign=top>";
        $html .= '<a target="_blank" href="' . $link . '">' . $file['filename'] . '</a>';
        $html .= "<td valign=top class=f9>" . $file["description"];
        //$html .= "<td valign=top>". $file["id_usuario"];
        $html .= "<td valign=top>" . byte_convert($file['size']);
        $stat = stat($real_filename);
        $html .= "<td valign=top class=f9>" . date("Y-m-d H:i:s", $stat['mtime']);
        // Delete attachment
        if (give_acl($config['id_user'], $incident['id_grupo'], 'IM')) {
            $html .= "<td>" . '<a class="delete" name="delete_file_' . $file["id_attachment"] . '" href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $id . '&tab=files&id_attachment=' . $file["id_attachment"] . '&delete_file=1#incident-operations">
Esempio n. 2
0
function get_incident_file($id_incident, $id_file)
{
    return get_db_row_filter('tattachment', array('id_incidencia' => $id_incident, 'id_attachment' => $id_file));
}
Esempio n. 3
0
        echo ui_print_success_message(__('Successfully deleted'), '', true, 'h3', true);
    }
    $operation = "";
}
// CREATE new newsboard(form) or Update
if ($operation == "create" or $operation == "update") {
    $title = "";
    $content = "";
    $expire = 0;
    $date = date('Y-m-d', time() + 604800);
    //one week later
    $time = date('H:i:s', time());
    $id_grupo = 0;
    if ($operation == "update") {
        $id = get_parameter("id");
        $news = get_db_row_filter('tnewsboard', array('id' => $id));
        $title = $news["title"];
        $content = $news["content"];
        $expire = $news["expire"];
        $date = explode(" ", $news["expire_timestamp"]);
        $time = $date[1];
        $date = $date[0];
        $id_grupo = $news['id_group'];
    }
    $table = new StdClass();
    $table->width = '100%';
    $table->class = 'search-table-button';
    $table->colspan = array();
    $table->colspan[1][0] = 2;
    $table->colspan[2][0] = 4;
    $table->colspan[3][0] = 2;
Esempio n. 4
0
// CHECK LOGIN AND ACLs
check_login();
// SET VARS
$width = '99%';
if (!give_acl($config['id_user'], 0, "IR")) {
    audit_db($config['id_user'], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access ticket viewer");
    require "general/noaccess.php";
    exit;
}
$incident_id = get_parameter('incident_id', 0);
if ($incident_id == 0) {
    ui_print_error_message(__('Unable to load ticket'));
    exit;
}
// GET THE DETAILS
$incident['details'] = get_db_row_filter('tincidencia', array('id_incidencia' => $incident_id), '*');
// SHOW THE DETAILS
$table->class = 'result_table listing';
$table->width = $width;
$table->id = 'incident_search_result_table';
$separator_style = 'border-bottom: 1px solid rgb(204, 204, 204);border-top: 1px solid rgb(204, 204, 204);';
$table->style = array();
$table->data = array();
$table->rowstyle[0] = $separator_style;
$table->rowstyle[1] = $separator_style;
$table->rowstyle[2] = $separator_style;
$table->rowstyle[3] = $separator_style;
$table->rowstyle[4] = $separator_style;
$table->colspan[4][0] = 2;
$table->colspan[5][0] = 2;
$table->head = array();
function incidents_update_stats_item($id_incident, $id_aditional, $metric, $time_from, $time_to)
{
    $holidays_seconds = incidents_get_holidays_seconds_by_timerange($time_from, $time_to);
    $diff_time = $time_to - $time_from - $holidays_seconds;
    $filter = array('id_incident' => $id_incident, "metric" => $metric);
    switch ($metric) {
        case INCIDENT_METRIC_USER:
            $filter["id_user"] = $id_aditional;
            break;
        case INCIDENT_METRIC_STATUS:
            $filter["status"] = $id_aditional;
            break;
        case INCIDENT_METRIC_GROUP:
            $filter["id_group"] = $id_aditional;
            break;
    }
    $stats_item = get_db_row_filter("tincident_stats", $filter);
    if ($stats_item) {
        //We have previous data for this stat, so update it
        $val_upd_time = array("seconds" => $stats_item["seconds"] + $diff_time);
        $val_upd_time_where = array("id" => $stats_item["id"]);
        process_sql_update("tincident_stats", $val_upd_time, $val_upd_time_where);
    } else {
        $values = array("id_incident" => $id_incident, "seconds" => $diff_time, "metric" => $metric);
        switch ($metric) {
            case INCIDENT_METRIC_USER:
                $values["id_user"] = $id_aditional;
                break;
            case INCIDENT_METRIC_STATUS:
                $values["status"] = $id_aditional;
                break;
            case INCIDENT_METRIC_GROUP:
                $values["id_group"] = $id_aditional;
                break;
            default:
                break;
        }
        process_sql_insert("tincident_stats", $values);
    }
}
Esempio n. 6
0
// GNU General Public License for more details.

if (defined ('AJAX')) {
	
	ob_clean();
	
	$id_group = get_parameter('id_group');
	$id_user = get_parameter('id_user');

	if (($id_group == null) || ($id_user == null)) {
		echo "//";
		echo "null";
		return;
	}
	
	$group = get_db_row_filter('tgrupo', array('id_grupo' => $id_group));
	//soft limit is open incidents.
	//hard limit is count all incidents.

	if (($group['hard_limit'] == 0) && ($group['soft_limit'] == 0)) {
		echo "correct"; //type			
		$inventoryObject = get_db_row_sql('SELECT * FROM tinventory
			WHERE id IN (
			SELECT id_inventory_default
			FROM tgrupo
			WHERE id_grupo = ' . $id_group . ')');
		
		if ($inventoryObject !== false) {
			echo "//";
			echo $inventoryObject['id'];
			echo "//";
Esempio n. 7
0
            $error_update = true;
        }
    }
    if ($error_update) {
        echo '<h3 class="error">' . __('Field could not be updated. Empty combo value') . '</h3>';
    } else {
        $result_update = process_sql_update('tuser_field', $value_update, array('id' => $id_field));
        if ($result_update === false) {
            echo '<h3 class="error">' . __('Field could not be updated') . '</h3>';
        } else {
            echo '<h3 class="suc">' . __('Field updated successfully') . '</h3>';
        }
    }
}
if ($id_field) {
    $field_data = get_db_row_filter('tuser_field', array('id' => $id_field));
    $label = $field_data['label'];
    $type = $field_data['type'];
    $combo_value = $field_data['combo_value'];
}
echo '<h1>' . __('User fields editor') . '</h1>';
$table->width = "99%";
$table->class = "search-table-button";
$table->data = array();
$table->data[0][0] = print_input_text('label', $label, '', 45, 100, true, __('Field name'));
$types = array('text' => __('Text'), 'textarea' => __('Textarea'), 'combo' => __('Combo'));
$table->data[0][1] = print_label(__("Type"), "label-id", 'text', true);
$table->data[0][1] .= print_select($types, 'type', $type, '', __('Select type'), '0', true);
$table->data['id_combo_value'][0] = print_input_text('combo_value', $combo_value, '', 45, 100, true, __('Combo value')) . print_help_tip(__("Set values separated by comma"), true);
if (!$id_field) {
    $button = print_input_hidden('add_field', 1, true);
Esempio n. 8
0
    // Doesn't have access to this page
    audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", 'Trying to access chat of ticket #' . $id_incident . " '" . $titulo . "'");
    include "general/noaccess.php";
    exit;
}
echo '<h3>' . __('Ticket') . ' #' . $id_incident . ' - ' . $incident['titulo'] . '</h3>';
echo '<div class="result"></div>';
$table = null;
$table->width = '95%';
$table->style[1] = 'text-align: right; vertical-align: top;';
$table->data[0][0] = '<div id="chat_box" style="width: 95%;
	height: 300px; background: #ffffff; border: 1px inset black;
	overflow: auto; padding: 10px;"></div>';
$table->data[0][1] = '';
//Show the button to save only for assigned user
$exists_as_creator = get_db_row_filter('tincidencia', array('id_usuario' => $config['id_user'], 'id_incidencia' => $id_incident));
$exists_as_creator = !empty($exists_as_creator);
if ($exists_as_creator) {
    $table->data[0][1] = '<span id="saving_in_progress" style="display: none;"><img src="images/spinner.gif" />' . __('Saving chat') . '</span>' . print_button(__("Save chat into workunit"), 'save', false, 'save_message()', 'class="sub save" style="width: 100%"', true);
}
$table->data[0][1] .= '<h4>' . __('Users Online') . '</h4>' . '<div id="userlist_box" style="width: 75% !important; height: 200px !important;
		height: 300px; background: #ffffff; border: 1px inset black;
		overflow: auto; padding: 10px;"></div>';
$table->data[1][0] = print_input_text('message_box', '', '', 100, 150, true);
$table->data[1][1] = print_button(__('Send'), 'send', false, 'send_message()', 'class="sub next" style="width: 100%"', true);
//$table->data[1][1] .= print_button(__("Save chat into workunit"), 'save', false, 'save_message()',
//	'class="sub next" style="width: 100%"', true);
print_table($table);
?>
<span id="chat_active" style="display: none;">1</span>
<script type="text/javascript">
Esempio n. 9
0
    $file_description = get_parameter("file_description");
    $result = array();
    $result["status"] = false;
    $result["message"] = "";
    $result['status'] = (bool) process_sql_update('tattachment', array('description' => $file_description), array('id_attachment' => $id_file));
    if (!$result['status']) {
        $result['message'] = __('Description not updated');
    }
    echo json_encode($result);
    return;
}
$get_file_row = (bool) get_parameter("get_file_row");
if ($get_file_row) {
    $id_file = (int) get_parameter("id_attachment");
    $id_invoice = (int) get_parameter("id");
    $file = get_db_row_filter('tattachment', array('id_invoice' => $id_invoice, 'id_attachment' => $id_file));
    $html = "";
    if ($file) {
        $link = "operation/common/download_file.php?id_attachment=" . $file["id_attachment"] . "&type=company";
        $real_filename = $config["homedir"] . "/attachment/" . $file["id_attachment"] . "_" . rawurlencode($file["filename"]);
        $html .= "<tr>";
        $html .= "<td valign=top>";
        $html .= '<a target="_blank" href="' . $link . '">' . $file['filename'] . '</a>';
        $stat = stat($real_filename);
        $html .= "<td valign=top class=f9>" . $file["description"];
        //$html .= "<td valign=top>". $file["id_usuario"];
        $html .= "<td valign=top>" . byte_convert($file['size']);
        $html .= "<td valign=top class=f9>" . date("Y-m-d", $stat['mtime']);
        // Delete attachment
        if (give_acl($config['id_user'], $incident['id_grupo'], 'IM')) {
            $html .= "<td>" . '<a class="delete" name="delete_file_' . $file["id_attachment"] . '" href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $id . '&tab=files&id_attachment=' . $file["id_attachment"] . '&delete_file=1#incident-operations">
	if ($id_field) {
		echo "<div id='button-bar-title'><ul>";
			echo "<li><a href='index.php?sec=customers&sec2=operation/contracts/contract_custom_fields'>".print_image ("images/flecha_volver.png", true, array("title" => __("Back")))."</a></li>";
		echo "</ul></div>";
	}
echo "</h4>";
		
$contract_fields = get_db_all_rows_sql ("SELECT * FROM tcontract_field");

if ($contract_fields === false) {
	$contract_fields = array ();
}

$id_field = get_parameter ('id_field');
if ($id_field) {
	$field_data   = get_db_row_filter('tcontract_field', array('id' => $id_field));
	$label        = $field_data['label'];
	$type 	      = $field_data['type'];
	$combo_value  = $field_data['combo_value'];
	$parent       = $field_data['parent'];
	$linked_value = $field_data['linked_value'];
	$show_in_list = $field_data['show_in_list'];
}

$table = new StdClass();
$table->width = "100%";
$table->class = "search-table";
$table->data = array ();

$table->data[0][0] = print_input_text ('label', $label, '', 45, 100, true, __('Field name'));
$types = array('text' =>__('Text'), 'textarea' => __('Textarea'), 'combo' => __('Combo'), 'linked' => __('Linked'), 'numeric' => __('Numeric'), 'date' => __('Date'));
Esempio n. 11
0
		$result['status'] = (bool) process_sql_update('tattachment',
			array('description' => $file_description), array('id_attachment' => $id_file));

		if (!$result['status'])
			$result['message'] = __('Description not updated');

		echo json_encode($result);
		return;
	}

	$get_file_row = (bool) get_parameter("get_file_row");
	if ($get_file_row) {
		$id_file = (int) get_parameter("id_attachment");
		
		$file = get_db_row_filter ('tattachment', array('id_contact' => $id, 'id_attachment' => $id_file));

		$html = "";
		if ($file) {
			$link = "operation/common/download_file.php?id_attachment=".$file["id_attachment"]."&type=contact";
			$real_filename = $config["homedir"]."/attachment/".$file["id_attachment"]."_".rawurlencode ($file["filename"]);    

			$html .= "<tr>";
			$html .= "<td valign=top>";
			$html .= '<a target="_blank" href="'.$link.'">'. $file['filename'].'</a>';

			$stat = stat ($real_filename);
			$html .= "<td valign=top class=f9>".date ("Y-m-d H:i:s", $stat['mtime']);

			$html .= "<td valign=top class=f9>". $file["description"];
			//$html .= "<td valign=top>". $file["id_usuario"];
Esempio n. 12
0
function users_save_text_message($message = false, $type = 'message')
{
    global $config;
    global $dir;
    global $id;
    $file_global_counter_chat = $dir . '/incident.' . $id . '.global_counter.txt';
    $log_chat_file = $dir . '/incident.' . $id . '.log.json.txt';
    $return = array('correct' => false);
    $id_user = $config['id_user'];
    $user = get_db_row_filter('tusuario', array('id_usuario' => $id_user));
    $message_data = array();
    $message_data['type'] = $type;
    $message_data['id_user'] = $id_user;
    $message_data['user_name'] = $user['nombre_real'];
    $message_data['text'] = safe_input_html($message);
    //The $message_data['timestamp'] set when adquire the files to save.
    //First lock the file
    $fp_global_counter = @fopen($file_global_counter_chat, "a+");
    if ($fp_global_counter === false) {
        echo json_encode($return);
        return;
    }
    //Try to look MAX_TIMES times
    $tries = 0;
    while (!flock($fp_global_counter, LOCK_EX)) {
        $tries++;
        if ($tries > MAX_TIMES) {
            echo json_encode($return);
            return;
        }
        sleep(1);
    }
    @fscanf($fp_global_counter, "%d", $global_counter_file);
    if (empty($global_counter_file)) {
        $global_counter_file = 0;
    }
    //Clean the file
    ftruncate($fp_global_counter, 0);
    $message_data['timestamp'] = time();
    $message_data['human_time'] = date($config['date_format'], $message_data['timestamp']);
    $global_counter = $global_counter_file + 1;
    $status = fwrite($fp_global_counter, $global_counter);
    if ($status === false) {
        fclose($fp_global_counter);
        echo json_encode($return);
        return;
    } else {
        $text_encode = @file_get_contents($log_chat_file);
        $log = json_decode($text_encode, true);
        $log[$global_counter] = $message_data;
        $status = file_put_contents($log_chat_file, json_encode($log));
        fclose($fp_global_counter);
        $return['correct'] = true;
        echo json_encode($return);
    }
    return;
}
Esempio n. 13
0
function integria_sendmail($to, $subject = "[INTEGRIA]", $body, $attachments = false, $code = "", $from = "", $remove_header_footer = 0, $cc = "", $extra_headers = "", $images = false)
{
    global $config;
    if ($to == '') {
        return false;
    }
    $to = trim(safe_output($to));
    $from = trim(safe_output($from));
    $cc = trim(safe_output($cc));
    $config["mail_from"] = trim($config["mail_from"]);
    $current_date = date("Y/m/d H:i:s");
    // We need to convert to pure ASCII here to use carriage returns
    // CAUTION: Do not safe_output($body. Data here SHOULD have HTML encoding in place
    // to avoid bad rendering of contents
    $subject = ascii_output($subject);
    if ($remove_header_footer == 0) {
        // Add global header and footer to mail
        $body = safe_output($config["HEADER_EMAIL"]) . "\r\n" . html_entity_decode($body) . "\r\n" . safe_output($config["FOOTER_EMAIL"]);
    }
    // Add custom code to the end of message subject (to put there ID's).
    if ($code != "") {
        $subject = "[{$code}] " . $subject;
        // $body = $body."\r\nNOTICE: Please don't alter the SUBJECT when answer to this mail, it contains a special code who makes reference to this issue.";
    }
    // This is a special scenario... we store all the information "ready" in the database,
    // without HTML encoding. THis is because it is not to be rendered on a browser,
    // it will be directly to a SMTP connection.
    //New check, if exist any data with same data, doesn't insert in DB.
    $check = array('recipient' => $to, 'body' => mysql_real_escape_string(safe_output($body)), 'attachment_list' => $attachments, 'from' => $from, 'cc' => $cc, 'image_list' => $images);
    $checked = get_db_row_filter('tpending_mail', $check, '*');
    if (!$checked) {
        $values = array('date' => $current_date, 'attempts' => 0, 'status' => 0, 'recipient' => $to, 'subject' => mysql_real_escape_string($subject), 'body' => mysql_real_escape_string(safe_output($body)), 'attachment_list' => $attachments, 'from' => $from, 'cc' => $cc, 'extra_headers' => $extra_headers, 'image_list' => $images);
        process_sql_insert('tpending_mail', $values);
    }
}
		
		$id_profile = get_parameter('id_profile');
		$id_task = get_parameter('id_task');
		$have_cost = get_parameter ("have_cost");
		$public = get_parameter('public');
		$keep_cost = get_parameter ("keep_cost");
		$keep_public = get_parameter('keep_public');
		
		$result_ids = explode(',', $ids);
		$result = '';
	
		foreach ($result_ids as $id) {

			$values = array();
			
			$wu_data = get_db_row_filter('tworkunit', array('id'=>$id));
			
			$values['id_profile'] = $id_profile;
			$values['have_cost'] = ($have_cost == "true") ? 1: 0;
			$values['public'] = ($public == "true") ? 1: 0;
			
			if ($id_profile == -1) { //No change option
				$values['id_profile'] = $wu_data['id_profile'];
			}
			if ($keep_cost == "true") {
				$values['have_cost'] = $wu_data['have_cost'];
			}
			if ($keep_public == "true") {
				$values['public'] = $wu_data['public'];
			}
			
	case "create":
		$label = "";
		$type = "numeric";
		$combo_value = "";
		$external_table_name = "";
		$external_reference_field = "";
		$parent_table_name = "";
		$parent_reference_field = "";
		$unique = 0;
		$inherit = 0;
		$show_list = 0;
		$not_allow_updates = 0;
		$external_label = "";
		break;
	case "update":
		$object_type_field = get_db_row_filter('tobject_type_field', array('id' => $id_object_type_field));
		$label = $object_type_field["label"];
		$type = $object_type_field["type"];
		$combo_value = $object_type_field["combo_value"];
		$external_table_name = $object_type_field["external_table_name"];
		$external_reference_field = $object_type_field["external_reference_field"];
		$parent_table_name = $object_type_field["parent_table_name"];
		$parent_reference_field = $object_type_field["parent_reference_field"];
		$unique = $object_type_field["unique"];
		$inherit = $object_type_field["inherit"];
		$show_list = $object_type_field["show_list"];
		$not_allow_updates = $object_type_field["not_allow_updates"];
		$external_label = $object_type_field["external_label"];
		break;			
}
Esempio n. 16
0
}
$id_incident_type = (int) get_parameter('id');
$add_field = (int) get_parameter('add_field');
$update_field = (int) get_parameter('update_field');
$id_field = (int) get_parameter('id_field');
$label = '';
$type = 'text';
$combo_value = '';
$linked_value = '';
$parent = '';
$show_in_list = false;
$global_field = false;
$add_linked_value = '';
if ($id_field) {
    $filter = array('id' => $id_field);
    $field_data = get_db_row_filter('tincident_type_field', $filter);
    if (!empty($field_data)) {
        $label = $field_data['label'];
        $type = $field_data['type'];
        $combo_value = $field_data['combo_value'];
        $show_in_list = (bool) $field_data['show_in_list'];
        $parent = $field_data['parent'];
        $linked_value = $field_data['linked_value'];
        $global_field = $field_data['global_id'];
    }
}
echo '<h1>' . __('Ticket fields management') . '</h1>';
$table->width = "99%";
$table->class = "search-table-button";
$table->data = array();
// Field name
	if ($id_field) {
		echo "<div id='button-bar-title'><ul>";
			echo "<li><a href='index.php?sec=customers&sec2=operation/companies/company_custom_fields'>".print_image ("images/flecha_volver.png", true, array("title" => __("Back")))."</a></li>";
		echo "</ul></div>";
	}
echo "</h4>";
		
$company_fields = get_db_all_rows_sql ("SELECT * FROM tcompany_field");

if ($company_fields === false) {
	$company_fields = array ();
}

$id_field = get_parameter ('id_field');
if ($id_field) {
	$field_data = get_db_row_filter('tcompany_field', array('id' => $id_field));
	$label = $field_data['label'];
	$type = $field_data['type'];
	$combo_value = $field_data['combo_value'];
	$parent = $field_data['parent'];
	$linked_value = $field_data['linked_value'];
}

$table = new StdClass();
$table->width = "100%";
$table->class = "search-table";
$table->data = array ();

$table->data[0][0] = print_input_text ('label', $label, '', 45, 100, true, __('Field name'));
$types = array('text' =>__('Text'), 'textarea' => __('Textarea'), 'combo' => __('Combo'), 'linked' => __('Linked'), 'numeric' => __('Numeric'), 'date' => __('Date'));
$table->data[1][0] = print_label (__("Type"), "label-id", 'text', true);