0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: reciept_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['cmbaccname']; $acc_name=$acc_name_array[$accountname]; $voucher=@$_POST['txtvoucher']; $amount=@$_POST['txtamount']; $discount=@$_POST['txtdiscount']; $description=@$_POST['txtdes']; $rd_mm= @$_POST['cmbr_mm']; $rd_dd=@$_POST['cmbr_dd']; $rd_yy=@$_POST['txtr_yy']; $rd=$rd_yy."-".$rd_mm."-".$rd_dd; if(isset($_POST['save'])) { //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 ($rd < $verify_date and $verify_date!='') { $message="Cannot submit transactions before verification date"; $error_flag=1; } //verify date......................... if (!is_numeric(@$_POST['txtr_yy'])) { $error['rd_numeric']="Please enter valid date"; $error_flag=1; } if (!is_numeric(@$_POST['txtamount'])) { $error['amount_numeric']="Only allow numbers"; $error_flag=1; } if (!is_numeric(@$_POST['txtdiscount'])) { $error['discount_numeric']="Only allow numbers"; $error_flag=1; } //---------Null---/ if($rd_yy=="") { $error['receiptdate']="Please Enter year"; $error_flag=1; } if($amount=="") { $error['amount']="Please Enter Amount"; $error_flag=1; } if($discount=="") { $error['Discount']="Please Enter Dicsount"; $error_flag=1; } /*if($description=="") { $error['Descriptions']="Please Enter Description"; $error_flag=1; }*/ if($voucher!="") { $result=Financial::rvoucherNumbercheck($voucher); if($result=="True") { $error_flag=1; $error['Voucher_number']="voucher number exists."; } } $acc_group="Income"; /*$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("Receipt.php"); exit(); } else { $table_id=Common::getTableID("reciept","receipt_id"); $table_id=$table_id+1; $result= Financial::addReceipt($voucher,$acc_name,$rd,$amount,$discount,$description); if ($result == "False") { $message="Invalid Characters found. Operation Failed.."; include("Receipt.php"); exit(); } $resultledger=Reports::Ledger("Income",$acc_name,$rd,"Receipt",$table_id,0,$amount,$description); if ($resultledger == "False") { $message="Invalid Characters found. Operation Failed.."; include("Receipt.php"); exit(); } Financial::createAccount($u_id,$p_id,"Income",$acc_name); //create account if($discount>0) { $resultledger=Reports::Ledger("Discount Paid",$acc_name,$rd,"Receipt",$table_id,$discount,0,$description); if ($resultledger == "False") { $message="Invalid Characters found. Operation Failed.."; include("Receipt.php"); exit(); } Financial::createAccount($u_id,$p_id,"Discount Paid",$acc_name); //create account } if (($result && $resultledger) =="True") { $message="Registration Completed successfully.."; include("Receipt.php"); exit(); } else { $message="Registration Failed.Invalid charactors found"; include("Receipt.php"); exit(); } } } ?>