require_once('includes/SI_PaymentSchedule.php');

checkLogin();

$project = new SI_Project();
$task = new SI_Task();
$ta = new SI_TaskActivity();
$activities = array();

if(!empty($_REQUEST['task_id'])){
	$task->get($_REQUEST['task_id']);
	$project->get($task->project_id);
	if(!$project->hasRights(PROJECT_RIGHT_VIEW)){
		fatal_error('Insufficent access rights for this project!');
	}
	$activities = $ta->retrieveSet("task_id = ".$task->id);
	if($activities === FALSE){
		$error_msg .= "Error getting list of task time!\n";
		debug_message($ta->getLastError());
	}
}else{
	fatal_error("Task ID must be supplied!\n");
}

$my_url = $_SERVER['PHP_SELF']."?task_id=".$task->id."&";

$_REQUEST['detail'] = strtolower(substr($_REQUEST['detail'],0,1)) == "y" ? TRUE : FALSE;

$title = "Time for ".$task->name;

$total_time = 0;
Beispiel #2
0
  	function getPDF($detail = false){
		if(!is_array($this->_lines) || count($this->_lines) == 0){
			$this->error = "Invoice has no line items.";
			return FALSE;
		}
		
		$company =& $this->getCompany();
		$company_info = $this->getInvoiceText();
		
		$client_info = array();
		$client_info['name'] = $company->name;
		$client_info['address1'] = $company->address1;
		$client_info['address2'] = $company->address2;
		$client_info['address3'] = $company->city.", ".$company->state."  ".$company->zip;
		$client_info['phone1'] = $company->phone;
		$client_info['fax'] = $company->fax;
		
		$line_items = array();
		$line_index = 0;
		foreach($this->_lines as $line){
			$line_items[$index]['item_code'] = $line->getItemCodeCode();
			$line_items[$index]['quantity'] = $line->quantity;
			$line_items[$index]['description'] = $line->description;
			$line_items[$index]['unit_price'] = number_format($line->unit_price, 2);
			$line_items[$index]['tax_amount'] = number_format($line->getTaxAmount(), 2);
			$line_items[$index]['tax_rate'] = $line->getTaxRate();
			$line_items[$index]['subtotal'] = $line->getSubTotal();
			$line_items[$index]['total'] = $line->getTotal();
			$index++;
			if($detail){
				$activity_ids = $line->getTaskActivityIDs();
				$activities = SI_TaskActivity::retrieveSet("a.id IN (".join(', ', $activity_ids).")");
				foreach ($activities as $act){
					$line_items[$index]['item_code'] = '';
					$line_items[$index]['quantity'] = '';
					$line_items[$index]['unit_price'] = '';
					$line_items[$index]['tax_amount'] = '';
					$line_items[$index]['tax_rate'] = '';
					$line_items[$index]['subtotal'] = '';
					$line_items[$index]['total'] = '';
					$line_items[$index]['description'] = $act->getUsername()." ".date('Y-m-d H:i', $act->start_ts)." - ".date('H:i', $act->end_ts);
					$index++;
					
					
					$line_items[$index]['item_code'] = '';
					$line_items[$index]['quantity'] = '';
					$line_items[$index]['unit_price'] = '';
					$line_items[$index]['tax_amount'] = '';
					$line_items[$index]['tax_rate'] = '';
					$line_items[$index]['subtotal'] = '';
					$line_items[$index]['total'] = '';
					$line_items[$index]['description'] = $act->text;
					$index++;
				}
			}
		}
		
		$inv_pdf = new SI_PDFInvoice($this->id, $company_info, $client_info, $line_items, $this->terms, $this->timestamp, $this->getAmountPaid());
		$pdf_file = $inv_pdf->get_invoice_pdf();
		if($pdf_file === FALSE){
			$this->error = "Error creating invoice PDF: ".$inv_pdf->error;
			return FALSE;
		}
  			
		return $pdf_file;
  	}
	function getByTaskId($task_id){
		global $db_conn;

		$task_id = intval($task_id);
		if($task_id <= 0){
			$this->error = "SI_TaskActivity::getByTaskId() : TaskActivity task_id not set\n";
			return FALSE;
		}

		$TaskActivity = SI_TaskActivity::retrieveSet("WHERE a.task_id = $task_id");
		if($TaskActivity === FALSE){
			return FALSE;
		}

		return $TaskActivity;
	}
	function _getLinked(){
		$id = intval($this->id);
		if($id <= 0)
			return TRUE;
			
		if($this->_ta == FALSE){
			$ta = new SI_TaskActivity();
			$tas = $ta->retrieveSet("WHERE a.cost_trans_id = $id OR a.com_trans_id = $id");
			if($tas === FALSE){
				$this->error = "Error getting linked task: ".$ta->getLastError();
				return FALSE;	
			}
			if(count($tas) == 1){
				$this->_ta = &$tas[0];
			}
		}
		
		if($this->_check == FALSE){
			$check = new SI_Check();
			$checks = $check->retrieveSet("WHERE trans_id = $id");
			if($checks === FALSE){
				$this->error = "Error getting linked task: ".$check->getLastError();
				return FALSE;	
			}
			if(count($checks) == 1){
				$this->_check = &$checks[0];
			}
		}

		return TRUE;
	}