示例#1
0
		if(isset($_POST['start_ts'])) $_POST['start_ts'] = getTSFromInput($_POST['start_ts']['date'], $_POST['start_ts']['time']);
		if(isset($_POST['end_ts'])) $_POST['end_ts'] = getTSFromInput($_POST['end_ts']['date'], $_POST['end_ts']['time']);
		if($user->get($_POST['user_id']) === FALSE){
			fatal_error("Could not get user information!\n");
			debug_message($user->getLastError());
		}

		$hourly_rate = $item_code->getCompanyPrice($company->id, $_POST['item_code_id']);
		if($hourly_rate === FALSE){
			$error_msg = "Error getting price for this item code!";
			debug_message($item_code->getLastError());
		}
		if(!isset($_POST['hourly_rate']) || empty($_POST['hourly_rate'])){
			$_POST['hourly_rate'] = $hourly_rate;
		}
		$task_activity->updateFromAssocArray($_POST);
		if($task_activity->add()){
			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();