Пример #1
0
     ob_clean();
     $package = (string) get_parameter("package");
     // All files extracted
     $files_total = $package . "/files.txt";
     // Number of files extracted
     $files_num = $package . "/files.info.txt";
     // Files copied
     $files_copied = $package . "/files.copied.txt";
     $files = @file($files_copied);
     if (empty($files)) {
         $files = array();
     }
     $total = (int) @file_get_contents($files_num);
     $progress = 0;
     if (count($files) > 0 && $total > 0) {
         $progress = format_numeric(count($files) / $total * 100, 2);
         if ($progress > 100) {
             $progress = 100;
         }
     }
     $return = array();
     $return['info'] = (string) implode("<br />", $files);
     $return['progress'] = $progress;
     if ($progress >= 100) {
         unlink($files_total);
         unlink($files_num);
         unlink($files_copied);
     }
     echo json_encode($return);
     return;
 }
Пример #2
0
	$table->style = array ();
	$table->rowstyle = array ();

	$table->head = array ();
	$table->head[0] = __('Filename');
	$table->head[1] = __('Description');
	$table->head[2] = __('Size');
	$table->head[3] = __('Date');
	$table->head[4] = __('Ops.');

	foreach ($files as $file) {
		$data = array ();
		
		$data[0] = "<a href='operation/common/download_file.php?id_attachment=".$file["id_attachment"]."&type=lead'>".$file["filename"] . "</a>";
		$data[1] = $file["description"];
		$data[2] = format_numeric($file["size"]);
		$data[3] = $file["timestamp"];

		// Todo. Delete files owner of lead and admins only
		if ( (dame_admin($config["id_user"])) || ($file["id_usuario"] == $config["id_user"]) ){
			$data[4] = "<a href='index.php?sec=customers&sec2=operation/leads/lead_detail&id=$id&op=files&deletef=".$file["id_attachment"]."'><img src='images/cross.png'></a>";
		}

		array_push ($table->data, $data);
		array_push ($table->rowstyle, $style);
	}
	print_table ($table);

} else {
	echo ui_print_error_message (__('There is no files attached for this lead'), '', true, 'h3', true);
}
Пример #3
0
function pager($records, $records_pp = 50, $break_on_page = 15)
{
    if ($records == 0) {
        return;
    }
    $cur = (int) get_var('p');
    $uri = '?';
    foreach ($_GET as $var => $val) {
        if ($var != 'p') {
            $uri .= $var . '=' . urlencode($val) . '&amp;';
        }
    }
    if ($records < $records_pp) {
        return;
    }
    echo '<ul class="pager">';
    // adjust start page, if neccessary
    $total_pages = (int) ($records / $records_pp + 0.5);
    $start_page = 0;
    if ($total_pages > $break_on_page) {
        if ($total_pages - $cur < $break_on_page / 2) {
            $start_page = $total_pages - $break_on_page;
        } else {
            $start_page = $cur - (int) ($break_on_page / 2);
            if ($start_page < 0) {
                $start_page = 0;
            }
        }
    }
    $page = $start_page;
    $start_rec = $page * $records_pp + 1;
    $broken = false;
    while ($start_rec < $records + 1) {
        printf('<li%s><a href="%sp=%d">%d</a></li>', $page == $cur ? ' class="selected"' : '', $uri, $page, $page + 1);
        $start_rec += $records_pp;
        $page++;
        if ($page == $break_on_page + $start_page + 1) {
            $broken = true;
            break;
        }
    }
    if ($broken) {
        echo "<li class=\"recordcount\">" . (1 + $total_pages) . ' ' . format_numeric(1 + $total_pages, "page", "pages") . ", {$records} " . format_numeric($records, 'record', 'records') . "</li>";
    } else {
        echo "<li class=\"recordcount\">{$records} " . format_numeric($records, 'record', 'records') . "</li>";
    }
    echo '</ul>';
    echo '<div class="afterpgr">&nbsp;</div>';
}
Пример #4
0
        $table->head[1] = __('Owner');
        $table->head[2] = __('Company');
        $table->head[3] = __('Updated at');
        $table->head[4] = __('Country');
        $table->head[5] = __('Progress');
        $table->head[6] = __('Estimated sale');
        $counter = 0;
        foreach ($leads as $lead) {
            $data = array();
            $data[0] = "<a href='index.php?sec=customers&sec2=operation/leads/lead_detail&id=" . $lead["id"] . "'>" . $lead["fullname"] . "</a>";
            $data[1] = $lead["owner"];
            $data[2] = $lead["company"];
            $data[3] = $lead["modification"];
            $data[4] = $lead["country"];
            $data[5] = translate_lead_progress($lead["progress"]);
            $data[6] = format_numeric($lead["estimated_sale"]);
            array_push($table->data, $data);
        }
        print_table($table);
        if ($section_write_permission || $section_manage_permission) {
            echo '<form method="post" action="index.php?sec=customers&sec2=operation/leads/lead_detail&id_company=' . $id . '">';
            echo '<div style="width: ' . $table->width . '; text-align: right;">';
            print_submit_button(__('Create'), 'new_btn', false, 'class="sub next"');
            print_input_hidden('new', 1);
            echo '</div>';
            echo '</form>';
        }
    }
} else {
    if ($op == 'projects') {
        $sql = "SELECT DISTINCT id_project FROM trole_people_task, ttask WHERE ttask.id = trole_people_task.id_task\n\t\t\tAND id_user IN (SELECT id_usuario FROM tusuario WHERE id_company={$id})";
    $a_day = 24 * 3600;
    $fields = array($a_day => "1 day", 2 * $a_day => "2 days", 7 * $a_day => "1 week", 14 * $a_day => "2 weeks", 30 * $a_day => "1 month");
    $period = get_parameter("period", $a_day);
    $ttl = 1;
    if ($clean_output) {
        $ttl = 2;
    }
    if ($clean_output) {
        $incident_sla .= "<strong>" . $fields[$period] . "</strong>";
    } else {
        $incident_sla .= print_select($fields, "period", $period, 'reload_sla_slice_graph(\'' . $id . '\');', '', '', true, 0, false, false, false, 'width: 75px');
    }
    $incident_sla .= "</td>";
    $incident_sla .= "<td colspan=2 style='text-align: center; width: 50%;'>";
    $incident_sla .= __('SLA total compliance (%)') . ': ';
    $incident_sla .= format_numeric(get_sla_compliance_single_id($id));
    $incident_sla .= "</td>";
    $incident_sla .= "</tr>";
    $incident_sla .= "<tr>";
    $incident_sla .= "<td id=slaSlicebarField colspan=2 style='text-align: center; padding: 1px 2px 1px 5px;'>";
    $incident_sla .= graph_sla_slicebar($id, $period, 155, 15, $ttl);
    $incident_sla .= "</td>";
    $incident_sla .= "<td colspan=2 style='text-align: center;' >";
    $incident_sla .= "<div class='pie_frame'>";
    $incident_sla .= graph_incident_sla_compliance($id, 155, 80, $ttl);
    $incident_sla .= "</div>";
    $incident_sla .= "</td>";
    $incident_sla .= "<tr>";
    $incident_sla .= "</table>";
}
$right_side .= print_container('incident_sla', __('SLA information'), $incident_sla);
Пример #6
0
/** 
 * Render numeric data for a graph. It adds magnitude suffix to the number 
 * (M for millions, K for thousands...) base-10
 *
 * TODO: base-2 multiplication
 * 
 * @param float $number Number to be rendered
 * @param int $decimals Numbers after comma. Default value: 1
 * @param dec_point Decimal separator character. Default value: .
 * @param thousands_sep Thousands separator character. Default value: ,
 * 
 * @return string A string with the number and the multiplier
 */
function format_for_graph($number, $decimals = 1, $dec_point = ".", $thousands_sep = ",", $divisor = 1000)
{
    $shorts = array("", "K", "M", "G", "T", "P");
    $pos = 0;
    while ($number >= $divisor) {
        //as long as the number can be divided by divisor
        $pos++;
        //Position in array starting with 0
        $number = $number / $divisor;
    }
    return format_numeric($number, $decimals) . $shorts[$pos];
    //This will actually do the rounding and the decimals
}
Пример #7
0
    $total_per_profile_havecost = projects_get_cost_by_profile($id_project, true);
    if (!empty($total_per_profile_havecost)) {
        foreach ($total_per_profile_havecost as $name => $total_profile) {
            if ($total_profile) {
                $budget .= "<tr>";
                $budget .= '<td>&nbsp;&nbsp;&nbsp;&nbsp;' . __($name) . '</td>';
                $budget .= '<td>' . format_numeric($total_profile) . " " . $config["currency"] . '</td>';
                $budget .= "</tr>";
            }
        }
    }
    $budget .= "<tr>";
    $budget .= '<td><b>' . __('Average Cost per Hour') . ' </b>';
    $budget .= "</td><td>";
    if ($total_hr > 0) {
        $budget .= format_numeric($total_project_costs / $total_hr) . " " . $config["currency"];
    } else {
        $budget .= __("N/A");
    }
    $budget .= "</td></tr>";
    $budget .= "</table>";
    // Workload distribution
    $workload_distribution = '<div class="pie_frame">' . graph_workunit_project_user_single(350, 150, $id_project, $graph_ttl) . '</div>';
    // Task detail
    $tasks_report = '';
    $sql = sprintf('SELECT tt.id, tt.name, tt.hours AS estimated_time
					FROM ttask tt
					WHERE tt.id_project = %d', $id_project);
    $tasks = get_db_all_rows_sql($sql);
    if (!empty($tasks)) {
        foreach ($tasks as $task) {
Пример #8
0
						$data[1] = __("N/A");
					}
					
					$partial = get_invoice_amount ($invoice["id"]);
					
					if (isset($total[$invoice["currency"]]))
						$total[$invoice["currency"]] = $total[$invoice["currency"]] + $partial;
					else
						$total[$invoice["currency"]] = $partial;

					$data[2] = format_numeric($partial). " " . strtoupper ($invoice["currency"]);

					$tax = get_invoice_tax ($invoice["id"]);
					$tax_amount = get_invoice_amount ($invoice["id"]) * (1 + $tax/100);
					if ($tax != 0 && $tax_amount > 0)
						$data[2] .= print_help_tip (__("With taxes"). ": ".format_numeric($tax_amount)." ".strtoupper($invoice["currency"]), true);

					$data[3] = __($invoice["status"]);
					$data[5] = "<span style='font-size: 10px'>".$invoice["invoice_create_date"] . "</span>";

                    array_push ($table->data, $data);
            }

            print_table ($table);
        }
}

// Leads
if ( check_crm_acl('lead', 'cr') && $show_customers != MENU_HIDDEN ){

        $where_clause = " WHERE fullname LIKE '%".$search_string."%'
Пример #9
0
function crm_print_company_projects_tree($projects)
{
    require_once "include/functions_tasks.php";
    //~ echo '<table width="100%" cellpadding="0" cellspacing="0" border="0px" class="result_table listing" id="incident_search_result_table">';
    $img = print_image("images/input_create.png", true, array("style" => 'vertical-align: middle;', "id" => $img_id));
    $img_project = print_image("images/note.png", true, array("style" => 'vertical-align: middle;'));
    foreach ($projects as $project) {
        $project_name = get_db_value('name', 'tproject', 'id', $project['id_project']);
        //print project name
        //~ echo '<tr><td colspan="10" valign="top">';
        //~ echo "
        //~ <a onfocus='JavaScript: this.blur()' href='javascript: show_detail(\"" . $project['id_project']. "\")'>" .
        //~ $img . "&nbsp;" . $img_project ."&nbsp;" .  safe_output($project_name)."&nbsp;</a>"."&nbsp;&nbsp;";
        //~ echo '</td></tr>';
        $id_project = $project['id_project'];
        $people_inv = get_db_sql("SELECT COUNT(DISTINCT id_user) FROM trole_people_task, ttask WHERE ttask.id_project={$id_project} AND ttask.id = trole_people_task.id_task;");
        $total_hr = get_project_workunit_hours($id_project);
        $total_planned = get_planned_project_workunit_hours($id_project);
        $project_data = get_db_row('tproject', 'id', $id_project);
        $start_date = $project_data["start"];
        $end_date = $project_data["end"];
        // Project detail
        $table_detail = "<table class='advanced_details_table alternate'>";
        $table_detail .= "<tr>";
        $table_detail .= '<td><b>' . __('Start date') . ' </b>';
        $table_detail .= "</td><td>";
        $table_detail .= $start_date;
        $table_detail .= "</td></tr>";
        $table_detail .= "<tr>";
        $table_detail .= '<td><b>' . __('End date') . ' </b>';
        $table_detail .= "</td><td>";
        $table_detail .= $end_date;
        $table_detail .= "</td></tr>";
        $table_detail .= "<tr>";
        $table_detail .= '<td><b>' . __('Total people involved') . ' </b>';
        $table_detail .= "</td><td>";
        $table_detail .= $people_inv;
        $table_detail .= "</td></tr>";
        //People involved (avatars)
        //Get users with tasks
        $sql = sprintf("SELECT DISTINCT id_user FROM trole_people_task, ttask WHERE ttask.id_project= %d AND ttask.id = trole_people_task.id_task", $id_project);
        $users_aux = get_db_all_rows_sql($sql);
        if (empty($users_aux)) {
            $users_aux = array();
        }
        $users_involved = array();
        foreach ($users_aux as $ua) {
            $users_involved[] = $ua['id_user'];
        }
        //Delete duplicated items
        if (empty($users_involved)) {
            $users_involved = array();
        } else {
            $users_involved = array_unique($users_involved);
        }
        $people_involved = "<div style='padding-bottom: 20px;'>";
        foreach ($users_involved as $u) {
            $avatar = get_db_value("avatar", "tusuario", "id_usuario", $u);
            if ($avatar != "") {
                $people_involved .= "<img src='images/avatars/" . $avatar . ".png' width=40 height=40 onclick='openUserInfo(\"{$u}\")' title='" . $u . "'/>";
            } else {
                $people_involved .= "<img src='images/avatars/avatar_notyet.png' width=40 height=40 onclick='openUserInfo(\"{$u}\")' title='" . $u . "'/>";
            }
        }
        $people_involved .= "</div>";
        $table_detail .= "<tr><td colspan='10'>";
        $table_detail .= $people_involved;
        $table_detail .= "</td></tr>";
        $table_detail .= "<tr>";
        $table_detail .= '<td><b>' . __('Total workunit (hr)') . ' </b>';
        $table_detail .= "</td><td>";
        $table_detail .= $total_hr . " (" . format_numeric($total_hr / $config["hours_perday"]) . " " . __("days") . ")";
        $table_detail .= "</td></tr>";
        $table_detail .= "<tr>";
        $table_detail .= '<td><b>' . __('Planned workunit (hr)') . ' </b>';
        $table_detail .= "</td><td>";
        $table_detail .= $total_planned . " (" . format_numeric($total_planned / $config["hours_perday"]) . " " . __("days") . ")";
        $table_detail .= "</td></tr>";
        $table_detail .= "</table>";
        $class = $project['id_project'] . "-project";
        $tr_status = 'class="' . $class . '"';
        //~ echo '<tr '.$tr_status.'><td>';
        print_container_div("project_" . $project['id_project'], $project_name, $table_detail, 'closed', false, true, '', '', 1, '', 'width:32%; float:left;');
        //~ echo '</td></tr>';
    }
    //~ echo '</table>';
}
Пример #10
0
function pager($records, $records_pp = 50, $break_on_page = 15)
{
    if ($records == 0) {
        return;
    }
    $cur = (int) get_var('p');
    $uri = '?';
    foreach ($_GET as $var => $val) {
        if ($var != 'p') {
            $uri .= $var . '=' . rawurlencode($val) . '&';
        }
    }
    if ($records < $records_pp) {
        return;
    }
    echo '<ul class="pager">';
    // adjust start page, if neccessary
    $total_pages = (int) ($records / $records_pp + 0.5);
    $start_page = 0;
    if ($total_pages > $break_on_page) {
        if ($total_pages - $cur < $break_on_page / 2) {
            $start_page = $total_pages - $break_on_page;
        } else {
            $start_page = $cur - (int) ($break_on_page / 2);
            if ($start_page < 0) {
                $start_page = 0;
            }
        }
    }
    $page = $start_page;
    $start_rec = $page * $records_pp + 1;
    $broken = false;
    while ($start_rec < $records + 1) {
        h('<li class="%s"><a href="%sp=%d">%d</a></li>', $page == $cur ? 'selected' : '', $uri, $page, $page + 1);
        $start_rec += $records_pp;
        $page++;
        if ($page == $break_on_page + $start_page + 1) {
            $broken = true;
            break;
        }
    }
    h('<li class="recordcount">%d %s</li>', $broken ? format_numeric(1 + $total_pages, '%d page', '%d pages') : format_numeric(1 + $total_pages, '%d record', '%d records'));
    echo '</ul>';
    echo '<div class="afterpgr">&nbsp;</div>';
}
Пример #11
0
function format_post_float($fieldnames)
{
    //takes a comma-separated list of POST keys and replaces them with monetary values or NULLs if they're empty
    global $_POST;
    $fields = array_post_fields($fieldnames);
    foreach ($fields as $field) {
        $_POST[$field] = format_numeric($_POST[$field]);
        if ($_POST[$field] === false) {
            $_POST[$field] = "NULL";
        }
    }
}
Пример #12
0
			} else {
				$overview = '';
			}
 			$data[3] = "<a href='index.php?sec=customers&sec2=operation/leads/lead&tab=search&id=".
				$lead['id']."'>".$lead['fullname'].$overview."</a><br>";
				$data[3] .= "<span style='font-size: 9px'><i>".$lead["company"]."</i></span>";


			$data[4] = "<a href='index.php?sec=customers&sec2=operation/companies/company_detail&id=".$lead['id_company']."'>".get_db_value ('name', 'tcompany', 'id', $lead['id_company'])."</a>";
			if ($lead["owner"] != "")
				$data[4] .= "<br><i>" . $lead["owner"] . "</i>";

			$data[5] = translate_lead_progress ($lead['progress']) . " <i>(".$lead['progress']. "%)</i>";
			
			if ($lead['estimated_sale'] != 0)
				$data[6] = format_numeric($lead['estimated_sale']);
			else
				$data[6] = "--";
		
			$data[7] = "<img src='images/lang/".$lead["id_language"].".png'>"; 
	
			$data[8] =  ucfirst(strtolower($lead['country']));
			$data[9] = "<span style='font-size: 9px' title='". $lead['creation'] . "'>" . human_time_comparation ($lead['creation']) . "</span>";
			$data[9] .= "<br><span style='font-size: 9px'>". human_time_comparation ($lead['modification']). "</span>";

			if ($lead['progress'] < 100 && $lead['owner'] == "")
				$data[10] = "<a href='index.php?sec=customers&sec2=operation/leads/lead&tab=search&id=".
				$lead['id']."&make_owner=1&offset=$offset'><img src='images/award_star_silver_1.png' title='".__("Take ownership of this lead")."'></a>&nbsp;";
			else
				$data[10] = "";
Пример #13
0
                $data[7] .= "<a href='#' onClick='javascript: show_validation_delete(\"delete_invoice\"," . $invoice["id"] . ",0," . $offset . ",\"" . $search_params . "\");'><img src='images/cross.png' title='" . __('Delete') . "'></a>";
            } else {
                if ($locked_id_user) {
                    $data[7] .= ' <img src="images/administrator_lock.png" width="18" height="18" 
					title="' . __('Locked by ' . $locked_id_user) . '">';
                }
            }
        }
        array_push($table->data, $data);
    }
    print_table($table);
    if ($total) {
        echo __("Subtotals for each currency: ");
    }
    foreach ($total as $key => $value) {
        echo "- {$key} : " . format_numeric($value, 2);
    }
} else {
    echo "<h3 class='no_result'>" . __("No invoices") . "</h3>";
}
if ($write || $manage and $clean_output == 0) {
    echo '<form method="post" action="index.php?sec=customers&sec2=operation/invoices/invoices">';
    echo '<div class="button" style="width: ' . $table->width . '">';
    print_submit_button(__('Create'), 'new_btn', false, 'class="sub next"');
    print_input_hidden('new_invoice', 1);
    echo '</div>';
    echo '</form>';
}
echo "<div class= 'dialog ui-dialog-content' title='" . __("Delete") . "' id='item_delete_window'></div>";
?>
Пример #14
0
ksort($inv_data_currency);
arsort($inv_data_company, SORT_NUMERIC);
$table->id = 'company_list';
$table->class = 'listing';
$table->width = '90%';
$table->data = array();
$table->head = array();
$table->style = array();
$table->head[0] = __('Currency');
$table->head[1] = __('Invoiced');
$i = 0;
foreach ($inv_total_currency as $curr => $val) {
    if ($i < 5) {
        $data = array();
        $data[0] = $curr;
        $data[1] = format_numeric($val);
        array_push($table->data, $data);
    }
    $i++;
}
$currency_table = print_table($table, true);
switch ($search_invoice_type) {
    case 'Submitted':
        $container_title = __("Submitted billing history");
        break;
    case 'Received':
        $container_title = __("Received billing history");
        break;
    default:
        $container_title = __(" Submitted billing history");
        break;
Пример #15
0
$table_advanced->data[0][0] .= print_label (__('Imputable costs'), '', '', true,
	task_workunit_cost ($id_task, 1).' '.$config['currency']);

$incident_cost = get_incident_task_workunit_cost ($id_task);
if ($incident_cost > 0)
	$incident_cost_label = "<span title='".__("Ticket costs")."'> ($incident_cost) </span>";
else
	$incident_cost_label = "";
	
$total_cost = $external_cost + task_workunit_cost ($id_task, 0) + $incident_cost;

$table_advanced->data[0][0] .= print_label (__('Total costs'), '', '', true,
	$total_cost . $incident_cost_label. $config['currency']);

$avg_hr_cost = format_numeric ($total_cost / $worked_time, 2);
$table_advanced->data[0][0] .= print_label (__('Average Cost per hour'), '', '', true,
	$avg_hr_cost .' '.$config['currency']);	

$external_cost = 0;
$external_cost = task_cost_invoices ($id_task);

if (!$external_cost) {
	$external_cost = 0;
}

$table_advanced->data[0][0] .= print_label (__("External costs"), '', '', true);
$table_advanced->data[0][0] .= $external_cost . " " . $config["currency"];	

// Abbreviation for "Estimated"
$labela = __('Est.');
Пример #16
0
/**
 * Print a table with statistics of a list of inventories.
 *
 * @param array List of inventories to get stats.
 * @param bool Whether to return an output string or echo now (optional, echo by default).
 *
 * @return Inventories stats if return parameter is true. Nothing otherwise
 */
function print_inventory_stats($inventories, $return = false)
{
    $output = '';
    $total = sizeof($inventories);
    $inventory_incidents = 0;
    $inventory_opened = 0;
    foreach ($inventories as $inventory) {
        $incidents = get_incidents_on_inventory($inventory['id'], false);
        if (sizeof($incidents) == 0) {
            continue;
        }
        $inventory_incidents++;
        foreach ($incidents as $incident) {
            if ($incident['estado'] != 7 && $incident['estado'] != 6) {
                $inventory_opened++;
                break;
            }
        }
    }
    $incidents_pct = 0;
    if ($total != 0) {
        $incidents_pct = format_numeric($inventory_incidents / $total * 100);
        $incidents_opened_pct = format_numeric($inventory_opened / $total * 100);
    }
    $table->width = '50%';
    $table->class = 'float_left blank';
    $table->style = array();
    $table->style[1] = 'vertical-align: top';
    $table->rowspan = array();
    $table->rowspan[0][1] = 3;
    $table->data = array();
    $table->data[0][0] = print_label(__('Total objects'), '', '', true, $total);
    $data = array(__('With tickets') => $inventory_incidents, __('Without tickets') => $total - $inventory_incidents);
    $table->data[0][1] = pie3d_chart($config['flash_charts'], $data, 200, 150);
    $table->data[1][0] = print_label(__('Total objects with tickets'), '', '', true, $inventory_incidents . ' (' . $incidents_pct . '%)');
    $table->data[2][0] = print_label(__('Total objects with opened tickets'), '', '', true, $inventory_opened . ' (' . $incidents_opened_pct . '%)');
    $output .= print_table($table, true);
    if ($return) {
        return $output;
    }
    echo $output;
}
Пример #17
0
        echo "<a href='index.php?sec=projects&sec2=operation/workorders/wo&owner={$nombre}'><img src='images/paste_plain.png' title='" . __("Workorders") . "' border=0></a></center></td>";
        // Total hours this month
        echo "<td  >";
        echo $row[0];
        // Total charged hours this month
        /*
        		            echo "<td  >";
        		            $tempsum = get_db_sql ("SELECT SUM(duration) FROM tworkunit WHERE have_cost = 1 AND id_user = '******' AND timestamp > '$begin_month' AND timestamp <= '$end_month'");
        		            if ($tempsum != "")
        		                echo $tempsum. " hr";
        		            else
        		                echo "--";
        */
        // Average incident scoring
        echo "<td>";
        $tempsum = get_db_sql("SELECT SUM(score) FROM tincidencia WHERE id_usuario = '{$nombre}' AND actualizacion > '{$begin_month}' AND actualizacion <= '{$end_month}' AND score > 0 ");
        if ($tempsum != "") {
            echo format_numeric($tempsum) . "/10";
        } else {
            echo "--";
        }
    }
}
echo "</table>";
?>

<script type="text/javascript" src="include/js/jquery.validation.functions.js"></script>
<script  type="text/javascript">
trim_element_on_submit('#text-search');
</script>
Пример #18
0
/**
 * Print a table with statistics of a list of incidents.
 *
 * @param array List of incidents to get stats.
 * @param bool Whether to return an output string or echo now (optional, echo by default).
 *
 * @return Incidents stats if return parameter is true. Nothing otherwise
 */
function print_incidents_stats_simply($incidents, $return = false, $simple_mode = false)
{
    global $config;
    require_once $config["homedir"] . "/include/functions_graph.php";
    $pdf_output = (int) get_parameter('pdf_output', 0);
    $ttl = $pdf_output + 1;
    // Max graph legend string length (without the '...')
    $max_legend_strlen = 17;
    // Necessary for flash graphs
    include_flash_chart_script();
    // TODO: Move this function to function_graphs to encapsulate flash
    // chart script inclusion or make calls to functions_graph when want
    // print a flash chart
    $output = '';
    $total = sizeof($incidents);
    $opened = 0;
    $total_hours = 0;
    $total_workunits = 0;
    $total_lifetime = 0;
    $max_lifetime = 0;
    $oldest_incident = false;
    $scoring_sum = 0;
    $scoring_valid = 0;
    if ($incidents === false) {
        $incidents = array();
    }
    $assigned_users = array();
    $creator_users = array();
    $submitter_label = "";
    $user_assigned_label = "";
    $incident_id_array = array();
    //Initialize incident status array
    $incident_status = array();
    $incident_status[STATUS_NEW] = 0;
    $incident_status[STATUS_UNCONFIRMED] = 0;
    $incident_status[STATUS_ASSIGNED] = 0;
    $incident_status[STATUS_REOPENED] = 0;
    $incident_status[STATUS_VERIFIED] = 0;
    $incident_status[STATUS_RESOLVED] = 0;
    $incident_status[STATUS_PENDING_THIRD_PERSON] = 0;
    $incident_status[STATUS_CLOSED] = 0;
    //Initialize priority array
    $incident_priority = array();
    $incident_priority[PRIORITY_INFORMATIVE] = 0;
    $incident_priority[PRIORITY_LOW] = 0;
    $incident_priority[PRIORITY_MEDIUM] = 0;
    $incident_priority[PRIORITY_SERIOUS] = 0;
    $incident_priority[PRIORITY_VERY_SERIOUS] = 0;
    $incident_priority[PRIORITY_MAINTENANCE] = 0;
    //Initialize status timing array
    $incident_status_timing = array();
    $incident_status_timing[STATUS_NEW] = 0;
    $incident_status_timing[STATUS_UNCONFIRMED] = 0;
    $incident_status_timing[STATUS_ASSIGNED] = 0;
    $incident_status_timing[STATUS_REOPENED] = 0;
    $incident_status_timing[STATUS_VERIFIED] = 0;
    $incident_status_timing[STATUS_RESOLVED] = 0;
    $incident_status_timing[STATUS_PENDING_THIRD_PERSON] = 0;
    $incident_status_timing[STATUS_CLOSED] = 0;
    //Initialize users time array
    $users_time = array();
    //Initialize groups time array
    $groups_time = array();
    foreach ($incidents as $incident) {
        $inc_stats = incidents_get_incident_stats($incident["id_incidencia"]);
        if ($incident['actualizacion'] != '0000-00-00 00:00:00') {
            $lifetime = $inc_stats[INCIDENT_METRIC_TOTAL_TIME];
            if ($lifetime > $max_lifetime) {
                $oldest_incident = $incident;
                $max_lifetime = $lifetime;
            }
            $total_lifetime += $lifetime;
        }
        //Complete incident status timing array
        foreach ($inc_stats[INCIDENT_METRIC_STATUS] as $key => $value) {
            $incident_status_timing[$key] += $value;
        }
        //fill users time array
        foreach ($inc_stats[INCIDENT_METRIC_USER] as $user => $time) {
            if (!isset($users_time[$user])) {
                $users_time[$user] = $time;
            } else {
                $users_time[$user] += $time;
            }
        }
        //Inidents by group time
        foreach ($inc_stats[INCIDENT_METRIC_GROUP] as $key => $time) {
            if (!isset($groups_time[$key])) {
                $groups_time[$key] = $time;
            } else {
                $groups_time[$key] += $time;
            }
        }
        //Get only id from incident filter array
        //used for filter in some functions
        array_push($incident_id_array, $incident['id_incidencia']);
        // Take count of assigned / creator users
        if (isset($assigned_users[$incident["id_usuario"]])) {
            $assigned_users[$incident["id_usuario"]]++;
        } else {
            $assigned_users[$incident["id_usuario"]] = 1;
        }
        if (isset($creator_users[$incident["id_creator"]])) {
            $creator_users[$incident["id_creator"]]++;
        } else {
            $creator_users[$incident["id_creator"]] = 1;
        }
        // Scoring avg.
        if ($incident["score"] > 0) {
            $scoring_valid++;
            $scoring_sum = $scoring_sum + $incident["score"];
        }
        $hours = get_incident_workunit_hours($incident['id_incidencia']);
        $workunits = get_incident_workunits($incident['id_incidencia']);
        $total_hours += $hours;
        $total_workunits = $total_workunits + sizeof($workunits);
        //Open incidents
        if ($incident["estado"] != 7) {
            $opened++;
        }
        //Incidents by status
        $incident_status[$incident["estado"]]++;
        //Incidents by priority
        $incident_priority[$incident["prioridad"]]++;
    }
    $closed = $total - $opened;
    $opened_pct = 0;
    $mean_work = 0;
    $mean_lifetime = 0;
    if ($total != 0) {
        $opened_pct = format_numeric($opened / $total * 100);
        $mean_work = format_numeric($total_hours / $total, 2);
    }
    $mean_lifetime = $total_lifetime / $total;
    // Get avg. scoring
    if ($scoring_valid > 0) {
        $scoring_avg = format_numeric($scoring_sum / $scoring_valid);
    } else {
        $scoring_avg = "N/A";
    }
    // Get incident SLA compliance
    $sla_compliance = get_sla_compliance($incidents);
    //Create second table
    // Find the 5 most active users (more hours worked)
    $most_active_users = array();
    if ($incident_id_array) {
        $most_active_users = get_most_active_users(8, $incident_id_array);
    }
    $users_label = '';
    $users_data = array();
    foreach ($most_active_users as $user) {
        $users_data[$user['id_user']] = $user['worked_hours'];
    }
    // Remove the items with no value
    foreach ($users_data as $key => $value) {
        if (!$value || $value <= 0) {
            unset($users_data[$key]);
        }
    }
    if (empty($most_active_users) || empty($users_data)) {
        $users_label = "<div class='container_adaptor_na_graphic2'>";
        $users_label .= graphic_error(false);
        $users_label .= __("N/A");
        $users_label .= "</div>";
    } else {
        arsort($users_data);
        $users_label .= pie3d_graph($config['flash_charts'], $users_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // Find the 5 most active incidents (more worked hours)
    $most_active_incidents = get_most_active_incidents(5, $incident_id_array);
    $incidents_label = '';
    foreach ($most_active_incidents as $incident) {
        $incidents_data[$incident['id_incidencia']] = $incident['worked_hours'];
    }
    // Remove the items with no value
    foreach ($incidents_data as $key => $value) {
        if (!$value || $value <= 0) {
            unset($incidents_data[$key]);
        }
    }
    if (empty($most_active_incidents) || empty($incidents_data)) {
        $incidents_label .= graphic_error(false);
        $incidents_label .= __("N/A");
        $incidents_label = "<div class='container_adaptor_na_graphic'>" . $incidents_label . "</div>";
    } else {
        arsort($incidents_data);
        $incidents_label .= pie3d_graph($config['flash_charts'], $incidents_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // TOP X creator users
    $creator_assigned_data = array();
    foreach ($creator_users as $clave => $valor) {
        $creator_assigned_data["{$clave} ({$valor})"] = $valor;
    }
    if (empty($creator_assigned_data)) {
        $submitter_label = "<div style='width:300px; height:150px;'>";
        $submitter_label .= graphic_error(false);
        $submitter_label .= __("N/A");
        $submitter_label .= "</div>";
    } else {
        arsort($creator_assigned_data);
        $submitter_label .= "<br/>" . pie3d_graph($config['flash_charts'], $creator_assigned_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // TOP X scoring users
    $scoring_label = "";
    $top5_scoring = get_best_incident_scoring(5, $incident_id_array);
    foreach ($top5_scoring as $submitter) {
        $scoring_data[$submitter["id_usuario"]] = $submitter["total"];
    }
    if (empty($top5_scoring)) {
        $scoring_label .= graphic_error(false);
        $scoring_label .= __("N/A");
        $scoring_label = "<div class='container_adaptor_na_graphic2'>" . $scoring_label . "</div>";
    } else {
        arsort($scoring_data);
        $scoring_label .= "<br/>" . pie3d_graph($config['flash_charts'], $scoring_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // TOP X assigned users
    $user_assigned_data = array();
    foreach ($assigned_users as $clave => $valor) {
        $user_assigned_data["{$clave} ({$valor})"] = $valor;
    }
    if (empty($user_assigned_data)) {
        $user_assigned_label = "<div style='width:300px; height:150px;'>";
        $user_assigned_label .= graphic_error(false);
        $user_assigned_label .= __("N/A");
        $user_assigned_label .= "</div>";
    } else {
        arsort($user_assigned_data);
        $user_assigned_label .= "<br/>" . pie3d_graph($config['flash_charts'], $user_assigned_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // Show graph with incidents by group
    foreach ($incidents as $incident) {
        $grupo = safe_output(dame_grupo($incident["id_grupo"]));
        if (strlen($grupo) > $max_legend_strlen) {
            $grupo = substr($grupo, 0, $max_legend_strlen) . "...";
        }
        if (!isset($incident_group_data[$grupo])) {
            $incident_group_data[$grupo] = 0;
        }
        $incident_group_data[$grupo] = $incident_group_data[$grupo] + 1;
    }
    arsort($incident_group_data);
    // Show graph with incidents by source group
    foreach ($incidents as $incident) {
        $grupo_src = safe_output(dame_grupo($incident["id_group_creator"]));
        if (strlen($grupo_src) > $max_legend_strlen) {
            $grupo_src = substr($grupo_src, 0, $max_legend_strlen) . "...";
        }
        if (!isset($incident_group_data2[$grupo_src])) {
            $incident_group_data2[$grupo_src] = 0;
        }
        $incident_group_data2[$grupo_src] = $incident_group_data2[$grupo_src] + 1;
    }
    arsort($incident_group_data2);
    // Show graph with tickets open/close histogram
    $ticket_oc_graph = '<div class="pie_frame">' . graph_ticket_oc_histogram($incidents, 650, 250, $ttl) . "</div>";
    $container_title = __("Ticket Open/Close histogram");
    $container_ticket_oc = print_container('container_ticket_oc', $container_title, $ticket_oc_graph, 'open', true, true, "container_simple_title", "container_simple_div");
    // Show graph with tickets open/close histogram
    $ticket_activity_graph = '<div class="pie_frame">' . graph_ticket_activity_calendar($incidents) . "</div>";
    $container_title = __("Ticket activity");
    $container_ticket_activity = print_container('container_ticket_activity', $container_title, $ticket_activity_graph, 'open', true, true, "container_simple_title", "container_simple_div");
    //Print first table
    $output .= "<table class='listing' width=190px border=0 cellspacing=0 cellpadding=0 border=0 >";
    $output .= "<tr>";
    $output .= "<th>" . __("Metric") . "</th>";
    $output .= "<th>" . __("Value") . "</th>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>" . __('Total tickets') . "</strong></td>";
    $output .= "<td valign=top align=center>";
    $output .= $total;
    $output .= "</td>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>" . __('Avg. life time') . "</strong></td>";
    $output .= "<td valign=top align=center>";
    $output .= format_numeric($mean_lifetime / 86400, 2) . " " . __("Days");
    $output .= "</td>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>";
    $output .= __('Avg. work time');
    $output .= "</strong></td>";
    $output .= "<td align=center>" . $mean_work . ' ' . __('Hours') . "</td>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>";
    $output .= __('Avg. Scoring');
    $output .= "</strong></td>";
    $output .= "<td align=center>" . $scoring_avg . "</td>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>";
    $output .= __('Total work time');
    $output .= "</strong></td>";
    $output .= "<td align=center>" . $total_hours . " " . __("Hours") . "</td>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>";
    $output .= __('Total work units');
    $output .= "</strong></td>";
    $output .= "<td align=center>" . $total_workunits . "</td>";
    $output .= "</tr></table>";
    $container_title = __("Tickets statistics");
    $container_incident_statistics = print_container('container_incident_statistics', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $output = "<div class='pie_frame'>" . $incidents_label . "</div>";
    $container_title = __("Top 5 active tickets");
    $container_top5_incidents = print_container('container_top5_incidents', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    if ($incidents) {
        $output = graph_incident_statistics_sla_compliance($incidents, 300, 150, $ttl);
    } else {
        $output = "<div style='width:300px; height:150px;'>";
        $output .= graphic_error(false);
        $output .= __("N/A");
        $output .= "</div>";
    }
    $output = "<div class='container_adaptor_graphic'>" . $output . "</div>";
    $output = "<div class='pie_frame'>" . $output . "</div>";
    $container_title = __("SLA compliance");
    $container_sla_compliance = print_container('container_sla_compliance', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $status_aux .= "<table class='listing' style='width: 420px; margin: 10px auto;' cellspacing=0 cellpadding=0 border=0>";
    $status_aux .= "<tr>";
    $status_aux .= "<th style='text-align:center;'><strong>" . __("Status") . "</strong></th>";
    $status_aux .= "<th style='text-align:center;'><strong>" . __("Number") . "</strong></th>";
    $status_aux .= "<th style='text-align:center;'><strong>" . __("Total time") . "</strong></th>";
    $status_aux .= "</tr>";
    foreach ($incident_status as $key => $value) {
        $name = get_db_value('name', 'tincident_status', 'id', $key);
        $status_aux .= "<tr>";
        $status_aux .= "<td>" . $name . "</td>";
        $status_aux .= "<td style='text-align:center;'>" . $value . "</td>";
        $time = $incident_status_timing[$key];
        $status_aux .= "<td style='text-align:center;'>" . give_human_time($time, true, true, true) . "</td>";
        $status_aux .= "</tr>";
    }
    $status_aux .= "</table>";
    $container_title = __("Ticket by status");
    $container_status_incidents = print_container('container_status_incidents', $container_title, $status_aux, 'no', true, true, "container_simple_title", "container_simple_div");
    $priority_aux .= "<table class='listing table_priority_report' style='width: 420px;' cellspacing=0 cellpadding=0 border=0>";
    $priority_aux .= "<tr>";
    $priority_aux .= "<th style='text-align:center;'><strong>" . __("Priority") . "</strong></th>";
    $priority_aux .= "<th style='text-align:center;'><strong>" . __("Number") . "</strong></th>";
    $priority_aux .= "</tr>";
    foreach ($incident_priority as $key => $value) {
        $priority_aux .= "<tr>";
        $priority_aux .= "<td>" . get_priority_name($key) . "</td>";
        $priority_aux .= "<td style='text-align:center;'>" . $value . "</td>";
        $priority_aux .= "</tr>";
    }
    $priority_aux .= "</table>";
    $priority_aux = $priority_aux;
    $container_title = __("Tickets by priority");
    $container_priority_incidents = print_container('container_priority_incidents', $container_title, $priority_aux, 'no', true, true, "container_simple_title", "container_simple_div");
    if ($oldest_incident) {
        $oldest_incident_time = get_incident_workunit_hours($oldest_incident["id_incidencia"]);
        $output = "<table class='listing'>";
        $output .= "<th>";
        $output .= __("Metric");
        $output .= "</th>";
        $output .= "<th>";
        $output .= __("Value");
        $output .= "</th>";
        $output .= "</tr>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<strong>" . __("Ticket Id") . "</strong>";
        $output .= "</td>";
        $output .= "<td>";
        $output .= '<a href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $oldest_incident['id_incidencia'] . '">#' . $oldest_incident['id_incidencia'] . "</strong></a>";
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<strong>" . __("Ticket title") . "</strong>";
        $output .= "</td>";
        $output .= "<td>";
        $output .= '<a href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $oldest_incident['id_incidencia'] . '">' . $oldest_incident['titulo'] . "</strong></a>";
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<strong>" . __("Worktime hours") . "</strong>";
        $output .= "</td>";
        $output .= "<td>";
        $output .= $oldest_incident_time . " " . __("Hours");
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<strong>" . __("Lifetime") . "</strong>";
        $output .= "</td>";
        $output .= "<td>";
        $output .= format_numeric($max_lifetime / 86400) . " " . __("Days");
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "</table>";
    } else {
        $output = graphic_error(false);
        $output .= __("N/A");
    }
    $output_aux = "<div style='width:100%; height:170px;'>";
    $output_aux .= $output;
    $output_aux .= "</div>";
    $container_title = __("Longest closed ticket");
    $container_longest_closed = print_container('container_longest_closed', $container_title, $output_aux, 'no', true, true, "container_simple_title", "container_simple_div");
    $data = array(__('Open') => $opened, __('Closed') => $total - $opened);
    $data = array(__('Close') => $total - $opened, __('Open') => $opened);
    $output = pie3d_graph($config['flash_charts'], $data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    $output = "<div class='pie_frame'>" . $output . "</div>";
    $container_title = __("Open / Close ticket");
    $container_openclose_incidents = print_container('container_openclose_incidents', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $clean_output = get_parameter("clean_output");
    $container_title = __("Top active users");
    $output = "<div class='pie_frame'>" . $users_label . "</div>";
    $container_topactive_users = print_container('container_topactive_users', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Top ticket submitters");
    $output = "<div class='pie_frame'>" . $submitter_label . "</div>";
    $container_topincident_submitter = print_container('container_topincident_submitter', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Top assigned users");
    $output = "<div class='pie_frame'>" . $user_assigned_label . "</div>";
    $container_user_assigned = print_container('container_user_assigned', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Tickets by group");
    $output = "<br/>" . pie3d_graph($config['flash_charts'], $incident_group_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'] - 1, $ttl);
    $output = "<div class='pie_frame'>" . $output . "</div>";
    $container_incidents_group = print_container('container_incidents_group', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Tickets by creator group");
    $output = "<br/>" . pie3d_graph($config['flash_charts'], $incident_group_data2, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'] - 1, $ttl);
    $output = "<div class='pie_frame'>" . $output . "</div>";
    $container_incident_creator_group = print_container('container_incident_creator_group', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Top 5 average scoring by user");
    $output = "<div class='pie_frame'>" . $scoring_label . "</div>";
    $container_top5_scoring = print_container('container_top5_scoring', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    //Print second table
    $output = "<table class='listing' style='width: 320px; margin: 10px auto'>";
    $output .= "<tr>";
    $output .= "<th style='text-align:center;'><strong>" . __("Group") . "</strong></th>";
    $output .= "<th style='text-align:center;'><strong>" . __("Time") . "</strong></th>";
    $output .= "</tr>";
    $count = 1;
    arsort($groups_time);
    foreach ($groups_time as $key => $value) {
        //Only show first 5
        if ($count == 5) {
            break;
        }
        $output .= "<tr>";
        $group_name = get_db_value('nombre', 'tgrupo', 'id_grupo', $key);
        $output .= "<td>" . $group_name . "</td>";
        $output .= "<td style='text-align: center'>" . give_human_time($value, true, true, true) . "</td>";
        $output .= "</tr>";
        $count++;
    }
    $output .= "</table>";
    $output .= '<br>';
    $output .= '<br>';
    $container_title = __("Top 5 group by time");
    $container_top5_group_time = print_container('container_top5_group_time', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $output = "<table class='listing' style='width: 420px; margin: 10px'>";
    $output .= "<tr>";
    $output .= "<th style='text-align:center;'><strong>" . __("User") . "</strong></th>";
    $output .= "<th style='text-align:center;'><strong>" . __("Time") . "</strong></th>";
    $output .= "</tr>";
    $count = 1;
    arsort($users_time);
    foreach ($users_time as $key => $value) {
        //Only show first 5
        if ($count == 5) {
            break;
        }
        $output .= "<tr>";
        $user_real = get_db_value('nombre_real', 'tusuario', 'id_usuario', $key);
        $output .= "<td>" . $user_real . "</td>";
        $output .= "<td style='text-align: center'>" . give_human_time($value, true, true, true) . "</td>";
        $output .= "</tr>";
        $count++;
    }
    $output .= "</table>";
    $output .= "</table>";
    $container_title = __("Top 5 users by time");
    $container_top5_user_time = print_container('container_top5_user_time', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    if ($simple_mode) {
        // First row
        echo $container_incidents_group;
        echo $container_topincident_submitter;
        echo $container_user_assigned;
        // Second row
        echo $container_incident_statistics;
        echo $container_top5_group_time;
        echo $container_sla_compliance;
    } else {
        // First row
        echo $container_incidents_group;
        echo $container_topincident_submitter;
        echo $container_user_assigned;
        // Second row
        echo $container_incident_statistics;
        echo $container_top5_group_time;
        echo $container_sla_compliance;
        echo '<br><br>';
        // Third row
        echo $container_status_incidents;
        echo $container_priority_incidents;
        //Fourth row
        echo $container_topactive_users;
        echo $container_top5_incidents;
        echo $container_openclose_incidents;
        echo '<br><br><br>';
        //~ // Fifth row
        echo $container_ticket_oc;
        echo '<br><br><br><br><br><br><br><br><br><br><br><br>';
        //~ // Sixth row
        echo $container_ticket_activity;
    }
}
Пример #19
0
					<td style="padding-bottom:15px; width:124px; font-size:15px;">
						<?php 
echo '<b>' . format_numeric($irpf_amount, 2) . ' ' . $invoice['currency'] . '</b>';
?>
					</td>
					<td style="padding-bottom:15px; width:124px; font-size:15px;">
						<?php 
echo '<b>' . format_numeric($tax_amount, 2) . ' ' . $invoice['currency'] . '</b>';
?>
					</td>
					<td style="padding-bottom:15px; width:124px; font-size:15px;">
						<?php 
echo '<b>' . format_numeric($irpf_amount, 2) . ' ' . $invoice['currency'] . '</b>';
?>
					</td>
					<td style="padding-bottom:15px; width:124px; font-size:15px;">
						<?php 
echo '<b>' . format_numeric($total, 2) . ' ' . $invoice['currency'] . '</b>';
?>
					</td>
				</tr>
			</table>
			<?php 
if ($invoice['description']) {
    echo "<table style='border-bottom:1px solid black; width:620px; text-align:center; padding-bottom:15px; '>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='font-size:14px;'>\n\t\t\t\t\t\t\t\t\t<div><pre>" . $invoice['description'] . "</pre></div>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>";
}
?>
		</td>
	</tr>
</table>
Пример #20
0
						echo '<b>'.format_numeric($before_amount,2).' '.$invoice['currency'].'</b>';
					echo '</td>';
					echo '<td style="padding-bottom:15px; width:'. $tdwidth .'px; font-size:15px;">';
						echo '<b>'.format_numeric($tax_amount,2).' '.$invoice['currency'].'</b>';
					echo '</td>';
					if ($irpf_amount != 0){
						echo '<td style="padding-bottom:15px; width:'. $tdwidth .'px; font-size:15px;">';
							echo '<b>'.format_numeric($irpf_amount,2).' '.$invoice['currency'].'</b>';
						echo '</td>';
					}
					echo '<td style="padding-bottom:15px; width:'. $tdwidth .'px; font-size:15px;">';
						echo '<b>'.format_numeric($total,2).' '.$invoice['currency'].'</b>';
					echo '</td>';
					if($invoice['rates'] != 0.00){
						echo '<td style="padding-bottom:15px; width:'. $tdwidth .'px; font-size:15px;">';
							echo '<b>'.format_numeric($total_currency_change,2).' '.$invoice['currency_change'].'</b>';
						echo '</td>';
					}
				echo '</tr>';
			echo '</table>';
			if ($invoice['description']) {
				echo "<table style='border-bottom:1px solid black; width:680px; text-align:center; padding-bottom:15px; '>
							<tr>
								<td style='font-size:14px;'>
									<div><pre>".$invoice['description']."</pre></div>
								</td>
							</tr>
						</table>";
			}
			?>
		</td>
Пример #21
0
 unset($filter['limit']);
 if ($incidents === false) {
     $table->colspan[0][0] = 9;
     $table->data[0][0] = __('Nothing was found');
     $incidents = array();
 }
 foreach ($incidents as $incident) {
     $data = array();
     $link = "index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=" . $incident["id_incidencia"];
     $data[0] = '<strong><a href="' . $link . '">#' . $incident['id_incidencia'] . '</a></strong></td>';
     $data[1] = '';
     if ($incident["affected_sla_id"] != 0) {
         $data[1] = '<img src="images/exclamation.png" />';
     }
     if ($incident["affected_sla_id"] != 0) {
         $data[2] = format_numeric(get_sla_compliance_single_id($incident['id_incidencia']));
     } else {
         $data[2] = "";
     }
     $data[3] = '<a href="' . $config["base_url"] . '/index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $incident['id_incidencia'] . '">' . $incident['titulo'] . '</a>';
     $data[4] = get_db_value("nombre", "tgrupo", "id_grupo", $incident['id_grupo']);
     if ($config["show_creator_incident"] == 1) {
         $id_creator_company = get_db_value("id_company", "tusuario", "id_usuario", $incident["id_creator"]);
         if ($id_creator_company != 0) {
             $company_name = (string) get_db_value('name', 'tcompany', 'id', $id_creator_company);
             $data[4] .= "<br><span style='font-style:italic'>{$company_name}</span>";
         }
     }
     $resolution = isset($resolutions[$incident['resolution']]) ? $resolutions[$incident['resolution']] : __('None');
     $data[5] = '<strong>' . $statuses[$incident['estado']] . '</strong><br /><em>' . $resolution . '</em>';
     $data[6] = print_priority_flag_image($incident['prioridad'], true);
Пример #22
0
            $company = get_db_row('tcompany', 'id', $id);
            foreach ($invoices as $invoice) {
                $lock_permission = crm_check_lock_permission($config["id_user"], $invoice["id"]);
                $is_locked = crm_is_invoice_locked($invoice["id"]);
                $locked_id_user = false;
                if ($is_locked) {
                    $locked_id_user = crm_get_invoice_locked_id_user($invoice["id"]);
                }
                $data = array();
                $url = "index.php?sec=customers&sec2=operation/contracts/contract_detail&view_invoice=1&id_contract=" . $id . "&id=" . $invoice['id_company'] . "&op=invoices&id_invoice=" . $invoice["id"];
                $data[0] = "<a href='{$url}'>" . $invoice["bill_id"] . "</a>";
                $data[2] = format_numeric(get_invoice_amount($invoice["id"])) . " " . strtoupper($invoice["currency"]);
                $tax = get_invoice_tax($invoice["id"]);
                $tax_amount = get_invoice_amount($invoice["id"]) * (1 + $tax / 100);
                if ($tax != 0) {
                    $data[2] .= print_help_tip(__("With taxes") . ": " . format_numeric($tax_amount), true);
                }
                $data[3] = __($invoice["invoice_type"]);
                $data[4] = __($invoice["status"]);
                $data[5] = "<span style='font-size: 10px'>" . $invoice["invoice_create_date"] . "</span>";
                $data[6] = "<span style='font-size: 10px'>" . $invoice["invoice_expiration_date"] . "</span>";
                array_push($table->data, $data);
            }
            print_table($table);
        }
    }
} elseif ($op == "") {
    $id = get_parameter('id_contract');
    if ($id || $id_company) {
        if ($id && !$id_company) {
            $id_company = get_db_value('id_company', 'tcontract', 'id', $id);
Пример #23
0
	$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');
	} else {
		$completion = format_numeric (calculate_project_progress ($project['id']));
		$data[2] = progress_bar($completion, 90, 20);
	}

	// Last update time
	$sql = sprintf ('SELECT tworkunit.timestamp
		FROM ttask, tworkunit_task, tworkunit
		WHERE ttask.id_project = %d
		AND ttask.id = tworkunit_task.id_task
		AND tworkunit_task.id_workunit = tworkunit.id
		ORDER BY tworkunit.timestamp DESC LIMIT 1',
		$project['id']);
	$timestamp = get_db_sql ($sql);
	if ($timestamp != "")
		$data[3] = "<span style='font-size: 10px'>".human_time_comparation ($timestamp)."</span>";
	else
Пример #24
0
function get_user_work_home($id_user, $year)
{
    global $config;
    $hours = get_db_sql("SELECT SUM(tworkunit.duration) FROM tworkunit, tworkunit_task WHERE tworkunit_task.id_workunit = tworkunit.id AND tworkunit_task.id_task > 0 AND id_user = '******' AND timestamp >= '{$year}-01-00 00:00:00' AND timestamp <= '{$year}-12-31 23:59:59' AND tworkunit.work_home=1");
    return format_numeric($hours / $config["hours_perday"]);
}
Пример #25
0
function show_workunit_user($id_workunit, $full = 0, $show_multiple = true)
{
    global $config;
    $sql = "SELECT * FROM tworkunit WHERE id = {$id_workunit}";
    if ($res = mysql_query($sql)) {
        $row = mysql_fetch_array($res);
    } else {
        return;
    }
    $timestamp = $row["timestamp"];
    $duration = $row["duration"];
    $id_user = $row["id_user"];
    $avatar = get_db_value("avatar", "tusuario", "id_usuario", $id_user);
    $nota = $row["description"];
    $have_cost = $row["have_cost"];
    $profile = $row["id_profile"];
    $public = $row["public"];
    $locked = $row["locked"];
    $work_home = $row["work_home"];
    $id_task = get_db_value("id_task", "tworkunit_task", "id_workunit", $row["id"]);
    if (!$id_task) {
        $id_incident = get_db_value("id_incident", "tworkunit_incident", "id_workunit", $row["id"]);
    }
    $id_project = get_db_value("id_project", "ttask", "id", $id_task);
    $id_profile = get_db_value("id_profile", "tworkunit", "id", $id_workunit);
    $task_title = get_db_value("name", "ttask", "id", $id_task);
    if (!$id_task) {
        $incident_title = get_db_value("titulo", "tincidencia", "id_incidencia", $id_incident);
    }
    $project_title = get_db_value("name", "tproject", "id", $id_project);
    // ACL Check for visibility
    if (!$public && $id_user != $config["id_user"]) {
        if ($id_task) {
            $task_access = get_project_access($config["id_user"], false, $id_task, false, true);
            if (!$task_access["manage"]) {
                return;
            }
        } elseif (!give_acl($config["id_user"], 0, "TM")) {
            return;
        }
    }
    echo "<form method='post' action='index.php?sec=projects&sec2=operation/projects/task_workunit'>";
    // Show data
    echo "<div class='notetitle'>";
    // titulo
    echo "<table class='blank' border=0 width='100%' cellspacing=0 cellpadding=0 style='margin-left: 0px;margin-top: 0px; background: transparent;'>";
    echo "<tr><td rowspan=4 width='7%'>";
    print_user_avatar($id_user, true);
    echo "<td width='60%'><b>";
    if ($id_task) {
        echo __('Task') . " </b> : ";
        echo "<a href='index.php?sec=projects&sec2=operation/projects/task_detail&id_task={$id_task}&operation=view'>{$task_title}</A>";
    } else {
        echo __('Ticket') . " </b> : ";
        echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident&id={$id_incident}'>{$incident_title}</A>";
    }
    echo "</td>";
    echo "<td width='13%'>";
    echo "<b>" . __('Duration') . "</b>";
    echo "</td>";
    echo "<td width='20%'>";
    echo " : " . format_numeric($duration);
    echo "</td>";
    echo "<td>";
    // Public WU ?
    echo "<span style='margin-bottom:0px; padding-right:10px;'>";
    if ($public == 1) {
        echo "<img src='images/group.png' title='" . __('Public Workunit') . "' />";
    } else {
        echo "<img src='images/delete.png' title='" . __('Non public Workunit') . "' />";
    }
    echo "</span>";
    echo "</td></tr>";
    echo "<tr>";
    echo "<td><b>";
    if ($id_task) {
        echo __('Project') . " </b> : ";
        echo "<a href='index.php?sec=projects&sec2=operation/projects/task&id_project={$id_project}'>{$project_title}</A>";
    } else {
        echo __('Group') . "</b> : ";
        echo dame_nombre_grupo(get_db_sql("SELECT id_grupo FROM tincidencia WHERE id_incidencia = {$id_incident}"));
    }
    echo "</td>";
    echo "<td><b>";
    if ($have_cost != 0) {
        $profile_cost = get_db_value("cost", "trole", "id", $profile);
        $cost = format_numeric($duration * $profile_cost);
        $cost = $cost . " &euro;";
    } else {
        $cost = __('N/A');
    }
    echo __('Cost');
    echo "</b>";
    echo "</td>";
    echo "<td>";
    echo " : " . $cost;
    echo "</td>";
    if ($show_multiple) {
        echo "<td>";
        echo print_checkbox_extended('op_multiple[]', $id_workunit, false, false, '', '', true);
        echo "</td>";
    }
    echo "</tr>";
    echo "<tr>";
    echo "<td><b>";
    echo __('Work from home');
    echo "</b>";
    if ($work_home == 0) {
        $wfh = __('No');
    } else {
        $wfh = __('Yes');
    }
    echo " : " . $wfh;
    echo "</td>";
    echo "<td><b>";
    echo __('Profile');
    echo "</b></td><td>";
    echo " : " . get_db_value("name", "trole", "id", $profile);
    echo "<tr>";
    echo "<td>";
    echo "<a href='index.php?sec=users&sec2=operation/users/user_edit&id={$id_user}'>";
    echo "<b>" . $id_user . "</b>";
    echo "</a>";
    echo " " . __('said on') . ' ' . $timestamp;
    echo "</td></tr>";
    echo "</table>";
    echo "</div>";
    echo "</form>";
    // Body
    //echo "<div class='notebody'>";
    echo "<div class='notebody' id='wu_{$id_workunit}'>";
    echo "<table width='100%'  class='blank'>";
    echo "<tr><td valign='top'>";
    if (strlen($nota) > 1024 and $full == 0) {
        echo topi_richtext(clean_output_breaks(substr($nota, 0, 1024)));
        echo "<br><br>";
        echo "<a href='index.php?sec=users&sec2=operation/users/user_workunit_report&id_workunit=" . $id_workunit . "&title={$task_title}'>";
        echo __('Read more...');
        echo "</a>";
    } else {
        echo topi_richtext(clean_output_breaks($nota));
    }
    echo "<td valign='top'>";
    echo "<table width='100%'  class='blank'>";
    if ($_GET["sec2"] == "operation/users/user_workunit_report") {
        $myurl = "index.php?sec=users&sec2=operation/users/user_workunit_report&id={$id_user}";
    } else {
        if ($id_project > 0) {
            $myurl = "index.php?sec=projects&sec2=operation/users/user_spare_workunit&id_project={$id_project}&id_task={$id_task}";
        } else {
            $myurl = "index.php?sec=users&sec2=operation/users/user_workunit_report&id={$id_user}";
        }
    }
    if (project_manager_check($id_project) == 1 or $id_user == $config["id_user"] or give_acl($config["id_user"], 0, "TM")) {
        echo "<tr><td align='right'>";
        echo "<br>";
        echo "<a class='delete-workunit' id='delete-{$id_workunit}' href='{$myurl}&id_workunit={$id_workunit}&operation=delete' onclick='if (!confirm(\"" . __('Are you sure?') . "\")) return false;'><img src='images/cross.png'  title='" . __('Delete workunit') . "'/></a>";
    }
    // Edit workunit
    if ((project_manager_check($id_project) == 1 or give_acl($config["id_user"], 0, "TM") or $id_user == $config["id_user"]) and ($locked == "" or give_acl($config["id_user"], 0, "UM"))) {
        echo "<tr><td align='right'>";
        echo "<br>";
        echo "<a class='edit-workunit' id='edit-{$id_workunit}' href='index.php?sec=projects&sec2=operation/users/user_spare_workunit&id_project={$id_project}&id_task={$id_task}&id_workunit={$id_workunit}&id_profile={$id_profile}'><img border=0 src='images/page_white_text.png' title='" . __('Edit workunit') . "'></a>";
        echo "</td>";
    }
    // Lock workunit
    if ((project_manager_check($id_project) == 1 or give_acl($config["id_user"], 0, "TM") or $id_user == $config["id_user"]) and $locked == "") {
        echo "<tr><td align='right'>";
        echo "<br>";
        echo "<a class='lock_workunit' id='lock-{$id_workunit}' href='{$myurl}&id_workunit={$id_workunit}&operation=lock'><img src='images/lock.png' title='" . __('Lock workunit') . "'></a>";
        echo "</td>";
    } else {
        echo "<tr><td align='right'>";
        echo "<br><img src='images/rosette.png' title='" . __('Locked by') . " {$locked}'";
        echo print_user_avatar($locked, true);
        echo "</td>";
    }
    echo "</tr></table>";
    echo "</tr></table>";
    echo "</div>";
}
Пример #26
0
			} else {
				if ($locked_id_user) {
					$data[7] .= ' <img src="images/administrator_lock.png" width="18" height="18" 
					title="'.__('Locked by '.$locked_id_user).'">';
				}
			}
		}
	
		array_push ($table->data, $data);
	}
	print_table ($table);

	if (!empty($final_total)) {
		echo __("Subtotals for each currency: ");
		foreach ($final_total as $key => $value) {
			echo " - $key : ". format_numeric ($value,2);
		}
	}

} else {
	echo ui_print_error_message (__("No invoices"), '', true, 'h3', true);
}


if (($write || $manage) AND ($clean_output == 0)) {
	echo '<form method="post" action="index.php?sec=customers&sec2=operation/invoices/invoices">';
	echo '<div class="button-form" style="width: '.$table->width.'">';
	print_submit_button (__('Create'), 'new_btn', false, 'class="sub next"');
	print_input_hidden ('new_invoice', 1);
	echo '</div>';
	echo '</form>';
Пример #27
0
/** 
 * INTERNAL (use print_timestamp for output): Transform an amount of time in seconds into a human readable
 * strings of minutes, hours or days.
 * 
 * @param int $seconds Seconds elapsed time
 * @param int $exactly If it's true, return the exactly human time
 * 
 * @return string A human readable translation of minutes.
 */
function human_time_description_raw($seconds, $exactly = false)
{
    if (empty($seconds) or $seconds < 0) {
        return __('Now');
        // slerena 25/03/09
        // Most times $seconds is empty is because last contact is current date
        // Put here "uknown" or N/A or something similar is not a good idea
    }
    if ($exactly) {
        $secs = $seconds % 60;
        $mins = $seconds / 60 % 60;
        $hours = $seconds / 3600 % 24;
        $days = $seconds / 86400 % 30;
        $months = format_numeric($seconds / 2592000, 0);
        if ($mins == 0 && $hours == 0 && $days == 0 && $months == 0) {
            return format_numeric($secs, 0) . ' ' . __('seconds');
        } else {
            if ($hours == 0 && $days == 0 && $months == 0) {
                return sprintf("%02d", $mins) . ':' . sprintf("%02d", $secs);
            } else {
                if ($days == 0 && $months == 0) {
                    return sprintf("%02d", $hours) . ':' . sprintf("%02d", $mins) . ':' . sprintf("%02d", $secs);
                } else {
                    if ($months == 0) {
                        return $days . ' ' . __('days') . ' 
' . sprintf("%02d", $hours) . ':' . sprintf("%02d", $mins) . ':' . sprintf("%02d", $secs);
                    } else {
                        return $months . ' ' . __('months') . ' ' . $days . ' ' . __('days') . ' 
' . sprintf("%02d", $hours) . ':' . sprintf("%02d", $mins) . ':' . sprintf("%02d", $secs);
                    }
                }
            }
        }
    }
    if ($seconds < 60) {
        return format_numeric($seconds, 0) . " " . __('seconds');
    }
    if ($seconds < 3600) {
        $minutes = floor($seconds / 60);
        $seconds = $seconds % 60;
        if ($seconds == 0) {
            return $minutes . ' ' . __('minutes');
        }
        $seconds = sprintf("%02d", $seconds);
        return $minutes . ':' . $seconds . ' ' . __('minutes');
    }
    if ($seconds < 86400) {
        return format_numeric($seconds / 3600, 0) . " " . __('hours');
    }
    if ($seconds < 2592000) {
        return format_numeric($seconds / 86400, 0) . " " . __('days');
    }
    if ($seconds < 15552000) {
        return format_numeric($seconds / 2592000, 0) . " " . __('months');
    }
    return "+6 " . __('months');
}
Пример #28
0
					
					// SLA Compliance    
					echo "<td>";
					echo format_numeric (get_sla_compliance_single_id ($incident["id"]));
					echo " %";
					echo "</td></tr>";
				}

				echo "<tr style='border-top: 2px solid #ccc'>";
				echo "<td><b>".__("Totals")."</b></td>";
				echo "<td>";
					echo "<b>".__("Number of tickets"). " </b>: ". $incident_count;
				echo "<td>";
				echo "<b>" . __('Total worktime'). " </b>: ". 
						$incident_totals . __("hr")." ( ". 
							format_numeric(get_working_days ($incident_totals)). " ".__("Working days").")";
				
			}
			echo "</table>";
			
			if ($incident_graph){
				echo "<div style='width:46%; float:left;'>";
					echo "<h3>" . __("Ticket graph report") . "</h3>";
					echo pie3d_graph ($config['flash_charts'], $incident_graph, 500, 
							250, __('others'), "", "", $config['font'], 
								$config['fontsize'], $ttl);
				echo "</div>";

				echo "<div style='width:40%; float:left;'>";
					echo "<h3>" . __("Ticket by group") . "</h3>";
					echo pie3d_graph ($config['flash_charts'], $incident_group_data, 500,