<?php
include_once '../session/admin-session.php';
include_once '../classes/class_admin.php';
include_once '../classes/validation.php';
include_once '../classes/common.php';
include_once 'read-configration.php';
ob_start();

$ObjDB = new class_db();
$log = new common();
$objadm = new class_admin();
$val = new validation();

$sub_code = $val->ValidateString($_REQUEST['sub_code']);
$sub_list = $val->ValidateString($_REQUEST['sub_list']);
$fac_roll = $val->ValidateString($_REQUEST['fac_roll']);

$sem_num = substr($sub_list, 1, 2);

$objadm->sem_num = $sem_num;
$SemListNameQ = $objadm->GetSemList();
while ($RowSem = mysqli_fetch_array($SemListNameQ)) {
    $SemName = $RowSem['sem_name'];
}


$qlist = "select a.*, b.sub_title, b.sub_crdit, b.stu_year, c.type_name  from isr_course_content_tbl a, isr_curriculum_tbl b, isr_course_type_tbl c where a.fac_roll = '$fac_roll' and a.sub_list = '$sub_list' and a.sub_code = '$sub_code'  and a.sub_code = b.sub_code and a.sub_list = b.sub_list and a.sub_type = c.type_code order by a.sub_code limit 1";
$ObjDB->sproc_name = $qlist;
$res_qlist = $ObjDB->SelectQuery();
$found = mysqli_num_rows($res_qlist);

$sub_row = mysqli_fetch_array($res_qlist);


$sub_code = $sub_row['sub_code'];
$sub_type = $sub_row['sub_type'];
$type_name = $sub_row['type_name'];

$opento_sem = $sub_row['stu_year'];

$sub_title = $sub_row['sub_title'];
$bsms_credit = $sub_row['sub_crdit'];

$sub_show = $sub_code . ' - ' . $sub_title;
$fac_roll = $sub_row['fac_roll'];
$pre_req = $sub_row['pre_req'];
$objective = $sub_row['objective'];
$topics = $sub_row['topics'];
$eval = $sub_row['eval'];
$reading = $sub_row['reading'];
$datetime = $sub_row['datetime'];
$when_next = $sub_row['when_next'];

$objadm->fac_roll = $fac_roll;
$qname = $objadm->GetFacultyList();
$row_fac = mysqli_fetch_array($qname);
$fac_name = $row_fac['name'];
$fac_name = '<B>Dr. ' . $fac_name . '</B>';

$qaux_name = "select a.name from isr_faculty_tbl a, isr_sub_aux_tbl b where a.roll = b.fac_roll and b.sub_code = '$sub_code' and b.sub_list = '$sub_list'";
$ObjDB->sproc_name = $qaux_name;
$res_aux = $ObjDB->SelectQuery();
$num_aux = mysqli_num_rows($res_aux);
if ($num_aux > 0) {
    while ($aux = mysqli_fetch_array($res_aux)) {
        $fac_aux = $aux['name'];
        $fac_name = $fac_name . '<BR>Dr. ' . $fac_aux;
    }
}
$qphd = "select course_code, course_credit from gsam_courses_tbl where bsms_code = '$sub_code' and b1_sem = '$sem_num' limit 1";
$ObjDB->sproc_name = $qphd;
$res_qphd = $ObjDB->SelectQuery();
$num_phd = mysqli_num_rows($res_qphd);
if ($num_phd > 0) {
    while ($aux = mysqli_fetch_array($res_qphd)) {
        $phd_code = $aux['course_code'];
        $phd_credit = $aux['course_credit'];
        $sub_code = $sub_code . ' / ' . $phd_code;
        $bsms_credit = $bsms_credit . ' / ' . $phd_credit;
    }
}
?>
<div class="container-fluid">
    <div class="row">
        <div class="col-xl-12 col-xxl-12 col-sm-12">
            <div class="card">
                <div class="card-header">
                    <h5 class="card-title">Course Content Preview</h5>
                </div>
                <div class="card-body">

                    <table class="table table-bordered course-table">
                        <tr>
                            <th>Semester</th>
                            <td><?php echo $SemName; ?></td>
                        </tr>
                        <tr>
                            <th>Open to Semester</th>
                            <td><?php echo $opento_sem; ?></td>
                        </tr>
                        <tr>
                            <th>Course Code</th>
                            <td><?php echo $sub_code; ?></td>
                        </tr>
                        <tr>
                            <th>Course Title</th>
                            <td><?php echo $sub_title; ?></td>
                        </tr>
                        <tr>
                            <th>Nature of Course</th>
                            <td><?php echo $sub_type.' - '.$type_name; ?></td>
                        </tr>
                        <tr>
                            <th>Credit</th>
                            <td><?php echo $bsms_credit; ?></td>
                        </tr>
                        <tr>
                            <th>Coordinator & Faculty</th>
                            <td>
                                <?php echo $fac_name; ?>
                            </td>
                        </tr>
                        <tr>
                            <th>Pre-requisites</th>
                            <td><div class="content-box"><?php echo $pre_req; ?></div></td>
                        </tr>
                        <tr>
                            <th>Objectives</th>
                            <td>
                                <div class="content-box">
                                    <?php echo $objective; ?>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>Course Content</th>
                            <td>
                                <div class="content-box">
                                    <?php echo $topics; ?>
                                </div>
                            </td>
                        </tr> 
                        <tr>
                            <th>Evaluation / Assessment</th>
                            <td>
                                <div class="content-box">
                                  <?php echo $eval; ?>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>Suggested readings</th>
                            <td>
                                <div class="content-box">
                                   <?php echo $reading; ?>
                                </div>
                            </td>
                        </tr> 
                        <tr>
                            <th>When the course will be offered next</th>
                            <td>
                                <div class="content-box">
                                   <?php echo $when_next; ?>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>Date Uploaded</th>
                            <td>
                                <div class="content-box">
                                   <?php echo $datetime;  ?>
                                </div>
                            </td>
                        </tr>
                    </table>  
                    <div class="row">
                        <div class=" col-lg-3"> 
                            <div class="text-end mt-3">
                                <a href="course-content-list.php" class="btn btn-primary">OK</a>
                            </div>  

                        </div>
                        <div class=" col-lg-3" style="margin-top: 14px;"> 
                            <FORM METHOD="POST" ACTION="course-add-content.php">
                                	<INPUT TYPE="hidden" NAME="edit_sub_code" value="<?php echo $sub_code; ?>">
			<INPUT TYPE="hidden" NAME="edit_sub_list" value="<?php echo $sub_list; ?>">
                            <button class="btn btn-primary">Edit</button>
                            </FORM>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>

</div>
<?php
$pagemaincontent = ob_get_contents();
ob_clean();
$PAGENAME = 'course-content-add';
$HTMLTITLE = '';
$HTMLDESCRIPTION = '';
$HTMLKEYWORDS = '';
include("admin-master.php");
?>