} else { $error_msg .= "Error updating user rights!\n"; debug_message($user->getLastError()); } } else { $error_msg .= "Error adding User!\n"; debug_message($user->getLastError()); } } } else { if ($_REQUEST['mode'] == 'edit') { $title = "Edit User"; if (empty($_REQUEST['id'])) { $error_msg .= "Error: No ID specified!\n"; } else { if (!$user->get($_REQUEST['id'])) { $error_msg .= "Error retrieving user information!\n"; debug_message($user->getLastError()); } } if ($_POST['save']) { if (!empty($_POST['password'])) { $_POST['password'] = md5($_POST['password']); } else { unset($_POST['password']); } $user->updateFromAssocArray($_POST); if ($user->update()) { if ($user->updateRights($_POST['rights'])) { goBack(); } else {
* http://www.gnu.org/copyleft/gpl.html * */ require_once('includes/common.php'); require_once('includes/SI_Check.php'); require_once('includes/SI_User.php'); require_once('includes/SI_UserTransaction.php'); require_once('includes/SI_TaskActivity.php'); checkLogin(); $activity = new SI_TaskActivity(); $check = new SI_Check(); $user = new SI_User(); if($user->get($_REQUEST['user_id']) === FALSE){ $error_msg .= "Could not retrieve information for User ID ".$_REQUEST['user_id']."!\n"; debug_message($user->getLastError()); } $activities = $user->getActivities($user->id); if($activities === FALSE){ $error_msg .= "Could not retrieve Activity List for User ID ".$user->id."!\n"; debug_message($user->getLastError()); } $commissions = $user->getCommissions($user->id); if($commissions === FALSE){ $error_msg .= "Could not retrieve Commission List for User ID ".$user->id."!\n"; debug_message($user->getLastError()); }
$task_activity->item_code_id = $project->default_item_code_id; $company = $project->getCompany(); if($company === FALSE){ fatal_error("Could not get company information!\n"); debug_message($project->getLastError()); } $task_activity->hourly_rate = $company->hourly_rate; $sct = $task->getSalesCommissionType(); $task_activity->sales_com_type_id = $sct->id; } if($_POST['save']){ if(!isset($_POST['user_id'])) $_POST['user_id'] = $loggedin_user->id; 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'])){
function getSalesCommissionUser(){ if($this->_sct_user == FALSE){ $sct_user = new SI_User(); if($this->sales_com == 'Y' && $this->sales_com_user_id > 0){ if($sct_user->get($this->sales_com_user_id) === FALSE){ $this->error = "SI_Project::getSalesCommissionUser(): Error getting sales commission user: "******"SI_Project::getSalesCommissionUser(): Invalid sales commission setting: {$this->sales_com}"; return FALSE; } } return $this->_sct_user; }
require_once 'includes/SI_Task.php'; $trans_per_page = 30; if (!isset($_REQUEST['page'])) { $_REQUEST['page'] = 0; } $url = $_SERVER['PHP_SELF'] . '?'; checkLogin(); $project = new SI_Project(); if ($loggedin_user->hasRight('admin') && isset($_REQUEST['id'])) { $user_id = $_REQUEST['id']; $url .= 'id=' . $_REQUEST['id'] . '&'; } else { $user_id = $loggedin_user->id; } $user = new SI_User(); if ($user->get($user_id) === FALSE) { $error_msg .= "Error getting user information!\n"; debug_message($user->getLastError()); } $balance = $user->getBalance(); if ($balance === FALSE) { $error_msg .= "Error getting your outstanding balance!"; debug_message($loggedin_user->getLastError()); } $transactions = $user->getTransactions(NULL, $trans_per_page, $_REQUEST['page'] * $trans_per_page); if ($transactions === FALSE) { $error_msg .= "Error getting your transactions!"; debug_message($user->getLastError()); } $total_transactions = $user->getTransactionCount(); if ($total_transactions === FALSE) {
function getUser(){ if($this->user_id <= 0){ $this->error = "SI_TaskActivity::getTask(): User id is not set"; return FALSE; } if($this->_user == FALSE){ $user = new SI_User(); if($user->get($this->user_id) === FALSE){ $this->error = "SI_TaskActivity::getUser(): Error getting user: ".$user->getLastError(); return FALSE; } $this->_user =& $user; } return $this->_user; }
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; }