0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: edit_leave_entry_ctrl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; include( "../lib/config.php"); include_once("../model/defaults_mdl.php"); require_once "../model/defaultValues_mdl.php"; $p_id=@$_SESSION['project_id']; $u_id=@$_SESSION['user_id']; $leave_id_db=$_GET['id']; $sql1="select * from leave_entry where user_id='$u_id' and leave_id='$leave_id_db'"; $sql1=mysql_query($sql1); while($row=mysql_fetch_array($sql1)) { //1 $emp_id=$row['emp_id']; $sql3="select * from employe where user_id='$u_id' and emp_id='$emp_id'"; $sql3=mysql_query($sql3); while($row3=mysql_fetch_array($sql3)) { //1 $emp_name_db=$row3['emp_name']; } $start_date=$row['start_date']; $leave_count=$row['leave_count']; $leave_type=$row['leave_type']; $description=$row['description']; list($start_yy, $start_mm, $start_dd) = split('[/.-]', $start_date); }//1 if(isset($_POST['Update'])) { //2 $error_flag=0; $check_full_half=@$_POST['radio']; $empname=@$_POST['txtemp']; $leavetype=@$_POST['cmbtype']; $edit_id=@$_POST['txtid']; $mm_restore=@$_POST['cmbmm']; $dd_restore=@$_POST['cmbdd']; $yy_restore=@$_POST['txtyy']; $date_restore= $yy_restore."-".$mm_restore."-".$dd_restore; $editdescription=@$_POST['txtdescription']; if (!is_numeric(@$_POST['txtyy'])) { $error['year_numeric']="Only allow numbers"; $error_flag=1; } if($yy_restore=="") { $error['yy__null']="Please Enter Year"; $error_flag=1; } if($empname=="") { $error['empname_null']="Please Enter Year"; $error_flag=1; } //if($leavetype=="") // { // $error['leavetype_null']="Please Select leave type"; // $error_flag=1; // } $sql="select * from employe where user_id='$u_id' and emp_name='$empname'"; mysql_query($sql); if (mysql_affected_rows()<=0) { $error['item_add']="Plz Add this employee first"; $error_flag=1; } $check_flage==0; if($check_full_half==haflf) { $check_flage=1; } else if($check_full_half==full) { $check_flage=1; } if($check_flage==0) { $error['leavecount_null']="Please Enter leave count"; $error_flag=1; } if($error_flag==1) { echo "<script>window.location='http://localhost/CPFMS/USER/edit_leave_entry.php</script>"; } else { if($leavetype==1) { $leavetype="CL"; } else { $leavetype="LWOS"; } $u_id= @$_SESSION['user_id']; $sql="select * from employe where user_id='$u_id' and emp_name='$empname'"; $sql=mysql_query($sql); while($row=mysql_fetch_array($sql)) { $emp_db=$row['emp_id']; $emp_name_db=$row['emp_name']; } if($check_full_half==half) { $days=.5; $sql="update `leave_entry` set `emp_id`='".$emp_db."', `start_date`='".$date_restore."' , `end_date`='".$date_restore."' , `leave_count`='".$days."', `leave_type`='".$leavetype."', `description`='".$editdescription."' where `leave_id`='".$edit_id."'"; } if($check_full_half==full) { $days=1; $sql="update `leave_entry` set `emp_id`='".$emp_db."', `start_date`='".$date_restore."' , `end_date`='".$date_restore."' , `leave_count`='".$days."', `leave_type`='".$leavetype."', `description`='".$editdescription."' where `leave_id`='".$edit_id."'"; } mysql_query($sql); if(mysql_affected_rows()>0) { $message="Updation Completed successfully.."; $url="http://".$server_ip."/CPFMS/USER/search_leave_entry.php?message=$message"; echo "<script>window.location='$url'</script>"; } else { $message="Updation Failed.."; $url="http://".$server_ip."/CPFMS/USER/search_leave_entry.php?message=$message"; echo "<script>window.location='$url'</script>"; } } } ?>