0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: payment_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"); $error_flag=0; $u_id= @$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="select distinct(account_name) from account where user_id='$u_id' and project_id='$p_id' order by account_name"; $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['cmbpaccname']; $acc_name=$acc_name_array[$accountname]; $error_flag=0; if(isset($_POST['save'])) { $pvoucher=@$_POST['txtpvoucher']; $pamount=@$_POST['txtpamount']; $pdiscount=@$_POST['txtpdiscount']; $pdescription=@$_POST['txtpdescription']; $pdate_mm= @$_POST['cmbpmm']; $pdate_dd=@$_POST['cmbpdd']; $pdate_yy=@$_POST['txtpyy']; $pdate=$pdate_yy."-".$pdate_mm."-".$pdate_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 ($pdate < $verify_date and $verify_date!='') { $message="Cannot submit transactions before verification date"; $error_flag=1; } //verify date......................... if (!is_numeric(@$_POST['txtpyy'])) { $error['pd_numeric']="Please enter valid date"; $error_flag=1; } if (!is_numeric(@$_POST['txtpamount'])) { $error['amount_numeric']="Only allow numbers"; $error_flag=1; } //---------Null---/ if($pdate_yy=="") { $error['paymentdate']="Please Enter year"; $error_flag=1; } if($pamount=="") { $error['amount']="Please Enter Amount"; $error_flag=1; } /*if($pdescription=="") { $error['description']="Please Enter Description"; $error_flag=1; }*/ if($pdiscount!="") { if (!is_numeric(@$_POST['txtpdiscount'])) { $error['discount_numeric']="Only allow numbers"; $error_flag=1; } } if($pvoucher!="") { $result=Financial::pvoucherNumbercheck($pvoucher); if($result=="True") { $error_flag=1; $error['Voucher_number']="voucher number exists."; } } $acc_group="Expenses"; /*$sql="select * from account where user_id='$u_id' and project_id='$p_id' and group_name='$acc_group' and account_name='$acc_name'"; mysql_query($sql); if (mysql_affected_rows()<=0) { $error['account_exist']="Account not exist. Plz add account first"; $error_flag=1; }*/ if($error_flag==1) { include("payment.php"); exit(); } else { $table_id=Common::getTableID("payment","payment_id"); $table_id=$table_id+1; $result= Financial::addPayment($pvoucher,$acc_name,$pdate,$pamount,$pdiscount,$pdescription); if ($result == "False") { $message="Invalid Characters found. Operation Failed.."; include("payment.php"); exit(); } $resultledger=Reports::Ledger("Expenses",$acc_name,$pdate,"Payment",$table_id,$pamount,0,$pdescription); if ($resultledger == "False") { $message="Invalid Characters found. Operation Failed.."; include("payment.php"); exit(); } Financial::createAccount($u_id,$p_id,"Expenses",$acc_name); //create account if($pdiscount>0) { $resultledger=Reports::Ledger("Discount Received",$acc_name,$pdate,"Payment",$table_id,0,$pdiscount,$pdescription); if ($resultledger == "False") { $message="Invalid Characters found. Operation Failed.."; include("payment.php"); exit(); } Financial::createAccount($u_id,$p_id,"Discount Received",$acc_name); //create account } if (($result && $resultledger) =="True") { $message="Registration Completed successfully.."; include("payment.php"); exit(); } else { $message="Registration Failed.Invalid charactors found"; include("payment.php"); exit(); } } } ?>