// Clean up amount
if(!empty($_POST['amount'])){
	$_POST['amount'] = preg_replace('/[^0-9\.]/','', $_POST['amount']);
}

if($_REQUEST['mode'] == 'add'){
	$title = "Add Scheduled Billing";

	$project_id = intval($_REQUEST['project_id']);
	$task_id = intval($_REQUEST['task_id']);
	if($project_id == 0 && $task_id == 0){
		fatal_error("You must provide a task_id or project_id for this scheduled payment!\n");
	}

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

		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());
		}
	}
 */
require_once('includes/common.php');
require_once('includes/SI_Project.php');
require_once('includes/SI_Task.php');
require_once('includes/SI_TaskActivity.php');
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."&";
Beispiel #3
0
 $task_activity->task_id = intval($_POST['ta_popup_task_id']);
 $task_activity->user_id = $loggedin_user->id;
 $task_activity->text = $_POST['ta_popup_text'];
 $task_activity->item_code_id = $_POST['ta_popup_item_code_id'];
 $debug_info = "\n\t\t\tPOST = " . print_r($_POST, true) . "\n\n\t\t\tstart_ts = {$task_activity->start_ts}\n\n\t\t\tend_ts = {$task_activity->end_ts}\n\n\t\t\ttask_id = {$task_activity->task_id}\n\n\t\t\tuser_id = {$task_activity->user_id}\n\n\t\t\titem_code_id = {$task_activity->item_code_id}\n\n\t\t\ttext = {$task_activity->text}\n\n\t\t";
 $output['debug'] = $debug_info;
 if ($task_activity->task_id > 0 || $task_activity->start_ts > 0 || $task_activity->end_ts > 0) {
     if ($task_activity->task_id <= 0 || $task_activity->start_ts <= 0 || $task_activity->end_ts <= 0) {
         $output['error'] = "Skipping incomplete entry\n";
         break;
     }
 } else {
     $output['error'] = "Skipping incomplete entry\n";
     break;
 }
 if ($task->get($task_activity->task_id) === FALSE) {
     $output['error'] = "Could not retreive task:\n" . $task->getLastError();
     break;
 }
 if ($project->get($task->project_id) === FALSE) {
     $output['error'] = "Could not retreive project:\n" . $project->getLastError();
     break;
 }
 if (!$project->hasRights(PROJECT_RIGHT_EDIT)) {
     $output['error'] = "Insufficent access rights for this project!\n";
     break;
 }
 $task_activity->hourly_cost = $loggedin_user->hourly_rate;
 $company = $project->getCompany();
 if ($company === FALSE) {
     $output['error'] = "Could not get company information:\n" . $project->getLastError();
Beispiel #4
0
				debug_message($project->getLastError());
			}

			if($_POST['save'] != "Add"){
				goBack();
			}
		}else{
			$error_msg .= "Error adding Task!\n";
		}
	}
}else if($_REQUEST['mode'] == 'edit'){
	$title = "Edit Task";
	if(empty($_REQUEST['id'])){
		$error_msg .= "Error: No ID specified!\n";
	}else{
		if(!$task->get($_REQUEST['id'])){
			debug_message($task->getLastError());
			fatal_error("Could not retreive task!");
		}
		if($project->get($task->project_id) === FALSE){
			debug_message($project->getLastError());
			fatal_error("Could not retreive project!");
		}
		if(!$project->hasRights(PROJECT_RIGHT_EDIT)){
			fatal_error('Insufficent access rights for this project!');
		}
	}

	if($_POST['save']){
		$_POST['due_ts'] = getTSFromInput($_POST['due_ts']);
		$task->updateFromAssocArray($_POST);
Beispiel #5
0
function soap_add_task_activity($username, $password, $task_activity)
{
    global $loggedin_user;
    $user = auth_user($username, $password);
    if ($user === FALSE) {
        return new soap_fault('Client', '', 'Access Denied');
    }
    $loggedin_user = $user;
    $task = new SI_Task();
    $project = new SI_Project();
    $item_code = new SI_ItemCode();
    $ta = new SI_TaskActivity();
    $ta->start_ts = $task_activity['start_ts'];
    $ta->end_ts = $task_activity['end_ts'];
    $ta->task_id = $task_activity['task_id'];
    $ta->user_id = $loggedin_user->id;
    $ta->text = $task_activity['text'];
    $ta->item_code_id = $task_activity['item_code_id'];
    if ($ta->task_id > 0 || $ta->start_ts > 0 || $ta->end_ts > 0) {
        if ($ta->task_id <= 0 || $ta->start_ts <= 0 || $ta->end_ts <= 0) {
            return new soap_fault('Client', '', 'Invalid data fields in task_activity');
        }
    }
    if ($task->get($ta->task_id) === FALSE) {
        return new soap_fault('Client', '', 'Could not retreive task ID ' . $ta->task_id, $task->getLastError());
    }
    if ($project->get($task->project_id) === FALSE) {
        return new soap_fault('Client', '', 'Could not retreive project!', $project->getLastError());
    }
    if (!$project->hasRights(PROJECT_RIGHT_EDIT)) {
        return new soap_fault('Client', '', 'Insufficent access rights for this project!');
    }
    $ta->hourly_cost = $loggedin_user->hourly_rate;
    $company = $project->getCompany();
    if ($company === FALSE) {
        return new soap_fault('Client', '', 'Could not get company information!', $project->getLastError());
    }
    $ta->hourly_rate = $item_code->getCompanyPrice($company->id, $ta->item_code_id);
    if ($ta->hourly_rate === FALSE) {
        return new soap_fault('Client', '', 'Error getting price for this item code!', $item_code->getLastError());
    }
    $sct = $task->getSalesCommissionType();
    $ta->sales_com_type_id = $sct->id;
    if ($ta->add()) {
        $project->sendUpdateNotification(array("Added new task activity " . $GLOBALS['CONFIG']['url'] . '/task_activity.php?mode=edit&id=' . $task_activity->id));
    } else {
        return new soap_fault('Client', '', 'Error adding Task Activity!', $ta->getLastError());
    }
    return $ta->id;
}
Beispiel #6
0
// Clean up price
if(!empty($_POST['price'])){
	$_POST['price'] = preg_replace('/[^0-9\.]/','', $_POST['price']);
}

if($_REQUEST['mode'] == 'add'){
	$title = "Add Expense";

	$project_id = intval($_REQUEST['project_id']);
	$task_id = intval($_REQUEST['task_id']);
	if($project_id == 0 && $task_id == 0){
		fatal_error("You must provide a task_id or project_id for this expense!\n");
	}

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

		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());
		}
	}
	function getTask(){
		if($this->task_id <= 0){
			$this->error = 	"SI_TaskActivity::getTask(): Task id is not set";
			return FALSE;
		}
		
		if($this->_task == FALSE){
			$task = new SI_Task();
			if($task->get($this->task_id) === FALSE){
				$this->error = "SI_TaskActivity::getTask(): Error getting task {$this->task_id}: ".$task->getLastError();
				return FALSE;
			}
			$this->_task =& $task;
		}

		return $this->_task;
	}
 function run($preview = true)
 {
     $results = array();
     if (is_readable($this->file)) {
         $handle = fopen($this->file, "r");
         $first_row = true;
         while (($data = fgetcsv($handle, 4096, ",")) !== FALSE) {
             if ($first_row) {
                 $first_row = false;
                 continue;
             }
             // Process a row
             $result = array();
             $result['action'] = 'Import';
             $result['start_ts'] = strtotime($data[$this->column_mappings[SI_IMPORT_COLUMN_START]]);
             if (isset($this->column_mappings[SI_IMPORT_COLUMN_DURATION])) {
                 // Duration based import
                 $result['end_ts'] = $result['start_ts'] + floatval($data[$this->column_mappings[SI_IMPORT_COLUMN_DURATION]]) * 60 * 60;
             } else {
                 // Start and end time provided
                 $result['start_ts'] = strtotime($data[$this->column_mappings[SI_IMPORT_COLUMN_END]]);
             }
             if (isset($this->column_mappings[SI_IMPORT_COLUMN_COMMENTS])) {
                 $result['comments'] = $data[$this->column_mappings[SI_IMPORT_COLUMN_COMMENTS]];
             } else {
                 $results['comments'] = '';
             }
             $user = $data[$this->column_mappings[SI_IMPORT_COLUMN_USER]];
             $normalized_user = $this->normalize($user);
             if (empty($normalized_user)) {
                 $normalized_user = '******';
             }
             if ($this->users[$normalized_user]['action'] == SI_IMPORT_ACTION_SKIP) {
                 $result['user_id'] = 0;
                 $result['message'] = "Skipped because no user map for '{$user}' was configured";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             } else {
                 $result['user_id'] = $this->users[$normalized_user]['param'];
             }
             $task = $data[$this->column_mappings[SI_IMPORT_COLUMN_TASK]];
             $normalized_task = $this->normalize($task);
             if (empty($normalized_task)) {
                 $normalized_task = '_blank_';
             }
             if ($this->tasks[$normalized_task]['action'] == SI_IMPORT_ACTION_SKIP) {
                 $result['task_id'] = 0;
                 $result['message'] = "Skipped because no task map for '{$task}' was configured";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             } else {
                 $result['task_id'] = $this->tasks[$normalized_task]['param'];
             }
             $task = new SI_Task();
             $task->get($result['task_id']);
             $ic = $data[$this->column_mappings[SI_IMPORT_COLUMN_ITEMCODE]];
             $normalized_ic = $this->normalize($ic);
             if (empty($normalized_ic)) {
                 $normalized_ic = '_blank_';
             }
             if ($this->item_codes[$normalized_ic]['action'] == SI_IMPORT_ACTION_SKIP) {
                 $result['item_code_id'] = $task->getDefaultItemCode();
                 if ($result['item_code_id'] == 0) {
                     $result['message'] = "Skipped because no item code map for '{$ic}' was configured and no default item code exists for project";
                     $result['action'] = "Skip";
                     $results[] = $result;
                     continue;
                 } else {
                     $result['message'] = "Item Code retreived from project";
                 }
             } else {
                 $result['item_code_id'] = $this->item_codes[$normalized_ic]['param'];
             }
             if ($result['start_ts'] <= 0 || $result['end_ts'] <= 0) {
                 $result['message'] = "Invalid start or end time";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             }
             if ($result['start_ts'] > $result['end_ts']) {
                 $result['message'] = "Start Time is before end time";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             }
             if ($result['end_ts'] - $result['start_ts'] > 12 * 60 * 60) {
                 $result['message'] = "Length of time is too long, >12 hours";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             }
             $project = new SI_Project();
             $company = new SI_Company();
             $task = new SI_Task();
             $item_code = new SI_ItemCode();
             $task_activity = new SI_TaskActivity();
             $task_activity->start_ts = $result['start_ts'];
             $task_activity->end_ts = $result['end_ts'];
             $task_activity->task_id = $result['task_id'];
             $task_activity->user_id = $result['user_id'];
             $task_activity->text = $result['comments'];
             $task_activity->item_code_id = $result['item_code_id'];
             if ($task_activity->task_id > 0 || $task_activity->start_ts > 0 || $task_activity->end_ts > 0) {
                 if ($task_activity->task_id <= 0 || $task_activity->start_ts <= 0 || $task_activity->end_ts <= 0) {
                     $result['action'] = "Skip";
                     $result['message'] = "Skipping incomplete entry\n";
                     $results[] = $result;
                     continue;
                 }
             } else {
                 $result['action'] = "Skip";
                 $result['message'] = "Skipping incomplete entry\n";
                 $results[] = $result;
                 continue;
             }
             if ($task->get($task_activity->task_id) === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Could not retreive task:\n" . $task->getLastError();
                 $results[] = $result;
                 continue;
             }
             if ($project->get($task->project_id) === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Could not retreive project:\n" . $project->getLastError();
                 $results[] = $result;
                 continue;
             }
             $user = new SI_User();
             if ($user->get($task_activity->user_id) === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Could not retreive user:\n" . $user->getLastError();
                 $results[] = $result;
                 continue;
             }
             $task_activity->hourly_cost = $user->hourly_rate;
             $company = $project->getCompany();
             if ($company === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Could not get company information:\n" . $project->getLastError();
                 $results[] = $result;
                 continue;
             }
             $task_activity->hourly_rate = $item_code->getCompanyPrice($company->id, $task_activity->item_code_id);
             if ($task_activity->hourly_rate === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Error getting price for this item code:\n" . $item_code->getLastError();
                 $results[] = $result;
                 continue;
             }
             $sct = $task->getSalesCommissionType();
             $task_activity->sales_com_type_id = $sct->id;
             if (!$preview) {
                 if (!$task_activity->add()) {
                     $result['action'] = "Skip";
                     $result['message'] = "Error adding Task Activity:\n" . $task_activity->getLastError();
                 }
             }
             $results[] = $result;
         }
     }
     return $results;
 }