Ejemplo n.º 1
0
		}
		$task_activity->hourly_rate = $hourly_rate;
		$task_activity->updateFromAssocArray($_POST);
		if($task_activity->update()){
			if(is_array($_POST['item_ids'])){
				if($task_activity->setItems($_POST['item_ids']) === FALSE){
					$error_msg .= "Error adding completed items to activity!\n";
					debug_message($task_activity->getLastError());
				}
			}
			if(is_array($_POST['expense']) && $_POST['expense']['item_code_id'] > 0){
				if(!empty($_POST['expense']['description']) && 
				   !empty($_POST['expense']['cost']) && 
				   !empty($_POST['expense']['price'])){
					$exp = new SI_Expense();
					$exp->updateFromAssocArray($_POST['expense']);
					$exp->task_id = $task_activity->task_id;
					$exp->created_ts = time();
					if($exp->add() === FALSE){
						$error_msg .= "Error adding new expense!\n";
						debug_message($exp->getLastError());	
					}
				}else{
					$error_msg .= "Not adding expense, description, cost and price must all be provided!";	
				}
			}elseif(is_array($_POST['expense']) && $_POST['expense']['item_code_id'] <= 0 && 
					(!empty($_POST['expense']['description']) ||
					!empty($_POST['expense']['cost']) ||
					!empty($_POST['expense']['price'])
					)){
				$error_msg .= "Not adding expense, item code must be selected!";	
Ejemplo n.º 2
0
		}

		if($project->get($task->project_id) === FALSE){
			$error_msg .= "Error getting project information!\n";
			debug_message($project->getLastError());
		}
	}else{
		if($project->get($project_id) === FALSE){
			$error_msg .= "Error getting project information!\n";
			debug_message($project->getLastError());
		}
	}


	if($_POST['save']){
		$expense->updateFromAssocArray($_POST);
		if($expense->add()){
			goBack();
		}else{
			$error_msg .= "Error adding Expense!\n";
			debug_message($expense->getLastError());
		}
	}
}else if($_REQUEST['mode'] == 'edit'){
	$title = "Edit Expense";
	if(empty($_REQUEST['id'])){
		$error_msg .= "Error: No ID specified!\n";
	}else{
		if(!$expense->get($_REQUEST['id'])){
			$error_msg .= "Error retrieving payment information!\n";
			debug_message($expense->getLastError());