print_string('notactiveerror', 'block_timetracker'); echo '<br />'; echo $OUTPUT->footer(); die; } if ($mform->is_cancelled()) { //user clicked cancel redirect($nextpage); } else { if ($formdata = $mform->get_data()) { $formdata->courseid = $formdata->id; unset($formdata->id); $formdata->payrate = $workerrecord->currpayrate; $formdata->lastedited = time(); $formdata->lasteditedby = $formdata->editedby; $worked = add_unit($formdata, true); //$addhourlog = $DB->insert_record('block_timetracker_workunit', $formdata); if ($worked) { add_to_log($COURSE->id, '', 'add work unit', '', 'TimeTracker work unit added.'); $status = 'Hourlog entry saved successfully.'; } else { add_to_log($COURSE->id, '', 'error adding work unit', '', 'TimeTracker worker tried to add work unit, but was unsuccessful.'); $status = 'There was an error. Please see your supervisor.'; } redirect($nextpage, $status, 1); } else { //form is shown for the first time echo $OUTPUT->header(); $tabs = get_tabs($urlparams, $canmanage, $courseid); $tabs = array($tabs); print_tabs($tabs, 'hourlog');
switch ($_POST[add]) { case "tower": unset($msg); add_tower($_POST['tw_id'], $_POST['desc']); break; //add tower //add tower case "type": unset($msg); add_type($_POST[type_id], $_POST[desc], $_POST[tw_id], $_POST[price]); break; //add type //add type case "unit": unset($msg); add_unit($_POST[ut_id], $_POST[type], $_POST[tw_id], $_POST[floor], $_POST[area]); break; //add unit //add unit case "plan": unset($msg); add_plan($_POST[bill_plan], $_POST[name], $_POST[years], $_POST[roi]); break; //add billing plan } ?> <div class="container"> <h2>Customer View</h2> <ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#home">Sales Order</a></li>
function get_content() { global $CFG, $DB, $USER, $OUTPUT, $COURSE; //$this->config = get_timetracker_config($COURSE->id); $clockin = optional_param('clockin', 0, PARAM_INTEGER); $clockout = optional_param('clockout', 0, PARAM_INTEGER); $courseid = $COURSE->id; $worker = $DB->get_record('block_timetracker_workerinfo', array('mdluserid' => $USER->id, 'courseid' => $COURSE->id)); if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); //echo $this->config->block_timetracker_default_max_earnings; if (!isset($this->config)) { if (has_capability('block/timetracker:manageworkers', $this->context)) { $this->content->text = 'TimeTracker block must be configured before used.'; } else { $this->content->text = '<span style="color: red"> TimeTracker is not yet configured. Contact your supervisor with this error</span>'; } return $this->content; } $baseurl = $CFG->wwwroot . '/blocks/timetracker'; $canmanage = false; if (has_capability('block/timetracker:manageworkers', $this->context)) { $canmanage = true; } $canview = false; if (has_capability('block/timetracker:viewonly', $this->context)) { $canview = true; } if ($canmanage || $canview) { //if config is setup to show term hours/earnings AND //terms are not configured, provide a link to the terms page. if ($this->config->block_timetracker_show_term_hours == 1 || $this->config->block_timetracker_show_term_earnings == 1) { $numterms = $DB->count_records('block_timetracker_term', array('courseid' => $COURSE->id)); if ($numterms == 0) { $this->content->text .= '<b><center><a style="color: red" href="' . $CFG->wwwroot . '/blocks/timetracker/terms.php?id=' . $COURSE->id . '">**Configure terms**</center></b></a>'; $this->content->text .= "<br /><br />"; } } $hasalerts = has_course_alerts($COURSE->id); if (has_capability('moodle/site:config', $this->context)) { $hasalerts = has_course_alerts($COURSE->id); } $indexparams['id'] = $courseid; $this->content->text .= '<div style="text-align: left">'; //check to see if the supervisor needs to manage if ($hasalerts && $canmanage) { $alertsurl = new moodle_url($baseurl . '/managealerts.php', $indexparams); $alerticon = new pix_icon('alert', 'Manage Alerts', 'block_timetracker'); $alertaction = $OUTPUT->action_icon($alertsurl, $alerticon); $this->content->text .= get_alerts_link($COURSE->id, $alerticon, $alertaction); } $hastimesheets = has_unsigned_timesheets($COURSE->id); if (has_capability('moodle/site:config', $this->context)) { $hastimesheets = has_unsigned_timesheets($COURSE->id); } if ($hastimesheets && $canmanage) { $timesheetsurl = new moodle_url($baseurl . '/supervisorsig.php', $indexparams); $timesheetsicon = new pix_icon('alert', 'Sign Timesheets', 'block_timetracker'); $timesheetsaction = $OUTPUT->action_icon($timesheetsurl, $timesheetsicon); $this->content->text .= get_timesheet_link($COURSE->id, $timesheetsicon, $timesheetsaction); } $index = new moodle_url($baseurl . '/index.php', $indexparams); $timeclockdataicon = new pix_icon('manage', 'Manage', 'block_timetracker'); $timeclockdataaction = $OUTPUT->action_icon($index, $timeclockdataicon); $this->content->text .= $timeclockdataaction . ' ' . $OUTPUT->action_link($index, 'Main') . '<br />'; $reportsurl = new moodle_url($baseurl . '/reports.php', $indexparams); $reportsaction = $OUTPUT->action_icon($reportsurl, new pix_icon('report', 'Reports', 'block_timetracker')); $this->content->text .= $reportsaction . ' ' . $OUTPUT->action_link($reportsurl, 'Reports') . '<br />'; $timesheeturl = new moodle_url($baseurl . '/timesheet.php', $indexparams); $timesheetaction = $OUTPUT->action_icon($timesheeturl, new pix_icon('date', 'Timesheets', 'block_timetracker')); $this->content->text .= $timesheetaction . ' ' . $OUTPUT->action_link($timesheeturl, 'Timesheet') . '<br />'; $manageurl = new moodle_url($baseurl . '/manageworkers.php', array('id' => $COURSE->id)); $manageaction = $OUTPUT->action_icon($manageurl, new pix_icon('user_group', 'Manage workers', 'block_timetracker')); $this->content->text .= $manageaction . ' ' . $OUTPUT->action_link($manageurl, 'Manage workers') . '<br />'; $numtimeclock = $DB->count_records('block_timetracker_workerinfo', array('courseid' => $courseid, 'timetrackermethod' => 0)); if ($numtimeclock > 0) { //show anyone who has a pending: $pendingunits = $DB->get_records('block_timetracker_pending', array('courseid' => $courseid)); $this->content->text .= "<br />Currently Clocked In:"; $this->content->text .= '<ul>'; if (!$pendingunits) { $this->content->text .= '<li>None</li>'; } else { $workers = $DB->get_records('block_timetracker_workerinfo'); foreach ($pendingunits as $pending) { $this->content->text .= '<li><a href="' . $CFG->wwwroot . '/blocks/timetracker/reports.php?id=' . $courseid . '&userid=' . $pending->userid . '">' . $workers[$pending->userid]->lastname . ', ' . $workers[$pending->userid]->firstname . ' ' . '</a>' . userdate($pending->timein, get_string('timeformat', 'block_timetracker')) . '</li>' . "\n"; } } } $this->content->text .= '</ul>'; } else { //worker //Worker doesn't exist yet, or has missing data if (!$worker) { // || ($worker->address=='0')){ //print_object($worker); $link = '/blocks/timetracker/updateworkerinfo.php?id=' . $COURSE->id . '&userid=' . $worker->id; $action = null; $this->content->text = '<center>'; $this->content->text .= '<span style="color: red">' . $OUTPUT->action_link($link, get_string('registerinfo', 'block_timetracker'), $action); $this->content->text .= '</span></center>'; return $this->content; } else { /* if($worker->active == 0){ $this->content->text = get_string('notactiveerror','block_timetracker'); return $this->content; } */ // Implement Icons - Timeclock Method if ($worker->timetrackermethod == 0) { $ttuserid = $worker->id; $pendingrecord = $DB->get_record('block_timetracker_pending', array('userid' => $ttuserid, 'courseid' => $courseid)); $urlparams['userid'] = $ttuserid; $urlparams['id'] = $courseid; $indexparams['userid'] = $ttuserid; $indexparams['id'] = $courseid; $index = new moodle_url($baseurl . '/index.php', $indexparams); if (!$pendingrecord) { $urlparams['clockin'] = 1; $timeclockurl = new moodle_url($baseurl . '/timeclock.php', $urlparams); $timeclockicon = new pix_icon('clock_play', 'Clock in', 'block_timetracker'); $timeclockdesc = ' Clock-in'; } else { $urlparams['clockout'] = 1; $urlparams['ispending'] = true; $urlparams['unitid'] = $pendingrecord->id; $timeclockurl = new moodle_url($CFG->wwwroot . '/blocks/timetracker/timeclock.php', $urlparams); $timeclockicon = new pix_icon('clock_stop', 'Clock in', 'block_timetracker'); $timeclockdesc = ' Clock-out'; $alertlink = new moodle_url($baseurl . '/alert.php', $urlparams); $alerticon = new pix_icon('alert', 'Alert Supervisor of Error', 'block_timetracker'); $alertaction = $OUTPUT->action_icon($alertlink, $alerticon); } //Icons $timeclockaction = $OUTPUT->action_icon($timeclockurl, $timeclockicon); $timeclockdataicon = new pix_icon('manage', 'Manage', 'block_timetracker'); $timeclockdataaction = $OUTPUT->action_icon($index, $timeclockdataicon); $editurl = new moodle_url($baseurl . '/updateworkerinfo.php', $indexparams); $editurl->params(array('mdluserid' => $USER->id)); $editaction = $OUTPUT->action_icon($editurl, new pix_icon('user_edit', get_string('edit'), 'block_timetracker')); $reportsurl = new moodle_url($baseurl . '/reports.php', $indexparams); $reportsurl->params(array('userid' => $worker->id)); $reportsaction = $OUTPUT->action_icon($reportsurl, new pix_icon('report', 'Reports', 'block_timetracker')); $timesheeturl = new moodle_url($baseurl . '/timesheet.php', $indexparams); $timesheeturl->params(array('userid' => $worker->id)); $timesheetaction = $OUTPUT->action_icon($reportsurl, new pix_icon('date', 'Timesheets', 'block_timetracker')); $this->content->text .= '<div style="text-align: left">'; $this->content->text .= $timeclockdataaction . ' <a href="' . $index . '">Main</a><br />' . $timeclockaction . ' <a href="' . $timeclockurl . '">' . $timeclockdesc . '</a><br />' . $reportsaction . ' <a href="' . $reportsurl . '">Reports</a><br />' . $timesheetaction . ' <a href="' . $timesheeturl . '">Timesheets</a><br />' . $editaction . ' <a href="' . $editurl . '"> Edit my info</a><br /><br />'; $this->content->text .= '</div>'; if ($pendingrecord) { $pendingtimestamp = $DB->get_record('block_timetracker_pending', array('userid' => $ttuserid, 'courseid' => $courseid)); $this->content->text .= 'Clock-in:<br />' . $alertaction . ' ' . userdate($pendingtimestamp->timein, get_string('datetimeformat', 'block_timetracker')) . '<br />'; } $this->content->text .= '<hr>'; } else { if ($worker->timetrackermethod == 1) { //Hourlog Method $ttuserid = $worker->id; $urlparams['userid'] = $ttuserid; $urlparams['id'] = $courseid; $indexparams['userid'] = $ttuserid; $indexparams['id'] = $courseid; $hourlogurl = new moodle_url($CFG->wwwroot . '/blocks/timetracker/hourlog.php', $urlparams); $index = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', $indexparams); // Clock In Icon $this->content->text .= '<div style="text-align: left">'; $clockinicon = new pix_icon('clock_add', 'Add work unit', 'block_timetracker'); $clockinaction = $OUTPUT->action_icon($hourlogurl, $clockinicon); $timeclockdataicon = new pix_icon('manage', 'Manage', 'block_timetracker'); $timeclockdataaction = $OUTPUT->action_icon($index, $timeclockdataicon); $reportsurl = new moodle_url($baseurl . '/reports.php', $indexparams); $reportsurl->params(array('userid' => $worker->id)); $reportsaction = $OUTPUT->action_icon($reportsurl, new pix_icon('report', 'Reports', 'block_timetracker')); $editurl = new moodle_url($baseurl . '/updateworkerinfo.php', $indexparams); $editurl->params(array('mdluserid' => $USER->id)); $editaction = $OUTPUT->action_icon($editurl, new pix_icon('user_edit', get_string('edit'), 'block_timetracker')); $timesheeturl = new moodle_url($baseurl . '/timesheet.php', $indexparams); $timesheeturl->params(array('userid' => $worker->id)); $timesheetaction = $OUTPUT->action_icon($reportsurl, new pix_icon('date', 'Timesheets', 'block_timetracker')); $this->content->text .= '<div style="text-align: left">'; $this->content->text .= $timeclockdataaction . ' <a href="' . $index . '">Main</a><br />' . $clockinaction . ' <a href="' . $hourlogurl . '">Add work unit</a><br />' . $reportsaction . ' <a href="' . $reportsurl . '">Reports</a><br />' . $timesheetaction . ' <a href="' . $timesheeturl . '">Timesheets</a><br />' . $editaction . ' <a href="' . $editurl . '"> Edit my info</a><br /><br />'; $this->content->text .= '</div>'; $this->content->text .= '<hr>'; } } $stats = get_worker_stats($ttuserid, $COURSE->id); //calculate if this user is within $50 of reaching maxtermearnings $closetomax = false; if ($worker->maxtermearnings > 0 && ($stats['termearnings'] > $worker->maxtermearnings || $worker->maxtermearnings - $stats['termearnings'] <= 50)) { $closetomax = true; } $this->content->text .= '<br /><span style="font-weight: bold;">' . '*Official term earnings: $' . number_format(get_official_earnings_this_term($ttuserid, $COURSE->id), 2) . '</span><br /><br />'; $this->content->text .= '<span style="font-size: x-small">*This represents hours for which you have already been paid</span>'; $this->content->text .= '<hr />'; if ($this->config->block_timetracker_show_month_hours || $this->config->block_timetracker_show_term_hours || $this->config->block_timetracker_show_ytd_hours || $this->config->block_timetracker_show_total_hours) { $this->content->text .= '<span style="font-weight: bold">' . get_string('hourstitle', 'block_timetracker') . '</span>'; if ($this->config->block_timetracker_show_month_hours) { $this->content->text .= '<br />'; $this->content->text .= get_string('totalmonth', 'block_timetracker'); $this->content->text .= $stats['monthhours']; } if ($this->config->block_timetracker_show_term_hours && $worker->maxtermearnings > 0) { $this->content->text .= '<br />'; if ($closetomax) { $this->content->text .= '<span style="color: red; font-weight:bold">'; } $this->content->text .= get_string('totalterm', 'block_timetracker'); $this->content->text .= $stats['termhours']; $remearnings = $worker->maxtermearnings - $stats['termearnings']; $remhours = $remearnings / $worker->currpayrate; if ($remhours < 0) { $remhours = 0; } $this->content->text .= '<br />'; $this->content->text .= get_string('remaining', 'block_timetracker'); $this->content->text .= round($remhours, 2); if ($closetomax) { $this->content->text .= '</span>'; } } if ($this->config->block_timetracker_show_ytd_hours) { $this->content->text .= '<br />'; $this->content->text .= get_string('totalytd', 'block_timetracker'); $this->content->text .= $stats['yearhours']; } if ($this->config->block_timetracker_show_total_hours) { $this->content->text .= '<br />'; $this->content->text .= get_string('total', 'block_timetracker'); $this->content->text .= $stats['totalhours']; } if ($this->config->block_timetracker_show_month_earnings || $this->config->block_timetracker_show_term_earnings || $this->config->block_timetracker_show_ytd_earnings || $this->config->block_timetracker_show_total_earnings) { $this->content->text .= '<br /><br />'; $this->content->text .= '<span style="font-weight: bold">' . get_string('earningstitle', 'block_timetracker') . '</span>'; if ($this->config->block_timetracker_show_month_earnings) { $this->content->text .= '<br />'; $this->content->text .= get_string('totalmonth', 'block_timetracker'); $this->content->text .= '$' . $stats['monthearnings']; } if ($this->config->block_timetracker_show_term_earnings && $worker->maxtermearnings > 0) { $this->content->text .= '<br />'; if ($closetomax) { $this->content->text .= '<span style="color: red; font-weight:bold">'; } $this->content->text .= get_string('totalterm', 'block_timetracker'); $this->content->text .= '$' . $stats['termearnings']; $remearnings = $worker->maxtermearnings - $stats['termearnings']; if ($remearnings < 0) { $remearnings = 0; } $this->content->text .= '<br />'; $this->content->text .= get_string('remaining', 'block_timetracker'); $this->content->text .= '$' . round($remearnings, 2); if ($closetomax) { $this->content->text .= '</span>'; } } if ($this->config->block_timetracker_show_ytd_earnings) { $this->content->text .= '<br />'; $this->content->text .= get_string('totalytd', 'block_timetracker'); $this->content->text .= '$' . $stats['yearearnings']; } if ($this->config->block_timetracker_show_total_earnings) { $this->content->text .= '<br />'; $this->content->text .= get_string('total', 'block_timetracker'); $this->content->text .= '$' . $stats['totalearnings']; } } $ttuserid = $worker->id; if ($clockin == 1) { //protect against refreshing a 'clockin' screen $pendingrecord = $DB->record_exists('block_timetracker_pending', array('userid' => $ttuserid, 'courseid' => $courseid)); if (!$pendingrecord) { $cin = new stdClass(); $cin->userid = $ttuserid; $cin->timein = time(); $cin->courseid = $courseid; $DB->insert_record('block_timetracker_pending', $cin); } } else { if ($clockout == 1) { $cin = $DB->get_record('block_timetracker_pending', array('userid' => $ttuserid, 'courseid' => $courseid)); if ($cin) { $cin->timeout = time(); $cin->lastedited = time(); $cin->lasteditedby = $USER->id; unset($cin->id); $worked = add_unit($cin); if ($worked) { $DB->delete_records('block_timetracker_pending', array('userid' => $ttuserid, 'courseid' => $courseid)); } else { print_error('couldnotclockout', 'block_timetracker', $CFG->wwwroot . '/blocks/timetracker/timeclock.php?id=' . $courseid . '&userid=' . $ttuserid); } } } } } } } $this->content->text .= '</div>'; return $this->content; }
We have logged the error. Please contact your supervisor.'); add_to_log($COURSE->id, '', 'error adding clock-in', '' . $COURSE->id, 'ERROR: TimeTracker clock-in failed.'); } } } else { if ($clockout == 1) { $status = 'Clock out successful'; $cin = $DB->get_record('block_timetracker_pending', array('userid' => $ttuserid, 'courseid' => $courseid)); if ($cin) { $nowtime = time(); //timein && timeout are same day $cin->lastedited = $nowtime; $cin->timeout = $nowtime; $cin->lasteditedby = $USER->id; $cin->payrate = $workerrecord->currpayrate; unset($cin->id); $worked = add_unit($cin); if ($worked) { $DB->delete_records('block_timetracker_pending', array('userid' => $ttuserid, 'courseid' => $courseid)); } else { print_error('You tried to clock-out, but something went wrong. We have logged the error. Please contact your supervisor.'); } } else { $status = 'No matching clock-in. Work unit not recorded'; add_to_log($COURSE->id, '', 'error finding clock-in', '' . $COURSE->id, 'ERROR: No Matching clock-in.'); } } } } redirect($nextpage, $status, 1);
/** * Given an object that holds all of the values necessary from block_timetracker_workunit, * add update it in the DB * @return the true if updated successfully, false if not * */ function update_unit($unit) { global $DB; $id = $unit->id; $result = add_unit($unit); if ($result) { $deleteresult = $DB->delete_records('block_timetracker_workunit', array('id' => $id)); if (!$deleteresult) { //log error in deleting? return false; } } else { return false; } return true; }
add_product_class($values); $responseArray['message'] = 'Class successfully added'; break; case 'get_product_classes': include_once __DIR__ . '/products/get_product_classes.php'; $responseArray['response'] = get_product_classes($values); $responseArray['message'] = 'Classes successfully read'; break; case 'update_product_class': include_once __DIR__ . '/products/update_product_class.php'; update_product_class($values); $responseArray['message'] = 'Product class successfully updated'; break; case 'add_unit': include_once __DIR__ . '/products/add_unit.php'; add_unit($values); $responseArray['message'] = 'Unit successfully added'; break; case 'get_units': include_once __DIR__ . '/products/get_units.php'; $responseArray['response'] = get_units($values); $responseArray['message'] = 'Units successfully read'; break; case 'update_unit': include_once __DIR__ . '/products/update_unit.php'; $responseArray['response'] = update_unit($values); $responseArray['message'] = 'Successfully updated unit'; break; case 'add_product_unit': include_once __DIR__ . '/products/add_product_unit.php'; add_product_unit($values);
} else { // Supervisor wishes to change data in the error alert $mform = new timetracker_changealert_form($context, $alertid); if ($mform->is_cancelled()) { //user clicked cancel redirect($nextpage); } else { if ($formdata = $mform->get_data()) { //Form is submitted, add the unit to the 'workunit' database; //email worker and any other //supervisors that the alert has been completed. if (isset($formdata->deleteunit)) { $DB->delete_records('block_timetracker_alertunits', array('id' => $alertid)); } else { $formdata->lastedited = time(); $insertok = add_unit($formdata); //$insertok = $DB->insert_record('block_timetracker_workunit', $formdata); if (!$insertok) { print_error('Error updating new work unit.'); } $from = $USER; // Email worker and any other supervisor(s) that the work unit //has been approved $subject = get_string('approvedsubject', 'block_timetracker', $worker->firstname . ' ' . $worker->lastname . ' in ' . $course->shortname); //********** PLAIN TEXT **********// $messagetext = get_string('amessage1', 'block_timetracker', $USER->firstname . ' ' . $USER->lastname); $messagetext .= get_string('br2', 'block_timetracker'); $messagetext .= get_string('amessage2', 'block_timetracker'); $messagetext .= get_string('br2', 'block_timetracker');
function player_init($account) { global $player_data; global $map_data; if ($account == "") { irciv_privmsg("error: no account"); return False; } if (isset($map_data["cols"]) == False) { irciv_privmsg("error: map not ready"); return False; } unset($player_data[$account]); $id = get_unique_player_id(); $player_data[$account] = array(); $player_data[$account]["init_time"] = time(); $player_data[$account]["player_id"] = $id; set_player_color($account); $player_data[$account]["units"] = array(); $player_data[$account]["cities"] = array(); $player_data[$account]["flags"]["public_status"] = ""; $player_data[$account]["flags"]["grid"] = ""; $player_data[$account]["flags"]["coords"] = ""; $player_data[$account]["flags"]["city_names"] = ""; $player_data[$account]["flags"]["crop_map"] = ""; $player_data[$account]["flags"]["irc_messages"] = ""; $player_data[$account]["fog"] = str_repeat("0", strlen($map_data["coords"])); $start_x = -1; $start_y = -1; if (random_coord(TERRAIN_LAND, $start_x, $start_y) == False) { return False; } add_unit($account, "settler", $start_x, $start_y); add_unit($account, "warrior", $start_x, $start_y); $player_data[$account]["active"] = -1; cycle_active($account); $player_data[$account]["start_x"] = $start_x; $player_data[$account]["start_y"] = $start_y; status($account); return True; }
print_string('notactiveerror', 'block_timetracker'); echo '<br />'; echo $OUTPUT->footer(); die; } if ($mform->is_cancelled()) { //user clicked cancel redirect($manage); } else { if ($formdata = $mform->get_data()) { $formdata->courseid = $formdata->id; unset($formdata->id); //$formdata->payrate = $workerrecord->currpayrate; $formdata->lastedited = time(); $formdata->lasteditedby = $formdata->editedby; $result = add_unit($formdata, true); //$DB->insert_record('block_timetracker_workunit', $formdata); if ($result) { $status = 'Work unit(s) added successfully.'; } else { $status = 'Error adding work unit(s)'; } redirect($nextpage, $status, 1); } else { //form is shown for the first time echo $OUTPUT->header(); $tabs = get_tabs($urlparams, $canmanage, $courseid); $tabs[] = new tabobject('addunit', new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php#', $urlparams), 'Add Work Unit'); $tabs = array($tabs); print_tabs($tabs, 'addunit'); $mform->display();