File: /home/thehunarfound/public_html/sms/func.php_8-sep-2018
<?php
include('lib/config.php');
if(isset($_POST['action']) && ($_POST['action']) == 'Submit')
{
// echo 's';
extract($_POST);
//$delsql = "delete from infrastucture_profile where institute_name = '".$institute_name."'";
// $_GET['id']
//$delsql = "delete from institute_resources where id = '". $_GET['id']."'";
// echo $delsq/
$delsql = "delete from institute_resources where institute_abb = '".$institute_abb."'";
$db->ExecuteQuery($delsql);
//$sqltime = "SELECT `time_start`, `time_end` FROM institute_profile WHERE abbreviation = '".$_GET['abbreviation']."'";
$sql="INSERT INTO institute_resources(`classroom_total_no`,`classroom_name`,`classroom_code`,`classroom_program`,`classroom_max`,
`workshop_total_no`,`workshop_name`,`workshop_code`,`workshop_program`,`workshop_max`,`institute_abb`)
VALUES ('".$class_total."','".implode(",",$classroom_name)."','".implode(",",$classroom_code)."','".implode(",",$classroom_program)."',
'".implode(",",$classroom_max)."','".$workshop_total."','".implode(",",$workshop_name)."','".implode(",",$workshop_code)."',
'".implode(",",$workshop_program)."','".implode(",",$workshop_max)."','".$institute_abb."')";
$db->ExecuteQuery($sql);
//insert into instructor key
$key=($db->GetSingleRecord("Select id from institute_resources Order By id DESC LIMIT 1"));
if(isset($_POST['instructor_name'])) {
$fcount = 0;
foreach($instructor_name as $fn){
$sqlo="INSERT INTO instructor(`instructor_name`,`instructor_code`,`instructor_designation`,
`instructor_max_hr`,`instructor_max_sess`,`instructor_subjects`,`instructor_time`,`instructor_days`,`institute_id`)
VALUES ('".$instructor_name[$fcount]."','".$instructor_code[$fcount]."','".$instructor_designation[$fcount]."',
'".$instructor_max_hr[$fcount]."','".$instructor_max_sess[$fcount]."','".implode(",",$instructor_subject[$fcount])."',
'".implode(",",$instructor_time[$fcount])."','".implode(",",$instructor_days[$fcount])."','".$key."')";
$db->ExecuteQuery($sqlo);
$fcount++;
}
//echo $sqlo; die;
}
echo "<script>alert('Information Added !');</script>";
reDirectUsingJavascript('institute-resources-view.php');
} //end if
if(isset($_GET['id'])){
extract($_POST);
/* $sqli="SELECT `classroom_total_no`,`classroom_name`,`classroom_code`,`classroom_program`,`classroom_max`, `workshop_total_no`,`workshop_name`,
`workshop_code`,`workshop_program`,`workshop_max` FROM institute_resources WHERE id = '".$_GET['id']."'";
$res = $db->ExecuteQuery($sqli);
list($classtotal,$classroomname,$classroomcode,$classroomprogram,$classroommax,$workshoptotal,$workshopname,
$workshop_code, $workshopprogram, $workshopmax)
*/
//maybe add a join here
//$sqli="SELECT `abbreviation`,`time_start`,`time_end`,`classroom_total_no`,`workshop_total_no`,`teaching_staff_total`,`non_teaching_staff_total` FROM institute_profile WHERE id = '".$_GET['id']."'";
// echo $sqli; die;
$sqlz= "SELECT `abbreviation`, `time_start`, `time_end` FROM `institute_profile` WHERE id = '".$_GET['id']."'";
$rest = $db->ExecuteQuery($sqlz);
list($abbreviation1,$timestart,$timeend)
= $rest->FetchAsArray();
$sqltotal = "SELECT `classroom_total_no`,`workshop_total_no` FROM `institute_resources` WHERE id = '".$_GET['id']."'";
$resl = $db->ExecuteQuery($sqltotal);
list($classtotal,$workshoptotal)
= $resl->FetchAsArray();
} //end if
// echo $sqli;
?>
<script type="text/javascript">
var timeoutId = 0;
function gtTime(){
clearTimeout(timeoutId);
timeoutId = setTimeout(function() {
var insttime = document.getElementById('institute_abb').value;
$.ajax({
url: "get-institute-time.php",
dataType: "JSON",
type: "post",
data: {
'institute': insttime
},
success: function(data){
// alert('asdf');
console.log(data);
alert(data);
$('#stime').val(data[0][0]);
$('#etime').val(data[0][1]);
$('#inst').html(data[0][2]);
},
error: function (xhr, textStatus, errorThrown)
{
alert(xhr.responseText);
}
// }
});
},100);
} //end function timing()
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- head scripts -->
<?php include('includes/head-scripts.php')?>
<link rel="stylesheet" type="text/css" href="css/select.css">
</head>
<body>
<div id="sb-site">
<!-- chat sidebar -->
<?php include('includes/chat-drawer.php')?>
<!-- page-wrapper -->
<div id="page-wrapper">
<div id="mobile-navigation"><button id="nav-toggle" class="collapsed" data-toggle="collapse" data-target="#page-sidebar"><span></span></button>
</div>
<!-- Left NAV -->
<?php include('includes/sidebar.php'); ?>
<!-- Right Content Area -->
<div id="page-content-wrapper">
<div id="page-content">
<?php include('includes/header.php'); ?>
<!-- Query log MORE --->
<div id="page-title">
<h2>INSTITUTE RESOURCES</h2>
</div>
<div class="panel">
<div class="panel-body">
<div class="example-box-wrapper">
<form class="form-horizontal bordered-row" id="demo-form" method="post" >
<div class="row">
<div class="form-group col-sm-6">
<label class="col-sm-3 control-label" style="padding-top:8px">Institute</label>
<div class="col-sm-4" id="div_class_total">
<?php
if(isset($_GET['id'])){ //if there is an institute id
extract($_POST);
$sqlabb = "SELECT `institute_abb` FROM `institute_resources` WHERE id = '".$_GET['id']."'";
$resl = $db->ExecuteQuery($sqlabb);
echo $res1;
list($abb) = $resl->FetchAsArray();
?>
<input class="form-control" id="institute_abb" name="institute_abb" value="<?=$abb?>" readonly>
<?php } //end if
else {
?>
<select class="form-control" id="institute_abb" name="institute_abb" required onChange="gtTime();chkInstituteExist();">
<option disabled selected>-Select-</option>
<?php
$sql = "SELECT `abbreviation` FROM `institute_profile` ORDER BY abbreviation ASC " ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
<option value="<?=$available_prog?>" <?php if($available_prog == $classroomprogram1[$z] ){ echo "selected"; } ?>><?=$available_prog?></option>
<?php } //end while
?>
</select>
<?php
} //end else
?>
</div>
</div>
<div class="form-group col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">Time Start</label>
<div class="col-sm-6">
<input type="time" name="time_start" id = "stime" onkeyup="timing();" class="form-control" value="" placeholder="" readonly style="background-color:#F6F4F3;">
<!-- <input type="text" name="time_start" onKeyUp="timing();" id="time_start" pattern="^(?:(?<!\d)[0-9]|0[0-9]|1[0-2]):[0-5][0-9]" placeholder="HH:MM (EX:08:00)" value="" class="form-control"> -->
</div>
</div> <!-- end form-group-->
<div class="form-group">
<label class="col-sm-4 control-label">Time End</label>
<div class="col-sm-6">
<input type="time" name= "time_end" id="etime" onkeyup="timing();" class="form-control" value="" placeholder="" readonly style="background-color:#F6F4F3;">
<!-- <input type="text" name="time_end" onKeyUp="alert('s')timing();" id="time_end" pattern="^(?:(?<!\d)[0-9]|0[0-9]|1[0-2]):[0-5][0-9]" placeholder="HH:MM (EX:08:00)" value="" class="form-control"> -->
<!-- <input type="text" name="time_end" " id="time_end" pattern="^(?:(?<!\d)[0-9]|0[0-9]|1[0-2]):[0-5][0-9]" placeholder="HH:MM (EX:16:00)" value="" class="form-control"> -->
</div>
</div> <!-- end form-group-->
<?php
$m = 60;
$time_end = strtotime("+$m min", strtotime($selectedTime));
$temp = date('h:i', $time_end);
?>
</div>
</div> <!--end row -->
<h3>Classes</h3><br>
<div class="row">
<div class="form-group col-sm-6">
<label class="col-sm-3 control-label" style="padding-top:8px">Number of Classes</label>
<div class="col-sm-4" id="div_class_total">
<input type="text" name="class_total" id="class_total" class="form-control" value="<?=$classtotal?>" readonly style="background-color:#F6F4F3;">
</div>
</div>
<div class="form-group col-sm-6">
</div>
</div>
<div class="row" id="showClasses">
<!-- <hr class="hr-gray">-->
<div class="col-md-11">
<table id="datatable-responsive-class" class="table table-striped table-bordered responsive no-wrap dataTable dtr-inline" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
<thead>
<tr role="row" class="thead-color">
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Name</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Code</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Program</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Max. Occupancy</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_GET['id'])){ //if there is an institute id
extract($_POST);
$query = "SELECT `classroom_name`,`classroom_code`,`classroom_program`,`classroom_max` FROM `institute_resources` where id = '".$_GET['id']."'";
$res1 = $db->ExecuteQuery($query);
// $num = $res->GetSelectedRows();
/* if($num==0){
echo '<h2>NO RESULT FOUND</h2>';
}
*/
while(list($classroomname,$classroomcodes,$classroomprogram,$classroommax) = $res1->FetchAsArray())
{
$classroomname1 = explode(',', $classroomname);
$classcode1 = explode(',', $classroomcodes);
$classroomprogram1 = explode(',', $classroomprogram);
$classroommax1 = explode(',', $classroommax);
$z=0;
foreach($classroomname1 as $cls){
?>
<tr role="row" class="odd">
<td class=""><input type="text" id="classroom_name" name="classroom_name[]" class="form-control" value="<?=$cls?>" /></td><!-- <?=$cls?>-->
<td class=""><input type="text" id="classroom_code" name="classroom_code[]" class="form-control" value="<?=$classcode1[$z]?>" /></td>
<td class="">
<select class="form-control" id="classroom_program" name="classroom_program[]">
<option disabled selected>-Select-</option>
<?php
$sql = "SELECT `program_title` FROM `programs_inst`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
<option value="<?=$available_prog?>" <?php if($available_prog == $classroomprogram1[$z] ){ echo "selected"; } ?>><?=$available_prog?></option>
<?php } ?>
</select>
</td>
<td class=""><input type="text" id="classroom_max" name="classroom_max[]" class="form-control" value="<?=$classroommax1[$z]?>" /></td>
<td class=""><button type="button" onclick="remdiv_class()" class="btn btn-danger btn-sm"> x </button> </td>
</tr>
<?php
$z++; } //end foreach
} //end while
} else {
?>
<tr role="row" class="odd" id="classes_result_row">
<td class=""><input type="text" id="classroom_name" name="classroom_name[]" class="form-control" value="" /></td>
<td class=""><input type="text" id="classroom_code" name="classroom_code[]" class="form-control" value="<?=$classroomcode[$i]?>" /></td>
<td class="">
<select class="form-control" id="classroom_program" name="classroom_program[]">
<option disabled selected>-Select-</option>
<?php
// $sql = "SELECT `value` FROM `add_setup` WHERE name='program'" ;
$sql = "SELECT `program_title` FROM `programs_inst`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
<option value="<?=$available_prog?>" <?php if($available_prog == $classroom_program ){ echo "selected"; } ?>><?=$available_prog?></option>
<?php } ?>
</select>
</td>
<td class=""><input type="text" id="classroom_max" name="classroom_max[]" class="form-control" value="" /></td>
</tr>
<?php
} //end if
?>
<!-- <button onClick="duplicateInterview();return false;">ADD</button> -->
</tbody>
</table>
</div>
<div class="col-md-1">
<!--Added to fill row -->
</div>
<!--adding new table div -->
<div id="pkg_class" >
</div>
<div class="col-md-6">
<button type="button" onclick="duplicateClass()" style="" class="btn btn-primary btn-sm">+ Add </button>
</div>
<div class="col-md-2">
<input type="hidden" name="counter" id="counter_class" value="1" />
<input type="hidden" name="pkgs" id="pkgs_class" value="0" />
<!--<input type="hidden" name="action" value="submit_form" /> -->
</div>
</div> <!--end showClasses -->
<br /><br />
<h3>Workshops</h3><br>
<div class="row" >
<div class="form-group col-sm-6">
<label class="col-sm-3 control-label" style="padding-top:8px">Number of Wokshops</label>
<div class="col-sm-4"><input type="text" name="workshop_total" id="workshop_total" class="form-control" value="<?=$workshoptotal?>" readonly style="background-color:#F6F4F3;">
</div>
</div>
<div class="form-group col-sm-6">
</div>
</div>
<div class="row" id="showWorkshops">
<!-- <hr class="hr-gray">-->
<div class="col-md-11">
<table id="datatable-responsive" class="table table-striped table-bordered responsive no-wrap dataTable dtr-inline" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
<thead>
<tr role="row" class="thead-color">
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Name</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Code</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Program</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Max. Occupancy</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_GET['id'])){ //if there is an institute id
// extract($_POST);
$query = "SELECT `workshop_name`,`workshop_code`,`workshop_program`,`workshop_max` FROM `institute_resources` where id = '".$_GET['id']."'";
$res1 = $db->ExecuteQuery($query);
$num = $res->GetSelectedRows();
/* if($num==0){
echo '<h2>NO RESULT FOUND</h2>';
}
*/
while(list($workshopname,$workshopcode,$workshopprogram,$workshopmax) = $res1->FetchAsArray())
{
$workshopname1 = explode(',', $workshopname);
$workshopcode1 = explode(',', $workshopcode);
$workshopprogram1 = explode(',', $workshopprogram);
$workshopmax1 = explode(',', $workshopmax);
// print_r($classtest); die;
// print $classroomcode12 = explode(',', $classroom_codes);
$y=0;
foreach($workshopname1 as $wkshp){
?>
<tr role="row" class="odd">
<td class=""><input type="text" id="workshopname" name="workshop_name[]" class="form-control" value="<?=$workshopname1[$y]?>"/></td>
<td class=""><input type="text" id="workshopcode" name="workshop_code[]" class="form-control" value="<?=$workshopcode1[$y]?>"/></td>
<td class="">
<select class="form-control" id="workshopprogram" name="workshop_program[]">
<option disabled selected>-Select-</option>
<?php
//$sql = "SELECT `value` FROM `add_setup` WHERE name='program'" ;
$sql = "SELECT `program_title` FROM `programs_inst`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
<option value="<?=$available_prog?>" <?php if( $workshopprogram1[$y] == $available_prog ){ echo "selected"; } ?>><?=$available_prog?></option>
<!-- <option value="<?=$available_prog?>" <?php if($workshop_program == $available_prog){ echo "selected"; } ?>><?=$available_prog?></option> -->
<?php
}
?>
</select>
</td>
<td class=""><input type="text" id="workshopmax" name="workshop_max[]" class="form-control" value="<?=$workshopmax1[$y]?>" /></td>
<td class=""><button type="button" onclick="remdiv_workshop(1)" class="btn btn-danger btn-sm"> x </button> </td>
</tr>
<?php
$y++; } //end foreach
} //end while
} else {
?>
<tr role="row" class="odd" id="workshop_result_row">
<td class=""><input type="text" id="workshop_name" name="workshop_name[]" class="form-control" value=""/></td>
<td class=""><input type="text" id="workshop_code" name="workshop_code[]" class="form-control" value=""/></td>
<td class="">
<select class="form-control" id="workshop_program" name="workshop_program[]">
<option disabled selected>-Select-</option>
<?php
// $sql = "SELECT `value` FROM `add_setup` WHERE name='program'" ;
$sql = "SELECT `program_title` FROM `programs_inst`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
<option value="<?=$available_prog?>" <?php if($workshop_program == $available_prog){ echo "selected"; } ?>><?=$available_prog?></option>
<?php
}//end while
?>
</select>
</td>
<td class=""><input type="text" id="workshop_max" name="workshop_max[]" class="form-control" value=""/></td>
</tr>
<?php
} //end else
?>
</tbody>
</table>
</div>
<div class="col-md-1">
<!--Added to fill row -->
</div>
<!--adding new table div -->
<div id="pkg_workshop" >
</div>
<div class="col-md-6">
<button type="button" onclick="duplicateWorkshop()" style="" class="btn btn-primary btn-sm">+ Add </button>
</div>
<div class="col-md-2">
<input type="hidden" name="counter" id="counter_workshop" value="1" />
<input type="hidden" name="pkgs" id="pkgs_workshop" value="0" />
<!--<input type="hidden" name="action" value="submit_form" /> -->
</div>
</div> <!--end showWorkshops -->
<br /><br /> <br />
<h3>Human Resources</h3><br>
<div class="row">
<div class="form-group col-sm-4">
<div class="col-sm-4">
<label>Total staff</label>
</div>
<div class="col-sm-4"><input type="text" name="hidden_staff" id="hidden_staff" class="form-control" value="<?=$db->GetSingleRecord("SELECT Count(*) FROM `infrastucture_profile` WHERE instructor_designation != 'Other'");?>" readonly>
</div>
</div>
</div>
<!-- <div class="row">
<div class="form-group col-sm-4">
<label class="col-sm-4 control-label" style="padding-top:8px">Teaching Staff</label>
<div class="col-sm-6"><input type="text" name="teaching_staff_total" id="teaching_staff_total" class="form-control" value="">
</div>
</div>
<div class="form-group col-sm-4">
<label class="col-sm-5 control-label" style="padding-top:8px">Non-Teaching Staff</label>
<div class="col-sm-6 ">
<input type="text" name="non_teaching_staff_total" id="non_teaching_staff_total" class="form-control" value="">
</div>
</div>
</div> --><!-- end of row-->
<div class="row" id="showHumanResources">
<!-- <hr class="hr-gray">-->
<div class="col-md-11">
<table id="datatable-responsive" class="table table-striped table-bordered responsive no-wrap dataTable dtr-inline" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
<thead>
<tr role="row" class="thead-color">
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Instructor Name</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Code</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Designation</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Max. hours/week</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Max. session/week</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Subjects</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Time</th>
<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1">Days</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_GET['id'])){ //if there is an institute id
extract($_POST);
$query = "SELECT `instructor_name`,`instructor_code`,`instructor_designation`,
`instructor_max_hr`,`instructor_max_sess`,`instructor_subjects`,`instructor_time`,
`instructor_days` FROM `instructor` where institute_id = '".$_GET['id']."'";
$res1 = $db->ExecuteQuery($query);
$num = $res->GetSelectedRows();
/* if($num==0){
echo '<h2>NO RESULT FOUND</h2>';
}
*/
while(list($instructorname,$instructorcode,$instructordesignation,$instructormaxhr,
$instructormaxsess, $instructorsubjects, $instructortime, $instructordays)
= $res1->FetchAsArray())
{
$instructorname1 = explode(',', $instructorname);
$instructorcode1 = explode(',', $instructorcode);
$instructordesignation1 = explode(',', $instructordesignation);
$instructormaxhr1 = explode(',', $instructormaxhr);
$instructormaxsess1 = explode(',', $instructormaxsess);
$instructorsubjects1 = explode(',', $instructorsubjects);
$instructortime1 = explode(',', $instructortime);
$instructordays1 = explode(',', $instructordays);
$w=0;
foreach($instructorname1 as $instructorhr){
?>
<tr role="row" class="odd" id="workshopresultrow">
<td class=""><input type="text" id="instructorname" name="instructor_name[]" class="form-control" value="<?=$instructorname1[$w]?>" /></td>
<td class=""><input type="text" id="instructorcode" name="instructor_code[]" class="form-control" value="<?=$instructorcode1[$w]?>"/></td>
<td class="">
<select class=" instructor_designation form-control" name="instructor_designation[]">
<option disabled selected>-Select-</option>
<option value="Instructor" <?php if(in_array('Instructor',$instructordesignation1)){ echo "selected"; }?>>Instructor</option>
<option value="Instructor Level 1" <?php if(in_array('Instructor Level 1',$instructordesignation1)){ echo "selected"; }?>>Instructor Level 1</option>'+
<option value="Sr. Instructor" <?php if(in_array('Sr. Instructor',$instructordesignation1)){ echo "selected"; }?>>Sr. Instructor</option>'+
<option value="Principal" <?php if(in_array('Principal',$instructordesignation1)){ echo "selected"; }?>>Principal</option>
<option value="Other" <?php if(in_array('Other',$instructordesignation1)){ echo "selected"; }?>>Other</option>
</select>
</td>
<td class=""><input type="text" id="instructor_max_hr" name="instructor_max_hr[]" class="form-control" value="<?=$instructormaxhr1[$w]?>" /></td>
<td class=""><input type="text" id="instructor_max_sess" name="instructor_max_sess[]" class="form-control" value="<?=$instructormaxsess1[$w]?>" /></td>
<td class="">
<select class="multiselect-ui form-control" multiple="multiple" id="instructor_subject" name="instructor_subject[][]">
<option disabled selected>-Select-</option>
<?php
$sql = "SELECT DISTINCT `subject_title` FROM `subjects_prog`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
<option value="<?=$available_prog?>" <?php if(in_array($available_prog,$instructorsubjects1)){ echo "selected"; } ?>><?=$available_prog?></option>
<?php } //end while
?>
</select>
</td>
<td class="timings">
</td>
<td class=""><!--<input type="text" id="hr_inst_time" name="hr_inst_time[]" class="form-control" value="<?=$hr_inst_day?>" <?php if(in_array($hr_inst_day)){ echo "selected"; } ?>/> -->
<input type="hidden" id="hiddenDay" name="instructor_days[][]" value="" />
<select class="multiselect-ui form-control" multiple="multiple" id="instructordays" >
<option disabled selected>-Select-</option>
<option value="Monday" <?php if(in_array('Monday',$instructordays1)){ echo "selected"; }?>>Monday</option>
<option value="Tuesday" <?php if(in_array('Tuesday',$instructordays1)){ echo "selected"; }?>>Tuesday</option>
<option value="Wednesday" <?php if(in_array('Wednesday',$instructordays1)){ echo "selected"; }?>>Wednesday</option>
<option value="Thursday" <?php if(in_array('Thursday',$instructordays1)){ echo "selected"; }?>>Thursday</option>
<option value="Friday" <?php if(in_array('Friday',$instructordays1)){ echo "selected"; }?>>Friday</option>
<option value="Saturday" <?php if(in_array('Saturday',$instructordays1)){ echo "selected"; }?>>Saturday</option>
<option value="Sunday" <?php if(in_array('Sunday',$instructordays1)){ echo "selected"; }?>>Sunday</option>
</select>
</td>
<td class=""><button type="button" onclick="remdiv_hr(1)" class="btn btn-danger btn-sm"> x </button> </td>
</tr>
<?php
$w++; } //end foreach
} //end while
} else {
?>
<tr role="row" class="odd" id="workshop_result_row">
<td class=""><input type="text" id="instructorname" name="instructor_name[]" class="form-control" value="" /></td>
<td class=""><input type="text" id="instructorcode" name="instructor_code[]" class="form-control" value=""/></td>
<td class="">
<select class=" instructor_designation form-control" name="instructor_designation[]">
<option disabled selected>-Select-</option>
<option value="Instructor">Instructor</option>
<option value="Instructor Level 1">Instructor Level 1</option>'+
<option value="Sr. Instructor">Sr. Instructor</option>'+
<option value="Principal">Principal</option>
<option value="Other">Other</option>
</select>
</td>
<td class=""><input type="text" id="instructor_max_hr" name="instructor_max_hr[]" class="form-control" value="" /></td>
<td class=""><input type="text" id="instructor_max_sess" name="instructor_max_sess[]" class="form-control" value="" /></td>
<td class="">
<input type="hidden" id="hiddenSubject" name="instructor_subjects[][]" value=""/>
<select class="multiselect-ui form-control" multiple="multiple" id="instructor_subject" onchange="addSubjInstruct();">
<option disabled selected>-Select-</option>
<?php
// $sql = "SELECT `subject` FROM `subject` WHERE name='program'" ;
$sql = "SELECT DISTINCT `subject_title` FROM `subjects_prog`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
<option value="<?=$available_prog?>" <?php if(in_array($available_prog,$instructor_subject)){ echo "selected"; } ?>><?=$available_prog?></option>
<?php } ?>
</select>
</td>
<td class="" id = "inst" >
<!-- <select class="multiselect-ui form-control" multiple="multiple" id="instructor_time" name="instructor_time[]">
<?php
// $time = explode(",",$instructor_time);
?>
<?php
?>
<!--<option disabled selected>-Select-</option>-->
<!--<optgroup label = "Morning Shift"
<option value="8.30 - 9.15" <?php if(in_array('8.30 - 9.15',$time)){ echo "selected"; }?>>8.30 - 9.15</option>
<option value="9.15 - 10.00" <?php if(in_array('9.15 - 10.0',$time)){ echo "selected"; }?>>9.15 - 10.00</option>
<option value="10:00 - 10:45" <?php if(in_array('10:00 - 10:45',$time)){ echo "selected"; }?>>10:00 - 10:45</option>
<option value="10:45 - 11:00" <?php if(in_array('10:45 - 11:00',$time)){ echo "selected"; }?>>10:45 - 11:00</option>
<option value="11:00 - 11:45" <?php if(in_array('11:00 - 11:45',$time)){ echo "selected"; }?>>11:00 - 11:45</option>
<option value="11:45 - 12:30" <?php if(in_array('11:45 - 12:30',$time)){ echo "selected"; }?>>11:45 - 12:30</option>
</optgroup>
-->
<!-- <optgroup label = "Afternoon Shift">
<option value="1.00 - 1.45" <?php if(in_array('1.00 - 1.45',$time)){ echo "selected"; }?>>1.00 - 1.45</option>
<option value="1.45 - 2.30" <?php if(in_array('1.45 - 2.30',$time)){ echo "selected"; }?>>1.45 - 2.30</option>
<option value="2:30 - 3:15" <?php if(in_array('2:30 - 3:15',$time)){ echo "selected"; }?>>2:30 - 3:15</option>
<option value="3:15 - 4:00" <?php if(in_array('3:15 - 4:00',$time)){ echo "selected"; }?>>3:15 - 4:00</option>
<option value="4:00 - 4:45" <?php if(in_array('4:00 - 4:45',$time)){ echo "selected"; }?>>4:00 - 4:45</option>
<option value="4:45 - 5:30" <?php if(in_array('4:45 - 5:30',$time)){ echo "selected"; }?>>4:45 - 5:30</option>
</optgroup>-->
<!-- </select>-->
</td>
<td class=""><!--<input type="text" id="hr_inst_time" name="hr_inst_time[]" class="form-control" value="<?=$hr_inst_day?>" <?php if(in_array($hr_inst_day)){ echo "selected"; } ?>/> -->
<input type="hidden" id="hiddenDay" name="instructor_days[][]" value=""/>
<select class="multiselect-ui form-control" multiple="multiple" id="instructor_day" onChange="addDay();">
<option disabled selected>-Select-</option>
<option value="Monday">Monday</option>
<option value="Tuesday">Tuesday</option>
<option value="Wednesday">Wednesday</option>
<option value="Thursday">Thursday</option>
<option value="Friday">Friday</option>
<option value="Saturday">Saturday</option>
<option value="Sunday">Sunday</option>
</select>
</td>
</tr>
<?php
} //end else
?>
</tbody>
</tbody>
</table>
</div>
<div class="col-md-1">
<!--Added to fill row -->
</div>
<!--adding new table div -->
<div id="pkg_hr" >
</div>
<div class="col-md-6">
<button type="button" onclick="duplicateHResources();" style="" class="btn btn-primary btn-sm">+ Add </button>
</div>
<div class="col-md-2">
<input type="hidden" name="counter" id="counter_hr" value="1" />
<input type="hidden" name="pkgs" id="pkgs_hr" value="0" />
<!--<input type="hidden" name="action" value="submit_form" /> -->
</div>
</div> <!--end showClasses -->
<div class="bg-default content-box text-center pad20A mrg25T">
<input type="hidden" name="action" value="infrastructure" />
<input type="submit" class="btn btn-lg btn-primary" name="action" value="Submit">
<!-- <button class="btn btn-lg btn-primary">Submit</button> -->
</div>
</form>
</div> <!--end example-box-wrapper -->
</div>
</div> <!--end of Panel body -->
</div><!--end of Panel div -->
</div>
<!-- Right Content Area -->
</div>
<!-- page-wrapper -->
<!-- foot Scripts -->
<?php include('includes/foot-scripts.php')?>
</div>
</div>
</body>
</html>
<script src="js/ms-select-everyday.js" type="text/javascript"></script>
<script>
//Code for adding and removing Classroom row
var counter_class = 0;
var a =1;
function duplicateClass(){
var $counter_class=$("#counter_class").val();
$("#pkg_class").append('<div style="display:none" id="newdiv_class-'+$counter_class+'">'+
'<div class="col-md-11">'+
'<table id="datatable-responsive" class= "table table-striped table-bordered responsive no-wrap dataTable dtr-inline" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">'+
'<tbody>'+
'<tr role="row" class="odd" id="classes_result_row">'+
'<td class=""><input type="text" id="classroom_name" name="classroom_name[]" class="form-control" value="" /></td>'+
'<td class=""><input type="text" id="classroom_code" name="classroom_code[]" class="form-control" value="" /></td>'+
'<td class="">'+
'<select class="form-control" id="classroom_program" name="classroom_program[]">'+
'<option disabled selected>-Select-</option>'+
<?php
$sql = "SELECT `program_title` FROM `programs_inst`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
'<option value="<?=$available_prog?>" <?php if($workshop_program == $available_prog){ echo "selected"; } ?>><?=$available_prog?></option>'+
<?php } ?>
'</select>'+
'</td>'+
'<td class=""><input type="text" id="classroom_max" name="classroom_max[]" class="form-control" value="" /></td>'+
'</tr>'+
'</tbody>'+
'</table>' +
'</div>' +
'<div class="col-md-1" >'+
'<a id="test" onclick="remdiv_class('+$counter_class+')"><h1 class="btn btn-danger" style="margin-top:22px;">x</h1></a>' +
'</div>' );
$("#newdiv_class-"+$counter_class).slideDown();
$counter_class++;
$("#counter_class").val($counter_class);
var pkgs_class=parseInt($("#pkgs_class").val())+1;
$("#pkgs_class").val(pkgs_class);
// $("#div_class_total").text(pkgs_class+1); //this will add the increment value to div
if (pkgs_class !== null) { //if new div added
a = a+1;//then increment counter
$('input[name=class_total]').val(a); //place counter value in input
}
}
function remdiv_class(id){
if(a > 1){
var pkgs_class=parseInt($("#pkgs_class").val())-1;
$("#newdiv_class-"+id).slideUp();
$("#newdiv_class-"+id).empty();
$("#pkgs_class").val(pkgs_class);
a = a-1;
$('input[name=class_total]').val(a);
}
}
//Code for adding and removing Worskhop row
var counter_workshop = 0;
var w = 1;
function duplicateWorkshop(){
var $counter_workshop=$("#counter_workshop").val();
$("#pkg_workshop").append('<div style="display:none" id="newdiv_workshop-'+$counter_workshop+'">'+
'<div class="col-md-11">'+
'<table id="datatable-responsive" class= "table table-striped table-bordered responsive no-wrap dataTable dtr-inline" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">'+
'<tbody>'+
'<tr role="row" class="odd" id="workshop_result_row">'+
'<td class=""><input type="text" id="workshop_name" name="workshop_name[]" class="form-control" value="" /></td>'+
'<td class=""><input type="text" id="workshop_code" name="workshop_code[]" class="form-control" value="" /></td>'+
'<td class="">'+
'<select class="form-control" id="workshop_program" name="workshop_program[]">'+
' <option disabled selected>-Select-</option>'+
<?php
$sql = "SELECT `program_title` FROM `programs_inst`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
'<option value="<?=$available_prog?>" <?php if($workshop_program == $available_prog){ echo "selected"; } ?>><?=$available_prog?></option>'+
<?php } ?>
'</select>'+
'</td>'+
'<td class=""><input type="text" id="workshop_max" name="workshop_max[]" class="form-control" value="" /></td>'+
'</tr>'+
'</tbody>'+
'</table>' +
'</div>' +
'<div class="col-md-1">'+
'<a onclick="remdiv_workshop('+$counter_workshop+')"><h1 class="btn btn-danger" style="margin-top:22px;">x</h1></a>' +
'</div>' );
$("#newdiv_workshop-"+$counter_workshop).slideDown();
$counter_workshop++;
$("#counter_workshop").val($counter_workshop);
var pkgs_workshop=parseInt($("#pkgs_workshop").val())+1;
$("#pkgs_workshop").val(pkgs_workshop);
if (pkgs_workshop !== null) { //if new div added
w = w+1;//then increment counter
$('input[name=workshop_total]').val(w); //place counter value in input
}
}
function remdiv_workshop(id){
if(w > 1){
var pkgs_workshop=parseInt($("#pkgs_workshop").val())-1;
$("#newdiv_workshop-"+id).slideUp();
$("#newdiv_workshop-"+id).empty();
$("#pkgs_workshop").val(pkgs_workshop);
w = w-1; //decrement counter
$('input[name=workshop_total]').val(w); //add value to input
}
}
//Code for adding and removing Human Resources row
var counter_hr = 1;
var staff = 0;
var non_staff=0;
function duplicateHResources(){
var $counter_hr=parseInt($("#counter_hr").val());
$("head").append('<link rel="stylesheet" href="css/select.css" type="text/css" />');
multiTiming(); //adds timings to Instructor row
$("#pkg_hr").append('<div style="display:none" id="newdiv_hr-'+$counter_hr+'">'+
'<div class="col-md-11">'+
'<table id="datatable-responsive" class= "table table-striped table-bordered responsive no-wrap dataTable dtr-inline" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">'+
'<tbody>'+
'<tr role="row" class="odd" id="wrkshp_result_row">'+
'<td class=""><input type="text" id="instructor_name" name="instructor_name[]" class="form-control" value=""/></td>'+
'<td class=""><input type="text" id="instructor_code" name="instructor_code[]" class="form-control" value="" style="width:90px;"/></td>'+
'<td class="">'+
'<select class="instructor_designation form-control " name="instructor_designation[]">'+
<?php
$designation = explode(",",$instructor_designation);
?>
'<option disabled selected>-Select-</option>'+
'<option value="Instructor">Instructor</option>'+
'<option value="Instructor Level 1">Instructor Level 1</option>'+
'<option value="Sr. Instructor">Sr. Instructor</option>'+
'<option value="Principal">Principal</option>'+
'<option value="Other">Other</option>'+
'</select>'+
'</td>'+
'<td class=""><input type="text" id="instructor_max_hr" name="instructor_max_hr[]" class="form-control" value="" style="width:40px;" /></td>'+
'<td class=""><input type="text" id="instructor_max_sess" name="instructor_max_sess[]" class="form-control" value="" style="width:40px;" /></td>'+
'<td class="">'+
'<input type="hidden" id="hiddenSubjects'+$counter_hr+'" name="instructor_subjects[][]" value=""/>'+
'<select class="multiselect-ui form-control" multiple="multiple" id="instructor_subjects'+$counter_hr+'" onChange="addSubjInstructor('+$counter_hr+')">'+
'<option disabled selected>-Select-</option>'+
<?php
$sql = "SELECT DISTINCT `subject_title` FROM `subjects_prog`" ;
$res = $db->ExecuteQuery($sql);
while(list($available_prog) = $res->FetchAsArray())
{
?>
'<option value="<?=$available_prog?>" <?php if($instructor_subject == $available_prog){ echo "selected"; } ?>><?=$available_prog?></option>'+
<?php } ?>
'</select>'+
'</td>'+
'<td class="timingHR" id="multiTimings'+$counter_hr+'"></td>'+
'<td class="">'+
'<select class="multiselect-ui-every form-control ins_designation" multiple="multiple" id="instructor_days" name="instructor_days[][]">'+
<?php
$days = explode(",",$instructor_days);
?>
'<option disabled selected>-Select-</option>'+
'<option value="Monday">Monday</option>'+
'<option value="Tuesday">Tuesday</option>'+
'<option value="Wednesday">Wednesday</option>'+
'<option value="Thursday">Thursday</option>'+
'<option value="Friday">Friday</option>'+
'<option value="Saturday">Saturday</option>'+
'<option value="Sunday">Sunday</option>'+
'</select>'+
'</td>'+
'</tr>'+
'</tbody>'+
'</table>' +
'</div>' +
'<script src="js/ms-select-everyday.js" type="text/javascript"><\/script>'+
'<div class="col-md-1">'+
'<a onclick="remdiv_hr('+$counter_hr+')"><h1 class="btn btn-danger" style="margin-top:22px;">x</h1></a>' +
'</div>'+
'<script src="js/mselect.js" type="text/javascript"><\/script>');
$("#newdiv_hr-"+$counter_hr).slideDown();
$counter_hr++;
$("#counter_hr").val($counter_hr);
var pkgs_hr=parseInt($("#pkgs_hr").val())+1;
$("#pkgs_hr").val(pkgs_hr);
/* if (pkgs_hr !== null) { //if new div added
staff = staff+1;//then increment counter
$('input[name=teaching_staff_total]').val(staff); //place counter value in input
}//end if */
if (pkgs_hr !== null) {
counter_hr = counter_hr+1;
$('input[name=hidden_staff]').val(counter_hr);
} //end if
}
function remdiv_hr(id){
if(counter_hr > 1){
// if($pkgs_hr >1)
var pkgs_hr=parseInt($("#pkgs_hr").val())-1;
$("#newdiv_hr-"+id).slideUp();
$("#newdiv_hr-"+id).empty();
$("#pkgs_hr").val(pkgs_hr);
/* staff = staff-1;
$('input[name=teaching_staff_total]').val(staff);
non_staff = non_staff -1;
$('input[name=non_teaching_staff_total]').val(non_staff);
*/
counter_hr =counter_hr-1;
$('input[name=hidden_staff]').val(counter_hr);
}
} //end remdiv_hr()
// add multiple subjects to hidden field
function addSubjInstructor(ele){
$('#instructor_subjects'+ele).each(function() {
var subj = $(this).val(); // var subj = $('#subject_assesment').val();
$("#hiddenSubjects"+ele).val(subj)
});
}
function addSubjInstruct(){
$('#instructor_subject').each(function() {
var subj = $(this).val(); // var subj = $('#subject_assesment').val();
$("#hiddenSubject").val(subj)
});
}
/* $('.instructor_designation').change(function() {
if($(this).val() === 'Other'){
non_staff = non_staff+1;
$('input[name=non_teaching_staff_total]').val(non_staff);
staff = staff-1;
$('input[name=teaching_staff_total]').val(staff);
} //end if
if($(this).val() === 'Principal' || 'Instructor'||'Instructor Level 1'||'Sr. Instructor') {
staff = staff+1;
$('input[name=teaching_staff_total]').val(staff);
non_staff = non_staff-1;
$('input[name=non_teaching_staff_total]').val(non_staff);
} //end if
}); //end function
*/
//check if Resources for Institute already exist.
function chkInstituteExist() {
var institute = $("#institute_abb").val();
$.ajax({
url: "get-duplicate-institute.php",
dataType: "JSON",
type: "post",
data: {
'instituteabb': institute
},
success: function(data) {
if (data == 1) {
alert('The resources already exists for '+institute+'. Please select another institute or existing data will be overwritten.');
}
},
error: function(xhr, textStatus, errorThrown) {
alert(xhr.responseText);
}
}); //end ajax
} //end chkInstituteExist()
</script>
<script src="js/mselect.js" type="text/javascript"></script>