Skip to content
Snippets Groups Projects
Commit 54a56cbc authored by 3i Logic LMS's avatar 3i Logic LMS
Browse files

Update learning_plan_form.php

parent fec794ac
No related branches found
No related tags found
No related merge requests found
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
......@@ -13,28 +14,28 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* Learning Plan Block
* This plugin serves as a database and plan for all learning activities in the organziation,
* where such activities are organized for a more structured learning program.
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @date: 20-Aug-2014
* @copyright Copyrights © 2012 - 2014 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("{$CFG->libdir}/formslib.php");
// Add Learning Plans.
class learningplan_form extends moodleform {
public function definition() {
$mform = & $this->_form;
$errors = array();
$mform->addElement('header', 'displayinfo', get_string('learningpath', 'block_learning_plan'));
$mform->addElement('text', 'learning_plan', get_string('learningplan', 'block_learning_plan'));
$mform->addRule('learning_plan', get_string('plan_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client');
// $mform->addRule('learning_plan', get_string('plan_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client');
$mform->addRule('learning_plan', $errors, 'required', null, 'server');
$mform->setType('learning_plan', PARAM_RAW);
$mform->setType('learning_plan', PARAM_TEXT);
$attributes = array('rows' => '8', 'cols' => '40');
$mform->addElement('textarea', 'description', get_string('desc', 'block_learning_plan'), $attributes);
$mform->setType('description', PARAM_TEXT);
......@@ -42,9 +43,9 @@ class learningplan_form extends moodleform {
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
// $this->add_action_buttons();
$this->add_action_buttons($cancel = false);
}
public function validation($data, $files) {
global $DB;
$errors = array();
......@@ -55,6 +56,7 @@ class learningplan_form extends moodleform {
return $errors;
}
}
public function display_list() {
global $DB, $OUTPUT, $CFG;
// Page parameters.
......@@ -62,7 +64,6 @@ class learningplan_form extends moodleform {
$perpage = optional_param('perpage', 10, PARAM_INT); // how many per page
$sort = optional_param('sort', 'learning_plan', PARAM_ALPHA);
$dir = optional_param('dir', 'DESC', PARAM_ALPHA);
$changescount = $DB->count_records('learning_learningplan');
$columns = array('learning_plan' => get_string('learning_plan', 'block_learning_plan'),
'description' => get_string('desc', 'block_learning_plan'),);
......@@ -86,17 +87,14 @@ class learningplan_form extends moodleform {
$columnicon = $dir == 'ASC' ? 'down' : 'up';
}
$columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
}
$hcolumns[$column] = "<a href=\"view.php?viewpage=1&sort=$column&amp;dir=$columndir&amp;page=$page&amp;perpage=$perpage\">" . $strcolumn . "</a>$columnicon";
}
$baseurl = new moodle_url('view.php?viewpage=1', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
$table = new html_table();
$table->head = array(get_string('s_no', 'block_learning_plan'), $hcolumns['learning_plan'], $hcolumns['description'], 'Edit', 'Remove');
$table->size = array('10%', '35%', '35%');
$table->head = array(get_string('s_no', 'block_learning_plan'), $hcolumns['learning_plan'], $hcolumns['description'], get_string('edit'), get_string('remove'));
$table->size = array('10%', '30', '45%', '10%', '10%', '10%');
$table->align = array('center', 'left', 'left', 'center', 'center', 'center');
$table->width = '100%';
$orderby = "$sort $dir";
......@@ -106,35 +104,39 @@ class learningplan_form extends moodleform {
foreach ($rs as $log) {
$row = array();
$row[] = $inc++;
$row[] = $log->learning_plan;
$row[] = $log->description;
$row[] = '<center><center><a title="Edit" href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=1&edit=edit&id='.$log->id.'"/>
<img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall" /></a></center>';
$row[] = '<center><center><a title="Remove" href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=1&rem=remove&id='.$log->id.'"/>
<img src="'.$OUTPUT->pix_url('t/delete') . '" class="iconsmall"/></a></center>';
$row[] = format_string($log->learning_plan, false);
$row[] = format_string($log->description, false);
$row[] = '<center><center><a title="' . get_string('edit') . '" href="' . $CFG->wwwroot . '/blocks/learning_plan/view.php?viewpage=1&edit=edit&id=' . $log->id . '"/>
<img alt="" src="' . $OUTPUT->pix_url('t/edit') . '" class="iconsmall" /></a></center>';
$row[] = '<center><center><a title="' . get_string('delete') . '" href="' . $CFG->wwwroot . '/blocks/learning_plan/view.php?viewpage=1&rem=remove&id=' . $log->id . '"/>
<img alt="" src="' . $OUTPUT->pix_url('t/delete') . '" class="iconsmall"/></a></center>';
$table->data[] = $row;
}
// $rs->close();
return $table;
// echo html_writer::table($table);
}
}
// Add Training Types.
class training_form extends moodleform {
public function definition() {
$mform = & $this->_form;
$mform->addElement('header', 'displayinfo', get_string('add_training', 'block_learning_plan'));
$radioarray = array();
if (!isset($attributes)) $attributes = "";
if (!isset($errors)) $errors = array();
if (!isset($attributes))
$attributes = "";
if (!isset($errors))
$errors = array();
$radioarray[] = & $mform->createElement('radio', 'type_id', '', get_string('elearning', 'block_learning_plan'), 1);
$radioarray[] = & $mform->createElement('radio', 'type_id', '', get_string('classroom', 'block_learning_plan'), 2, $attributes);
$radioarray[] = & $mform->createElement('radio', 'type_id', '', get_string('onthejob', 'block_learning_plan'), 3, $attributes);
$mform->addGroup($radioarray, 'type_id', get_string('training_method', 'block_learning_plan'), array('<br>'), false);
$mform->addRule('type_id', $errors, 'required', null, 'server');
$mform->addElement('text', 'training_name', get_string('training_name', 'block_learning_plan'));
$mform->addRule('training_name', get_string('training_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client');
// $mform->addRule('training_name', get_string('training_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client');
$mform->addRule('training_name', $errors, 'required', null, 'server');
$mform->setType('training_name', PARAM_TEXT);
// $attributes = array('maxbytes' => '4194304', 'accepted_types' => "*");
......@@ -150,16 +152,15 @@ class training_form extends moodleform {
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
// $this->add_action_buttons();
$this->add_action_buttons($cancel = false);
}
public function validation($data, $files) {
global $DB;
$errors = array();
if ($data['id']) {
return true;
}
else if ($DB->record_exists('learning_training', array('training_name'=>$data['training_name']))) {
} else if ($DB->record_exists('learning_training', array('training_name' => $data['training_name']))) {
$errors['training_name'] = get_string('training_exist', 'block_learning_plan');
}
if ($data['start_date'] >= $data['end_date']) {
......@@ -173,13 +174,13 @@ class training_form extends moodleform {
// page parameters.
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 10, PARAM_INT); // how many per page
$sort = optional_param('sort', 'training_name', PARAM_ALPHA);
$sort = optional_param('sort', 'training_name', PARAM_TEXT);
$dir = optional_param('dir', 'DESC', PARAM_ALPHA);
$changescount = $DB->count_records('learning_training');
$columns = array('training_name' => get_string('training_name', 'block_learning_plan'),
'type_id' => get_string('training_method', 'block_learning_plan'),
'start_date' => get_string('start_date', 'block_learning_plan'),
'end_date' => get_string('end_date', 'block_learning_plan'));
'end_date' => get_string('end_date', 'block_learning_plan'),);
$hcolumns = array();
if (!isset($columns[$sort])) {
$sort = 'training_name';
......@@ -200,17 +201,15 @@ class training_form extends moodleform {
$columnicon = $dir == 'ASC' ? 'down' : 'up';
}
$columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
}
$hcolumns[$column] = "<a href=\"view.php?viewpage=2&sort=$column&amp;dir=$columndir&amp;page=$page&amp;perpage=$perpage\">" . $strcolumn . "</a>$columnicon";
}
$baseurl = new moodle_url('view.php?viewpage=2', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
$table = new html_table();
$table->head = array(get_string('s_no', 'block_learning_plan'), $hcolumns['training_name'], $hcolumns['type_id'], $hcolumns['start_date'], $hcolumns['end_date'], 'Edit', 'Remove');
$table->size = array('10%', '15%', '15%', '15%', '15%', '15%', '15%', '15%');
$table->align = array('center', 'left', 'left', 'center', 'center', 'center', 'center');
$table->head = array(get_string('s_no', 'block_learning_plan'), $hcolumns['training_name'], $hcolumns['type_id'], $hcolumns['start_date'], $hcolumns['end_date'], get_string('edit'), get_string('remove'));
$table->size = array('10%', '15%', '15%', '15%', '15%', '15%', '15%');
$table->align = array('center', 'left', 'left', 'center', 'center', 'center');
$table->width = '100%';
$orderby = "$sort $dir";
$sql = "SELECT id, training_name, type_id, start_date, end_date, url from {learning_training} ORDER BY $orderby ";
......@@ -220,9 +219,9 @@ class training_form extends moodleform {
$row = array();
$row[] = $inc++;
if (strlen($log->url) > 0) {
$row[] = '<a title="Training" href="'.$log->url.'">'.$log->training_name.'</a>';
$row[] = '<a title="' . get_string('training', 'block_learning_plan') . '" href="' . $log->url . '">' . format_string($log->training_name, false) . '</a>';
} else {
$row[] = $log->training_name;
$row[] = format_string($log->training_name, false);
}
$training_method;
if ($log->type_id == 1) {
......@@ -232,24 +231,27 @@ class training_form extends moodleform {
} else if ($log->type_id == 3) {
$training_method = get_string('onthejob', 'block_learning_plan');
}
$row[] = $training_method;
$row[] = format_string($training_method, false);
// $row[] = date('d-m-Y', $log->start_date);
$row[] = date('M j, Y, g:i a', $log->start_date);
$row[] = date('M j, Y, g:i a', $log->end_date);
$row[] = userdate($log->start_date, get_string('strftimedatetime', 'core_langconfig')); // date('M j, Y, g:i a', $log->start_date);
$row[] = userdate($log->end_date, get_string('strftimedatetime', 'core_langconfig')); // date('M j, Y, g:i a', $log->end_date);
// $row[] = date('d-m-Y', $log->end_date);
// $row[] = "<a href=".$log->url."/>Link</a>";
$row[] = '<center><center><a title="Edit" href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2&edit=edit&id='.$log->id.'"/>
<img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall" /></a></center>';
$row[] = '<center><center><a title="Remove" href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2&rem=remove&id='.$log->id.'"/>
<img src="'.$OUTPUT->pix_url('t/delete') . '" class="iconsmall"/></a></center>';
$row[] = '<center><center><a title="' . get_string('edit') . '" href="' . $CFG->wwwroot . '/blocks/learning_plan/view.php?viewpage=2&edit=edit&id=' . $log->id . '"/>
<img alt="" src="' . $OUTPUT->pix_url('t/edit') . '" class="iconsmall" /></a></center>';
$row[] = '<center><center><a title="' . get_string('remove') . '" href="' . $CFG->wwwroot . '/blocks/learning_plan/view.php?viewpage=2&rem=remove&id=' . $log->id . '"/>
<img alt="" src="' . $OUTPUT->pix_url('t/delete') . '" class="iconsmall"/></a></center>';
$table->data[] = $row;
}
//$rs->close();
return $table;
}
}
// Add Training Method.
class trainingmethod_form extends moodleform {
public function definition() {
$mform = & $this->_form;
$mform->addElement('header', 'displayinfo', get_string('add_training_method', 'block_learning_plan'));
......@@ -260,7 +262,6 @@ class trainingmethod_form extends moodleform {
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
// $this->add_action_buttons();
$this->add_action_buttons($cancel = false);
}
......@@ -275,25 +276,27 @@ class trainingmethod_form extends moodleform {
$table->data[] = $row;
return $table;
}
}
// Assign Training into Learning Plan.
class assigntraining_learningplan__form extends moodleform {
public function definition() {
global $DB, $CFG;
$mform = & $this->_form;
$mform->addElement('header', 'displayinfo', get_string('assign_training_learningplan', 'block_learning_plan'));
$attributes = $DB->get_records_sql_menu('SELECT id, learning_plan FROM {learning_learningplan}', null, $limitfrom = 0, $limitnum = 0);
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=1', 'label' => get_string('add_learningplan', 'block_learning_plan')));
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null, null);
$attributes = $DB->get_records_sql_menu('SELECT id, training_name FROM {learning_training}', null, $limitfrom = 0, $limitnum = 0);
$select = $mform->addElement('selectwithlink', 't_id', get_string('training', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2', 'label' => get_string('add_training', 'block_learning_plan')));
$training_types = array('1' => get_string('elearning', 'block_learning_plan'), '2' => get_string('classroom', 'block_learning_plan'), '3' => get_string('onthejob', 'block_learning_plan'));
$mform->addElement('select', 'training_type', get_string('training_method', 'block_learning_plan'), $training_types);
$select = $mform->addElement('selectwithlink', 't_id', get_string('training', 'block_learning_plan'), $attributes, null, null);
$select->setmultiple(true);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
// $this->add_action_buttons();
$this->add_action_buttons($cancel = false);
}
......@@ -302,12 +305,11 @@ class assigntraining_learningplan__form extends moodleform {
// Page parameters.
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 10, PARAM_INT); // how many per page
$sort = optional_param('sort', 'learning_plan', PARAM_ALPHA);
$sort = optional_param('sort', 'learning_plan', PARAM_TEXT);
$dir = optional_param('dir', 'DESC', PARAM_ALPHA);
$changescount = $DB->count_records('learning_learningplan');
$columns = array('learning_plan' => get_string('learning_plan', 'block_learning_plan'),
'training_name' => get_string('training_name', 'block_learning_plan'),
'type_id' => get_string('training_method', 'block_learning_plan'),
);
$hcolumns = array();
if (!isset($columns[$sort])) {
......@@ -329,89 +331,132 @@ class assigntraining_learningplan__form extends moodleform {
$columnicon = $dir == 'ASC' ? 'down' : 'up';
}
$columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
}
$hcolumns[$column] = "<a href=\"view.php?viewpage=4&sort=$column&amp;dir=$columndir&amp;page=$page&amp;perpage=$perpage\">" . $strcolumn . "</a>$columnicon";
}
$baseurl = new moodle_url('view.php?viewpage=4', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
$orderby = "$sort $dir";
$table = new html_table();
$table->head = array(get_string('s_no', 'block_learning_plan'), $hcolumns['learning_plan'], $hcolumns['training_name'], 'Remove');
$table->size = array('10%', '35%', '35%', '35%');
$table->align = array('center', 'left', 'left', 'center');
$table->head = array(get_string('s_no', 'block_learning_plan'), $hcolumns['learning_plan'], $hcolumns['training_name'], $hcolumns['type_id'], get_string('remove'));
$table->size = array('10%', '30%', '30%', '45%', '35%');
$table->align = array('center', 'left', 'left', 'left', 'center');
$table->width = '100%';
$orderby = "$sort $dir";
$sql = "SELECT id, (select learning_plan from {learning_learningplan} where id=lp_id) as learning_plan, (select training_name from {learning_training} where id=t_id)
as training_name from {learning_plan_training} ORDER BY $orderby ";
$sql = "SELECT id, (select learning_plan from {learning_learningplan} where id=lp_id) as learning_plan,
(select training_name from {learning_training} where id=t_id) as training_name,
(select type_id from {learning_training} where id=t_id) as type_id from {learning_plan_training} ORDER BY $orderby ";
$inc = 1;
$rs = $DB->get_recordset_sql($sql, array(), $page * $perpage, $perpage);
foreach ($rs as $log) {
$row = array();
$row[] = $inc++;
$row[] = $log->learning_plan;
$row[] = $log->training_name;
$row[] = '<center><center><a title="Remove" href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=4&rem=remove&id='.$log->id.'"/>
$row[] = format_string($log->learning_plan, false);
$row[] = format_string($log->training_name, false);
$row[] = training_type($log->type_id);
$row[] = '<center><center><a title="' . get_string('remove') . '" href="' . $CFG->wwwroot . '/blocks/learning_plan/view.php?viewpage=4&rem=remove&id=' . $log->id . '"/>
<img src="' . $OUTPUT->pix_url('t/delete') . '" class="iconsmall"/></a></center>';
$table->data[] = $row;
}
// $rs->close();
echo $OUTPUT->paging_bar($inc + 1, $page, $perpage, $baseurl);
return $table;
}
}
// Assign Learning plan to User.
class assignlerningplan_user_form extends moodleform {
public function definition() {
global $DB, $CFG, $USER;
$mform = & $this->_form;
if (!isset($attributes1)) $attributes1 = "";
if (!isset($attributes1))
$attributes1 = "";
$mform->addElement('header', 'displayinfo', get_string('assign_learningplan_user', 'block_learning_plan'));
$attributes = $DB->get_records_sql_menu('SELECT id, learning_plan FROM {learning_learningplan}', null, $limitfrom = 0, $limitnum = 0);
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=1', 'label' => get_string('add_learningplan', 'block_learning_plan')));
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null, null);
if (!isGroup_null()) {
$attributes = array('1' => 'No Group');
} else
$attributes = array('1' => 'No Group', '2' => 'Group');
$select = $mform->addElement('select', 'g_selection', get_string('group_selection', 'block_learning_plan'), $attributes, null, array(null));
$mform->disabledIf('g_id', 'g_selection', 'eq', 1);
$attributes = $DB->get_records_sql_menu('SELECT id, name FROM {groups}', null, $limitfrom = 0, $limitnum = 0);
$select = $mform->addElement('select', 'g_id', get_string('department', 'block_learning_plan'), $attributes, null, array(null));
$attributes = $DB->get_records_sql_menu('SELECT id, CONCAT(firstname," ", lastname)FROM {user} where username!="guest"', array($params = null), $limitfrom = 0, $limitnum = 0);
$select = $mform->addElement('select', 'u_id', get_string('users', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot.'/user/editadvanced.php?id=-1', 'label' => get_string('addusers', 'block_learning_plan'), $attributes1));
$select = $mform->addElement('select', 'u_id', get_string('users', 'block_learning_plan'), $attributes, null, array('link' => $CFG->wwwroot . '/user/editadvanced.php?id=-1', 'label' => get_string('addusers', 'block_learning_plan'), $attributes1));
$select->setMultiple(true);
// $mform->addElement('hidden', 'assignee', $USER->id);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
// $this->add_action_buttons();
$this->add_action_buttons($cancel = false);
}
public function display_list() {
global $DB, $OUTPUT, $CFG;
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 10, PARAM_INT); // how many per page
$sort = optional_param('sort', 'learning_plan', PARAM_TEXT);
$dir = optional_param('dir', 'DESC', PARAM_ALPHA);
$columns = array('learning_plan' => get_string('learning_plan', 'block_learning_plan'),
'fullname' => get_string('users', 'block_learning_plan'),);
$hcolumns = array();
if (!isset($columns[$sort])) {
$sort = 'learning_plan';
}
foreach ($columns as $column => $strcolumn) {
if ($sort != $column) {
$columnicon = '';
if ($column == 'learning_plan') {
$columndir = 'DESC';
} else {
$columndir = 'ASC';
}
} else {
$columndir = $dir == 'ASC' ? 'DESC' : 'ASC';
if ($column == 'learning_plan') {
$columnicon = $dir == 'ASC' ? 'up' : 'down';
} else {
$columnicon = $dir == 'ASC' ? 'down' : 'up';
}
$columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
}
$hcolumns[$column] = "<a href=\"view.php?viewpage=5&sort=$column&amp;dir=$columndir&amp;page=$page&amp;perpage=$perpage\">" . $strcolumn . "</a>$columnicon";
}
$baseurl = new moodle_url('view.php?viewpage=5', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
$orderby = "$sort $dir";
$table = new html_table();
$table->head = array(get_string('s_no', 'block_learning_plan'), get_string('learning_plan', 'block_learning_plan'), get_string('users', 'block_learning_plan'),
get_string('assignee', 'block_learning_plan'), get_string('remove', 'block_learning_plan'));
$table->size = array('10%', '25%', '25%', '25%', '15%');
$table->align = array('center', 'left', 'left', 'left');
$table->head = array(get_string('s_no', 'block_learning_plan'), $hcolumns['learning_plan'], $hcolumns['fullname'], get_string('remove', 'block_learning_plan'));
$table->size = array('10%', '35%', '25%', '15%');
$table->align = array('center', 'left', 'left', 'center');
$table->width = '100%';
$table->data = array();
$sql = 'SELECT id, (SELECT concat(firstname," ", lastname) FROM {user} WHERE id = u_id) as fullname, (SELECT learning_plan
FROM {learning_learningplan} WHERE id = lp_id) as learning_plan, (SELECT concat(firstname," ", lastname) FROM
{user} WHERE id = assignee_id) as assignee FROM {learning_user_learningplan}'; // ORDER BY $orderby';
$sql = "SELECT id, u_id, lp_id, (SELECT concat(firstname,' ', lastname) FROM {user} WHERE id = u_id) as fullname,
(SELECT learning_plan FROM {learning_learningplan} WHERE id = lp_id) as learning_plan,
(SELECT concat(firstname,' ', lastname) FROM {user} WHERE id = assignee_id) as assignee
FROM {learning_user_learningplan} ORDER BY $orderby";
$inc = 0;
$rs = $DB->get_recordset_sql($sql, array());
$rs = $DB->get_recordset_sql($sql, array(), $page * $perpage, $perpage);
foreach ($rs as $log) {
$row = array();
$row[] = ++$inc;
$row[] = $log->learning_plan;
$row[] = $log->fullname;
$row[] = $log->assignee;
$row[] = '<center><center><a title="Remove" href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=5&rem=remove&id='.$log->id.'"/>
<img src="'.$OUTPUT->pix_url('t/delete') . '" class="iconsmall"/></a></center>';
$row[] = format_string($log->learning_plan, false);
$row[] = format_string($log->fullname);
// $row[] = $log->assignee;
$row[] = '<a title="' . get_string('remove') . '" href="' . $CFG->wwwroot . '/blocks/learning_plan/view.php?viewpage=5&rem=remove&id=' . $log->u_id . '&lp=' . $log->lp_id . '"/>'
. ' <img src="' . $OUTPUT->pix_url('t/delete') . '" class="iconsmall"/></a>';
$table->data[] = $row;
}
echo $OUTPUT->paging_bar($inc + 1, $page, $perpage, $baseurl);
return $table;
}
}
// Set Training Status.
class trainingstatus_form extends moodleform {
public function definition() {
global $DB, $CFG;
$l_id = optional_param('l_id', null, PARAM_INT);
......@@ -421,31 +466,23 @@ class trainingstatus_form extends moodleform {
$mform->addElement('header', 'displayinfo', get_string('trainingstatus', 'block_learning_plan'));
if (isset($l_id)) {
$attributes = $DB->get_records_sql_menu('SELECT id, learning_plan FROM {learning_learningplan} where id=?', array($l_id), $limitfrom = 0, $limitnum = 0);
}
else {
} else {
$attributes = $DB->get_records_sql_menu('SELECT id, learning_plan FROM {learning_learningplan}', null, $limitfrom = 0, $limitnum = 0);
}
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=1', 'label' => get_string('add_learningplan', 'block_learning_plan')));
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null, null);
if (isset($u_id)) {
$attributes = $DB->get_records_sql_menu('SELECT id, CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id=?',
array ($u_id), $limitfrom=0, $limitnum=0);
}
else {
$attributes = $DB->get_records_sql_menu('SELECT id, CONCAT(firstname," ", lastname)FROM {user} where username!="guest"',
array ($params=null), $limitfrom=0, $limitnum=0);
$attributes = $DB->get_records_sql_menu('SELECT id, CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id=?', array($u_id), $limitfrom = 0, $limitnum = 0);
} else {
$attributes = $DB->get_records_sql_menu('SELECT id, CONCAT(firstname," ", lastname)FROM {user} where username!="guest"', array($params = null), $limitfrom = 0, $limitnum = 0);
}
$mform->addElement('selectwithlink', 'u_id', get_string('users', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot."/user/editadvanced.php?id=-1", 'label' => get_string('addusers', 'block_learning_plan')));
$mform->addElement('selectwithlink', 'u_id', get_string('users', 'block_learning_plan'), $attributes, null, null);
if (isset($t_id)) {
$attributes = $DB->get_records_sql_menu('SELECT id, training_name FROM {learning_training} where id=?', array($t_id), $limitfrom = 0, $limitnum = 0);
}
else {
} else {
$attributes = $DB->get_records_sql_menu('SELECT id, training_name FROM {learning_training}', null, $limitfrom = 0, $limitnum = 0);
}
$mform->addElement('selectwithlink', 't_id', get_string('training', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2', 'label' => get_string('add_training', 'block_learning_plan')));
$attributes = array('In-progress', 'Not Yet Started', 'Complete');
$mform->addElement('selectwithlink', 't_id', get_string('training', 'block_learning_plan'), $attributes, null, null);
$attributes = array(get_string('status_in_progress', 'block_learning_plan'), get_string('status_not_started', 'block_learning_plan'), get_string('status_completed', 'block_learning_plan'));
$mform->addElement('select', 'status', get_string('status', 'block_learning_plan'), $attributes);
$attributes = array('size' => '50', 'maxlength' => '1000');
$mform->addElement('text', 'remarks', get_string('remarks', 'block_learning_plan'), $attributes);
......@@ -454,7 +491,6 @@ class trainingstatus_form extends moodleform {
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
// $this->add_action_buttons();
$this->add_action_buttons($cancel = false);
}
......@@ -463,25 +499,26 @@ class trainingstatus_form extends moodleform {
}
}
class search extends moodleform {
public function definition() {
global $DB, $CFG;
$mform = & $this->_form;
$mform->addElement('header', 'displayinfo', get_string('searchusers', 'block_learning_plan'));
$attributes = $DB->get_records_sql_menu('SELECT id, learning_plan FROM {learning_learningplan}', null, $limitfrom = 0, $limitnum = 0);
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=1', 'label' => get_string('add_learningplan', 'block_learning_plan')));
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null, null);
$attributes = $DB->get_records_sql_menu('SELECT id, training_name FROM {learning_training}', null, $limitfrom = 0, $limitnum = 0);
$mform->addElement('selectwithlink', 't_id', get_string('training', 'block_learning_plan'), $attributes, null,
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2', 'label' => get_string('add_training', 'block_learning_plan')));
$attributes = array('In-progress', 'Not Yet Started', 'Complete', 'All Status');
$mform->addElement('selectwithlink', 't_id', get_string('training', 'block_learning_plan'), $attributes, null, null);
$attributes = array(get_string('status_in_progress', 'block_learning_plan'), get_string('status_not_started', 'block_learning_plan'), get_string('status_completed', 'block_learning_plan'), get_string('status_all', 'block_learning_plan'));
$mform->addElement('select', 'status', get_string('status', 'block_learning_plan'), $attributes);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('button', 'showuser', 'Search', array("id" => "btnajax"));
$mform->addElement('button', 'showuser', get_string('search'), array("id" => "btnajax"));
}
public function display_list($lp_id = "", $t_id = "", $status = "") {
// if ($lp_id && $t_id) {
global $DB, $OUTPUT, $CFG;
......@@ -490,41 +527,51 @@ class search extends moodleform {
$table->head = array(get_string('s_no', 'block_learning_plan'), get_string('training_name', 'block_learning_plan'), get_string('users', 'block_learning_plan'),
get_string('start_date', 'block_learning_plan'), get_string('end_date', 'block_learning_plan'), get_string('status', 'block_learning_plan'),
get_string('remarks', 'block_learning_plan'), get_string('setting', 'block_learning_plan'));
$table->size = array('5%', '30%', '20%', '10%', '10%', '10%', '25%', '10%');
$table->size = array('10%', '20%', '15%', '10%', '10%', '10%', '25%', '10%');
$table->align = array('center', 'left', 'left', 'center', 'center', 'center', 'left', 'left', 'center');
$table->width = '100%';
$table->data = array();
if ($status == '3') {
$sql = 'select t_id, lp_id, lut.status, lut.remarks, `u_id` as id,(select training_name from {learning_training} where id =t_id)
as training,(select learning_plan from {learning_learningplan} where id =lp_id) as learning_plan, (SELECT
CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id = u_id) as name,(select
start_date from {learning_training} where id =t_id)as date1,(select end_date from {learning_training}
where id =t_id)as date2 from {learning_plan_training} lpt inner join {learning_user_trainingplan} lut
on lut.lpt_id=lpt.id where lpt.lp_id=? AND lpt.t_id= ?'; // ORDER BY $orderby';
$sql = 'select t_id, lp_id, lut.status, lut.remarks, `u_id` as id,
(select training_name from {learning_training} where id =t_id) as training,
(select learning_plan from {learning_learningplan} where id =lp_id) as learning_plan,
(SELECT CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id = u_id) as name,
(select start_date from {learning_training} where id =t_id)as date1,
(select end_date from {learning_training} where id =t_id)as date2
from {learning_plan_training}
lpt inner join {learning_user_trainingplan} lut on lut.lpt_id=lpt.id where lpt.lp_id=? AND lpt.t_id= ?'; // ORDER BY $orderby';
} else {
$sql = 'select t_id, lp_id, lut.status, lut.remarks, `u_id` as id,(select training_name from {learning_training} where id =t_id)
as training,(select learning_plan from {learning_learningplan} where id =lp_id) as learning_plan, (SELECT
CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id = u_id) as name,(select
start_date from {learning_training} where id =t_id)as date1,(select end_date from {learning_training}
where id =t_id)as date2 from {learning_plan_training} lpt inner join {learning_user_trainingplan} lut
on lut.lpt_id=lpt.id where lpt.lp_id=? AND lpt.t_id= ? AND lut.status = ?'; // ORDER BY $orderby';
$sql = 'select t_id, lp_id, lut.status, lut.remarks, `u_id` as id,
(select training_name from {learning_training} where id =t_id)as training,
(select learning_plan from {learning_learningplan} where id =lp_id) as learning_plan,
(SELECT CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id = u_id) as name,
(select start_date from {learning_training} where id =t_id)as date1,
(select end_date from {learning_training} where id =t_id)as date2
from {learning_plan_training}
lpt inner join {learning_user_trainingplan} lut
on lut.lpt_id=lpt.id where lpt.lp_id=? AND lpt.t_id= ? AND lut.status = ?';
}
$inc = 0;
$rs = $DB->get_recordset_sql($sql, array($lp_id, $t_id, $status));
if (count($rs) > 0) {
foreach ($rs as $log) {
$row = array();
$row[] = ++$inc;
$row[] = $log->training;
$row[] = $log->name;
$row[] = format_string($log->training);
$row[] = format_string($log->name);
$row[] = date('d-m-Y', $log->date1);
$row[] = date('d-m-Y', $log->date2);
$row[] = status_value($log->status);
$row[] = $log->remarks;
$row[] = format_string($log->remarks);
$row[] = '<a href="' . $CFG->wwwroot . '/blocks/learning_plan/view.php?viewpage=6&l_id=' . $log->lp_id . '&u_id=' . $log->id . '&t_id=' . $log->t_id . '&setting=1">Setting</a>';
// $row[] = '<center><center><a title="Remove" href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=5&rem=remove&id='.$log->id.'"/>
// <img src="'.$OUTPUT->pix_url('t/delete') . '" class="iconsmall"/></a></center>';
$table->data[] = $row;
}
} else {
$row = array('None');
}
return $table;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment