function drop_old_sla_table()
{
    echo "Deleting the table 'tincident_sla_graph'...\n";
    $sql = "DROP TABLE IF EXISTS tincident_sla_graph";
    process_sql($sql);
    echo "Deleting the table 'tincident_sla_graph'... DONE\n";
}
function workorders_insert_note($id, $user, $note, $date)
{
    $sql = sprintf('INSERT INTO ttodo_notes (`id_todo`,`written_by`,`description`, `creation`)
                                        VALUES (%d, "%s", "%s", "%s")', $id, $user, $note, $date);
    $res = process_sql($sql, 'insert_id');
    mail_workorder($id, 4, $res);
    return $res;
}
Example #3
0
function mysql_session_gc($maxlifetime = 300)
{
    global $config;
    if (isset($config['session_timeout'])) {
        $maxlifetime = $config['session_timeout'];
    }
    $CutoffTime = time() - $maxlifetime;
    $retval = process_sql("DELETE FROM tsessions_php \n\t\t\tWHERE last_active < {$CutoffTime}");
    return $retval;
}
		SET timestamp = "%s", duration = %.2f, description = "%s",
		have_cost = %d, id_profile = %d, public = %d, id_user = "******",
		work_home = %d 
		WHERE id = %d',
		$timestamp, $duration, $description, $have_cost,
		$id_profile, $public, $wu_user, $work_home, $id_workunit);
	$result = process_sql ($sql);

	if ($id_task !=0) {
	    // Old old association
	    process_sql ("DELETE FROM tworkunit_task WHERE id_workunit = $id_workunit");
	    // Create new one
            $sql = sprintf ('INSERT INTO tworkunit_task
                            (id_task, id_workunit) VALUES (%d, %d)',
                                        $id_task, $id_workunit);
            $result = process_sql ($sql, 'insert_id');
	}
	$result_output = ui_print_success_message (__('Workunit updated'), '', true, 'h3', true);
	audit_db ($config["id_user"], $config["REMOTE_ADDR"], "PWU", "Updated PWU. $description");
	
	if ($result !== false) {
		set_task_completion ($id_task);
	}
}

$multiple_wu_report = array();

if ($operation == 'multiple_wu_insert') {
	
	//Walk post array looking for 
	$i = 1;
Example #5
0
    if ($id_parent == 0) {
        $idParentValue = 'NULL';
    } else {
        $idParentValue = sprintf('%d', $id_parent);
    }
    // DONT use MySQL NOW() or UNIXTIME_NOW() because
    // Integria can override localtime zone by a user-specified timezone.
    $timestamp = print_mysql_timestamp();
    $sql = sprintf('INSERT INTO tincidencia
			(inicio, actualizacion, titulo, descripcion,
			id_usuario, estado, prioridad,
			id_grupo, id_creator, notify_email, id_task,
			resolution, id_incident_type, sla_disabled, email_copy, epilog)
			VALUES ("%s", "%s", "%s", "%s", "%s", %d, %d, %d, "%s",
			%d, %d, %d, %d, %d, "%s", "%s")', $timestamp, $timestamp, $title, $description, $id_user_responsible, $estado, $priority, $group_id, $id_creator, $email_notify, $id_task, $resolution, $id_incident_type, $sla_disabled, $email_copy, $epilog);
    $id = process_sql($sql, 'insert_id');
    if ($id !== false) {
        /* Update inventory objects in incident */
        update_incident_inventories($id, array($id_inventory));
        $result_msg = ui_print_success_message(__('Successfully created') . ' (id #' . $id . ')', '', true);
        $result_msg .= '<h4><a href="index.php?sec=incidents&sec2=operation/incidents_simple/incident&id=' . $id . '">' . __('Please click here to continue working with ticket #') . $id . "</a></h4>";
        audit_db($config["id_user"], $config["REMOTE_ADDR"], "Ticket created", "User " . $config['id_user'] . " created ticket #" . $id);
        incident_tracking($id, INCIDENT_CREATED);
        //Add traces and statistic information
        incidents_set_tracking($id, 'create', $priority, $estado, $resolution, $id_user_responsible, $group_id);
        // Email notify to all people involved in this incident
        if ($email_notify) {
            mail_incident($id, $id_user_responsible, "", 0, 1);
        }
        //insert data to incident type fields
        if ($id_incident_type > 0) {
function calendar_get_users_holidays_date_range($start, $end, $id_user)
{
    $mysql_start = date('Y-m-d', $start);
    $mysql_end = date('Y-m-d', $end);
    $user_clause = "";
    if (is_array($id_user)) {
        $aux_ids = array();
        foreach ($id_user as $iu) {
            array_push($aux_ids, "'" . $iu . "'");
        }
        $user_clause = "id_user IN (" . join(",", $aux_ids) . ")";
    } else {
        $user_clause = "id_user = '******'";
    }
    $sql = sprintf("SELECT tworkunit.timestamp AS date, tworkunit.id_user as user FROM tworkunit, tworkunit_task WHERE \n\t\t\t\t\t{$user_clause} AND tworkunit_task.id_workunit = tworkunit.id AND tworkunit_task.id_task =-1 AND \n\t\t\t\t\ttimestamp >= '{$mysql_start}' AND timestamp <= '{$mysql_end}' ORDER BY date ASC");
    $res = process_sql($sql);
    if (!$res) {
        $res = array();
    }
    $holidays = array();
    $holidays_counters = array();
    $holidays_last_day = array();
    foreach ($res as $r) {
        if (!isset($holidays[$r["user"]])) {
            $holidays[$r["user"]] = array();
            $holidays_counters[$r["user"]] = -1;
            $holidays_last_day[$r["user"]] = 0;
        }
        //Calculate start and end for the holiday value
        if (isset($holidays_last_day[$r["user"]])) {
            //Last day minus current day is 1 we increase dates for stored holidays
            $last_time = strtotime($holidays_last_day[$r["user"]]);
            $current_time = strtotime($r["date"]);
            $day_in_seconds = 24 * 3600;
            if ($current_time - $last_time <= $day_in_seconds) {
                $pos = $holidays_counters[$r["user"]];
                $holidays[$r["user"]][$pos]["end"] = strtotime($r["date"]);
                $holidays_last_day[$r["user"]] = strtotime($r["date"]);
            } else {
                array_push($holidays[$r["user"]], array("start" => strtotime($r["date"]), "end" => strtotime($r["date"])));
                $holidays_last_day[$r["user"]] = $r["date"];
                $holidays_counters[$r["user"]]++;
            }
        }
        //Update last day
        $holidays_last_day[$r["user"]] = $r["date"];
    }
    $full_holidays = array();
    $colors = array("#aa3333", "#33aa33", "#3a3a3a", "#3333aa", "#045FB4", "#DF7401", "#01DF3A", "#BE81F7", "#8181F7", "#81BEF7", "#F781F3", "#F7D358", "#F78181", "#FA8258", "#BCF5A9", "#A9A9F5", "#D0A9F5", "#E2A9F3", "#A9F5D0", "#A9F5E1", "#BDBDBD", "#E6E6E6", "#F6CECE", "#6AA4B2", "#6AB277", "#B28E6A", "#B26A97", "#776AB2", "#A58EB4", "#8EB490", "#8E96B4", "#B48E98");
    $i = 0;
    $colors_size = count($colors);
    foreach ($holidays as $key => $values) {
        $i = $i % $colors_size;
        $name = get_db_value("nombre_real", "tusuario", "id_usuario", $key);
        $url = "index.php?sec=users&sec2=operation/user_report/holidays_calendar&custom_dates=1&id_user="******"name" => safe_output($name), "dates" => $values, "bgColor" => $colors[$i], "link" => $url));
        $i++;
    }
    return $full_holidays;
}
Example #7
0
    } 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>";
                }
            }
        }
    }
}
// ---------------------
// Edition / View mode
// ---------------------
function um_component_is_blacklisted($component, $name)
{
    global $config;
    switch ($config["dbtype"]) {
        case "mysql":
            $result = process_sql('SELECT COUNT(*) AS blacklisted FROM ' . DB_PREFIX . 'tupdate_component_blacklist WHERE component = "' . $component->name . '" AND name = "' . $name . '"');
            break;
        case "postgresql":
        case "oracle":
            $result = process_sql('SELECT COUNT(*) AS blacklisted
				FROM ' . DB_PREFIX . 'tupdate_component_blacklist
				WHERE component = \'' . $component->name . '\' AND name = \'' . $name . '\'');
            break;
    }
    if ($result === false) {
        echo '<strong>Error getting blacklist item</strong> <br />';
        return false;
    }
    $retval = um_std_from_result($result);
    return $retval->blacklisted ? true : false;
}
Example #9
0
 public function deleteWorkOrder($id_workorder)
 {
     $result = process_sql("DELETE FROM ttodo WHERE id = {$id_workorder}");
     if ($result) {
         return true;
     }
     return false;
 }
function sql_insert($table, $values)
{
    //Empty rows or values not processed
    if (empty($values)) {
        return false;
    }
    $values = (array) $values;
    $query = sprintf("INSERT INTO `%s` ", $table);
    $fields = array();
    $values_str = '';
    $i = 1;
    $max = count($values);
    foreach ($values as $field => $value) {
        //Add the correct escaping to values
        if ($field[0] != "`") {
            $field = "`" . $field . "`";
        }
        array_push($fields, $field);
        if (is_null($value)) {
            $values_str .= "NULL";
        } elseif (is_int($value) || is_bool($value)) {
            $values_str .= sprintf("%d", $value);
        } else {
            if (is_float($value) || is_double($value)) {
                $values_str .= sprintf("%f", $value);
            } else {
                $values_str .= sprintf("'%s'", $value);
            }
        }
        if ($i < $max) {
            $values_str .= ",";
        }
        $i++;
    }
    $query .= '(' . implode(', ', $fields) . ')';
    $query .= ' VALUES (' . $values_str . ')';
    return process_sql($query, 'insert_id');
}
Example #11
0
}

// ---------------
// Set progress
// ---------------

if ($set_progress > -1 ) {
	$todo = get_db_row ("ttodo", "id", get_parameter ("id"));

	if (! get_workorder_acl($todo["id"])) {
		no_permission();
	}
	
	$datetime = date ("Y-m-d H:i:s");
	$sql_update = "UPDATE ttodo SET progress = $set_progress, last_update = '$datetime' WHERE id = ".$todo["id"];
	$result = process_sql($sql_update);
}

// ---------------
// CREATE new todo (form)
// ---------------

if ($operation == "create" || $operation == "update" || $operation == "view")  {
	if ($operation == "create") {
		echo "<h2>".__('New Work order')."</h2><h4>".__('Add work')."</h4>";
		
		$progress = 0;
		$priority = 2;
		$name = '';
		$description = '';
		$creator = $config["id_user"];
Example #12
0
function user_search_result($filter, $ajax, $size_page, $offset, $clickin, $search_text, $disabled_user, $level, $group, $from_tickets = false)
{
    global $config;
    if ($filter != 0) {
        $offset = $filter['offset'];
        $search_text = $filter['search_text'];
        $disabled_user = $filter['disabled_user'];
        $level = $filter['level'];
        $group = $filter['group'];
    }
    $search = "WHERE 1=1 ";
    if ($search_text != "") {
        $search .= " AND (id_usuario LIKE '%{$search_text}%' OR comentarios LIKE '%{$search_text}%' OR nombre_real LIKE '%{$search_text}%' OR direccion LIKE '%{$search_text}%')";
    }
    if ($disabled_user > -1) {
        $search .= " AND disabled = {$disabled_user}";
    }
    if ($level > -10) {
        $search .= " AND nivel = {$level}";
    }
    if ($group == -1) {
        $search .= " AND tusuario.id_usuario NOT IN (select id_usuario from tusuario_perfil)";
    } else {
        if ($group > 0) {
            $search .= " AND tusuario.id_usuario = ANY (SELECT id_usuario FROM tusuario_perfil WHERE id_grupo = {$group})";
        }
    }
    $query1 = "SELECT * FROM tusuario {$search} ORDER BY id_usuario";
    if ($from_tickets) {
        $query1 = users_get_allowed_users_query($config['id_user'], $filter);
    }
    $count = get_db_sql("SELECT COUNT(id_usuario) FROM tusuario {$search} ");
    $sql1 = "{$query1} LIMIT {$offset}, " . $size_page;
    echo "<div class='divresult'>";
    pagination($count, "index.php?sec=users&sec2=godmode/usuarios/lista_usuarios&search_text=" . $search_text . "&disabled_user="******"&level=" . $level . "&group=" . $group, $offset, true);
    $resq1 = process_sql($sql1);
    if (!$resq1) {
        echo ui_print_error_message(__("No users"), '', true, 'h3', true);
    } else {
        echo '<table width="100%" class="listing">';
        if ($filter == 0) {
            echo '<th>' . print_checkbox('all_user_checkbox', 1, false, true);
            echo '<th title="' . __('Enabled/Disabled') . '">' . __('E/D');
            echo '<th title="' . __('Enabled login') . '">' . __('Enabled login');
        }
        echo '<th>' . __('User ID');
        echo '<th>' . __('Name');
        echo '<th>' . __('Company');
        echo '<th>' . __('Last contact');
        echo '<th>' . __('Profile');
        if ($filter == 0) {
            echo '<th>' . __('Delete');
        }
        // Init vars
        $nombre = "";
        $nivel = "";
        $comentarios = "";
        $fecha_registro = "";
        if ($resq1) {
            foreach ($resq1 as $rowdup) {
                $nombre = $rowdup["id_usuario"];
                $nivel = $rowdup["nivel"];
                $realname = $rowdup["nombre_real"];
                $fecha_registro = $rowdup["fecha_registro"];
                $avatar = $rowdup["avatar"];
                if ($rowdup["nivel"] == 0) {
                    $nivel = "<img src='images/group.png' title='" . __("Grouped user") . "'>";
                } elseif ($rowdup["nivel"] == 1) {
                    $nivel = "<img src='images/integria_mini_logo.png' title='" . __("Administrator") . "'>";
                } else {
                    $nivel = "<img src='images/user_gray.png' title='" . __("Standalone user") . "'>";
                }
                $disabled = $rowdup["disabled"];
                $id_company = $rowdup["id_company"];
                $enabled_login = $rowdup["enable_login"];
                echo "<tr>";
                if ($filter == 0) {
                    echo "<td>";
                    echo print_checkbox_extended("user-" . $rowdup["id_usuario"], $rowdup["id_usuario"], false, false, "", "class='user_checkbox'", true);
                    echo "<td>";
                    if ($disabled == 1) {
                        echo "<img src='images/lightbulb_off.png' title='" . __("Disabled") . "'> ";
                    }
                    echo "<td>";
                    if ($enabled_login == 1) {
                        echo "<img src='images/accept.png' title='" . __("Enabled login") . "'> ";
                    } else {
                        echo "<img src='images/fail.png' title='" . __("Disabled login") . "'> ";
                    }
                }
                echo "<td>";
                if ($filter == 0) {
                    echo "<a href='index.php?sec=users&sec2=godmode/usuarios/configurar_usuarios&update_user="******"'>" . ucfirst($nombre) . "</a>";
                } else {
                    $url = "javascript:loadContactUser(\"" . $nombre . "\",\"" . $clickin . "\");";
                    echo "<a href='" . $url . "'>" . ucfirst($nombre) . "</a>";
                }
                echo "<td style=''>" . $realname;
                $company_name = (string) get_db_value('name', 'tcompany', 'id', $id_company);
                echo "<td>" . $company_name . "</td>";
                echo "<td style=''>" . human_time_comparation($fecha_registro);
                echo "<td>";
                print_user_avatar($nombre, true);
                echo "&nbsp;";
                if ($config["enteprise"] == 1) {
                    $sql1 = 'SELECT * FROM tusuario_perfil WHERE id_usuario = "' . $nombre . '"';
                    $result = mysql_query($sql1);
                    echo "<a href='#' class='tip'>&nbsp;<span>";
                    if (mysql_num_rows($result)) {
                        while ($row = mysql_fetch_array($result)) {
                            echo dame_perfil($row["id_perfil"]) . "/ ";
                            echo dame_grupo($row["id_grupo"]) . "<br>";
                        }
                    } else {
                        echo __('This user doesn\'t have any assigned profile/group');
                    }
                    echo "</span></a>";
                }
                echo $nivel;
                if ($filter == 0) {
                    echo '<td align="center">';
                    echo '<a href="index.php?sec=users&sec2=godmode/usuarios/lista_usuarios&borrar_usuario=' . $nombre . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) return false;"><img src="images/cross.png"></a>';
                    echo '</td>';
                }
            }
        }
        echo "</table>";
    }
    echo "</div>";
}
Example #13
0
		// Todo: Delete the invoice files from disk
		if ($invoice["id_attachment"] != ""){
			process_sql ("DELETE FROM tattachment WHERE id_attachment = ". $invoice["id_attachment"]);
		}
		$res = process_sql ("DELETE FROM tinvoice WHERE id = $id_invoice");
		if ($res > 0) {
			$company_name = get_db_value('name', 'tcompany', 'id', $invoice['id_company']);
			audit_db ($config["id_user"], $config["REMOTE_ADDR"], "Invoice deleted", "Invoice Bill ID: ".$invoice['bill_id'].", Company: $company_name");
			
			//update last activity
			$datetime =  date ("Y-m-d H:i:s");
			$comments = __("Invoice deleted by ".$config['id_user']);
			$sql_add = sprintf ('INSERT INTO tcompany_activity (id_company, written_by, date, description) VALUES (%d, "%s", "%s", "%s")', $invoice['id_company'], $config["id_user"], $datetime, $comments);
			process_sql ($sql_add);
			$sql_activity = sprintf ('UPDATE tcompany SET last_update = "%s" WHERE id = %d', $datetime, $invoice['id_company']);
			$result_activity = process_sql ($sql_activity);
		}
	}
}

// Lock/Unlock INVOICE
// ----------------
if ($lock_invoice == 1 && $id_invoice) {
	
	$locked = crm_is_invoice_locked ($id_invoice);
	$res = crm_change_invoice_lock ($config["id_user"], $id_invoice);
	
	if ($res === -1) { // -1 equals to false permission to lock or unlock the invoice
		audit_db ($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to lock/unlock an invoice");
		include ("general/noaccess.php");
		exit;
Example #14
0
/**
 * This function returns an array with the descendants ids of the
 * company id passed as an argument.
 */
function get_company_descendants($id_company)
{
    global $config;
    $text_id_companies = "";
    $id_companies = array();
    if (is_array($id_company)) {
        for ($i = 0; $i < count($id_company); $i++) {
            $text_id_companies .= $id_company[$i];
            if ($i < count($id_company) - 1) {
                $text_id_companies .= ", ";
            }
        }
    } else {
        $text_id_companies .= $id_company;
    }
    $sql = "SELECT id FROM tcompany WHERE id_parent IN (" . $text_id_companies . ")";
    $result = process_sql($sql);
    foreach ($result as $row) {
        $id_companies[] = $row['id'];
    }
    if (count($id_companies) >= 1) {
        $id_companies = array_merge($id_companies, get_company_descendants($id_companies));
    }
    return $id_companies;
}
Example #15
0
/**
 * This function deletes tevent workflow data with more than X days.
 */
function delete_old_workflow_event_data()
{
    global $config;
    $DELETE_DAYS = (int) $config["max_days_workflow_events"];
    if ($DELETE_DAYS > 0) {
        $limit = date("Y/m/d H:i:s", strtotime("now") - $DELETE_DAYS * 86400);
        $sql = "DELETE FROM tevent WHERE timestamp < '{$limit}'\n\t\t\tAND `type` LIKE '%WORKFLOW%'";
        process_sql($sql);
    }
}
Example #16
0
	private function showIncidents ($message = "") {
		
		$system = System::getInstance();
		$ui = Ui::getInstance();
		
		$ui->createPage();
		
		$back_href = 'index.php?page=home';
		$ui->createDefaultHeader(__("Tickets"),
			$ui->createHeaderButton(
				array('icon' => 'back',
					'pos' => 'left',
					'text' => __('Back'),
					'href' => $back_href)));
		$ui->beginContent();
			
			// Message popup
			if ($message != "") {
				$options = array(
					'popup_id' => 'message_popup',
					'popup_custom' => true,
					'popup_content' => $message
					);
				$ui->addPopup($options);
				$ui->contentAddHtml("<script type=\"text/javascript\">
										$(document).on('pageshow', function() {
											$(\"div.popup-back\")
												.click(function (e) {
													e.preventDefault();
													$(this).remove();
												})
												.show();
										});
									</script>");
			}
			
			$ui->contentBeginCollapsible(__('Filter'));
				$options = array(
					'action' => "index.php?page=incidents",
					'method' => 'POST',
					'data-ajax' => 'false'
					);
				$ui->beginForm($options);
					// Filter search
					$options = array(
						'name' => 'filter_search',
						'label' => __('Search'),
						'value' => $this->filter_search
						);
					$ui->formAddInputSearch($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'),
						'label' => __('Status'),
						'items' => $values,
						'selected' => $this->filter_status
						);
					$ui->formAddSelectBox($options);
					// Filter owner
					$options = array(
						'name' => 'filter_owner',
						'id' => 'text-filter_owner',
						'label' => __('Owner'),
						'value' => $this->filter_owner,
						'placeholder' => __('Owner'),
						'autocomplete' => 'off'
						);
					$ui->formAddInputText($options);
						// Owner autocompletion
						// List
						$ui->formAddHtml("<ul id=\"ul-autocomplete_owner\" data-role=\"listview\" data-inset=\"true\"></ul>");
						// Autocomplete binding
						$ui->bindMobileAutocomplete("#text-filter_owner", "#ul-autocomplete_owner");
					$options = array(
						'name' => 'submit_button',
						'text' => __('Apply filter'),
						'data-icon' => 'search'
						);
					$ui->formAddSubmitButton($options);
				$form_html = $ui->getEndForm();
			$ui->contentCollapsibleAddItem($form_html);
			$ui->contentEndCollapsible("collapsible-filter", "d");
			// Incidents listing
			$html = $this->getIncidentsList();
			$ui->contentAddHtml($html);
			if ($this->getCountIncidents() > $system->getPageSize()) {
				$ui->contentAddHtml('<div style="text-align:center;" id="loading_rows">
										<img src="../images/spinner.gif">&nbsp;'
											. __('Loading...') .
										'</img>
									</div>');
				$this->addIncidentsLoader();
			}
		$ui->endContent();
		// Foooter buttons
		// New
		$button_new = "<a href='index.php?page=incident' data-role='button'
							data-ajax='false' data-icon='plus'>".__('New')."</a>\n";
		// Pagination
		// $filter = "";
		// if ($this->filter_search != '') {
		// 	$filter .= "&filter_search=".$this->filter_search;
		// }
		// if ($this->filter_status) {
		// 	$filter .= "&filter_status=".$this->filter_status;
		// }
		// if ($this->filter_owner != '') {
		// 	$filter .= "&filter_owner=".$this->filter_owner;
		// }
		// $paginationCG = $ui->getPaginationControgroup("incidents$filter", $this->offset, $this->getNumPages());
		$ui->createFooter($button_new);
		$ui->showFooter();
		$ui->showPage();
	}
Example #17
0
                    if (!$result2) {
                        echo "<h3 class='error'>" . __('An error ocurred setting the permissions for the task ' . $data) . "</h3>";
                    }
                } else {
                    echo "<h3 class='error'>" . __('The task ' . $data . ' could not be created') . "</h3>";
                }
            }
        }
    }
}
$project_name = get_db_value("name", "tproject", "id", $id_project);
echo "<h1>" . __("Task planning") . " &raquo; {$project_name}</h1>";
//Calculate task summary stats!
//Draw task status statistics by hand!
$sql = sprintf("SELECT id, completion FROM ttask WHERE id_project = %d", $id_project);
$res = process_sql($sql);
if (empty($res)) {
    $res = array();
}
$verified = 0;
$completed = 0;
$in_process = 0;
$pending = 0;
foreach ($res as $r) {
    if ($r['completion'] < 40) {
        $pending++;
    } else {
        if ($r['completion'] < 90) {
            $in_process++;
        } else {
            if ($r['completion'] < 100) {
	if ($ku["user"]) {
		if (isset($key_users_info[$ku["user"]])) {
				$key_users_info[$ku["user"]] .= ", ".$ku["role"];
		} else {
				$key_users_info[$ku["user"]] = $ku["role"];
		}
	}
}

//Get all users with a workunit in the incident

$sql = sprintf("SELECT W.id_user FROM tworkunit W, tworkunit_incident WI  
                WHERE W.id = WI.id_workunit AND WI.id_incident = %d", $id_incident);

$wu_users = process_sql($sql);

foreach ($wu_users as $wu) {
	if (!isset($key_users_info[$wu["id_user"]])) {
		$key_users_info[$wu["id_user"]] = __("Participant");
	}
}

$incident_contacts = array();	

foreach ($inventories as $inventory) {
	$contacts = get_inventory_contacts ($inventory['id'], false);
	
	foreach ($contacts as $contact) {
		$data = array ();
Example #19
0
function combo_download_categories($id_category, $show_any = false, $label = false, $return = false)
{
    global $config;
    enterprise_include('include/functions_form.php');
    $result = enterprise_hook('combo_download_categories_extra', array($id_category, $show_any, $label, true));
    if ($result === ENTERPRISE_NOT_HOOK) {
        $sql = "SELECT * FROM tdownload_category ORDER BY 2";
        $result = process_sql($sql);
        if ($result == false) {
            $result = array();
        }
        $categories = array();
        foreach ($result as $row) {
            if (give_acl($config["id_user"], $row["id_group"], "KR")) {
                $categories[$row["id"]] = $row["name"];
            }
        }
        if ($show_any) {
            $nothing = __('Any');
        } else {
            $nothing = '';
        }
        if ($label) {
            $label = __('Category');
        } else {
            $label = false;
        }
        $result = print_select($categories, 'id_category', $id_category, '', $nothing, 0, $return, 0, false, $label);
    }
    if ($return) {
        return $result;
    } else {
        echo $result;
    }
}
Example #20
0
echo "<div class='divresult'>";
pagination($total_events, "index.php?sec=godmode&sec2=godmode/setup/audit&text={$text}&action={$action}", $offset);
$table = new StdClass();
$table->width = '100%';
$table->class = 'listing';
$table->head = array();
$table->head[0] = __('Accion');
$table->head[1] = __('User');
$table->head[2] = __('IP');
$table->head[3] = __('Description');
$table->head[4] = __('Extra info');
$table->head[5] = __('Timestamp');
$table->data = array();
$sql = sprintf('SELECT * FROM tsesion %s
	ORDER by utimestamp DESC LIMIT %d OFFSET %d', $where, $config["block_size"], $offset);
$events = process_sql($sql);
if ($events === false) {
    $events = array();
}
foreach ($events as $event) {
    $data = array();
    $data[0] = $event["accion"];
    $data[1] = $event["ID_usuario"];
    $data[2] = $event["IP_origen"];
    $data[3] = $event["descripcion"];
    $data[4] = $event["extra_info"];
    $data[5] = $event["fecha"];
    array_push($table->data, $data);
}
print_table($table);
echo "</div>";
Example #21
0
		echo ui_print_success_message (__("Successfully deleted"), '', true, 'h3', true);

	}
}

// Upload file
if (isset($_GET["upload"])) {
	
	if (isset($_POST['upfile']) && ( $_POST['upfile'] != "" )){ //if file
		$filename= $_POST['upfile'];
		$file_tmp = sys_get_temp_dir().'/'.$filename;
		$size = filesize ($file_tmp);
		$description = get_parameter ("description", "");

		$sql = sprintf("INSERT INTO tattachment (id_lead, id_usuario, filename, description, timestamp, size) VALUES (%d, '%s', '%s', '%s', '%s', %d)", $id, $config["id_user"], $filename, $description, date('Y-m-d H:i:s'), $size);
		$id_attach = process_sql ($sql, 'insert_id');

		$filename_encoded = $id_attach . "_" . $filename;
		
		// Copy file to directory and change name
		$file_target = $config["homedir"]."/attachment/".$filename_encoded;

		if (!(copy($file_tmp, $file_target))){
			echo ui_print_error_message (__("Could not be attached"), '', true, 'h3', true);
		} else {
			// Delete temporal file
			echo ui_print_success_message (__("Successfully attached"), '', true, 'h3', true);
			$location = $file_target;
			unlink ($file_tmp);
		}
Example #22
0
     $config["enable_pass_policy"] = get_parameter("enable_pass_policy", 0);
     $config["pass_size"] = get_parameter("pass_size", 4);
     $config["pass_needs_numbers"] = get_parameter("pass_needs_numbers", 0);
     $config["pass_needs_symbols"] = get_parameter("pass_needs_symbols", 0);
     $config["pass_expire"] = get_parameter("pass_expire", 0);
     $config["first_login"] = get_parameter("first_login", 1);
     $config["mins_fail_pass"] = get_parameter("mins_fail_pass", 5);
     $config["number_attempts"] = get_parameter("number_attempts", 5);
 }
 update_config_token("timezone", $config["timezone"]);
 //TODO: Change all "process_sqlxxx" for update_config_token in following code:
 update_config_token("language_code", $config["language_code"]);
 update_config_token("sitename", $config["sitename"]);
 update_config_token("max_file_size", $config["max_file_size"]);
 process_sql("DELETE FROM tconfig WHERE token = 'incident_reporter'");
 process_sql("INSERT INTO tconfig (token, value) VALUES ('incident_reporter', '" . $config["incident_reporter"] . "')");
 update_config_token("api_acl", $config["api_acl"]);
 update_config_token("api_password", $config["api_password"]);
 update_config_token("error_log", $config["error_log"]);
 update_config_token("first_day_week", $config["first_day_week"]);
 update_config_token("access_protocol", $config["access_protocol"]);
 update_config_token("access_port", $config["access_port"]);
 update_config_token("url_updatemanager", $config["url_updatemanager"]);
 update_config_token("access_public", $config["access_public"]);
 update_config_token("loginhash_pwd", $config["loginhash_pwd"]);
 update_config_token("csv_standard_encoding", $config["csv_standard_encoding"]);
 update_config_token("enable_update_manager", $config["enable_update_manager"]);
 update_config_token("max_direct_download", $config["max_direct_download"]);
 if ($is_enterprise) {
     update_config_token("enable_pass_policy", $config["enable_pass_policy"]);
     update_config_token("pass_size", $config["pass_size"]);
Example #23
0
function graph_ticket_activity_calendar($incidents)
{
    global $config;
    // Iterates through the incidents array to fill the incidents ids array
    $incidents_ids = array();
    foreach ($incidents as $incident) {
        $incidents_ids[] = $incident['id_incidencia'];
    }
    if (empty($incidents_ids)) {
        $ids = 0;
    } else {
        $ids = implode(",", $incidents_ids);
    }
    $sql = "SELECT COUNT(id_it) AS num, DATE(timestamp) AS date\n\t\t\tFROM tincident_track\n\t\t\tWHERE id_incident IN ({$ids})\n\t\t\tGROUP BY date\n\t\t\tORDER BY date ASC";
    $track_data = process_sql($sql);
    // Iterates through the track data array to get their max value
    $max_value = 0;
    foreach ($track_data as $key => $value) {
        if ($value['num'] > $max_value) {
            $max_value = $value['num'];
        }
    }
    // Iterates through the incidents array and fill the incidents ids array passed by reference
    $data = array();
    foreach ($track_data as $key => $value) {
        $data[$value['date']] = $value['num'] * 100 / $max_value;
    }
    $output = "";
    $date_start = $track_data[0]['date'];
    end($track_data);
    $last_key = key($track_data);
    $date_end = $track_data[$last_key]['date'];
    $datetime1 = date_create($date_start);
    $datetime2 = date_create($date_end);
    $interval = date_diff($datetime1, $datetime2);
    if ($interval->y > 0 && ($interval->m > 0 || $interval->d > 0)) {
        $udate_start = strtotime($date_start);
        $udate_end = strtotime($date_end);
        $year_start = date('Y', $udate_start);
        $year_end = date('Y', $udate_end);
        for ($i = $year_start; $i <= $year_end; $i++) {
            if ($i == $year_start) {
                $output .= print_activity_calendar($data, $date_start, $year_start . "-12-31", true);
            } elseif ($i == $year_end) {
                $output .= print_activity_calendar($data, $year_end . "-01-01", $date_end, true);
            } else {
                $output .= print_activity_calendar($data, $i . "-01-01", $i . "-12-31", true);
            }
        }
    } else {
        $output .= print_activity_calendar($data, $date_start, $date_end, true);
    }
    return $output;
}
Example #24
0
		default_company = %d, welcome_email = "%s", email_queue = "%s", 
		default_profile = %d, nivel = %d, id_incident_type = %d, email_from = "%s", email_group = "%s"
		WHERE id_grupo = %d', $parent, $name, $icon, $forced_email, $banner, $id_user_default, $soft_limit, $hard_limit, $enforce_soft_limit, $id_sla, $id_inventory, $autocreate_user, $grant_access, $send_welcome, $default_company, $welcome_email, $email_queue, $default_profile, $user_level, $incident_type, $email_from, $email_group, $id);
    $result = process_sql($sql);
    if ($result === false) {
        echo '<h3 class="error">' . __('There was a problem modifying group') . '</h3>';
    } else {
        audit_db($config["id_user"], $config["REMOTE_ADDR"], "Group management", "Modified group now called '{$name}'");
        echo '<h3 class="suc">' . __('Successfully updated') . '</h3>';
    }
}
// Delete group
if ($delete_group) {
    $name = get_db_sql("SELECT nombre FROM tgrupo WHERE id_grupo = {$id}");
    $sql = sprintf('DELETE FROM tgrupo WHERE id_grupo = %d', $id);
    $result = process_sql($sql);
    if ($result === false) {
        echo '<h3 class="error">' . __('There was a problem deleting group') . '</h3>';
    } else {
        audit_db($config["id_user"], $config["REMOTE_ADDR"], "Group management", "Deleted group '{$name}'");
        echo '<h3 class="suc">' . __('Successfully deleted') . '</h3>';
    }
}
$offset = get_parameter("offset", 0);
$search_text = get_parameter("search_text", "");
echo "<table class='search-table' style='width: 99%;'><form name='bskd' method=post action='index.php?sec=users&sec2=godmode/grupos/lista_grupos'>";
echo "<td>";
echo "<b>" . __('Search text') . "</b>&nbsp;&nbsp;";
print_input_text("search_text", $search_text, '', 40, 0, false);
echo "</td>";
echo "<td>";
Example #25
0
    no_permission();
}
// MAIN LIST OF PROJECTS GROUPS
echo "<h1>" . __("Projects overview") . "</h1>";
// -------------
// Show headers
// -------------
echo "<table width='99%' class='listing'>";
echo "<tr>";
echo "<th>" . __("Project group");
echo "<th>" . __("Icon");
echo "<th>" . __("# Projects");
// -------------
// Show DATA TABLE
// -------------
$project_groups = process_sql("SELECT * FROM tproject_group ORDER by name");
if ($project_groups === false) {
    $project_groups = array();
}
$nogroup = array();
$nogroup["id"] = 0;
$nogroup["name"] = __('Without group');
$nogroup["icon"] = '../group.png';
$project_groups[] = $nogroup;
$first = true;
foreach ($project_groups as $group) {
    if ($group['id'] == 0) {
        $prefix = 'last_';
    } elseif ($first) {
        $prefix = 'first_';
        $first = false;
Example #26
0
<?php

require_once 'php-sql-parser.php';
$parser = new PHPSQLParser();
if (count($argv) == 1) {
    echo "usage: \n";
    echo "php " . $argv[0] . " [schema] < inserts.sql\n";
    echo "-------------------------------------\n\nThis script expects a file to be redirected to STDIN. \n\nIt expects the file to be a set of INSERT ... SELECT statements.\n\nEach statement should be terminated by a semicolon (;)\n\nThe script takes one commandline argument. This argument specifies a schema.  The specified schema is used for:\nA) The location into which to place the materialized view(s)\nB) The location to use for tables that are not explicitly prefixed with a schema name in the FROM clause of the SELECT statement.\n\n";
    exit;
}
$sql = file_get_contents('php://stdin');
process_sql($sql, @mysql_escape_string($argv[1]));
function process_parsed($p, $default_db = "")
{
    $q = new StdClass();
    $q->mode = 'INCREMENTAL';
    if (!empty($p['GROUP'])) {
        $q->group = true;
    } else {
        $q->group = false;
    }
    $output = "";
    $notes = "";
    #process the select list
    foreach ($p['SELECT'] as $s) {
        $expr = "CALL flexviews.add_expr(@mvid,'";
        switch ($s['expr_type']) {
            case 'colref':
                if ($q->group) {
                    $expr .= "GROUP','";
                } else {
Example #27
0
$is_enterprise = false;
if (file_exists("enterprise/load_enterprise.php")) {
    $is_enterprise = true;
}
/* Tabs list */
print_setup_tabs('mail', $is_enterprise);
$update = (bool) get_parameter("update");
$pending_ok = (bool) get_parameter("pending_ok");
$pending_delete = (bool) get_parameter("pending_delete");
if ($pending_ok) {
    echo "<h3 class='suc'>" . __('Mail queue refreshed') . "</h3>";
    process_sql("UPDATE tpending_mail SET attempts = 0, status = 0 WHERE status = 1");
}
if ($pending_delete) {
    echo "<h3 class='suc'>" . __('Mail queue deleted') . "</h3>";
    process_sql("DELETE FROM tpending_mail");
}
if ($update) {
    $config["notification_period"] = (int) get_parameter("notification_period", 86400);
    $config["FOOTER_EMAIL"] = (string) get_parameter("footer_email", "");
    $config["HEADER_EMAIL"] = (string) get_parameter("header_email", "");
    $config["mail_from"] = (string) get_parameter("mail_from");
    $config["smtp_user"] = (string) get_parameter("smtp_user");
    $config["smtp_pass"] = (string) get_parameter("smtp_pass");
    $config["smtp_host"] = (string) get_parameter("smtp_host");
    $config["smtp_port"] = (string) get_parameter("smtp_port");
    $config["news_smtp_user"] = (string) get_parameter("news_smtp_user");
    $config["news_smtp_pass"] = (string) get_parameter("news_smtp_pass");
    $config["news_smtp_host"] = (string) get_parameter("news_smtp_host");
    $config["news_smtp_port"] = (string) get_parameter("news_smtp_port");
    $config["pop_user"] = (string) get_parameter("pop_user");
Example #28
0
function check_email_queue($get_count = false)
{
    global $config;
    $sql = "SELECT COUNT(*) FROM tpending_mail";
    $count_aux = process_sql($sql);
    $count = $count_aux[0][0];
    if ($get_count) {
        return $count;
    }
    if (!isset($config['max_pending_mail'])) {
        $config['max_pending_mail'] = 15;
    }
    if ($count < $config['max_pending_mail']) {
        return true;
    }
    return false;
}
Example #29
0
if ($send) {
    if ($subject != "" and $from != "" and $to != "") {
        echo "<h3 class='suc'>" . __('Mail queued') . "</h3>";
        integria_sendmail($to, $subject, $mail, false, "", $from, true);
        if ($cco != "") {
            integria_sendmail($cco, $subject, $mail, false, "", $from, true);
        }
        $datetime = date("Y-m-d H:i:s");
        // Update tracking
        $sql = sprintf('INSERT INTO tlead_history (id_lead, id_user, timestamp, description) VALUES (%d, "%s", "%s", "%s")', $id, $config["id_user"], $datetime, "Forwarded lead by mail to {$to}");
        process_sql($sql);
        // Update activity
        $comments = __("Forwarded lead by mail to {$to}") . "&#x0d;&#x0a;" . $mail;
        // this adds &#x0d;&#x0a;
        $sql = sprintf('INSERT INTO tlead_activity (id_lead, written_by, creation, description) VALUES (%d, "%s", "%s", "%s")', $id, $config["id_user"], $datetime, $comments);
        process_sql($sql);
    } else {
        echo "<h3 class='error'>" . __('Could not be created') . "</h3>";
    }
}
// Mark with case ID
$subject = __("Lead forward") . " [#{$id}] : " . $lead["company"] . " / " . $lead["country"];
$mail = __("Hello");
$mail .= "\n\n";
$mail .= __("Lead details") . ":\n\n";
$mail .= " " . __("Name") . ": " . $lead["fullname"] . "\n";
$mail .= " " . __("Company") . ": " . $lead["company"] . "\n";
$mail .= " " . __("Position") . ": " . $lead["position"] . "\n";
$mail .= " " . __("Country") . ": " . $lead["country"] . "\n";
$mail .= " " . __("Language") . ": " . $lead["id_language"] . "\n";
$mail .= " " . __("Email") . ": " . $lead["email"] . "\n";
Example #30
0
function api_delete_user($return_type, $params)
{
    // Cannot delete the admin user
    if ($params === 'admin') {
        return;
    }
    $sql = sprintf('DELETE FROM tusuario WHERE id_usuario = "%s"', $params);
    $ret = process_sql($sql);
    $res = 0;
    if ($ret) {
        $res = 1;
    }
    if ($return_type == 'xml') {
        $return = "<xml>\n";
        $return .= "<user>\n";
        $return .= "<exists>";
        $return .= "<![CDATA[" . $res . "]]>";
        $return .= "</exists>\n";
        $return .= "</user>\n";
        $return .= "</xml>\n";
    } else {
        $return = $res;
    }
    return $return;
}