Пример #1
0
/**
 The purpose of this script is to find earnings/max earnings for this term
*/
function generate_xls()
{
    //Would like to ask for term to generate report for.  Can we do this?
    global $CFG, $DB, $USER;
    //find all workers
    $workers = $DB->get_records('block_timetracker_workerinfo');
    foreach ($workers as $worker) {
        //demo courses, et. al.
        if ($worker->courseid >= 73 && $worker->courseid <= 76) {
            continue;
        }
        $earnings = get_earnings_this_term($worker->id, $worker->courseid);
        $course = $DB->get_record('course', array('id' => $worker->courseid));
        echo $course->shortname . ',' . $worker->lastname . ',' . $worker->firstname . ',' . $earnings . ',' . $worker->maxtermearnings . "\n";
    }
}
Пример #2
0
/**
 The purpose of this script is to find earnings/max earnings for this term
*/
function generate_xls()
{
    global $CFG, $DB, $USER;
    //find all workers
    $workers = $DB->get_records('block_timetracker_workerinfo');
    foreach ($workers as $worker) {
        //demo courses, et. al.
        if ($worker->courseid >= 73 && $worker->courseid <= 76) {
            continue;
        }
        $earnings = get_earnings_this_term($worker->id, $worker->courseid);
        $course = $DB->get_record('course', array('id' => $worker->courseid));
        $remaining = $worker->maxtermearnings - $earnings;
        //Formatting
        $format_bold =& $workbook->add_format();
        $format_bold->set_bold();
        //Create worksheet
        $worksheet = array();
        $worksheet[1] =& $workbook->add_worksheet('Earnings');
        // Set column widths
        $worksheet[1]->set_column(0, 8, 10.57);
        //Write header data
        $worksheet[1]->write_string(0, 0, 'Department', $format_bold);
        $worksheet[1]->write_string(1, 0, 'Worker Name', $format_bold);
        $worksheet[1]->write_string(2, 0, 'Earnings This Term', $format_bold);
        $worksheet[1]->write_string(3, 0, 'Maximum Term Earnings', $format_bold);
        $worksheet[1]->write_string(4, 0, 'Amount Remaining', $format_bold);
        //Write data to spreadsheet
        //Finish worksheet and workbook and close
        $workbook->close();
        return $fn;
    }
    //Print results in a table
    echo '<table cellspacing="10" cellpadding="5" width="85%">';
    echo '<tr>';
    echo '<td><b>Department</b></td>';
    echo '<td><b>Worker Name</b></td>';
    echo '<td><b>Earnings This Term</b></td>';
    echo '<td><b>Maximum Term Earnings</b></td>';
    echo '<td><b>Amount Remaining</b></td>';
    echo '</tr>';
    echo '<tr><td>' . $course->shortname . '</td><td>' . $worker->lastname . ', ' . $worker->firstname . '</td><td>' . $earnings . '</td><td>' . $worker->maxtermearnings . '</td><td>' . $remaining . '</td></tr>';
}
Пример #3
0
define('CLI_SCRIPT', true);
require_once '../../config.php';
require_once 'lib.php';
/**
 The purpose of this script is to find earnings/max earnings for this term
*/
global $CFG, $DB, $USER;
//find all workers
$workers = $DB->get_records('block_timetracker_workerinfo');
foreach ($workers as $worker) {
    //demo courses, et. al.
    if ($worker->courseid >= 73 && $worker->courseid <= 76) {
        continue;
    }
    $earnings = get_earnings_this_term($worker->id, $worker->courseid);
    $remaining = $worker->maxtermearnings - $earnings;
    $course = $DB->get_record('course', array('id' => $worker->courseid));
    $context = get_context_instance(CONTEXT_COURSE, $worker->courseid);
    $teachers = get_users_by_capability($context, 'block/timetracker:manageworkers');
    /*
    if(!$teachers){
        echo ('No supervisor is enrolled in the course.');
    }
    */
    $supervisor = '';
    $email = '';
    foreach ($teachers as $teacher) {
        if (is_enrolled($context, $teacher->id)) {
            $supervisor .= $teacher->firstname . ' ' . $teacher->lastname . ',' . $teacher->email . ',';
        }
Пример #4
0
/**
* Gives an array with worker stats:
* $stats['totalhours']
* $stats['monthhours'
* $stats['yearhours']
* $stats['termhours']
* $stats['totalearnings'] 
* $stats['monthearnings']
* $stats['yearearnings']
* $stats['termearnings']
* @return an array with useful values
*/
function get_worker_stats($userid, $courseid)
{
    global $DB;
    $stats['totalhours'] = get_total_hours($userid, $courseid);
    $stats['monthhours'] = get_hours_this_month($userid, $courseid);
    $stats['yearhours'] = get_hours_this_year($userid, $courseid);
    $stats['termhours'] = get_hours_this_term($userid, $courseid);
    $stats['totalearnings'] = get_total_earnings($userid, $courseid);
    $stats['monthearnings'] = get_earnings_this_month($userid, $courseid);
    $stats['yearearnings'] = get_earnings_this_year($userid, $courseid);
    $stats['termearnings'] = get_earnings_this_term($userid, $courseid);
    return $stats;
}