Current File : /home/inlingua/public_html/dwarka/icentex/admin_calendar/ingl_calendar.select.php
<?php
//  Created on: 13-12-2014
session_start();
/*
$loggedUserNo = $_SESSION['loggedUserNo'];
if ($loggedUserNo == "")
{	echo "Please <a href='index.php'>login</a> first.";
	exit(0);
}
*/

// Include header
include "header_calendar.php";
// Include the database connection details
require('../pdo_conn/dbConnection.php');

// Include common functions
require('../pdo_conn/commonFunc.php');

// Include common functions
require('../pdo_conn/globalVars.php');

// Include the table handler class
require('../pdo_conn/dbHandler.class.php');

// Init and connect to database
$dbObject = new dbHandler($conn);


?>
<script>
	$(function() {
	          
		$('#organized_date').datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: "-4:+4"
		});
	});
</script>

<div style='text-align:left;'><h3>&nbsp;&nbsp;&nbsp;View Events (<a href="ingl_calendar.main.php" title='Add entry'>Add New Event</a>)</h3></div>

<?php if ($_SESSION['dispMesg'][1] != "" && (date("U") - $_SESSION['dispMesg'][0] < 7)) 
{ 	?>
	<span id='mesgSpan'><font color='#da0000'><?php echo $_SESSION['dispMesg'][1];?></font></span>
	<script>
	setTimeout(function() {   $('#mesgSpan').fadeOut('slow'); }, 4000); // <-- time in milliseconds 
	</script>
	<br>
	<?php
}
unset($_SESSION['dispMesg']);
?><form method="post" action="ingl_calendar.select.php">
<table>
	<tr><td>Search : </td><td>Center</td><td>
<select id="centre "  name="centre" class="required" style="width:200px;">
<option value="">Select Location</option>
<?php
if(in_array("calendar_super_admin",$_SESSION['allowed_modules'])){
$queryB="select * from timesheet_location where status='1' order by location";
	
}
else{
$queryB="select * from timesheet_location where status='1' && location='".$_SESSION['branch']."' order by location";
}
$resultB=$conn->query($queryB);
//$resultB->execute(array());
while($numB=$resultB->fetch_assoc())
{
if($numB[location]=="S.Extn")
{
$showL="South Extension";
}
else
{
$showL=$numB[location];
}
echo"<option value='".$numB[location]."'";
if($_REQUEST['centre']==$numB[location]) echo"selected";
echo">".$showL."</option>";
}
?>
</select>
		
		
	</td>
	
	<td>Date</td><td><input type="text" name='organized_date' id="organized_date" value="<?php echo $_REQUEST['organized_date'] ?>"></td>
	<td>Event</td><td><input type="text" name="event" value="<?php echo $_REQUEST['event'] ?>"></td>
	<td><input type="submit" value="Search"></td></tr>
</table>
</form>
<?php
//$dbObject->connect();

// Records selection sql
$sqlQuery = "SELECT a.*,b.location  FROM ingl_calendar a left join timesheet_location b on a.centre=b.recNo where 1=1 ";

if(in_array("calendar_super_admin",$_SESSION['allowed_modules'])){
	
}
else{
$sqlQuery .= " && location='".$_SESSION['branch']."' ";
}

if($_REQUEST['centre']!=""){
$sqlQuery .= " && location='".$_REQUEST['centre']."' ";	
}

if($_REQUEST['organized_date']!=""){
$sqlQuery .= " && DATE(organized_date)='".$_REQUEST['organized_date']."' ";	
}

if($_REQUEST['event']!=""){
$sqlQuery .= " && event like '%".$_REQUEST['event']."%' ";	
}
$sqlQuery .= " order by organized_date desc";
//echo $sqlQuery; 
// Prepare page navigation
$resultsPerPage = 20; // number of rows to return per page

// Prepare add on URL
$addOnUrl = "&centre=".$_REQUEST['centre']."&organized_date=".$_REQUEST['organized_date']."&event=".$_REQUEST['event']."";
$offset=$_REQUEST['offset'];
if ($resultsPerPage > 0)
{	$prev_next_links = $dbObject->prev123Next($sqlQuery, $resultsPerPage,$addOnUrl);
	$sqlQuery .= " limit " . $offset . "," . $resultsPerPage ;
}

// Print navigation bar
function printArray($element) { echo "$element"; }

if ($resultsPerPage > 0 && $prev_next_links && count($prev_next_links) > 1)
{	//echo "Page: ";
	//array_walk($prev_next_links, 'printArray'); 
}

// Select records from table
$selectedRecords = $dbObject->Select($sqlQuery);
?>
<div id="contentnew">
<table border='0' class='pa-nor pa-table' width="100%">
<tr valign='top' class='rowH'>
<td>id</td>
<td>Centre</td>
<td>Event</td>
<td>Date</td>

<td>Action</td>
</tr>
<?php
// If no records selected, print message
if (!$selectedRecords)
{	?>
	<tr><td colspan='5'>There are no entries</td></tr> 
	<?php
}
$i=1;	
while($objectData=$dbObject->SelectNext())
{	?>
	<tr valign='top' onmouseover="this.className='pa-row-highlight'" onmouseout="this.className='pa-nor'">
	<td><?php echo $i;?></td>
	<td><?php echo $objectData['location'];?></td>
	<td><?php echo $objectData['event'];?></td>
	<td><?php echo date("Y-m-d",strtotime($objectData['organized_date']));?> (<?php echo $objectData['start_hour'];?>:<?php echo $objectData['start_minute'];?> - <?php echo $objectData['end_hour'];?>:<?php echo $objectData['end_minute'];?>)</td>

	<td>
	<a href='ingl_calendar.main.php?aC=sM&kV=<?php echo $objectData['recNo'] ;?>' title='Modify entry'><img src='../images/edit.png' border='0' hspace='2'></a> |
	<a href='ingl_calendar.main.php?aC=sV&kV=<?php echo $objectData['recNo'] ;?>' title='View entry'><img src='../images/view.png' border='0' hspace='2'></a> | 
	<a onclick='return confDel();' href='ingl_calendar.main.php?aC=Delete&kV=<?php echo $objectData['recNo'] ;?>' title='Delete entry'><img src='../images/delete.png' border='0' hspace='2'></a><br>
	<a href='ingl_calendar_participate.select.php?kV=<?php echo $objectData['recNo'] ;?>'>View Paricipants</a>
	</td>
	</tr>
	<?php
	$i++;
}
?>
</table>

<?php
// Print navigation bar
if ($resultsPerPage > 0 && $prev_next_links  && count($prev_next_links) > 1)
{	echo "Page: ";
	array_walk($prev_next_links, 'printArray'); 
	echo "<br>";
}
?>
<br>
<a href="ingl_calendar.main.php" title='Add entry'>Add New Event</a>
</div>

<script type="text/javascript">
function confDel()
{	var agree = confirm("Click OK to delete permanently or cancel");
	if (agree)
		return true;
	else
		return false;
}
</script>

<?php 
$dbObject->CloseConnection();

// Include footer
include "footer_calendar.php";
?>