task_data.php
/**
 * Handle a 'move' request. 
 * 
 * The task was moved from one box to another, update the tasks status in the database.
 * @param unknown $task_id
 * @param unknown $status The new status of the task
 * @param unknown $owner The person performing the move.
 */
Handle a 'move' request.

The task was moved from one box to another, update the tasks status in the database.
@param unknown $task_id
@param unknown $status The new status of the task
@param unknown $owner The person performing the move.
Handle a ' move ' request . The task was moved from one box to another update the tasks status in the database . @param unknown $task_id @param unknown $status The new status of the task @param unknown $owner The person performing the move .
function handle_move( $task_id, $status, $owner, $ref_date, $estimate = null, $spent = null)
{
	global $database;
	$task_id = $database->escape($task_id);
	$status = $database->escape( $status);
	if (isset($estimate) && isset( $spent))
	{
	    if (!isset($ref_date))
	    {
	        $ref_date =  date('Y-m-d');
	    }
	    update_report( $task_id, $ref_date, $estimate, $spent);    
	}
	if (isset( $owner))
	{
		$owner = $database->escape($owner);
		$owner_update = ", resource_id = $owner";
	}
	else {
		$owner_update = '';
	}
	$move_query = "UPDATE task SET status='$status' $owner_update WHERE task_id = $task_id";
	$success = $database->exec($move_query);
	if ($status == 'forwarded' || $status == 'done')
	{
	    $reason = ($status == 'forwarded')?'forward':'estimate';
		$select_query =
		    "SELECT * FROM report WHERE task_id=" . $task_id . " AND date=CURDATE()";
		$result = $database->exec($select_query);
		if (mysql_num_rows($result) > 0)
		{
			$report_query = 
				"UPDATE report SET estimate=0, reason='$reason' WHERE task_id=" . $task_id . " AND date=CURDATE()";
		}
		else
		{
			$report_query = 
				"INSERT INTO report(task_id, resource_id, date, reason, burnt, estimate) ".
				"SELECT $task_id, resource_id, NOW(), '$reason', 0, 0 FROM task WHERE task_id = $task_id";
		}	
		$database->exec( $report_query);
	}
	if ($success)
	{
	    print_single_task($task_id);
	}
	$log = new Log( $database);
	$log->move($task_id, $status);
}
function handle_move ( $ task_id , $ status , $ owner , $ ref_date , $ estimate = null , $ spent = null ) { global $ database ; $ task_id = $ database -> escape ( $ task_id ) ; $ status = $ database -> escape ( $ status ) ; if ( isset ( $ estimate ) && isset ( $ spent ) ) { if ( ! isset ( $ ref_date ) ) { $ ref_date = date ( 'Y-m-d' ) ; } update_report ( $ task_id , $ ref_date , $ estimate , $ spent ) ; } if ( isset ( $ owner ) ) { $ owner = $ database -> escape ( $ owner ) ; $ owner_update = " , resource_id =  $ owner " ; } else { $ owner_update = '' ; } $ move_query = " UPDATE task SET status=' $ status '  $ owner_update  WHERE task_id =  $ task_id " ; $ success = $ database -> exec ( $ move_query ) ; if ( $ status == 'forwarded' || $ status == 'done' ) { $ reason = ( $ status == 'forwarded' ) ? 'forward' : 'estimate' ; $ select_query = " SELECT * FROM report WHERE task_id= " . $ task_id . "  AND date=CURDATE() " ; $ result = $ database -> exec ( $ select_query ) ; if ( mysql_num_rows ( $ result ) > 0 ) { $ report_query = " UPDATE report SET estimate=0, reason=' $ reason ' WHERE task_id= " . $ task_id . "  AND date=CURDATE() " ; } else { $ report_query = " INSERT INTO report(task_id, resource_id, date, reason, burnt, estimate)  " . " SELECT  $ task_id , resource_id, NOW(), ' $ reason ', 0, 0 FROM task WHERE task_id =  $ task_id " ; } $ database -> exec ( $ report_query ) ; } if ( $ success ) { print_single_task ( $ task_id ) ; } $ log = new Log ( $ database ) ; $ log -> move ( $ task_id , $ status ) ; }
Handle a 'move' request.
Handle a ' move ' request .
// if the new status is 'forwarded' or 'done', automatically add a report setting the tasks new estimate to 0 // Update the existing report for today. // Add a report with estimate set to 0.