0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: advancetakenentry_ctrl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; include("../model/financial_mdl.php"); include("../model/financial_report_mdl.php"); $u_id= @$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="select * from account where user_id='$u_id' and project_id='$p_id' "; $sql=mysql_query($sql); $i=0; while($row=mysql_fetch_array($sql)) { $acc_group=$row['account_name']; $i=$i+1; $acc_name_array[$i]=$acc_group; } $accountname=@$_POST['cmbaccname']; $acc_name=$acc_name_array[$accountname]; $table_id=Common::getTableID("advance_taken_entry","advance_id"); $table_id=$table_id+1; $error_flag=0; if(isset($_POST['savedtn'])) {//24 $advance_impresed=@$_POST['cmbad_im']; $entry_num=@$_POST['txtentryno']; $name=@$_POST['txtname']; $amount=@$_POST['txtamount']; $description=@$_POST['txtdescription']; $date_mm= @$_POST['cmbadvancemm']; $date_dd=@$_POST['cmbadvancedd']; $date_yy=@$_POST['txtadvanceyy']; $date=$date_yy."-".$date_mm."-".$date_dd; //verify date.......................... $u_id= @$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="select verify_date from addproject where user_id='$u_id' and project_id='$p_id'"; $sql=mysql_query($sql); while($row=mysql_fetch_array($sql)) { $verify_date=$row['verify_date']; } if ($date < $verify_date and $verify_date!='') { $message="Cannot submit transactions before verification date"; $error_flag=1; } //verify date......................... if (!is_numeric(@$_POST['txtadvanceyy'])) { $error['year_numeric']="Please enter valid date"; $error_flag=1; } if (!is_numeric(@$_POST['txtamount'])) { $error['amount_numeric']="Only allow numbers"; $error_flag=1; } //---------Null---/ if($date_yy=="") { $error['dateyear']="Please Enter year"; $error_flag=1; } if($amount=="") { $error['amount']="Please Enter Amount"; $error_flag=1; } if($name=="") { $error['name']="Please Enter name"; $error_flag=1; } if($error_flag==1) { include("advancetakenentry.php"); exit(); } else { //72 if($advance_impresed==1) // advance { $advance_impresed="Advance"; $u_id=@$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="INSERT INTO `advance_taken_entry` ( `advance_id`, `user_id`, `project_id`, `advance_impresed`, `date`, `name`, `account_name`, `amount`, `description` ) VALUES ('$entry_num','$u_id',$p_id,'$advance_impresed','$date','$name','$acc_name','$amount','$description' ) "; } else { $advance_impresed="Imprest"; $u_id=@$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="INSERT INTO `advance_taken_entry` ( `advance_id`, `user_id`, `project_id`, `advance_impresed`, `date`, `name`, `account_name`, `amount`, `description` ) VALUES ( '$entry_num','$u_id',0,'$advance_impresed','$date','$name','$acc_name','$amount','$description' ) "; } mysql_query($sql); if (mysql_affected_rows()>0) { $table_id=Common::getTableID("advance_taken_entry","advance_id"); $table_id=$table_id+1; Financial::createAccount($u_id,$p_id,"Expenses",$acc_name); // For creating account $message="Data Entered successfully.."; /*if($advance_impresed=="Imprest") // imprest { // Ledger entry - Only for Imprest. For advance there is no ledger entry, since we asume that we already enter the project fund. $ledgertype="AI Taken"; $groupname="Income"; $acc_name="Imprest"; $table_id=Common::getTableID("advance_taken_entry","advance_id"); $resultledger=Reports::Ledger($groupname,$acc_name,$date,$ledgertype,$table_id,0,$amount,$description); if($resultledger=="False") { $message=$message."Ledger Entry Failed"; } }*/ $table_id=Common::getTableID("advance_taken_entry","advance_id"); $table_id=$table_id+1; include("advancetakenentry.php"); exit(); } else { $message="Processes Failed.Invalid charactors found"; include("advancetakenentry.php"); exit(); } }//72 }//24 ?>