function fill_new_sla_table()
{
    echo "Filling the table 'tincident_sla_graph_data'...\n";
    $last_values = array();
    $sql = "SELECT id_incident, utimestamp, value\n\t\t\tFROM tincident_sla_graph\n\t\t\tORDER BY utimestamp ASC";
    $new = true;
    while ($data = get_db_all_row_by_steps_sql($new, $result_sla, $sql)) {
        $new = false;
        $id_incident = $data["id_incident"];
        $value = $data["value"];
        $utimestamp = $data["utimestamp"];
        if (!isset($last_values[$id_incident]) || isset($last_values[$id_incident]) && $last_values[$id_incident] != $value) {
            $last_values[$id_incident] = $value;
            $values = array("id_incident" => $id_incident, "utimestamp" => $utimestamp, "value" => $value);
            process_sql_insert("tincident_sla_graph_data", $values);
        }
    }
    echo "Filling the table 'tincident_sla_graph_data'... DONE\n";
}
Ejemplo n.º 2
0
function combo_task_user_manager($id_user, $actual = 0, $return = false, $label = false, $name = false, $nothing = true, $multiple = false, $id_project = false, $id_task_out = false)
{
    $output = '';
    $values = array();
    if ($id_project) {
        $where = "AND id={$id_project}";
    } else {
        $where = "";
    }
    if ($id_task_out) {
        $task_out = "AND id<>{$id_task_out}";
    } else {
        $task_out = "";
    }
    $sql = "select tp.* from tproject tp, ttask tt, trole_people_project tpp  \n\t\t\twhere tp.id=tt.id_project and tpp.id_project=tp.id and disabled = 0 \n\t\t\tand tpp.id_user="******"'" . $id_user . "'" . " ORDER BY name;";
    $new = true;
    while ($project = get_db_all_row_by_steps_sql($new, $result_project, $sql)) {
        $sql = "SELECT *\n\t\t\t\tFROM ttask\n\t\t\t\tWHERE id_project=" . $project['id'] . "\n\t\t\t\t\tAND id_project IN(SELECT id\n\t\t\t\t\t\t\t\t\t  FROM tproject\n\t\t\t\t\t\t\t\t\t  WHERE disabled=0)\n\t\t\t\t\t{$task_out}\n\t\t\t\tORDER BY name";
        $new = true;
        $project_access = get_project_access($id_user, $project['id']);
        // ACL - To continue, the user should have read access
        if ($project_access['read']) {
            while ($task = get_db_all_row_by_steps_sql($new, $result_task, $sql)) {
                $new = false;
                $task_access = get_project_access($id_user, $project['id'], $task['id'], false, true);
                // ACL - To show the task, the user should have manage access
                if ($task_access['manage']) {
                    $values[$task['id']] = array('optgroup' => $project['name'], 'name' => '&nbsp;' . $task['name']);
                }
            }
        } else {
            $new = false;
        }
    }
    if (!$name) {
        $name = 'id_task';
    }
    if ($nothing && $nothing !== true) {
        $nothing = $nothing;
    } elseif ($nothing) {
        $nothing = __('N/A');
    } else {
        $nothing = '';
    }
    $output .= print_select($values, $name, $actual, '', $nothing, '0', true, $multiple, false, $label);
    if ($return) {
        return $output;
    }
    echo $output;
}
Ejemplo n.º 3
0
$table->head[3] = __('Updated');
$table->head[4] = '';
$table->data = array ();

$where_clause = "";
if ($search_text != "") {
	$where_clause .= sprintf (" AND (tproject.name LIKE '%%%s%%' OR tproject.description LIKE '%%%s%%')", $search_text, $search_text);
}
if ($search_id_project_group != 0) {
	$where_clause .= sprintf (" AND tproject.id_project_group=$search_id_project_group ");
}

$sql = get_projects_query ($config['id_user'], $where_clause, $view_disabled);
$new = true;

while ($project = get_db_all_row_by_steps_sql ($new, $result, $sql)) {
	
	$new = false;
	
	$project_permission = get_project_access ($config['id_user'], $project['id']);
	if (!$project_permission['read']) {
		continue;
	}
	$data = array ();
	
	// Project name
	$data[0] = '<a href="index.php?sec=projects&sec2=operation/projects/project_detail&id_project='.$project['id'].'">'.$project['name'].'</a>';
	$data[1] = $project["id_owner"];

	if ($project["start"] == $project["end"]) {
		$data[2] = __('Unlimited');
Ejemplo n.º 4
0
function show_task_tree(&$table, $id_project, $level, $id_parent_task, $users)
{
    global $config;
    $sql = sprintf('SELECT * FROM ttask
		WHERE id_project = %d
		AND id_parent_task = %d
		ORDER BY name', $id_project, $id_parent_task);
    $new = true;
    while ($task = get_db_all_row_by_steps_sql($new, $result, $sql)) {
        $new = false;
        //If user belong to task then create a new row in the table
        $task_access = get_project_access($config['id_user'], $id_project, $task['id'], false, true);
        if ($task_access['manage']) {
            //Each tr has the task id as the html id object!
            //Check completion for tr background color
            if ($task['completion'] < 40) {
                $color = "#FFFFFF";
            } else {
                if ($task['completion'] < 90) {
                    $color = "#FFE599";
                } else {
                    if ($task['completion'] < 100) {
                        $color = "#A4BCFA";
                    } else {
                        if ($task['completion'] == 100) {
                            $color = "#B6D7A8";
                        }
                    }
                }
            }
            echo "<tr id=" . $task['id'] . " bgcolor='{$color}'>";
            show_task_row($table, $id_project, $task, $level, $users);
            echo "</tr>";
        }
        show_task_tree($table, $id_project, $level + 1, $task['id'], $users);
    }
}
Ejemplo n.º 5
0
 public function getWorkUnitsList($href = "", $delete_button = true, $delete_href = "", $ajax = false)
 {
     $system = System::getInstance();
     $ui = Ui::getInstance();
     if ($href == "") {
         $href = "index.php?page=workunit";
     }
     if (!$ajax) {
         $html = "<ul id='listview' class='ui-itemlistview' data-role='listview' data-count-theme='e'>";
     }
     if ($this->getCountWorkUnits() > 0) {
         $sql = $this->getWorkUnitsQuery();
         $new = true;
         while ($workunit = get_db_all_row_by_steps_sql($new, $result_query, $sql)) {
             $new = false;
             $html .= "<li>";
             $html .= "<a href='{$href}&id_workunit=" . $workunit['id'] . "' class='ui-link-inherit' data-ajax='false'>";
             $date = strtotime($workunit['timestamp']);
             $html .= "<h3 class='ui-li-heading'>" . date("Y-m-d", $date) . "</h3>";
             $html .= "<p class='ui-li-desc'><strong>" . $workunit['id_user'] . "</strong></p>";
             $html .= "<p class='ui-li-desc'>" . $workunit['description'] . "</p>";
             $html .= "<span class=\"ui-li-count\">" . $workunit['duration'] . "&nbsp;" . __('hours') . "</span>";
             $html .= "</a>";
             if ($delete_button) {
                 if ($delete_href == "") {
                     $delete_href = 'index.php?page=workunits&operation=delete_workunit';
                 }
                 $options = array('popup_id' => 'delete_popup_' . $workunit['id'], 'delete_href' => $delete_href . '&id_workunit=' . $workunit['id']);
                 $html .= $ui->getDeletePopupHTML($options);
                 $html .= "<a data-icon=\"delete\" data-rel=\"popup\" href=\"#delete_popup_" . $workunit['id'] . "\"></a>";
             }
             $html .= "</li>";
         }
     } else {
         $html .= "<li>";
         $html .= "<h3 class='error'>" . __('There is no workunits') . "</h3>";
         $html .= "</li>";
     }
     if (!$ajax) {
         $html .= "</ul>";
     }
     return $html;
 }
Ejemplo n.º 6
0
/**
 * This function deletes incidents data with more than X days and closed.
 * Also deletes the data related to the deleted incidents.
 */
function delete_old_incidents()
{
    global $config;
    //$config['months_to_delete_incidents'] DELETE FROM OTHER PLACES
    $DELETE_DAYS = (int) $config["max_days_incidents"];
    if ($DELETE_DAYS > 0) {
        $limit = date("Y/m/d H:i:s", strtotime("now") - $DELETE_DAYS * 86400);
        $sql_select = "SELECT id_incidencia\n\t\t\t\t\t   FROM tincidencia\n\t\t\t\t\t   WHERE cierre < '{$limit}'\n\t\t\t\t\t\t   AND cierre > '0000-00-00 00:00:00'\n\t\t\t\t\t\t   AND estado = 7";
        $new = true;
        while ($incident = get_db_all_row_by_steps_sql($new, $result, $sql_select)) {
            $new = false;
            $error = false;
            // tincident_contact_reporters
            $sql_delete = "DELETE FROM tincident_contact_reporters\n\t\t\t\t\t\t   WHERE id_incident = " . $incident["id_incidencia"];
            $res = process_sql($sql_delete);
            if ($res === false) {
                $error = true;
            }
            // tincident_field_data
            $res = $sql_delete = "DELETE FROM tincident_field_data\n\t\t\t\t\t\t   WHERE id_incident = " . $incident["id_incidencia"];
            $res = process_sql($sql_delete);
            if ($res === false) {
                $error = true;
            }
            // tincident_inventory
            $sql_delete = "DELETE FROM tincident_inventory\n\t\t\t\t\t\t   WHERE id_incident = " . $incident["id_incidencia"];
            $res = process_sql($sql_delete);
            if ($res === false) {
                $error = true;
            }
            // tincident_sla_graph_data
            $sql_delete = "DELETE FROM tincident_sla_graph_data\n\t\t\t\t\t\t   WHERE id_incident = " . $incident["id_incidencia"];
            $res = process_sql($sql_delete);
            if ($res === false) {
                $error = true;
            }
            // tincident_stats
            $sql_delete = "DELETE FROM tincident_stats\n\t\t\t\t\t\t   WHERE id_incident = " . $incident["id_incidencia"];
            $res = process_sql($sql_delete);
            if ($res === false) {
                $error = true;
            }
            // tincident_track
            $sql_delete = "DELETE FROM tincident_track\n\t\t\t\t\t\t   WHERE id_incident = " . $incident["id_incidencia"];
            $res = process_sql($sql_delete);
            if ($res === false) {
                $error = true;
            }
            // tworkunit
            $sql_delete = "DELETE FROM tworkunit\n\t\t\t\t\t\t   WHERE id = ANY(SELECT id_workunit\n\t\t\t\t\t\t\t\t\t\t  FROM tworkunit_incident\n\t\t\t\t\t\t\t\t\t\t  WHERE id_incident = " . $incident["id_incidencia"] . ")";
            $res = process_sql($sql_delete);
            if ($res === false) {
                $error = true;
            }
            // tattachment
            $sql_delete = "DELETE FROM tattachment\n\t\t\t\t\t\t   WHERE id_incidencia = " . $incident["id_incidencia"];
            $res = process_sql($sql_delete);
            if ($res === false) {
                $error = true;
            }
            if (!$error) {
                // tincidencia
                $sql_delete = "DELETE FROM tincidencia\n\t\t\t\t\t\t\t   WHERE id_incidencia = " . $incident["id_incidencia"];
                process_sql($sql_delete);
            }
        }
    }
}
Ejemplo n.º 7
0
	public function getIncidentsList ($href = "", $ajax = false) {
		$system = System::getInstance();
		$ui = Ui::getInstance();

		if ($href == "") {
			$href = "index.php?page=incident";
		}

		$html = "";
		
		if (! $ajax) {
			$html .= "<ul id='listview' class='ui-itemlistview' data-role='listview'>";
		}
		if ($this->getCountIncidents() > 0) {
			$sql = $this->getIncidentsQuery();
			$new = true;
			while ( $incident = get_db_all_row_by_steps_sql($new, $result_query, $sql) ) {
				$new = false;
				// Background color
				if ($incident["estado"] < 3) {
					$background_color = "light-red-background";
				} elseif ($incident["estado"] < 7) {
					$background_color = "light-yellow-background";
				} elseif ($incident["estado"] == 7) {
					$background_color = "light-green-background";
				} else {
					$background_color = "";
				}
				$html .= "<li class=\"$background_color\">";
				$html .= "<a href='$href&id_incident=".$incident['id_incidencia']."' class='ui-link-inherit' data-ajax='false'>";
					//$html .= $ui->getPriorityFlagImage($incident['prioridad']);
					$html .= print_priority_flag_image ($incident['prioridad'], true, "../", "priority-list ui-li-icon");
					$html .= "<h3 class='ui-li-heading'>#".$incident['id_incidencia'];
					$html .= "&nbsp;&nbsp;-&nbsp;&nbsp;".$incident['titulo']."</h3>";
					$html .= "<p class='ui-li-desc'>".__('Owner').": ".$incident['id_usuario'];
					if ( include_once ($system->getConfig('homedir')."/include/functions_calendar.php") ) {
						$html .= "&nbsp;&nbsp;-&nbsp;&nbsp;".human_time_comparation($incident["actualizacion"])."&nbsp;".__('since the last update')."</p>";
					} else {
						$html .= "&nbsp;&nbsp;-&nbsp;&nbsp;".__('Last update').": ".$incident['actualizacion']."</p>";
					}
				$html .= "</a>";
				
				//~ $options = array(
					//~ 'popup_id' => 'delete_popup_'.$incident['id_incidencia'],
					//~ 'delete_href' => 'index.php?page=incidents&operation=delete&id_incident='.$incident['id_incidencia']
					//~ );
				//~ $html .= $ui->getDeletePopupHTML($options);
				//~ $html .= "<a data-icon=\"delete\" data-rel=\"popup\" href=\"#delete_popup_".$incident['id_incidencia']."\"></a>";
				$html .= "</li>";
			}
		} else {
			$html .= "<li>";
			$html .= "<h3 class='error'>".__('There is no tickets')."</h3>";
			$html .= "</li>";
		}
		if (! $ajax) {
			$html .= "</ul>";
		} else {
			ob_clean();
		}
		
		return $html;
	}
Ejemplo n.º 8
0
function incidents_get_incident_sla_graph_seconds($id_incident)
{
    $seconds = array();
    $seconds["OK"] = 0;
    $seconds["FAIL"] = 0;
    $last_value = -1;
    $last_timestamp = array();
    $last_timestamp["OK"] = 0;
    $last_timestamp["FAIL"] = 0;
    $sql = sprintf("SELECT utimestamp, value\n\t\t\t\t\tFROM tincident_sla_graph_data\n\t\t\t\t\tWHERE id_incident = %s\n\t\t\t\t\tORDER BY utimestamp ASC", $id_incident);
    $data = get_db_all_row_by_steps_sql(true, $result_sla, $sql);
    if ($data) {
        if ($data["value"] == 1) {
            $last_timestamp["OK"] = $data["utimestamp"];
        } else {
            $last_timestamp["FAIL"] = $data["utimestamp"];
        }
        $last_value = $data["value"];
    }
    while ($data = get_db_all_row_by_steps_sql(false, $result_sla, $sql)) {
        if ($data["value"] != $last_value) {
            if ($data["value"] == 1) {
                $seconds["FAIL"] += $data["utimestamp"] - $last_timestamp["FAIL"];
                $last_timestamp["OK"] = $data["utimestamp"];
            } else {
                $seconds["OK"] += $data["utimestamp"] - $last_timestamp["OK"];
                $last_timestamp["FAIL"] = $data["utimestamp"];
            }
            $last_value = $data["value"];
        }
    }
    if ($last_value == 1) {
        $seconds["OK"] += time() - $last_timestamp["OK"];
    } elseif ($last_value == 0) {
        $seconds["FAIL"] += time() - $last_timestamp["FAIL"];
    }
    return $seconds;
}
Ejemplo n.º 9
0
 public function getWorkOrdersList($href = "", $delete_button = true, $delete_href = "", $ajax = false)
 {
     $system = System::getInstance();
     $ui = Ui::getInstance();
     if ($href == "") {
         $href = "index.php?page=workorder&operation=view";
     }
     if (!$ajax) {
         $html = "<ul id='listview' class='ui-itemlistview' data-role='listview'>";
     }
     if ($this->getCountWorkorders() > 0) {
         $sql = $this->getWorkOrdersQuery();
         $new = true;
         while ($workorder = get_db_all_row_by_steps_sql($new, $result_query, $sql)) {
             $new = false;
             $html .= "<li>";
             $html .= "<a href='{$href}&id_workorder=" . $workorder['id'] . "' class='ui-link-inherit' data-ajax='false'>";
             //$html .= $ui->getPriorityFlagImage($workorder['priority']);
             $html .= print_priority_flag_image($workorder['priority'], true, "../", "priority-list ui-li-icon");
             $html .= "<h3 class='ui-li-heading'>" . $workorder['name'] . "</h3>";
             $html .= "<p class='ui-li-desc'>" . __('Owner') . ": " . $workorder['assigned_user'];
             $html .= "&nbsp;&nbsp;-&nbsp;&nbsp;" . __('Creator') . ": " . $workorder['created_by_user'] . "</p>";
             $html .= "</a>";
             if ($delete_button) {
                 if ($delete_href == "") {
                     $delete_href = "index.php?page=workorders&operation=delete&filter_status=0&filter_owner=" . $system->getConfig('id_user');
                 }
                 $options = array('popup_id' => 'delete_popup_' . $workorder['id'], 'delete_href' => "{$delete_href}&id_workorder=" . $workorder['id']);
                 $html .= $ui->getDeletePopupHTML($options);
                 $html .= "<a data-icon=\"delete\" data-rel=\"popup\" href=\"#delete_popup_" . $workorder['id'] . "\"></a>";
             }
             $html .= "</li>";
         }
     } else {
         $html .= "<li>";
         $html .= "<h3 class='error'>" . __('There is no workorders') . "</h3>";
         $html .= "</li>";
     }
     if (!$ajax) {
         $html .= "</ul>";
     }
     return $html;
 }
Ejemplo n.º 10
0
			echo "<span style='vertical-align:middle; display: inline-block;'>".$wo_icon."</span>";
			echo "<span style='margin-left: 4px; vertical-align:middle; display: inline-block;'>".$priority."</span>";
			echo "<span style='margin-left: 5px; min-width: 400px; vertical-align:middle; display: inline-block;'>".$name."</span>";
			echo "<span style='margin-left: 5px; min-width: 140px; vertical-align:middle; display: inline-block;'><small>"
				.__('Owner').":</small> <b>".$owner."</b></span>";
			echo "<span style='margin-left: 5px; min-width: 140px; vertical-align:middle; display: inline-block;'><small>"
				.__('Time used ').":</small> <b>".$wo['duration']."</b></span>";
			echo "</span>";
			echo "</li>";
		}
		
		// INCIDENTS
		$new = true;
		$count = 0;
		
		while ($incident = get_db_all_row_by_steps_sql($new, $result, $sql_incidents)) {
			
			$new = false;
			$count++;
			echo "<li style='margin: 0; padding: 0;'>";
			echo "<span style='display: inline-block;'>";
			
			foreach ($branches as $branch) {
				if ($branch) {
					print_image ("images/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
				} else {
					print_image ("images/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
				}
			}
			
			if ($count < $countIncidents) {
Ejemplo n.º 11
0
function tasks_print_tree($id_project, $sql_search = '')
{
    global $config;
    global $pdf_output;
    if ($pdf_output) {
        $graph_ttl = 2;
    } else {
        $graph_ttl = 1;
    }
    echo "<table class='blank' style='width:98%'>";
    echo "<tr><td style='width:60%' valign='top'>";
    $sql = "SELECT t.*\n\t\t\tFROM ttask t\n\t\t\tWHERE t.id_parent_task=0\n\t\t\t\tAND t.id>0\n\t\t\t\tAND t.id_project={$id_project}\n\t\t\t\t{$sql_search}\n\t\t\tORDER BY t.name";
    //$sql_search = base64_encode($sql_search);
    $sql_count = "SELECT COUNT(*) AS num\n\t\t\tFROM ttask t\n\t\t\tWHERE t.id_parent_task=0\n\t\t\t\tAND t.id>0\n\t\t\t\tAND t.id_project={$id_project}\n\t\t\t\t{$sql_search}";
    $countRows = process_sql($sql_count);
    if ($countRows === false) {
        $countRows = 0;
    } else {
        $countRows = (int) $countRows[0]['num'];
    }
    if ($countRows == 0) {
        echo '<h3 class="error">' . __('No tasks found') . '</h3>';
        return;
    }
    $new = true;
    $count = 0;
    echo "<ul style='margin: 0; margin-top: 20px; padding: 0;'>\n";
    $first = true;
    while ($task = get_db_all_row_by_steps_sql($new, $result, $sql)) {
        $new = false;
        $count++;
        echo "<li style='margin: 0; padding: 0;'>";
        echo "<span style='display: inline-block;'>";
        $branches = array();
        if ($first) {
            if ($count != $countRows) {
                $branches[] = true;
                $img = print_image("images/tree/first_closed.png", true, array("style" => 'vertical-align: middle;', "id" => "tree_image" . $task['id'] . "_task_" . $task['id'], "pos_tree" => "0"));
                $first = false;
            } else {
                $branches[] = false;
                $img = print_image("images/tree/one_closed.png", true, array("style" => 'vertical-align: middle;', "id" => "tree_image" . $task['id'] . "_task_" . $task['id'], "pos_tree" => "1"));
            }
        } else {
            if ($count != $countRows) {
                $branches[] = true;
                $img = print_image("images/tree/closed.png", true, array("style" => 'vertical-align: middle;', "id" => "tree_image" . $task['id'] . "_task_" . $task['id'], "pos_tree" => "2"));
            } else {
                $branches[] = false;
                $img = print_image("images/tree/last_closed.png", true, array("style" => 'vertical-align: middle;', "id" => "tree_image" . $task['id'] . "_task_" . $task['id'], "pos_tree" => "3"));
            }
        }
        $task_access = get_project_access($config["id_user"], $id_project, $task["id"], false, true);
        if ($task_access["read"]) {
            // Background color
            if ($task["completion"] < 40) {
                $background_color = "background: #FFFFFF;";
            } else {
                if ($task["completion"] < 90) {
                    $background_color = "background: #FFE599;";
                } else {
                    if ($task["completion"] < 100) {
                        $background_color = "background: #A4BCFA;";
                    } else {
                        if ($task["completion"] == 100) {
                            $background_color = "background: #B6D7A8;";
                        } else {
                            $background_color = "";
                        }
                    }
                }
            }
            // Priority
            $priority = print_priority_flag_image($task['priority'], true);
            // Task name
            $name = safe_output($task['name']);
            if (strlen($name) > 30) {
                $name = substr($name, 0, 30) . "...";
                $name = "<a title='" . safe_output($task['name']) . "' href='index.php?sec=projects&sec2=operation/projects/task_detail\n\t\t\t\t\t&id_project=" . $task['id_project'] . "&id_task=" . $task['id'] . "&operation=view'>" . $name . "</a>";
            } else {
                $name = "<a href='index.php?sec=projects&sec2=operation/projects/task_detail\n\t\t\t\t\t&id_project=" . $task['id_project'] . "&id_task=" . $task['id'] . "&operation=view'>" . $name . "</a>";
            }
            if ($task["completion"] == 100) {
                $name = "<s>{$name}</s>";
            }
            // Completion
            $progress = progress_bar($task['completion'], 70, 20, $graph_ttl);
            // Estimation
            $imghelp = "Estimated hours = " . $task['hours'];
            $taskhours = get_task_workunit_hours($task['id']);
            $imghelp .= ", Worked hours = {$taskhours}";
            $a = round($task["hours"]);
            $b = round($taskhours);
            $mode = 2;
            if ($a > 0) {
                $estimation = histogram_2values($a, $b, __("Planned"), __("Real"), $mode, 60, 18, $imghelp, $graph_ttl);
            } else {
                $estimation = "--";
            }
            // Time used on all child tasks + this task
            $recursive_timeused = task_duration_recursive($task["id"]);
            $time_used = _('Time used') . ": ";
            if ($taskhours == 0) {
                $time_used .= "--";
            } elseif ($taskhours == $recursive_timeused) {
                $time_used .= $taskhours;
            } else {
                $time_used .= $taskhours . "<span title='Subtasks WU/HR'> (" . $recursive_timeused . ")</span>";
            }
            $wu_incidents = get_incident_task_workunit_hours($task["id"]);
            if ($wu_incidents > 0) {
                $time_used .= "<span title='" . __("Time spent in related tickets") . "'> ({$wu_incidents})</span>";
            }
            // People
            $people = combo_users_task($task['id'], 1, true);
            $people .= ' ';
            $people .= get_db_value('COUNT(DISTINCT(id_user))', 'trole_people_task', 'id_task', $task['id']);
            // Branches
            $branches_json = json_encode($branches);
            // New WO / Incident
            $wo_icon = print_image("images/paste_plain.png", true, array("style" => 'vertical-align: middle;', "id" => "wo_icon", "title" => __('Work order')));
            $incident_icon = print_image("images/incident.png", true, array("style" => 'vertical-align: middle; height:19px; width:20px;', "id" => "incident_icon", "title" => __('Ticket')));
            $wo_icon = "<a href='index.php?sec=projects&sec2=operation/workorders/wo&operation=create&id_task=" . $task['id'] . "'>{$wo_icon}</a>";
            $incident_icon = "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_detail&id_task=" . $task['id'] . "'>{$incident_icon}</a>";
            $launch_icons = $wo_icon . "&nbsp;" . $incident_icon;
            echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadTasksSubTree(" . $task['id_project'] . "," . $task['id'] . ",\"" . $branches_json . "\", " . $task['id'] . ",\"" . $sql_search . "\")'>";
            echo "<script type=\"text/javascript\">\n\t\t\t\t\t  \$(document).ready (function () {\n\t\t\t\t\t\t  loadTasksSubTree(" . $task['id_project'] . "," . $task['id'] . ",\"" . $branches_json . "\", " . $task['id'] . ",\"" . $sql_search . "\");\n\t\t\t\t\t  });\n\t\t\t\t  </script>";
            echo $img;
            echo "</a>";
            echo "<span style='" . $background_color . " padding: 4px;'>";
            echo "<span style='vertical-align:middle; display: inline-block;'>" . $priority . "</span>";
            echo "<span style='margin-left: 5px; min-width: 250px; vertical-align:middle; display: inline-block;'>" . $name . "</span>";
            echo "<span title='" . __('Progress') . "' style='margin-left: 15px; vertical-align:middle; display: inline-block;'>" . $progress . "</span>";
            echo "<span style='margin-left: 15px; min-width: 70px; vertical-align:middle; display: inline-block;'>" . $estimation . "</span>";
            echo "<span style='margin-left: 15px; vertical-align:middle; display: inline-block;'>" . $people . "</span>";
            echo "<span style='margin-left: 15px; min-width: 200px; display: inline-block;'>" . $time_used . "</span>";
            echo "<span style='margin-left: 15px; vertical-align:middle; display: inline-block;'>" . __('New') . ": " . $launch_icons . "</span>";
            echo "</span>";
        } else {
            // Task name
            $name = safe_output($task['name']);
            if (strlen($name) > 60) {
                $name = substr($name, 0, 60) . "...";
                $name = "<div title='" . safe_output($task['name']) . "'>" . $name . "</a>";
            }
            if ($task["completion"] == 100) {
                $name = "<s>{$name}</s>";
            }
            // Priority
            $priority = print_priority_flag_image($task['priority'], true);
            // Branches
            $branches_json = json_encode($branches);
            echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadTasksSubTree(" . $task['id_project'] . "," . $task['id'] . ",\"" . $branches_json . "\", " . $task['id'] . ",\"" . $sql_search . "\")'>";
            echo "<script type=\"text/javascript\">\n\t\t\t\t\t  \$(document).ready (function () {\n\t\t\t\t\t\t  loadTasksSubTree(" . $task['id_project'] . "," . $task['id'] . ",\"" . $branches_json . "\", " . $task['id'] . ",\"" . $sql_search . "\");\n\t\t\t\t\t  });\n\t\t\t\t  </script>";
            echo $img;
            echo "</a>";
            echo "<span title='" . __('You are not assigned to this task') . "' style='padding: 4px;'>";
            echo "<span style='vertical-align:middle; display: inline-block;'>" . $priority . "</span>";
            echo "<span style='color: #D8D8D8; margin-left: 5px; display: inline-block;'>" . $name . "</span>";
            echo "</span>";
        }
        echo "<div hiddenDiv='1' loadDiv='0' style='display: none; margin: 0px; padding: 0px;' class='tree_view tree_div_" . $task['id'] . "' id='tree_div" . $task['id'] . "_task_" . $task['id'] . "'></div>";
        echo "</li>";
    }
    echo "</ul>";
    echo "</td></tr>";
    echo "</table>";
    return;
}
Ejemplo n.º 12
0
function print_groups_table($groups)
{
    enterprise_include("include/functions_groups.php");
    $return = enterprise_hook('print_groups_table_extra', array($groups));
    if ($return === ENTERPRISE_NOT_HOOK) {
        echo "<div class='divresult'>";
        echo '<table width="99%" class="listing" id="table1">';
        echo '<thead>';
        echo '<tr>';
        echo '<th class="header c0" scope="col">' . __('Users') . '</th>';
        echo '<th class="header c1" scope="col">' . __('Icon') . '</th>';
        echo '<th class="header c2" scope="col">' . __('Name') . '</th>';
        echo '<th class="header c3" scope="col">' . __('Parent') . '</th>';
        echo '<th class="header c4" scope="col">' . __('Delete') . '</th>';
        echo '</tr>';
        echo '</thead>';
        $count = 0;
        if ($groups === false) {
            $groups = array();
        }
        if (!empty($groups)) {
            foreach ($groups as $group) {
                $data = array();
                $num_users = get_db_value("COUNT(id_usuario)", "tusuario_perfil", "id_grupo", $group["id_grupo"]);
                if ($num_users > 0) {
                    $users_icon = '<a href="javascript:"><img src="images/group.png" title="' . __('Show and hide the user list') . '" /></a>';
                } else {
                    $users_icon = '';
                }
                $icon = '';
                if ($group['icon'] != '') {
                    $icon = '<img src="images/groups_small/' . $group['icon'] . '" />';
                }
                if ($group["id_grupo"] != 1) {
                    $group_name = '<a href="index.php?sec=users&sec2=godmode/grupos/configurar_grupo&id=' . $group['id_grupo'] . '">' . $group['nombre'] . '</a>';
                } else {
                    $group_name = $group["nombre"];
                }
                $parent = dame_nombre_grupo($group["parent"]);
                //Group "all" is special not delete and no update
                if ($group["id_grupo"] != 1) {
                    $delete_button = '<a href="index.php?sec=users&
							sec2=godmode/grupos/lista_grupos&
							id_grupo=' . $group["id_grupo"] . '&
							delete_group=1&id=' . $group["id_grupo"] . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) 
							return false;">
							<img src="images/cross.png"></a>';
                } else {
                    $delete_button = "";
                }
                echo '<tr id="table1-' . $count . '" style="border:1px solid #505050;" class="datos2">';
                echo '<td id="table1-' . $count . '-0" style="text-align:center; width:40px;" class="datos2">' . $users_icon . '</td>';
                echo '<td id="table1-' . $count . '-1" style="width:40px;" class="datos2">' . $icon . '</td>';
                echo '<td id="table1-' . $count . '-2" style=" font-weight: bold;" class="datos2">' . $group_name . '</td>';
                echo '<td id="table1-' . $count . '-3" style="" class="datos2">' . $parent . '</td>';
                echo '<td id="table1-' . $count . '-4" style=" text-align:center; width:40px;" class="datos2">' . $delete_button . '</td>';
                echo '</tr>';
                echo '<tr id="table1-' . $count . '-users" style="display:none;">';
                echo '<td colspan="5" style="text-align:center; background-color:#e6e6e6;">';
                echo '<table width="99%" cellpadding="0" cellspacing="0" border="0px" id="table_users_' . $count . '">';
                echo '<tr style="text-align:center;">';
                if ($num_users > 0) {
                    $users_sql = "SELECT * FROM tusuario_perfil WHERE id_grupo =" . $group["id_grupo"] . " ORDER BY id_usuario";
                    $count_users = 0;
                    $new = true;
                    while ($user = get_db_all_row_by_steps_sql($new, $result_users, $users_sql)) {
                        $new = false;
                        if ($count_users >= 4) {
                            $count_users = 0;
                            echo '</tr>';
                            echo '<tr style="text-align:center;">';
                        }
                        $user_name = "<a href=\"index.php?sec=users&sec2=godmode/usuarios/configurar_usuarios&update_user="******"\"><strong>" . $user['id_usuario'] . "</strong></a>";
                        $user_real_name = get_db_value("nombre_real", "tusuario", "id_usuario", $user['id_usuario']);
                        $delete_icon = '<a href="index.php?sec=users&sec2=godmode/grupos/lista_grupos&delete_user=1&id_user_delete=' . $user['id_usuario'] . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) return false;"><img src="images/cross.png"></a>';
                        $user_name = "{$user_name}&nbsp;({$user_real_name})&nbsp;" . $delete_icon;
                        echo '<td style="background-color:#e6e6e6;"">' . $user_name . '</td>';
                        $count_users++;
                    }
                } else {
                    echo '<td style="background-color:#e6e6e6;"">' . __('There are no users') . '</td>';
                }
                echo '</tr>';
                echo '</table>';
                echo '</td>';
                echo '</tr>';
                echo "<script type=\"text/javascript\">\n\t\t\t\t\t  \$(document).ready (function () {\n\t\t\t\t\t\t  \$(\"#table1-{$count}-0\").click(function() {\n\t\t\t\t\t\t\t  \$(\"#table1-{$count}-users\").toggle();\n\t\t\t\t\t\t  });\n\t\t\t\t\t  });\n\t\t\t\t\t  </script>";
                $count++;
            }
        }
        echo '</table>';
        if (empty($groups)) {
            echo ui_print_error_message(__("No groups"), '', true, 'h3', true);
        }
        echo '</div>';
    }
}
Ejemplo n.º 13
0
echo "<th>" . __("WU/Tsk");
echo "<th align='center'>" . __("Delete") . "</th>";
$sql = get_projects_query($id_user, "", 0, true);
$new = true;
$color = 1;
while ($project = get_db_all_row_by_steps_sql($new, $result_project, $sql)) {
    $sql = get_tasks_query($id_user, $project['id'], "", 0, true);
    $new = true;
    $project_access = get_project_access($config['id_user'], $project['id']);
    // ACL - To see the project, you should have read access
    if (!$project_access['read']) {
        $new = false;
        continue;
        // Does not show this project tasks
    }
    while ($task = get_db_all_row_by_steps_sql($new, $result_task, $sql)) {
        $new = false;
        $belong_task = user_belong_task($id_user, $task['id'], true);
        $task_access = get_project_access($config['id_user'], $project['id'], $task['id'], false, true);
        // ACL - To see the task, you should have read access
        if (!$task_access['read']) {
            continue;
            // Does not show this task
        }
        $role = get_db_sql("SELECT name\n\t\t\t\t\t\t\t FROM trole\n\t\t\t\t\t\t\t WHERE id IN(SELECT id_role\n\t\t\t\t\t\t\t\t\t\t FROM trole_people_task\n\t\t\t\t\t\t\t\t\t\t WHERE id_user='******'\n\t\t\t\t\t\t\t\t\t\t\tAND id_task=" . $task['id'] . ")");
        echo "<tr>";
        echo "<td>";
        echo "<a href='index.php?sec=projects&sec2=operation/projects/project_detail&id_project=" . $project['id'] . "'>" . $project['name'] . "</a>";
        echo "<td><b><a href='index.php?sec=projects&sec2=operation/projects/task_detail&id_project=" . $project['id'] . "&id_task=" . $task['id'] . "&operation=view'>" . $task['name'] . "</a></b>";
        echo "<td>" . $role;
        if ($belong_task) {
Ejemplo n.º 14
0
 private function getFilesList($href = "", $delete_button = false, $delete_href = "")
 {
     $system = System::getInstance();
     $ui = Ui::getInstance();
     if ($href == "") {
         $href = "index.php?page=incident&tab=file&id_incident=" . $this->id_incident;
     }
     session_start();
     $_SESSION["id_usuario"] = $system->getConfig('id_user');
     session_write_close();
     $html = "<ul class='ui-itemlistview' data-role='listview' data-count-theme='e'>";
     if ($this->getCountFiles() > 0) {
         $sql = $this->getFilesQuery();
         $new = true;
         while ($file = get_db_all_row_by_steps_sql($new, $result_query, $sql)) {
             $new = false;
             $html .= "<li>";
             $html .= "<a data-ajax='false' target='_blank' href='../operation/common/download_file.php?type=incident&id_attachment=" . $file['id_attachment'] . "' class='ui-link-inherit' target='_blank'>";
             $html .= "<h3 class='ui-li-heading'><img src='../images/attach.png'>&nbsp;" . $file['filename'] . "</img></h3>";
             $html .= "<p class='ui-li-desc'>" . $file['description'] . "</p>";
             $html .= "<span class=\"ui-li-aside\">" . round($file['size'] / 1024, 2) . "&nbsp;KB</span>";
             $html .= "</a>";
             if ($delete_button) {
                 if ($delete_href == "") {
                     $delete_href = "index.php?page=incident&tab=files&operation=delete_file";
                     $delete_href .= "&id_incident=" . $this->id_incident;
                 }
                 $options = array('popup_id' => 'delete_popup_' . $file['id_attachment'], 'delete_href' => $delete_href . "&id_file=" . $file['id_attachment']);
                 $html .= $ui->getDeletePopupHTML($options);
                 $html .= "<a data-icon=\"delete\" data-rel=\"popup\" href=\"#delete_popup_" . $file['id_attachment'] . "\"></a>";
             }
             $html .= "</li>";
         }
     } else {
         $html .= "<li>";
         $html .= "<h3 class='error'>" . __('There is no files') . "</h3>";
         $html .= "</li>";
     }
     $html .= "</ul>";
     return $html;
 }
Ejemplo n.º 15
0
/**
 * Get the number of readable tasks of a project for an user
 *
 * @param id_user User ID
 * @param id_project Project Id
 * @param id_parent Only count the tasks with that parent
 * 
 * @return int Count of tasks
*/
function get_accesible_task_count($id_user, $id_project, $id_parent = false)
{
    if ($id_parent !== false) {
        $parent = "id_parent_task={$id_parent}";
    } else {
        $parent = "1=1";
    }
    $sql = "SELECT id\n\t\t\tFROM ttask\n\t\t\tWHERE {$parent}\n\t\t\t\tAND id_project={$id_project}";
    $count = 0;
    $new = true;
    while ($task = get_db_all_row_by_steps_sql($new, $result_project, $sql)) {
        $new = false;
        $task_access = get_project_access($id_user, $id_project, $task['id'], false, true);
        if ($task_access['read']) {
            $count++;
        }
    }
    return $count;
}