* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once('learning_plan_form.php');
require_once("lib.php");
global$DB;
$attributes=array();
$lp_id=$_GET['id'];
$u_id=$_GET['u_id'];
$t=$_GET['t'];
$t_id=$_GET['t_id'];
$status=$_GET['status'];
$hidetraining=$_GET['hidetraining'];
$hideusers=$_GET['hideusers'];
if($lp_id&&$t_id){
$form=newsearch();
$table=$form->display_list($lp_id,$t_id,$status);
$a=html_writer::table($table);
echo$a;
}else{
// Change training on the base of learning plan and user.
if($lp_id&&$u_id){
$attributes=$DB->get_records_sql_menu('select lpt.t_id as id, (select training_name from {learning_training} where id =lpt.t_id) as name from {learning_plan_training}
lpt inner join {learning_user_trainingplan} lut on lut.lpt_id=lpt.id where lpt.lp_id=? AND lut.u_id=?',
array($lp_id,$u_id),$limitfrom=0,$limitnum=0);
}
// Find traiing on the base of lp Id.
elseif($lp_id&&$t){
$attributes=$DB->get_records_sql_menu('SELECT t_id as id,(select training_name from {learning_training} where id =t_id) as name FROM {learning_plan_training}
where lp_id= ?',array($lp_id),$limitfrom=0,$limitnum=0);
}
// Change users on the base of Learning plan
elseif($lp_id&&$hidetraining){
$attributes1=$DB->get_records_sql_menu('SELECT id, training_name as name from {learning_training} ',null,$limitfrom=0,$limitnum=0);
$attributes2=$DB->get_records_sql_menu('SELECT t_id as id, (SELECT training_name from {learning_training} where id =t_id) as name from {learning_plan_training}
where lp_id=?',array($lp_id),$limitfrom=0,$limitnum=0);
$attributes3=$DB->get_records_sql_menu('SELECT id, CONCAT(firstname," ", lastname) as name FROM {user} where firstname != "Guest User"',null,$limitfrom=0,$limitnum=0);
$attributes4=$DB->get_records_sql_menu('SELECT u_id as id, (SELECT concat(firstname," ", lastname) FROM {user} WHERE id = u_id) as name FROM {learning_user_learningplan}
where lp_id = ?',array($lp_id),$limitfrom=0,$limitnum=0);
$attributes=$DB->get_records_sql_menu('SELECT u.u_id as id, (SELECT CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id = u. u_id) as name FROM
{learning_user_learningplan} as u where lp_id= ?',array($lp_id),$limitfrom=0,$limitnum=0);
<TABLENAME="learning_traningtype"COMMENT="Default comment for the table, please edit me"PREVIOUS="learning_plan_training"NEXT="learning_user_learningplan">
<TABLENAME="learning_user_learningplan"COMMENT="Default comment for the table, please edit me"PREVIOUS="learning_traningtype"NEXT="learning_user_trainingplan">