Exemplo n.º 1
0
function selPermWhere($table, $idfld)
{
    global $AppUI;
    // get any companies denied from viewing
    $sql = "SELECT {$idfld}" . "\nFROM {$table}, permissions" . "\nWHERE permission_user = {$AppUI->user_id}" . "\n\tAND permission_grant_on = '{$table}'" . "\n\tAND permission_item = {$idfld}" . "\n\tAND permission_value = 0";
    $deny = db_loadColumn($sql);
    echo db_error();
    return "permission_user = {$AppUI->user_id}" . "\nAND permission_value <> 0" . "\nAND (" . "\n\t(permission_grant_on = 'all')" . "\n\tOR (permission_grant_on = '{$table}' and permission_item = -1)" . "\n\tOR (permission_grant_on = '{$table}' and permission_item = {$idfld})" . "\n\t)" . (count($deny) > 0 ? "\nAND {$idfld} NOT IN (" . implode(',', $deny) . ')' : '');
}
Exemplo n.º 2
0
function getReadableModule()
{
    global $AppUI;
    $perms =& $AppUI->acl();
    $sql = 'SELECT mod_directory FROM modules WHERE mod_active > 0 ORDER BY mod_ui_order';
    $modules = db_loadColumn($sql);
    foreach ($modules as $mod) {
        if ($perms->checkModule($mod, 'access')) {
            return $mod;
        }
    }
    return null;
}
Exemplo n.º 3
0
 /**
  * This function recursively updates all tasks project
  * to the one passed as parameter
  */
 function updateSubTasksProject($new_project, $task_id = null)
 {
     $q = new DBQuery();
     if (is_null($task_id)) {
         $task_id = $this->task_id;
     }
     $q->addTable('tasks');
     $q->addQuery('task_id');
     $q->addWhere("task_parent = '" . $task_id . "'");
     $sql = $q->prepare();
     $q->clear();
     $tasks_id = db_loadColumn($sql);
     if (count($tasks_id) == 0) {
         return true;
     }
     // update project of children
     $q->addTable('tasks');
     $q->addUpdate('task_project', $new_project);
     $q->addWhere("task_parent = '" . $task_id . "'");
     $q->exec();
     $q->clear();
     foreach ($tasks_id as $id) {
         if ($id != $task_id) {
             $this->updateSubTasksProject($new_project, $id);
         }
     }
 }
Exemplo n.º 4
0
 /**
  *	Overload of the dpObject::getDeniedRecords
  *	to ensure that the projects owned by denied companies are denied.
  *
  *	@author	handco <*****@*****.**>
  *	@see	dpObject::getAllowedRecords
  */
 function getDeniedRecords($uid)
 {
     $aBuf1 = parent::getDeniedRecords($uid);
     $oCpy = new CCompany();
     // Retrieve which projects are allowed due to the company rules
     $aCpiesAllowed = $oCpy->getAllowedRecords($uid, 'company_id,company_name');
     $q = new DBQuery();
     $q->addTable('projects');
     $q->addQuery('project_id');
     if (count($aCpiesAllowed)) {
         $q->addWhere('NOT (project_company IN (' . implode(',', array_keys($aCpiesAllowed)) . '))');
     }
     $sql = $q->prepare();
     $q->clear();
     $aBuf2 = db_loadColumn($sql);
     return array_merge($aBuf1, $aBuf2);
 }
Exemplo n.º 5
0
 $sum_total_hours_allocated = $sum_total_hours_worked = 0;
 $sum_hours_allocated_complete = $sum_hours_worked_complete = 0;
 //TODO: Split times for which more than one users were working...
 foreach ($user_list as $user_id => $user) {
     $sql = "SELECT task_id\n\t\t\t        FROM user_tasks\n\t\t\t        where user_id = {$user_id}";
     $tasks_id = db_loadColumn($sql);
     $total_hours_allocated = $total_hours_worked = 0;
     $hours_allocated_complete = $hours_worked_complete = 0;
     foreach ($tasks_id as $task_id) {
         if (isset($task_list[$task_id])) {
             // Now let's figure out how many time did the user spent in this task
             $sql = "SELECT sum(task_log_hours)\n\t\t        \t\t\tFROM task_log\n\t\t        \t\t\tWHERE task_log_task        = {$task_id}\n\t\t\t\t\t              AND task_log_creator = {$user_id}";
             $hours_worked = round(db_loadResult($sql), 2);
             $sql = "SELECT task_percent_complete\n                                                FROM tasks\n                                                WHERE task_id = {$task_id}";
             //                 echo $sql;
             $percent = db_loadColumn($sql);
             $complete = $percent[0] == 100;
             if ($complete) {
                 $hours_allocated_complete += $task_list[$task_id]["hours_allocated"];
                 $hours_worked_complete += $hours_worked;
             }
             $total_hours_allocated += $task_list[$task_id]["hours_allocated"];
             $total_hours_worked += $hours_worked;
         }
     }
     $sum_total_hours_allocated += $total_hours_allocated;
     $sum_total_hours_worked += $total_hours_worked;
     $sum_hours_allocated_complete += $hours_allocated_complete;
     $sum_hours_worked_complete += $hours_worked_complete;
     if ($total_hours_allocated > 0 || $total_hours_worked > 0) {
         $percentage = 0;
Exemplo n.º 6
0
}
if ($do_report) {
    $total = 0;
    if ($fullaccess) {
        $sql = "SELECT company_id FROM companies";
    } else {
        $sql = "SELECT company_id FROM companies WHERE company_owner='" . $AppUI->user_id . "'";
    }
    $companies = db_loadColumn($sql);
    if (!empty($companies)) {
        foreach ($companies as $company) {
            $total += showcompany($company);
        }
    } else {
        $sql = "SELECT company_id FROM companies";
        foreach (db_loadColumn($sql) as $company) {
            $total += showcompany($company, true);
        }
    }
    echo '<h2>' . $AppUI->_('Total Hours') . ":";
    printf("%.2f", $total);
    echo '</h2>';
    if ($log_pdf) {
        // make the PDF file
        $font_dir = dPgetConfig('root_dir') . "/lib/ezpdf/fonts";
        $temp_dir = dPgetConfig('root_dir') . "/files/temp";
        $base_url = dPgetConfig('base_url');
        require $AppUI->getLibraryClass('ezpdf/class.ezpdf');
        $pdf =& new Cezpdf();
        $pdf->ezSetCmMargins(1, 2, 1.5, 1.5);
        $pdf->selectFont("{$font_dir}/Helvetica.afm");
Exemplo n.º 7
0
    //Prevent users from editing other ppls timecards.
    $can_edit_task_logs = $HELPDESK_CONFIG['minimum_edit_level'] >= $AppUI->user_type;
    if (!$can_edit_task_logs) {
        if ($log->task_log_creator != $AppUI->user_id) {
            $AppUI->redirect("m=public&a=access_denied");
        }
    }
} else {
    $log->task_log_help_desk_id = $item_id;
    $log->task_log_name = $hditem['item_title'];
}
// Lets check which cost codes have been used before
$sql = "select distinct task_log_costcode\n        from task_log\n        where task_log_costcode != ''\n        order by task_log_costcode";
$task_log_costcodes = array("");
// Let's add a blank default option
$task_log_costcodes = array_merge($task_log_costcodes, db_loadColumn($sql));
//if ($canEdit) {
// Task Update Form
$df = $AppUI->getPref('SHDATEFORMAT');
$log_date = new CDate($log->task_log_date);
if ($task_log_id) {
    echo $AppUI->_("Edit Log");
} else {
    echo $AppUI->_("Add Log");
}
?>

<!-- TIMER RELATED SCRIPTS -->
<script language="JavaScript">
	// please keep these lines on when you copy the source
	// made by: Nicolas - http://www.javascript-page.com
Exemplo n.º 8
0
 /**
  * This function recursively updates all tasks project
  * to the one passed as parameter
  */
 function updateSubTasksProject($new_project, $task_id = null)
 {
     if (is_null($task_id)) {
         $task_id = $this->task_id;
     }
     $sql = "select task_id\n\t\t        from tasks\n\t\t        where task_parent = '{$task_id}'";
     $tasks_id = db_loadColumn($sql);
     if (count($tasks_id) == 0) {
         return true;
     }
     $sql = "update tasks set task_project = '{$new_project}' where task_parent = '{$task_id}'";
     db_exec($sql);
     foreach ($tasks_id as $id) {
         if ($id != $task_id) {
             $this->updateSubTasksProject($new_project, $id);
         }
     }
 }
Exemplo n.º 9
0
 /**
  * This function recursively updates all tasks project
  * to the one passed as parameter
  */
 function updateSubTasksProject($new_project, $task_id = null)
 {
     if (is_null($task_id)) {
         $task_id = $this->task_id;
     }
     $sql = "SELECT task_id FROM tasks WHERE task_parent = '{$task_id}'";
     $tasks_id = db_loadColumn($sql);
     if (count($tasks_id) == 0) {
         return true;
     }
     $sql = "UPDATE tasks SET task_project = '{$new_project}' WHERE task_parent = '{$task_id}'";
     db_exec($sql);
     foreach ($tasks_id as $id) {
         if ($id != $task_id) {
             $this->updateSubTasksProject($new_project, $id);
         }
     }
 }