public function definition()
 {
     global $USER, $cm;
     if (is_array($locations = praxe_get_available_locations($USER->id, praxe_record::getData('isced'), praxe_record::getData('studyfield'))) && count($locations)) {
         //$mform =& $this->_form;
         $this->content_before_form .= get_string('assigntolocation_text_forstudents', 'praxe');
         $form = '<form class="mform" action="' . praxe_get_base_url() . '" method="post">';
         $form .= '<input type="hidden" name="post_form" value="assignlocation" />';
         $form .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
         $table = new stdClass();
         $table->head = array('', get_string('school', 'praxe'), get_string('subject', 'praxe'), get_string('teacher', 'praxe'));
         $table->align = array('center', 'left', 'center', 'center');
         foreach ($locations as $loc) {
             $row = array('<input id="praxe_loc_' . $loc->id . '" type="radio" name="location" value="' . $loc->id . '" />');
             $sch = "<a href=\"" . praxe_get_base_url(array('viewaction' => 'viewschool', 'schoolid' => $loc->school)) . "\" title=\"" . get_string('school_detail', 'praxe') . "\">" . s($loc->name) . "</a>";
             $sch .= "<div class=\"praxe_detail\">" . s($loc->street) . ', ' . s($loc->city) . "</div>";
             $row[] = $sch;
             $row[] = s($loc->subject);
             if (!is_null($loc->teacherid)) {
                 $teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname));
                 $row[] = praxe_get_user_fullname($teacher);
             } else {
                 $row[] = '';
             }
             $table->data[] = $row;
             //$row .= '<label for="praxe_loc_'.$loc->id.'">'.$text.'</label>';
             //$form .= "<div class=\"tr\">$row</div>";
         }
         $form .= html_writer::table($table, true);
         $form .= '<div class="fitem center" style="margin: 10px 0;">' . '<input type="submit" id="id_submitbutton" value="Submit" name="submitbutton" /> ' . '<input type="submit" id="id_cancel" onclick="skipClientValidation = true; return true;" value="Cancel" name="cancel" />' . '</div>';
         $form .= '</form>';
         $this->content .= "<div>{$form}</div>";
         //$mform->addElement('header', null, get_string('locations', 'praxe'));
         /*
         			$options = array();
         $radioarray = array();
         foreach($locations as $loc) {
         	//print_object($loc);
         	$link = "<a target='_blank' href='view.php?id=$cm->id&amp;praxeaction=viewschool&amp;schoolid=$loc->school' title='".get_string('school_detail','praxe')."'>".get_string('school_detail','praxe')."</a>";
         	$text = s($loc->name) . "($link) - " . s($loc->subject);
         	$text .= "<br>".s($loc->street).', '.s($loc->zip).'&nbsp;&nbsp;'.s($loc->city);
         	if(!is_null($loc->teacherid)) {
         		$teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname));
         		$text .= " (".praxe_get_user_fullname($teacher).")";
         	}
         	$radioarray[] = $mform->createElement('radio', 'location', null, $text, $loc->id, array('class'=>'radio location'));
         }
         $mform->addGroup($radioarray, 'location', get_string('locations','praxe').':', '<hr>', false);
         $mform->addRule('location', get_string('locationisrequired', 'praxe'), 'required', null, 'client');
         $mform->addRule('location', get_string('locationisrequired', 'praxe'), 'required', null, 'server');
         //$mform->addElement('select', 'location', get_string('chooselocation', 'praxe'), $options, array('size' => count($options) > 15 ? '15' : count($options)+1));
         $mform->addElement('hidden', 'post_form', 'assigntolocation');
         */
         //$this->add_action_buttons(true, get_string('submit'));
     } else {
         $this->content_before_form .= get_string('nolocationsavailable', 'praxe');
     }
 }
 public function definition()
 {
     $err = false;
     global $USER, $cm, $course, $DB, $CFG;
     $location = praxe_get_location($this->locationid);
     $users = praxe_get_student_participants($cm->id);
     /// link back to list of locations - we will use it later
     $back = html_writer::link(new moodle_url(praxe_get_base_url(array('mode' => 'locations', 'schoolid' => 0))), get_string('back'));
     //if(praxe_get_use_status_of_location($location->id))
     //var_dump(praxe_get_use_status_of_location($location->id));
     //var_dump($location);
     if (!empty($location)) {
         $this->content_before_form .= html_writer::tag('p', get_string('assignstudtolocation_text', 'praxe'));
         $info = $location->name;
         if (strlen(trim($location->city))) {
             $info .= ", " . s($location->city);
         }
         if (strlen(trim($location->street))) {
             $info .= ", " . s($location->street);
         }
         $info = html_writer::tag('strong', $info);
         if (strlen(trim($location->subject))) {
             $info .= '<br>' . html_writer::tag('strong', s($location->subject));
         }
         if (!is_null($location->teacherid)) {
             $info .= '<br>' . s($location->teacher_name) . ' ' . s($location->teacher_lastname);
         }
         $info .= '<br>' . praxe_get_term_text($location->term) . ' ' . $location->year;
         $this->content_before_form .= html_writer::tag('p', $info);
         // location is occupied
         $sql = "SELECT rec.* FROM {praxe_records} rec WHERE rec.location = ? AND rec.status != ?";
         $params = array($this->locationid, PRAXE_STATUS_REFUSED);
         if ($ret = $DB->get_record_sql($sql, $params)) {
             $this->content .= html_writer::tag('div', get_string('location_is_not_available', 'praxe'));
             $this->content .= html_writer::tag('div', $back);
             /// location and users are available
         } else {
             if (is_array($users) && count($users)) {
                 $form = '<form class="mform" action="' . praxe_get_base_url(array('locationid' => $this->locationid), 'assigntolocation') . '" method="post">';
                 $form .= '<input type="hidden" name="post_form" value="assigntolocation" />';
                 $form .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
                 $form .= '<input type="hidden" name="location" value="' . $this->locationid . '" />';
                 $select = '<select name="student">';
                 $select .= '<option value="null">' . get_string('select_student', 'praxe') . '</option>';
                 foreach ($users as $us) {
                     $select .= '<option value="' . $us->id . '">' . s($us->firstname . ' ' . $us->lastname) . '</option>';
                 }
                 $select .= '</select>';
                 $form .= html_writer::tag('div', html_writer::tag('label', get_string('student')) . html_writer::tag('div', $select), array('class' => 'frow'));
                 /// option to send emails
                 require_once $CFG->dirroot . "/lib/pear/HTML/QuickForm/checkbox.php";
                 $checks = '';
                 if (!is_null($location->teacherid)) {
                     $check = new HTML_QuickForm_checkbox('sendemailtoextteacher', '', get_string('sendinfotoextteacher', 'praxe'));
                     $checks .= html_writer::tag('div', $check->toHtml());
                 }
                 $check = new HTML_QuickForm_checkbox('sendemailtostudent', '', get_string('sendinfotostudent', 'praxe'), 'checked');
                 $checks .= $check->toHtml();
                 $form .= html_writer::tag('div', html_writer::tag('label', get_string('informparticipants')) . html_writer::tag('div', $checks), array('class' => 'frow'));
                 /// action buttons
                 //$sub = '<div class="fitem center" style="margin: 10px 0;">'
                 $sub = '<input type="submit" id="id_submitbutton" value="Submit" name="submitbutton" /> ' . '<input type="submit" id="id_cancel" onclick="skipClientValidation = true; return true;" value="Cancel" name="cancel" />';
                 //felement fsubmit
                 $form .= html_writer::tag('div', $sub, array('class' => 'frow submit'));
                 $form .= '</form>';
                 $this->content .= html_writer::tag('div', $form, array('class' => 'thin-form'));
                 /// no students to be assigned to location
             } else {
                 $table->data[] = array(get_string('nostudentsavailable', 'praxe'));
                 $table->data[] = array($back);
                 $table->align = array('center');
                 $this->content .= html_writer::table($table, true);
             }
         }
     } else {
         $this->content_before_form .= html_writer::tag('strong', get_string('notallowedaction', 'praxe'));
         $this->content .= $back;
     }
 }
 public static function confirm_location_form($recordid)
 {
     $form = '<div>' . get_string('please_confirm_record', 'praxe') . '</div>';
     $form .= '<form action="' . praxe_get_base_url() . '" method="post">';
     $form .= '<input type="hidden" name="post_form" value="confirmlocation" />';
     $form .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
     $form .= '<input type="hidden" name="recordid" value="' . $recordid . '" />';
     $form .= '<input type="hidden" name="submitbutton" value="true" />';
     $form .= '<input type="submit" name="submitconfirm" value="' . get_string('confirm') . '" />';
     $form .= '&nbsp;&nbsp;<input type="submit" name="submitrefuse" value="' . get_string('refuse', 'praxe') . '" />';
     $form .= '</form>';
     return $form;
 }
Example #4
0
        case 'assignteachers':
            $params['mode'] = $tab_modes[strtolower($viewrole)][constant('PRAXE_TAB_' . $viewrole . '_TEACHERS')];
            $params['schoolid'] = optional_param('teacher_school', 0, PARAM_INT);
            break;
        case 'addlocation':
            $params['mode'] = $viewrole == 'EXTTEACHER' ? 'mylocations' : 'locations';
            $params['schoolid'] = optional_param('school', 0, PARAM_INT);
            break;
            /// student role ///
        /// student role ///
        case 'makeschedule':
            $params['mode'] = 'schedule';
            break;
        case 'assigntolocation':
            $params['mode'] = 'locations';
            if (optional_param('detail', 0, PARAM_INT) == 1 && ($schoolid = optional_param('schoolid', 0, PARAM_INT)) > 0) {
                $params['schoolid'] = $schoolid;
            } else {
                $params['schoolid'] = 0;
            }
            $params['factualloc'] = 1;
            break;
        default:
            break;
    }
    foreach ($_POST as $k => $v) {
        unset($_POST[$k]);
    }
    //echo praxe_get_base_url($params);
    redirect(praxe_get_base_url($params), get_string('action_canceled', 'praxe'), 1);
}
Example #5
0
                $params['fyearloc'] = (int) $filteryearloc;
            }
            $sel = new single_select(praxe_get_base_url($params), 'factualloc', $options, $filteractualloc, null, 'praxepop_praxelocationsselect');
            $sel->label = get_string('only_actual', 'praxe');
            $tab_content .= $OUTPUT->render($sel);
            /// year filter for locations///
            $years = praxe_get_years_for_filter(null, $viewschool, $filteractualloc);
            if (count($years) > 1) {
                $options = array("0" => get_string('all'));
                foreach ($years as $year) {
                    $options[$year->year] = $year->year;
                }
                if ($filteractualloc) {
                    $params1['factualloc'] = (int) $filteractualloc;
                }
                $sel = new single_select(praxe_get_base_url($params1), 'fyearloc', $options, $filteryearloc, null, 'praxepop_praxelocationsselectyear');
                $sel->label = get_string('year', 'praxe');
                $tab_content .= $OUTPUT->render($sel);
            }
        }
        break;
    default:
        break;
}
if (false === praxe_object_search($tab, $viewtabrows, 'id')) {
    if (false === praxe_object_search($tab, $subtabrows, 'id')) {
        $msg = get_string('notallowedaction', 'praxe');
        //redirect($CFG->wwwroot.'/mod/praxe/view.php?id='.$cm->id.'&amp;mode='.$tab_modes[strtolower($viewrole)][0], $msg);
    }
}
/// Put all this info together
Example #6
0
 /**
  * Builds and returns the body of the email notification in html format.
  *
  * @param string $post
  * @param object $userto
  * @param array $linkstofoot array of objects containing: link, text
  * @return string The email text in HTML format
  */
 private function makeMailHtml($post, $userto)
 {
     global $CFG, $cm, $OUTPUT;
     if ($userto->mailformat != 1) {
         // Needs to be HTML
         return '';
     }
     $praxe = praxe_record::getData();
     $site = get_site();
     $posthtml = '<head>';
     /*foreach ($CFG->stylesheets as $stylesheet) {
       $posthtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
         }TODO*/
     $posthtml .= '</head>';
     $posthtml .= "\n<body id=\"email\">\n\n";
     $posthtml .= '<div class="navbar">' . $OUTPUT->action_link($CFG->wwwroot . '/course/view.php?id=' . $this->course->id, $this->course->shortname) . " &raquo; " . $OUTPUT->action_link(praxe_get_base_url(), format_string($praxe->name, true)) . '</div>';
     if (strlen($this->subject)) {
         $posthtml .= '<div class="subject">' . format_text($this->subject) . '</div>';
     }
     if (strlen($post)) {
         $posthtml .= '<div class="message">' . format_text($post) . '</div>';
     }
     $posthtml .= "<hr /><div class=\"mdl-align unsubscribelink\">";
     foreach ($this->linkstofoot as $link) {
         $posthtml .= $OUTPUT->action_link($link->link, $link->text) . "&nbsp;";
     }
     $posthtml .= "</div><div class=\"mdl-align unsubscribelink\">" . $OUTPUT->action_link($CFG->wwwroot, $site->shortname) . "</div>";
     $posthtml .= '</body>';
     return $posthtml;
 }
Example #7
0
            redirect(praxe_get_base_url(array('mode' => 'schedule')));
        }
        break;
    case 'confirmschedule':
        require_sesskey();
        $teachermail = optional_param('mailtoextteacher', 0, PARAM_INT);
        $praxe = praxe_record::getData();
        $schedules = $DB->get_records('praxe_schedules', array('record' => $praxe->rec_id));
        if (empty($schedules)) {
            print_error('notallowedaction', 'praxe');
        }
        $post = (object) array('id' => $praxe->rec_id, 'status' => PRAXE_STATUS_SCHEDULE_DONE);
        if ($DB->update_record('praxe_records', $post) && $teachermail == 1) {
            $emfrom = get_complete_user_data('id', $praxe->rec_student);
            require_once $CFG->dirroot . '/mod/praxe/mailing.php';
            $mail = new praxe_mailing();
            $fak = new stdClass();
            $fak->name = fullname($emfrom);
            $fak->school = s($praxe->location->name);
            $mail->setSubject(get_string('confirmschedule_mailsubject', 'praxe'));
            $emtext = get_string('confirmschedule_mail', 'praxe', $fak);
            $mail->setPlain($emtext);
            $mail->setHtml($emtext);
            $emuser = get_complete_user_data('id', $praxe->location->teacherid);
            $mail->mailToUser($emuser, $emfrom);
        }
        redirect(praxe_get_base_url(array('mode' => 'schedule')));
        break;
}
$echo .= "</div>";
echo $echo;
Example #8
0
 /**
  *
  * @param array $schools - array of schools objects to be displayed
  * @param array $editlinkparams[optional] - default parameters to url that are always added: id=$cm->id, schoolid=id of school.<br>
  * Extra parameters to be added must be in array format as nameOfParameter=>value
  * @param array $aSort[optional] - used sorting in actual list of schools (name, type) - values (ASC, DESC)
  * Items must be in array format as nameOfParameter=>value
  * @return string
  */
 public static function show_schools($schools, $editlinkparams = array(), $aSort = array())
 {
     global $USER, $OUTPUT;
     $baseLink = praxe_get_base_url(array('mode' => 'schools'));
     $table = new html_table();
     $strname = get_string('schoolname', 'praxe');
     if (isset($aSort['name'])) {
         $toLink = $aSort['name'] == 'ASC' ? 'DESC' : 'ASC';
         $strname = $OUTPUT->action_link($baseLink . '&amp;sname=' . $toLink, $strname);
         $strname .= $OUTPUT->pix_icon('t/sort_' . strtolower($aSort['name']), $aSort['name']);
     } else {
         $strname = $OUTPUT->action_link($baseLink . '&amp;sname=ASC', $strname);
     }
     $strtype = get_string('schooltype', 'praxe');
     if (isset($aSort['type'])) {
         $toLink = $aSort['type'] == 'ASC' ? 'DESC' : 'ASC';
         $strtype = $OUTPUT->action_link($baseLink . '&amp;stype=' . $toLink, $strtype);
         $strtype .= $OUTPUT->pix_icon('t/sort_' . strtolower($aSort['type']), $aSort['type']);
     } else {
         $strtype = $OUTPUT->action_link($baseLink . '&amp;stype=ASC', $strtype);
     }
     $straddress = get_string('address', 'praxe');
     $strcontact = get_string('contact', 'praxe');
     $table->head = array($strname, $strtype, $straddress, $strcontact);
     $table->align = array('left', 'left', 'left', 'left');
     $params = array();
     foreach ($editlinkparams as $name => $val) {
         $params[s($name)] = s($val);
     }
     $baseLink = praxe_get_base_url($params);
     foreach ($schools as $sch) {
         $address = s($sch->street) . ', ' . s($sch->zip) . '  ' . s($sch->city);
         $contact = array();
         if (!empty($sch->email)) {
             $contact[] = s($sch->email);
         }
         if (!empty($sch->phone)) {
             $contact[] = s($sch->phone);
         }
         if (!empty($sch->website)) {
             $contact[] = s($sch->website);
         }
         $contact = html_writer::tag('p', implode("<br>", $contact));
         $schooltype = constant('PRAXE_SCHOOL_TYPE_' . (int) $sch->type . '_TEXT');
         $row = array(s($sch->name), $schooltype, $address, $contact);
         if (praxe_has_capability('editanyschool') || praxe_has_capability('editownschool') && $sch->headmaster == $USER->id) {
             $stredit = get_string('editschool', 'praxe');
             $row[] = $OUTPUT->action_icon($baseLink . '&amp;schoolid=' . $sch->id, new pix_icon('t/edit', $stredit));
         }
         $table->data[] = $row;
     }
     if (isset($stredit)) {
         $table->head[] = $stredit;
         $table->align[] = 'center';
     }
     return html_writer::table($table);
 }
Example #9
0
 public function show_schedule($schedules, $boolReturn = true, $editlinks = array())
 {
     global $CFG, $OUTPUT;
     if (!$schedules) {
         $ret = get_string('no_schedule_items', 'praxe');
         if ($boolReturn) {
             return $ret;
         } else {
             $this->content .= $ret;
             return true;
         }
     }
     $table = new html_table();
     $table->head = array(get_string('date'), get_string('lesson_number', 'praxe'), get_string('time'), get_string('yearclass', 'praxe'), get_string('schoolroom', 'praxe'), get_string('subject', 'praxe'), get_string('lesson_theme', 'praxe'), get_string('edit'), get_string('inspection', 'praxe'));
     $table->align = array('left', 'center', 'center', 'center', 'center', 'left', 'left', 'center', 'center');
     $editable = praxe_has_capability('editstudentschedule') || praxe_has_capability('manageallincourse');
     $params = $editlinks;
     $delparams = array('praxeaction' => 'deleteschedule');
     foreach ($schedules as $item) {
         if (is_null($item->lesnumber)) {
             $item->lesnumber = "---";
         } else {
             $item->lesnumber .= ".";
         }
         $row = array(userdate((int) $item->timestart, get_string('strftimedateshort')), $item->lesnumber, userdate((int) $item->timestart, "%H:%M") . ' - ' . userdate((int) $item->timeend, "%H:%M"), praxe_get_yearclass($item->yearclass), s($item->schoolroom), s($item->lessubject), format_text($item->lestheme));
         if ($editable && $item->timestart - PRAXE_TIME_TO_EDIT_SCHEDULE > time()) {
             $params['scheduleid'] = $item->id;
             $delparams['scheduleid'] = $item->id;
             $row[] = $OUTPUT->action_icon(praxe_get_base_url($params), new pix_icon('t/edit', get_string('edit'))) . $OUTPUT->action_icon(praxe_get_base_url($delparams), new pix_icon('t/delete', get_string('delete')));
         } else {
             $row[] = "---";
         }
         if (count($item->inspectors)) {
             $ins = "";
             foreach ($item->inspectors as $insp) {
                 $ins .= "<div class=\"inspector right\">" . $OUTPUT->render(new pix_icon('icon_inspect', get_string('inspection', 'praxe'), 'praxe')) . "&nbsp;" . praxe_get_user_fullname($insp) . "</div>";
             }
             $row[] = $ins;
         } else {
             $row[] = "&nbsp;";
         }
         $table->data[] = $row;
     }
     if ($boolReturn) {
         return html_writer::table($table);
     } else {
         $this->content .= html_writer::table($table);
         return true;
     }
 }