Current File : /home/inlingua/public_html/dwarka/icentex/admin_conveyance/ingl_conveyance_main.form.php
<?php
// Include header
include "header_conveyance.php";
?>

<h3><span class='pa-nor-navbar'><a href='admin_conveyance.php'>Home</a> >> <a href='ingl_conveyance_main.select.php'>Conveyance</a></span></h3>

<?php
echo $succFailMesg; 

// Show result of a form submission?
if ($showResult == "Y")
{	echo "<br><a href='ingl_conveyance_main.select.php'>Back</a><br>";
	// Include footer
	include "footer_conveyance.php";
	return; 
}

?>

<script type="text/javascript" src="js/jquery.validate.min.js"></script>

<script language="javascript">
<!--
function validate1(form) 
{	if (form.recNo.value=="")
	{	alert("recNo cannot be blank. Please enter it.");
		form.recNo.focus(); return false;
	}
	return true;
}
-->
</script>
<style>
#myDiv input

{
	font-family:Arial, Helvetica, sans-serif;
	font-size: 8pt;
	color: #000000; /* CHANGE TO CORPORATE COLOUR */
	background-color: #fff;
	border: 1px solid #aaa;
	/*cursor: text;	*/
}
</style>
<?php
if($currentMode=="Save>>")
{
$_REQUEST['year']=$dbObject->getDbField('year');
$_REQUEST['month']=$dbObject->getDbField('month');
}

$num = cal_days_in_month(CAL_GREGORIAN, $_REQUEST['month'], $_REQUEST['year']);
$leavedays=array();

for($msd=1;$msd<=$num;$msd++)
{
$msd1=mktime(0,0,0,$_REQUEST['month'],$msd,$_REQUEST['year']);
$msd2=date("Y-m-d",$msd1);
$queryL="select * from leaves where timesheet_user_id ='".$_SESSION[id]."' && '".$msd2."'>=fromDate && '".$msd2."'<=toDate && status='approved'";
		$resultL=mysqli_query($conn,$queryL);
		$countL=mysqli_num_rows($resultL);
		if($countL>0)
		{
		$leavedays[]=$msd;
		}
}
//print_r($leavedays);

?>
<script>
function datepick(id)
{

 var currentmonth=<?php echo date("m");?>;
 var monthp=<?php echo $_REQUEST['month'] ?>;
 var dateMin = new Date(<?php echo $_REQUEST['year'] ?>, <?php echo $_REQUEST['month'] ?> - 1, 1);
 
 if(monthp<currentmonth)
 {
 var dateMax= new Date(<?php echo $_REQUEST['year'] ?>, <?php echo $_REQUEST['month'] ?> - 1, <?php echo $num; ?>);
 }
 else
 {
 var dateMax=0;
 }
 
 var unavailableDates = [
    <?php
	foreach($leavedays as $val)
	{
	?>
    new Date(<?php echo $_REQUEST['year'] ?>, <?php echo $_REQUEST['month'] ?> -1, <?php echo $val ?>).valueOf(),
	<?php
	}
	?>
];

function unavailable(date) {
    if ($.inArray(date.valueOf(), unavailableDates) < 0) {
        return [true, ""];
    } else {
        return [false, "", "Unavailable"];
    }
}

 
 //var dateMin = min;
$(function() {
		$('#'+id+'').datepicker({
		    
			changeMonth: true,
			changeYear: true,
			dateFormat: "yy-mm-dd",
			beforeShowDay: unavailable,
			minDate: dateMin,
			maxDate: dateMax
			
			
			
			 
	})		
	
});	
}
</script>
<?php


if(!$_REQUEST[month] || !$_REQUEST[year])
{
$_SESSION['existsheet']="Please select Year, Month,Location First";
header('Location:conveyance.php');
}
else
{
$querySub="select * from ingl_conveyance_main where month='".$_REQUEST[month]."' && year='".$_REQUEST[year]."' && instructor='".$_SESSION['id']."' && status='Send'";
$resultSub=mysqli_query($conn,$querySub);
$countSub=mysqli_num_rows($resultSub);
if($countSub>0)
{
$_SESSION['existsheet1']="You have already entered the conveyance for this date and location.Please contact accounts/admin to resubmit.";
header('Location:conveyance.php');
}

}


$queryrates="select rates_designation from timesheet_user where recNo='".$_SESSION['id']."'";
$resultrates=mysqli_query($conn,$queryrates);
$numrates=mysqli_fetch_array($resultrates);
if($numrates['rates_designation']==0)
{
$_SESSION['existsheet1']="Your Rates apply is not defined.Please contact Administrator.";
header('Location:conveyance.php');
}

 /* $queryB="select MAX(fromDate) as maxdate from timesheet_block where status='block'";
	
	$resultB=mysqli_query($conn,$queryB) or die(mysql_error($conn));
	$numrowsB=mysqli_num_rows($resultB);
	$fetchrowsB=mysqli_fetch_array($resultB);
	$MaxD="".$_REQUEST['year']."-".$_REQUEST['month']."-".$num."";
	if($fetchrowsB[maxdate] >=$MaxD)
	{
	
	$_SESSION['existsheet1']="&nbsp;&nbsp;Now the entry is blocked by administrator upto this period";
	header('Location: conveyance.php');
	}
*/

    $monthP=date("m");
	$dateP=date("d");
	if($_REQUEST['month']>$monthP)
	{
	
	$_SESSION['existsheet1']="&nbsp;&nbsp;You are not allowed entry for future period.";
	header('Location: conveyance.php');
	}
	else if($_REQUEST['month']==$monthP && $dateP<15)
	{
	
	//$_SESSION['existsheet1']="&nbsp;&nbsp;You are not allowed entry for future period.";
	//header('Location: conveyance.php');
	}

//print_r($_SESSION);
?>

<form id='aForm' method='post' action='ingl_conveyance_main.main.php' onsubmit="return validate(this)">
<input type='hidden' name='recNo' class='required' value="<?php echo $dbObject->getDbField('recNo');?>">
<input type='hidden' name='kV' value="<?php echo $_REQUEST['kV'];?>">
<input type='hidden' name='instructor' value="<?php echo $_SESSION['id'];?>" size='11' maxlength='11'>
<input type='hidden' name='rates_apply' value="<?php echo $numrates['rates_designation'];?>" size='11' maxlength='11'>
<br />
<table border='0' class='pa-nor' cellpadding="5">
<!--<tr valign='top'><td>instructor</td><td><input type='text' name='instructor' value="<?php echo $dbObject->getDbField('instructor');?>" size='11' maxlength='11'></td><td></td></tr>-->


<tr valign='top'><td>Month</td><td><input type='text' name='month' value="<?php echo $dbObject->getDbField('month');?>" size='11' maxlength='11'></td><td></td></tr>
<tr valign='top'><td>Year</td><td><input type='text' name='year' value="<?php echo $dbObject->getDbField('year');?>" size='11' maxlength='11'></td><td></td></tr>
<tr valign='top'><td>Total Amount</td><td><input type='text' name='totalAmount' id='totalAmount' value="<?php echo $dbObject->getDbField('totalAmount');?>" size='20' maxlength='250' readonly class="required"></td><td></td></tr>
<tr><td colspan='3'>
<br />
<table id="myDiv" >
<tr style="background-color:#cccccc;">
<td>Date </td>	
<td>Start </td>
<td>Center1 </td>
<td>Km1 </td>
<td>Center2 </td>
<td>Km2 </td>
<td>Center3 </td>
<td>Km3 </td>
<td>Center4 </td>
<td>Km4 </td>
<td>End </td>
<td>Km5 </td>
<td>Kms </td>
<td>Band </td>
<td>Total </td>
<td>Remarks </td>
<td>&nbsp; </td>
</tr>

<!--<tr>
<td><input type='text' name='date_conveyance' value="<?php echo $dbObject->getDbField('date_conveyance');?>" size='10' maxlength='10'></td>	
<td><input type='text' name='start_center' value="<?php echo $dbObject->getDbField('start_center');?>" size='5' maxlength='10'></td>
<td>
<?php
$queryloc="select * from timesheet_location order by location";
$resultloc=mysqli_query($conn,$queryloc) or die(mysqli_query($conn,));
?>
<select name='center1'>
<option value="">Select</option>
<?php
while($num=mysqli_fetch_array($resultloc))
{
if($num[location]=="S.Extn")
{
echo"<option value='".$num[recNo]."' ";
if($dbObject->getDbField('center1')==$num[recNo])
{
echo"selected";
}
echo">South Extension</option>";

}
else
{


echo"<option value='".$num[recNo]."' ";
if($dbObject->getDbField('center1')==$num[recNo])
{
echo"selected";
}
echo">".$num[location]."</option>";
}
}
?>
</select>

</td>
<td><?php
$queryloc="select * from timesheet_location order by location";
$resultloc=mysqli_query($conn,$queryloc) or die(mysqli_query($conn,));
?>
<select name='center2'>
<option value="">Select</option>
<?php
while($num=mysqli_fetch_array($resultloc))
{
if($num[location]=="S.Extn")
{
echo"<option value='".$num[recNo]."' ";
if($dbObject->getDbField('center2')==$num[recNo])
{
echo"selected";
}
echo">South Extension</option>";

}
else
{


echo"<option value='".$num[recNo]."' ";
if($dbObject->getDbField('center2')==$num[recNo])
{
echo"selected";
}
echo">".$num[location]."</option>";
}
}
?>
</select> </td>
<td><?php
$queryloc="select * from timesheet_location order by location";
$resultloc=mysqli_query($conn,$queryloc) or die(mysqli_query($conn,));
?>
<select name='center3'>
<option value="">Select</option>
<?php
while($num=mysqli_fetch_array($resultloc))
{
if($num[location]=="S.Extn")
{
echo"<option value='".$num[recNo]."' ";
if($dbObject->getDbField('center3')==$num[recNo])
{
echo"selected";
}
echo">South Extension</option>";

}
else
{


echo"<option value='".$num[recNo]."' ";
if($dbObject->getDbField('center3')==$num[recNo])
{
echo"selected";
}
echo">".$num[location]."</option>";
}
}
?>
</select> </td>
<td><?php
$queryloc="select * from timesheet_location order by location";
$resultloc=mysqli_query($conn,$queryloc) or die(mysqli_query($conn,));
?>
<select name='center4'>
<option value="">Select</option>
<?php
while($num=mysqli_fetch_array($resultloc))
{
if($num[location]=="S.Extn")
{
echo"<option value='".$num[recNo]."' ";
if($dbObject->getDbField('center4')==$num[recNo])
{
echo"selected";
}
echo">South Extension</option>";

}
else
{


echo"<option value='".$num[recNo]."' ";
if($dbObject->getDbField('center4')==$num[recNo])
{
echo"selected";
}
echo">".$num[location]."</option>";
}
}
?>
</select> </td>
<td><input type='text' name='center5' value="<?php echo $dbObject->getDbField('center5');?>" size='5' maxlength='10'> </td>
<td><input type='text' name='totalkms' value="<?php echo $dbObject->getDbField('totalkms');?>" size='6' maxlength='11'> </td>
<td><input type='text' name='Band' value="<?php echo $dbObject->getDbField('Band');?>" size='5' maxlength='100'> </td>
<td><input type='text' name='total' value="<?php echo $dbObject->getDbField('total');?>" size='7' maxlength='11'> </td>
</tr>-->

<?php
if($currentMode=="Save>>")
{
   $queryService="select * from  ingl_conveyance where basic_recNo='".$_REQUEST[kV]."' order by recNo";
	$resultService=mysqli_query($conn,$queryService);
	$countservice=mysqli_num_rows($resultService);
}

if($countservice>0)
{
	
	include("normal_edit.php");
	$loop=$ci;
}
else
{

include("while_error.php");
$loop=2;

}
?>	
</table>	
<input type="hidden" value="<?php echo $loop; ?>" id="theValue" /> 
<table width="100%"><tr><td>


<span  style="text-align:left;border:#00FFCC solid 0px;width:100%" id="sub">


&nbsp;&nbsp;&nbsp;<a href='javascript:void(0);' onclick='displayStu("sub","1","more.php","myDiv","theValue")'>Add New Record</a>
<div id='empRecord1' style="display:none;">Please wait....<img src='loading.gif' border="0"  /></div>

</span>

</td></tr></table>

</td></tr>

<tr><td colspan='3'><input type='submit' name='aC' value='<?php echo $currentMode;?>'>&nbsp;&nbsp;
<?php
if($_REQUEST['month'] < date("m"))
{
?>
<input type='submit' name='aC' value='<?php echo $currentMode1;?>'>
<?php
}
else
{
?>
<input type='button' value='<?php echo $currentMode1;?>' onclick="javacript:alert('You will be allowed to send this sheet from  next month.');">
<?php
}
?>
</td></tr>
</table>
<font style="font-size:12px; color:#E84B1E">#Dates(if any) disabled in calendar , are your approved leaves. </font>
</form>




<script>
$(function() {
	$('#aForm').validate({
		errorPlacement: function(error, element) 
		{   error.appendTo( element.parent("td"));
		} 
	});
});
</script>

<script language='javascript' defer="defer">



//other(document.form1.labestt,document.form1.otherlab);

ci="<?php echo $ci; ?>";
//cit="2";



	
	window.onload=	function (){ 
	for(i=1;i<ci;i++)
	   {
	   
		datepick("date_conveyance"+i+"");
		//other(document.getElementById('gradelab'+i+''),document.getElementById('othergradelab'+i+''));
        //$('#workdetail'+i+'').wordCount({counterElement:"word_counter_service"+i+"", wordLimit:200});
		other(document.getElementById("center1"+i+""),document.getElementById("other1"+i+""));
		other(document.getElementById("center2"+i+""),document.getElementById("other2"+i+""));
		other(document.getElementById("center3"+i+""),document.getElementById("other3"+i+""));
		other(document.getElementById("center4"+i+""),document.getElementById("other4"+i+""));
       }
	   
	
	

}
//datepick("depufrom","deputo");

</script>

<?php
// Include footer
include "footer_conveyance.php";
?>

<script>
function gtotal()

	{



    var inputs = document.getElementsByTagName('input');

 totalamount=0;

for (var i = 0; i < inputs.length; ++i) {

 //alert(inputs[i].className);

  if(inputs[i].className=="net_tot")

  {

  val=inputs[i].value;

  totalamount=totalamount+(1*val);

  //alert(val);

  }

  document.getElementById('totalAmount').value= roundNumber(totalamount,2);
  
  }
  
  
  
  
}

function roundNumber(num, dec) {

	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);

	return result;

		 }

</script>