File: /var/www/nclive/technc/exam_link_list_update.php
<?php
include 'config.php';
?>
<!DOCTYPE html>
<!--[if IE 9]> <html class="ie9 no-focus" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-focus" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Naukri Connect - Dashboard</title>
<meta name="description" content="">
<meta name="author" content="pixelcave">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Icons -->
<!-- The following icons can be replaced with your own, they are used by desktop and mobile browsers -->
<link rel="shortcut icon" href="assets/img/favicons/favicon.png">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-160x160.png" sizes="160x160">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-192x192.png" sizes="192x192">
<link rel="apple-touch-icon" sizes="57x57" href="assets/img/favicons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="assets/img/favicons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/img/favicons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="assets/img/favicons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/img/favicons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="assets/img/favicons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/img/favicons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="assets/img/favicons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/img/favicons/apple-touch-icon-180x180.png">
<!-- END Icons -->
<!-- Stylesheets -->
<!-- Web fonts -->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400italic,600,700%7COpen+Sans:300,400,400italic,600,700">
<!-- Page JS Plugins CSS -->
<link rel="stylesheet" href="assets/js/plugins/slick/slick.min.css">
<link rel="stylesheet" href="assets/js/plugins/slick/slick-theme.min.css">
<!-- Bootstrap and OneUI CSS framework -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" id="css-main" href="assets/css/oneui.css">
<!-- You can include a specific file from css/themes/ folder to alter the default color theme of the template. eg: -->
<!-- <link rel="stylesheet" id="css-theme" href="assets/css/themes/flat.min.css"> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- END Stylesheets -->
</head>
<body>
<div id="page-container" class="sidebar-l sidebar-o side-scroll header-navbar-fixed">
<!-- Header -->
<header id="header-navbar" class="content-mini content-mini-full">
<!-- Header Navigation Left -->
<ul class="nav-header pull-left">
<li class="hidden-md hidden-lg">
<!-- Layout API, functionality initialized in App() -> uiLayoutApi() -->
<button class="btn btn-default" data-toggle="layout" data-action="sidebar_toggle" type="button">
<i class="fa fa-navicon"></i>
</button>
</li>
<li class="hidden-xs hidden-sm">
<!-- Layout API, functionality initialized in App() -> uiLayoutApi() -->
<button class="btn btn-default" data-toggle="layout" data-action="sidebar_mini_toggle" type="button">
<i class="fa fa-ellipsis-v"></i>
</button>
</li>
<li>
<!-- Opens the Apps modal found at the bottom of the page, before including JS code -->
<button class="btn btn-default pull-right" data-toggle="modal" data-target="#apps-modal" type="button">
<i class="si si-grid"></i>
</button>
</li>
<li class="visible-xs">
<!-- Toggle class helper (for .js-header-search below), functionality initialized in App() -> uiToggleClass() -->
<button class="btn btn-default" data-toggle="class-toggle" data-target=".js-header-search" data-class="header-search-xs-visible" type="button">
<i class="fa fa-search"></i>
</button>
</li>
<li class="js-header-search header-search">
<form class="form-horizontal" method="post">
<div class="form-material form-material-primary input-group remove-margin-t remove-margin-b">
<input class="form-control" type="text" id="base-material-text" name="base-material-text" placeholder="Search..">
<span class="input-group-addon"><i class="si si-magnifier"></i></span>
</div>
</form>
</li>
</ul>
<!-- END Header Navigation Left -->
</header>
<style>
.total_ques_div
{
background-color: white;
border-color: #C8D5E0;
border-image: none;
border-style: solid;
border-width: 1px 1px 2px;
color: #1E598E;
font-weight: bold;
padding: 8px 10px;
text-decoration: none;
}
.form-table td
{
padding:0px !important;
}
.extLink{
text-decoration: none;
cursor: pointer;
}
.fancybox-skin
{ margin-left: 400px!important;
width: 500px!important;
}
.form-table td {
padding: 5px !important;
}
</style>
<!--<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-3.3.1.js"></script>-->
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
<!--<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">-->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<!--<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap.min.css">-->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.bootstrap.min.css">
<main id="main-container">
<?php
$lid = $_REQUEST['lid'];
$query="SELECT el.id,el.exam_id,el.display_text,el.display_text_dates, el.description, el.links, el.date_type,el.date, el.status,e.exam_name,ee.name as entity_name,el.entity_id FROM sp_exam_links as el
left join sp_exam as e on e.exam_id=el.exam_id
left join sp_exam_entity as ee on ee.id=el.entity_id where el.id='$lid'";
$sql = $db->prepare($query);
$sql->execute();
$row = $sql->fetch();
?>
<?php
$curDate = date('Y-m-d H:i:s');
if(isset($_REQUEST['submit'])){
$id=$_REQUEST['id'];
$name= $_REQUEST['examname'];
$entity= $_REQUEST['entity'];
$dis= $_REQUEST['dis_text'];
$dis_text_dates=$_REQUEST['dis_text_dates'];
$desc= $_REQUEST['editor'];
$desc2=$_REQUEST['desc2'];
$link= $_REQUEST['link'];
$type=$_REQUEST['search_type'];
if($type=='N'){
$date=$_REQUEST['normal'];
}
else if($type=='FT'){
$date=$_REQUEST['fromdate'] .',' . $_REQUEST['todate'];
}
echo $query1="UPDATE sp_exam_links SET exam_id='$name',entity_id='$entity',display_text='$dis',display_text_dates='$display_text_dates',description='$desc',links='$link',date_type='$type',date='$date',update_by='$user_id',update_date='$curDate' WHERE id='$id'";
$sql1 = $db->prepare($query1);
if($sql1->execute()){
echo '<h3 style="color:green;">Data Update successfully</h3>';
echo "<meta http-equiv='refresh' content='0'>";
$lastid = $db->lastInsertId();
$query3="INSERT INTO sp_exam_update SET `exam_id`='$name',type='UL',`user_id`='$user_id',`date`='$curDate',`description`='$desc2'";
$sql2=$db->prepare($query3);
$sql2->execute();
echo '<h3 style="color:green;">Data Update successfully</h3>';
echo "<meta http-equiv='refresh' content='0'>";
} else {
echo "Update unsuccessfull!";
}
}
?>
<div class="content content-narrow">
<!-- Forms Row -->
<div class="row">
<div class="col-lg-12">
<!-- Bootstrap Forms Validation -->
<h2 class="content-heading">Update Details</h2>
<div class="block">
<div class="block-header">
<ul class="block-options">
<li>
<button type="button"><i class="si si-settings"></i></button>
</li>
</ul>
<h3 class="block-title"></h3>
</div>
<div class="block-content block-content-narrow">
<form class="js-validation-bootstrap form-horizontal" action="" method="post" id="form">
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Select Exam</label>
<div class="col-md-10">
<input type="hidden" name="id" id="id" value="<?php echo $row[id];?>">
<select class="js-select2 form-control" name="examname" style="width: 100%;">
<option selected="selected" id="examname" value="<?php echo $row['exam_id']; ?>"><?php echo $row['exam_name']; ?></option>
<?php
$sql1 = $db->prepare("SELECT exam_id,exam_name FROM sp_exam");
$sql->execute();
?><?php
while($row2=$sql1->fetch(PDO::FETCH_ASSOC))
{
?>
<option value="<?php echo $row2['exam_id']; ?>"><?php echo $row2['exam_name']; ?></option>
<?php
} ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Select Exam Entity</label>
<div class="col-md-10">
<select class="js-select2 form-control" name="entity" style="width: 100%;">
<option selected="selected" id="entity" value="<?php echo $row['entity_id']; ?>"><?php echo $row['entity_name']; ?></option>
<?php
$sql1 = $db->prepare("SELECT id,name FROM sp_exam_entity");
$sql1->execute();
while($row2=$sql1->fetch(PDO::FETCH_ASSOC)){
?>
<option value="<?php echo $row2['id']; ?>"><?php echo $row2['name']; ?></option>
<?php
} ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Display Text (Links)<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="dis_text" id="dis_text" value="<?php echo $row['display_text']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Display Text (Dates)<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="dis_text_dates" id="dis_text_dates" value="<?php echo $row['display_text_dates']; ?>">
</div>
</div>
<?php if( ($user_id == 3 ) || ($user_type == 'editor')) { ?> <div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Update Description<span class="text-danger">*</span></label>
<div class="col-md-10">
<textarea name="desc2" id="desc2" rows="5" cols="63"></textarea>
</div>
</div>
<?php } else { ?>
<div class="form-group">
<label class="col-md-2 control-label" for="val-email">Description<span class="text-danger">*</span></label>
<div class="col-md-10">
<textarea class="ckeditor" name="editor" id="editor"></textarea>
</div>
</div>
<?php } ?>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Links<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="link" id="link" value="<?php echo $row['links']; ?>">
</div>
</div>
<?php
$normal=$row['date_type'];
if($normal=='N'){?>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">On Date<span class="text-danger">*</span></label>
<div class="col-md-1">
<input type="radio" name="search_type" checked="checked" class="radio" value="N" id="N" />
</div>
<div class="col-md-5" id="normal" style="">
<input type="date" placeholder="Select Dates" class="dates_opted dates_opted_1 width_100" name="normal" id="nor" value="<?php echo $row['date']; ?>" style="width:400px">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">From & To Date<span class="text-danger">*</span></label>
<div class="col-md-1" >
<input type="radio" name="search_type" value="FT" class="radio" id="FT" checked="checked"/>
</div>
<div class="col-md-5" id="fromto" style="">
<input type="date" class="dates_opted dates_opted_1 width_100" name="fromdate" id="fromdate" value="">
<input type="date" class="dates_opted dates_opted_1 width_100" name="todate" id="todate" value="">
</div>
</div>
<?php } ?>
<?php
$fromto=$row['date_type'];
if($fromto=='FT'){
$date=$row['date'];
$dd=explode(",",$date);
$date1 = date('m-d-Y', strtotime($dd[0]));
$date2 = date('m-d-Y', strtotime($dd[1]));
$date = $date1 . " To " . $date2;
?>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">From & To Date<span class="text-danger">*</span></label>
<div class="col-md-1" >
<input type="radio" name="search_type" value="FT" class="radio" id="FT" checked="checked"/>
</div>
<div class="col-md-5" id="fromto" style="">
<input type="date" class="dates_opted dates_opted_1 width_100" name="fromdate" id="fromdate" value="<?php echo $dd[0]; ?>">
<input type="date" class="dates_opted dates_opted_1 width_100" name="todate" id="todate" value="<?php echo $dd[1]; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">On Date<span class="text-danger">*</span></label>
<div class="col-md-1">
<input type="radio" name="search_type" checked="checked" class="radio" value="N" id="N" />
</div>
<div class="col-md-5" id="normal" style="">
<input type="date" placeholder="Select Dates" class="dates_opted dates_opted_1 width_100" name="normal" id="nor" value="" style="width:400px">
</div>
</div>
<?php } else if ($row['date_type']=='') { ?>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">On Date<span class="text-danger">*</span></label>
<div class="col-md-1">
<input type="radio" name="search_type" class="radio" value="N" id="N" />
</div>
<div class="col-md-5" id="normal" style="">
<input type="date" placeholder="Select Dates" class="dates_opted dates_opted_1 width_100" name="normal" id="nor" value="<?php echo $row['date']; ?>" style="width:400px">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">From & To Date<span class="text-danger">*</span></label>
<div class="col-md-1" >
<input type="radio" name="search_type" value="FT" class="radio" id="FT" />
</div>
<div class="col-md-5" id="fromto" style="">
<input type="date" class="dates_opted dates_opted_1 width_100" name="fromdate" id="fromdate" value="<?php echo $dd[0]; ?>">
<input type="date" class="dates_opted dates_opted_1 width_100" name="todate" id="todate" value="<?php echo $dd[1]; ?>">
</div>
</div>
<?php } ?>
<div class="form-group">
<div class="col-md-10 col-md-offset-2">
<button class="btn btn-lg btn-primary" type="submit" name="submit">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!---------END STATUS MODEL----->
<!-- END Page Content -->
</main>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('.radio').on('change', function() {
if (this.value == 'N') {
$("#normal").css('display','block');
$("#fromto").css('display','none');
}
else if (this.value == 'FT') {
$("#fromto").css('display','block');
$("#normal").css('display','none');
}
});
});
</script>
<script>
function cleanArray(actual) {
var newArray = new Array();
for (var i = 0; i < actual.length; i++) {
if (actual[i]) {
newArray.push(actual[i]);
}
}
return newArray;
}
jQuery(document).ready(function($) {
$('.dates_opted').each(function(index){
var dates=[];
$(this).datepicker({
dateFormat: "yy-mm-dd",
onSelect: function(){
dates=cleanArray(dates);
dates.push($(this).val());
//console.log(dates);
$(this).val(dates);
},showAnim :'clip',
changeYear:true,
changeMonth:true,
yearRange:"2000:2030"
}).keyup(function(e) {
if(e.keyCode == 8 || e.keyCode == 46) {
var datesString=$(this).val().split(",");
dates=[];
for(var i=0 ; i<datesString.length-1;i++){
dates.push(datesString[i]);
}
$(this).blur();
$(this).val(dates);
}
});
});
});
</script>