Current File : /home/inlingua/www/dwarka/icentex/oral/ingl_oral_main.form_o.php |
<?php
// Created on: 18-02-2015
// Include header
include "header_oral.php";
?>
<h3 class='pa-nor-navbar'>Add New Oral</h3>
<?php
echo $succFailMesg;
// Show result of a form submission?
if ($showResult == "Y")
{ echo "<br><a href='ingl_oral_main.select.php'>Back</a><br>";
// Include footer
include "footer_oral.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>
<?php
if(!$_REQUEST[month] || !$_REQUEST[year])
{
$_SESSION['oral1']="Please select Year, Month,Location First";
header('Location:oral.php');
}
else
{
$querySub="select * from ingl_oral_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['oral1']="You have already entered the oral for this date and location.Please contact accounts/admin to resubmit.";
header('Location:oral.php');
}
}
$monthP=date("m");
$dateP=date("d");
$dateY=date("Y");
$date_current_month="".$dateY."-".$monthP."-01";
$date_apply_month="".$_REQUEST['year']."-".sprintf("%02d",$_REQUEST['month'])."-01";
if(($date_apply_month>$date_current_month))
{
$_SESSION['oral1']=" You are not allowed entry for future period.";
header('Location: oral.php');
}
else if($date_apply_month==$date_current_month && $dateP<15)
{
//$_SESSION['existsheet1']=" You are not allowed entry for future period.";
//header('Location: conveyance.php');
}
?>
<form id='aForm' method='post' action='ingl_oral_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' id="rates_apply" value="<?php echo $dbObject->getDbField('rates_apply');?>" size='11' maxlength='11'>
<table border='0' class='pa-nor' width="100%">
<tr valign='top'><td>Month: <input type='text' name='month' value="<?php echo sprintf("%02d",$dbObject->getDbField('month'));?>" size='11' maxlength='11' readonly> Year : <input type='text' name='year' value="<?php echo $dbObject->getDbField('year');?>" size='11' maxlength='11' readonly></td><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></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 />
<?php
$queryloc="select * from timesheet_location where status='1'";
$resultloc=mysqli_query($conn,$queryloc) or die(mysql_error($conn));
$location=array();
while ($numloc=mysqli_fetch_array($resultloc))
{
$location[]=$numloc['code_prefix'];
}
?>
<table id="myDiv" width="100%" border="1" cellspacing="0">
<tr style="font-weight:bold;">
<td width="3%" align='center'><b>Date</b></td>
<?php
$queryTy="select * from ingl_oral_type";
$resultTy=mysqli_query($conn,$queryTy);
$oral_ty=array();
$ky=1;
while($numTy=mysqli_fetch_array($resultTy)){
if($ky=="1"){
echo"<td colspan='13' align='center' style='background-color:#FFFFCC;'>";
}
else if($ky=="2"){
echo"<td colspan='3' align='center' style='background-color:#F28A8C;'>";
}
else if($ky=="3"){
echo"<td colspan='2' align='center' style='background-color:#CCFFCC;'>";
}
echo"<b>".$numTy['type_oral']."</b>";
echo"</td>";
$oral_ty[]=$numTy['type_oral'];
$ky++;
}
?>
</tr>
<tr>
<td> </td>
<?php
foreach($oral_ty as $key=>$val){
if($key=="0"){
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>1</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>2</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>3</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>4</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>5</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>6</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>7</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>8</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>9</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>10</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>11</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>12</td>";
echo"<td width='5%' align='center' style='background-color:#FFFFCC;'>13</td>";
}
else if($key=="1"){
echo"<td width='5%' align='center' style='background-color:#F28A8C;'>1</td>";
echo"<td width='5%' align='center' style='background-color:#F28A8C;'>2</td>";
echo"<td width='5%' align='center' style='background-color:#F28A8C;'>3</td>";
}
else if($key=="2"){
echo"<td width='5%' align='center' style='background-color:#CCFFCC;'>1</td>";
echo"<td width='5%' align='center' style='background-color:#CCFFCC;'>2</td>";
}
}
?>
</tr>
<?php
$month=$dbObject->getDbField('month');
$year=$dbObject->getDbField('year');
$numT = cal_days_in_month(CAL_GREGORIAN, $month, $year);
for($i=1;$i<=$numT;$i++){
$da="".$year."-".$month."-".$i."";
$dym=date("Y-m-d",strtotime($da));
echo"<tr><td>".$i."<input type='hidden' name='dates[]' value='".$dym."'></td>";
$queryO="select * from ingl_oral where main_id='".$_REQUEST['kV']."' && dates='".$dym."'";
$resultO=mysqli_query($conn,$queryO);
$numO=mysqli_fetch_array($resultO);
foreach($oral_ty as $key=>$val){
if($key=="1"){
$color='style="background-color:#F28A8C;"';
}
else if($key=="2"){
$color='style="background-color:#CCFFCC;"';
}
else{
$color='style="background-color:#FFFFCC;"';
}
$disO1=explode("-",$numO['oral_'.($key+1).'_1']);
$disO2=explode("-",$numO['oral_'.($key+1).'_2']);
$disO3=explode("-",$numO['oral_'.($key+1).'_3']);
$disO4=explode("-",$numO['oral_'.($key+1).'_4']);
$disO5=explode("-",$numO['oral_'.($key+1).'_5']);
$disO6=explode("-",$numO['oral_'.($key+1).'_6']);
$disO7=explode("-",$numO['oral_'.($key+1).'_7']);
$disO8=explode("-",$numO['oral_'.($key+1).'_8']);
$disO9=explode("-",$numO['oral_'.($key+1).'_9']);
$disO10=explode("-",$numO['oral_'.($key+1).'_10']);
$disO11=explode("-",$numO['oral_'.($key+1).'_11']);
$disO12=explode("-",$numO['oral_'.($key+1).'_12']);
$disO13=explode("-",$numO['oral_'.($key+1).'_13']);
echo"<td valign='top' ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_1_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO1['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_1_N[]' value='".$disO1['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_2_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO2['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_2_N[]' value='".$disO2['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
if($key=="0" || $key=="1"){
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_3_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO3['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_3_N[]' value='".$disO3['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
}
if($key=="0"){
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_4_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO4['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_4_N[]' value='".$disO4['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_5_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO5['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_5_N[]' value='".$disO5['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_6_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO6['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_6_N[]' value='".$disO6['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_7_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO7['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_7_N[]' value='".$disO7['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_8_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO8['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_8_N[]' value='".$disO8['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_9_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO9['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_9_N[]' value='".$disO9['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_10_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO10['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_10_N[]' value='".$disO10['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_11_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO11['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_11_N[]' value='".$disO11['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_12_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO12['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_12_N[]' value='".$disO12['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
echo"<td ".$color.">";
echo"<select style='width:36px;font-size:12px;;height:24px;' name='oral_".($key+1)."_13_C[]'>";
echo"<option></option>";
foreach($location as $val1){
if($disO13['0']==$val1){
echo"<option value='".$val1."' selected>".$val1."</option>";
}else{
echo"<option value='".$val1."'>".$val1."</option>";
}
}
echo"</select>";
echo"<input type='text' name='oral_".($key+1)."_13_N[]' value='".$disO13['1']."' style='width:27px;font-size:12px;height:20px;'>";
echo"</td>";
}
}
echo"</tr>";
}
?>
</table>
</td></tr>
<tr><td style="padding-left:5px;"><input type='submit' name='aC' value='<?php echo $currentMode;?>' class="submit1">
</td>
<td colspan='2' align="right" style="padding-right:5px;">
<?php if($currentMode1!="") {?>
<input type='submit' name='aC' value='<?php echo $currentMode1;?>' class="submit1">
<?php }?>
</td>
</tr>
</table>
</form>
<script>
$(function() {
$('#aForm').validate({
errorPlacement: function(error, element)
{ error.appendTo( element.parent("td").next("td") );
}
});
});
</script>
<style>
.highlight { background-color: red; }
</style>
<?php
// Include footer
include "footer_oral.php";
?>
<script>
function getCount(){
return $("select option:selected[value!='']").length;
}
$("select").change(function() {
//alert(getCount());
rates_apply=$("#rates_apply").val();
$("#totalAmount").val(rates_apply*getCount());
// $(this tr).css("background-color", "#000000");
$(this).closest( "tr" ).css("background-color", "yellow");
//$(this).closest( "tr" ).not(css("background-color", "white"));
});
</script>