0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: leave_credit_ctrl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; //include("../model/financial_mdl.php"); include("../model/defaultValues_mdl.php"); $error_flag=0; $u_id= @$_SESSION['user_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['cmbempname']; $emp_name=$emp_name_array[$empname]; $leavecredit=@$_POST['txtcredit']; $year=@$_POST['txtyear']; $salarydesc=@$_POST['txtsalarydes']; /*$date_mm= @$_POST['cmbmm']; $date_dd=@$_POST['cmbdd']; $date_yy=@$_POST['txtyy']; $date=$date_yy."-".$date_mm."-".$date_dd;*/ $date=date("Y-m-d"); if(isset($_POST['savebtn'])) { //if (!is_numeric(@$_POST['txtyy'])) // { // $error['date_numeric']="Please enter valid year"; // $error_flag=1; // } if (!is_numeric(@$_POST['txtyear'])) { $error['year_numeric']="Please enter valid year"; $error_flag=1; } if (!is_numeric(@$_POST['txtcredit'])) { $error['amount_numeric']="Credit Amount in numbers only"; $error_flag=1; } //if($date_yy=="") // { // $error['date_null']="Please Enter year"; // $error_flag=1; // } if($year=="") { $error['date_yy']="Please Enter year"; $error_flag=1; } if($leavecredit=="") { $error['leave']="Please Enter Credit Amount"; $error_flag=1; } $u_id=@$_SESSION['user_id']; //$p_id=@$_SESSION['project_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_id_db=$row['emp_id']; } //$sql_check="select * from leave_credit where user_id='$u_id' and emp_id='$emp_id_db' and year='$year'"; // $sql=mysql_query($sql_check); // if (mysql_affected_rows()>0) // { // $error['details_exist']="leave credit for this year for selectesd employee exist"; // $error_flag=1; // } if($error_flag==1) { include("leave_credit.php"); exit(); } else { $table_id=Common::getTableID("leave_credit","credit_id "); $table_id=$table_id+1; $sql="INSERT INTO `leave_credit` ( `credit_id`, `user_id`, `emp_id`, `credit_count`, `year`, `today_date` ) VALUES ( '$table_id','$u_id','$emp_id_db','$leavecredit', '$year', '$date') "; mysql_query($sql); if (mysql_affected_rows()>0) { $message="Registration Completed successfully.."; include("leave_credit.php"); exit(); } else { $message="Registration Failed.Invalid charactors found"; include("leave_credit.php"); exit(); } } } ?>