Esempio n. 1
0
/**
* Return total cost assigned to task on external costs attached
*
* $id_task	integer 	ID of task
**/
function project_cost_invoices($id_project)
{
    $tasks = get_db_all_rows_sql("SELECT * FROM ttask WHERE id_project = {$id_project}");
    if ($tasks === false) {
        $tasks = array();
    }
    $total = 0;
    foreach ($tasks as $task) {
        $total += task_cost_invoices($task["id"]);
    }
    return $total;
}
Esempio n. 2
0
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.');
$labelb = __('Real');
$a = round ($hours);
$b = round (get_task_workunit_hours ($id_task));

$image = histogram_2values($a, $b, $labela, $labelb);
Esempio n. 3
0
    $sql = sprintf('INSERT INTO tinvoice (description, id_user, id_task,
	bill_id, concept1, amount1, id_attachment) VALUES ("%s", "%s", %d, "%s", "%s", "%s", %d)', $description, $user_id, $id_task, $bill_id, 'Task cost', $amount, $id_attachment);
    //Check
    $ret = process_sql($sql, 'insert_id');
    if ($ret !== false) {
        echo '<h3 class="suc">' . __('Successfully created') . '</h3>';
    } else {
        echo '<h3 class="error">' . __('There was a problem creating adding the cost') . '</h3>';
    }
    $operation = "list";
}
// Show form to create a new cost
if ($operation == "list") {
    echo "<h3>";
    echo __('Cost unit listing') . " - {$task_name}</h3>";
    $total = task_cost_invoices($id_task);
    echo "<h4>" . __("Total cost for this task") . " : {$total}</h4>";
    $costs = get_db_all_rows_sql("SELECT * FROM tinvoice WHERE id_task = {$id_task}");
    if ($costs === false) {
        $costs = array();
    }
    $table->class = 'listing';
    $table->width = '90%';
    $table->data = array();
    $table->head = array();
    $table->head[0] = __('Description');
    $table->head[1] = __('Amount');
    $table->head[2] = __('Filename');
    $table->head[3] = __('Delete');
    foreach ($costs as $cost) {
        $data = array();