0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: leave_entry_ctrl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; require_once "../model/defaultValues_mdl.php"; $u_id= @$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="select * from employe where user_id='$u_id' and status=1"; $sql=mysql_query($sql); $i=0; while($row=mysql_fetch_array($sql)) { $emp_group=$row['emp_name']; $i=$i+1; $emp_name_array[$i]=$emp_group; } $empname=@$_POST['cmbemp_name']; $emp_name=$emp_name_array[$empname]; $error_flag=0; $leavetype=@$_POST['cmbleavetype']; $check_full_half=@$_POST['radio']; $fromdate_mm= @$_POST['cmbfrommm']; $fromdate_dd=@$_POST['cmbfromdd']; $fromdate_yy=@$_POST['txtfromyy']; $fromdate_date=$fromdate_yy."-".$fromdate_mm."-".$fromdate_dd; $description=@$_POST['txtdescription']; $todate_date=$todate_yy."-".$todate_mm."-".$todate_dd; if(isset($_POST['savebtn'])) {//45 if (!is_numeric(@$_POST['txtfromyy'])) { $error['yearfrom_numeric']="Only allow numbers"; $error_flag=1; } if($leavetype=="") { $error['leavetype_null']="Please Select leave type"; $error_flag=1; } if($fromdate_yy=="") { $error['year_from_null']="Please Enter year"; $error_flag=1; } $check_flage==0; if($check_full_half==radiohaflfday) { $check_flage=1; } else if($check_full_half==radiyofullday) { $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/stockentry.php</script>";*/ include("leave_entry.php"); exit(); } else {//74 $u_id= @$_SESSION['user_id']; $sql="select * from employe where user_id='$u_id' and emp_name='$emp_name'"; $sql=mysql_query($sql); while($row=mysql_fetch_array($sql)) { $emp_db=$row['emp_id']; $emp_name_db=$row['emp_name']; } $sql="select * from `leave_entry` where `start_date` ='$fromdate_date' and `emp_id`='$emp_db'"; $sql1=mysql_query($sql); $row1=mysql_fetch_array($sql1); if($row1 == NULL) {//90 $table_id=Common::getTableID("leave_entry","leave_id"); $table_id=$table_id+1; if($check_full_half==radiohaflfday) { $days=0.5; $sql="INSERT INTO `leave_entry` (`leave_id` ,`user_id` ,`emp_id` ,`start_date` ,`end_date`,`leave_count`,`leave_type`,`description`) VALUES ('$table_id','$u_id','$emp_db','$fromdate_date','$fromdate_date','$days','$leavetype','$description')"; } if($check_full_half==radiyofullday) { $days=1; $sql="INSERT INTO `leave_entry` (`leave_id` ,`user_id` ,`emp_id` ,`start_date`,`end_date` ,`leave_count`,`leave_type`,`description`) VALUES ('$table_id','$u_id','$emp_db','$fromdate_date','$fromdate_date','$days','$leavetype','$description')"; } mysql_query($sql); if (mysql_affected_rows()>0) {//99 $message="Leave entered successfully.."; //$sql="select * from employe where `emp_id`='$emp_db'"; // $sql=mysql_query($sql); // while($row=mysql_fetch_array($sql)) // { // $email_temp=$row['mail_id']; // } // $to=$email_temp; // // $sub= $category_array[$category_restore].'Leave Entry Details'; // $msg=' // <html> // <head> // <title>Please note that, CWRDM HR Admin entered '.$category_array[$category_restore].' Leave Entry for you. The details are given below,</title> // </head> // <body> // <p>Dear '.$staff_name_var.',<br></p> // <p>Please note that, CWRDM HR Admin entered '.$category_array[$category_restore].' Leave Entry for you. The details are given below,</p> // <table border="2" bordercolor="#CC0033"> // <tr> // <th width="50"><div align="center">Staff ID</div></th> // <th width="61"><div align="center">Leave ID</div></th> // <th width="61"><div align="center">Leave Type</div></th> // <th width="61"><div align="center">Start Date</div></th> // <th width="61"><div align="center">End Date</div></th> // <th width="50"><div align="center">Leave Count</div></th> // <th width="150"><div align="center">Description</div></th> // </tr> // <tr> // <td><div align="center">'.$staff_id_var.'</div></td> // <td><div align="center">'.$l_id.'</div></td> // <td><div align="center">'.$category_array[$category_restore].'</div></td> // <td><div align="center">'.$start.'</div></td> // <td><div align="center">'.$end.'</div></td> // <td><div align="center">'.$days.'</div></td> // <td><div align="center">'.$description_restore.'</div></td> // </tr> // </table>'.$mail_footer.' // // // </body> // </html>'; // // $status=Mail::sendMail($to,$sub,$msg); // // /*if($status) // { // echo "Mail send"; // } // else // { // echo "Mail send failed"; // }*/ // // ////////////////////// // }//99 else {//99 $message="Operation Failed.."; }//99 }//90 else {//90 $message="Leave for this date is already entered."; }//90 }//74 }//45 ?>