Exemplo n.º 1
0
require_once('includes/SI_Task.php');
require_once('includes/SI_Invoice.php');
require_once('includes/SI_Check.php');

checkLogin('accounting');

$project = new SI_Project();

$company = new SI_Company();
$companies = $company->getCompanysWithUnbilledAmount();
if($companies === FALSE){
	$error_msg .= "Could not retrieve Outstanding Hours list!\n";
	debug_message($company->getLastError());
}

$user = new SI_User();
$users = $user->getUnpaidUsers();
if($users === FALSE){
	$error_msg .= "Could not retrieve Unpaid Users's list!\n";
	debug_message($user->getLastError());
}

$invoice = new SI_Invoice();
$invoices = $invoice->getOutstanding();
if($invoices === FALSE){
	$error_msg .= "Could not retrieve Outstanding Invoice list!\n";
	debug_message($invoice->getLastError());
}

$check = new SI_Check();
$checks = $check->retrieveSet("ORDER BY timestamp DESC LIMIT 5");
Exemplo n.º 2
0
	function getUserByLogin($email, $password){
		global $db_conn;
		
		if(empty($email) || empty($password)){
			$this->error = "Both Email and Password are required!";
			return FALSE;
		}
		
		$users = SI_User::retrieveSet("email = '".$db_conn->escapeString($email)."' AND password = '******' AND u.active = 'Y' AND u.deleted = 'N'");
		if(is_object($users[0]) && is_a($users[0], 'SI_User')){
			$users[0]->last_login_ts = time();
			$users[0]->_updateLastLogin();
			return $users[0];
		}else{
			$this->error = "Username and password do not match any current accounts";
			return FALSE;
		}
	}
Exemplo n.º 3
0
 function authenticateUser($email, $password)
 {
     session_regenerate_id();
     $user = new SI_User();
     $login_user = $user->getUserByLogin($email, md5($password));
     if ($login_user === FALSE || is_null($login_user)) {
         $this->error = $user->getLastError();
         unset($_SESSION['userObj']);
         return FALSE;
     } else {
         $user->hasRight("admin");
         $_SESSION['userObj'] = $login_user;
         return $login_user;
     }
 }
Exemplo n.º 4
0
function loginUser($email, $password)
{
    $user = new SI_User();
    $login_user = $user->getUserByLogin($email, $password);
    if ($login_user === FALSE) {
        debug_message($user->getLastError());
        unset($_SESSION['userObj']);
        return FALSE;
    } else {
        $user->hasRight("admin");
        $_SESSION['userObj'] = $login_user;
        return TRUE;
    }
}
Exemplo n.º 5
0
echo checked($task->sales_com, "Y");
?>
 onClick="disableCom(false)">Hourly 
		<INPUT NAME="sales_com" TYPE="radio" VALUE="N" <?php 
echo checked($task->sales_com, "N");
?>
 onClick="disableCom(true)">Non-Billable&nbsp;
	</TD>
</TR>
<TR>
	<TD CLASS="form_field_header_cell">Commission User:</TD>
	<TD CLASS="form_field_cell">
		<SELECT NAME="sales_com_user_id" CLASS="input_text" DISABLED>
			<OPTION VALUE="0">None</OPTION>
			<?php 
echo SI_User::getSelectTags($task->sales_com_user_id);
?>
		</SELECT>
	</TD>
</TR>
<TR>
	<TD CLASS="form_field_header_cell">Commission Type:</TD>
	<TD CLASS="form_field_cell">
		<SELECT NAME="sales_com_type_id" CLASS="input_text" DISABLED>
			<OPTION VALUE="0">None</OPTION>
			<?php 
echo SI_SalesCommissionType::getSelectTags($task->sales_com_type_id);
?>
		</SELECT>
	</TD>
</TR>
Exemplo n.º 6
0
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
require_once 'includes/common.php';
require_once 'includes/SI_Project.php';
require_once 'includes/SI_Company.php';
require_once 'includes/SI_Task.php';
checkLogin();
$project = new SI_Project();
if ($loggedin_user->hasRight('admin') && isset($_REQUEST['id'])) {
    $user_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, 5);
if ($transactions === FALSE) {
    $error_msg .= "Error getting your last 5 transactions!";
    debug_message($user->getLastError());
}
$task = new SI_Task();
Exemplo n.º 7
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
require_once('includes/common.php');
require_once('includes/SI_User.php');

checkLogin("admin");

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

if($_REQUEST['show_all']){
	$clause = "WHERE u.deleted = 'N'";
}else{
	$clause = "WHERE u.active = 'Y' AND u.deleted = 'N'";
}
$users = $user->getAll("$clause ORDER BY first_name, last_name");
if($users === FALSE){
	$error_msg .= "Error getting users!\n";
	debug_message($user->getLastError());
}

$title = "User Administration";
Exemplo n.º 8
0
 *
 */
require_once('includes/common.php');
checkLogin();

require_once('includes/SI_Project.php');
require_once('includes/SI_Task.php');
require_once('includes/SI_TaskActivity.php');
require_once('includes/SI_Expense.php');
require_once('includes/SI_ItemCode.php');

$title = '';
$task_activity = new SI_TaskActivity();
$task = new SI_Task();
$project = new SI_Project();
$user = new SI_User();
$item_code = new SI_ItemCode();
$disabled = false;

if($_REQUEST['mode'] == 'add'){
	$title = "Add Time Entry";
	if(empty($_REQUEST['task_id'])){
		fatal_error("No Task ID specified!\n");
	}else{
		$task_activity->task_id = $_REQUEST['task_id'];
		$task_activity->completed_ts = time();
		$task_activity->user_id = $loggedin_user->id;
		if($task->get($task_activity->task_id) === FALSE){
			fatal_error("Could not retreive task!");
			debug_message($task->getLastError());
		}
Exemplo n.º 9
0
	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;
	}
Exemplo n.º 10
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
require_once('includes/common.php');
checkLogin();

require_once('includes/SI_User.php');
require_once('includes/SI_Company.php');
require_once('includes/SI_UserType.php');
$title = '';
$user = new SI_User();

$title = "Update Profile";
if($loggedin_user->hasRight('admin') && isset($_REQUEST['id'])){
	if($user->get($_REQUEST['id']) === FALSE){
		$error_msg .= "Error getting user information!\n";
		debug_message($user->getLastError());
	}
}else{
	$user = &$loggedin_user;
}


if($_POST['save']){
	if(!empty($_POST['password_1']) || !empty($_POST['password_2'])){
		if($_POST['password_1'] != $_POST['password_2']){
Exemplo n.º 11
0
">
		<img src="images/delete_small.gif" border="0" width="13" height="13" align="middle"/></a>&nbsp;<br>
<?  	}
		}else{?>
		<b>No CCs Setup</b>
<?	} ?>
	</td>
</tr>
<?if($_REQUEST['mode'] == 'edit' && $project->hasRights(PROJECT_RIGHT_EDIT)){?>
<tr>
	<td class="form_field_header_cell">Add CC:</td>
	<td class="form_field_cell">
		<select name="new_cc_id" class="input_text">
			<option value="0">Select User...</option>
			<?php 
echo SI_User::getSelectTags($_POST['new_cc_id'], $cur_cc_ids, FALSE);
?>
		</select>&nbsp;&nbsp;
		<input type="submit" class="button" name="save" value="Add CC">
	</td>
</tr>
<?}?>
<tr>
	<td class="form_field_header_cell">Created On:</td>
	<td class="form_field_cell"><?php 
echo $project->created_ts ? date("D M jS, Y \\a\\t h:i:s A", $project->created_ts) : "";
?>
</td>
</tr>
<tr>
	<td class="form_field_header_cell">Last Updated:</td>
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
	
	
}elseif($_REQUEST['user_id']){
	$title = "for User";
	$field_header = 'Paid';
	$field = 'check';
	$url = $_SERVER['PHP_SELF']."?user_id=".$_REQUEST['user_id']."&unpaid=".$_REQUEST['unpaid']."&";
	$_REQUEST['unpaid'] = strtolower(substr($_REQUEST['unpaid'],0,1)) == "y" ? TRUE : FALSE;
	
	if(!$loggedin_user->hasRight('admin') && !$loggedin_user->hasRight('accounting')){
		if($loggedin_user->id != $_REQUEST['user_id']){
			fatal_error('You do not have access to view this users activities!');
		}
	}
	
	$user = new SI_User();
	$activities = $user->getActivities($_REQUEST['user_id'], $_REQUEST['unpaid']);
	if($activities === FALSE){
		$error_msg .= "Could not retrieve Activity List for User ID ".$_REQUEST['user_id']."!\n";
		debug_message($user->getLastError());
	}
	$commissions = $user->getCommissions($_REQUEST['user_id']);
	if($commissions === FALSE){
		$error_msg .= "Could not retrieve Commission List for User ID ".$user->id."!\n";
		debug_message($user->getLastError());
	}	
}else{
	$display_form = TRUE;
	$title = 'Activity Log';
}
Exemplo n.º 14
0
	header("Location: ".getCurrentURL('time_import_4.php'));
	exit();
}

if(isset($_POST['save'])){
	header("Location: ".getCurrentURL('time_import_7.php'));
	exit();
}

if($_POST['preview']){
	$results = $importer->run();
}

//var_dump($importer);
$task = new SI_Task();
$user = new SI_User();
$ic = new SI_ItemCode();
?>
<? require('header.php'); ?>
<div class="box">
<div class="boxTitle"><h3><?php 
echo $title;
?>
</h3><span class="boxTitleRight">&nbsp;</span><span class="boxTitleCorner">&nbsp;</span></div><div class="boxContent">
<form name="time_import" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" METHOD="POST" ENCTYPE="multipart/form-data">
<table border="0" cellspacing="5" cellpadding="0" class="form_table">
<tr>
	<td>
Exemplo n.º 15
0
?>
&m=<?php 
echo $_GET['m'];
?>
&d=<?php 
echo $_GET['d'];
?>
&user_id="+user_id;
}
</SCRIPT>
<div class="tableContainer">
<a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)"><img src="images/arrow_down.jpg" alt="Hide table" />Calendar</a><div>
<B>Select User:&nbsp;</B>
<SELECT NAME="user_id" onChange="javascript:reloadPage(this)" CLASS="input_text">
	<?php 
echo SI_User::getSelectTags($user_id);
?>
</SELECT>
<?
} //if admin 
?>
<table BORDER="0" CELLSPACING="0" CELLPADDING="0" class="dg_table">
<tr>
	<td colspan="7" class="form_header_cell">
		<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
		<TR>
			<TD WIDTH="20%">
				<a class="link1" href="<?php 
echo $_SERVER['PHP_SELF'] . "?y=" . date('Y', $last) . "&m=" . date('m', $last) . "&d=1";
?>
&user_id=<?php 
Exemplo n.º 16
0
	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;
	}
Exemplo n.º 17
0
function auth_user($username, $password)
{
    return SI_User::getUserByLogin($username, md5($password));
}
Exemplo n.º 18
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
require_once 'includes/common.php';
checkLogin('admin');
require_once 'includes/SI_User.php';
require_once 'includes/SI_Company.php';
require_once 'includes/SI_UserType.php';
$title = '';
$user = new SI_User();
// Clean up hourly_rate
if (!empty($_POST['hourly_rate'])) {
    $_POST['hourly_rate'] = preg_replace('/[^0-9\\.]/', '', $_POST['hourly_rate']);
}
// Clean up salary
if (!empty($_POST['salary'])) {
    $_POST['salary'] = preg_replace('/[^0-9\\.]/', '', $_POST['salary']);
}
if ($_REQUEST['mode'] == 'add') {
    $title = "Add User";
    if ($_POST['save']) {
        $_POST['password'] = md5($_POST['password']);
        $user->updateFromAssocArray($_POST);
        if ($user->add()) {
            if ($user->updateRights($_POST['rights'])) {
Exemplo n.º 19
0
require_once 'includes/SI_Company.php';
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();
Exemplo n.º 20
0
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * 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());
Exemplo n.º 21
0
?>
">
		<?php 
echo $loggedin_user->company;
?>
<?	} ?>
	</td>
</tr>
<tr>
	<td class="form_field_header_cell">Resource:</td>
	<td class="form_field_cell">
<?	if($loggedin_user->hasRight('admin') || !$loggedin_user->isDeveloper()){?>
		<select name="resource_id" class="input_text">
			<option value="0">All</option>
			<?php 
echo SI_User::getSelectTags($_REQUEST['resource_id']);
?>
		</select>
<?	}else{ ?>
		<input name="resource_id" type="hidden" value="<?php 
echo $loggedin_user->id;
?>
">
		<?php 
echo $loggedin_user->first_name . ' ' . $loggedin_user->last_name;
?>
<?	} ?>
	</td>
</tr>
<tr>
	<td class="form_field_header_cell">Start:</td>