0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: custemaccountcashentry_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']; $sqlaccname="select * from account where user_id='$u_id' and project_id='$p_id' "; $sql1=mysql_query($sqlaccname); $i=0; while($row=mysql_fetch_array($sql1)) { $acc_name_db=$row['account_name']; $i=$i+1; $acc_name_array[$i]=$acc_name_db; } $accountname=@$_POST['cmbcustemaccname']; $acc_name=$acc_name_array[$accountname]; $sqlgroup="select * from accgroup where user_id='$u_id' and project_id='$p_id' "; $sql2=mysql_query($sqlgroup); $k=0; while($row2=mysql_fetch_array($sql2)) { $acc_group_db=$row2['groupname']; $k=$k+1; $acc_group_array[$k]=$acc_group_db; } $accounthead=@$_POST['cmbcustemacgroup']; $acc_group=$acc_group_array[$accounthead]; $error_flag=0; if(isset($_POST['save'])) { $radiovouchercheck=@$_POST['radio']; $custemvoucher=@$_POST['txtcustemvoucher']; $custemamount=@$_POST['txtcustemamount']; $custemdescription=@$_POST['txtcustemdescription']; $custemdate_mm= @$_POST['cmbcustemmm']; $custemdate_dd=@$_POST['cmbcustemdd']; $custemdate_yy=@$_POST['txtcustemyy']; $custemdate=$custemdate_yy."-".$custemdate_mm."-".$custemdate_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 ($custemdate < $verify_date and $verify_date!='') { $message="Cannot submit transactions before verification date"; $error_flag=1; } //verify date......................... if (!is_numeric(@$_POST['txtcustemyy'])) { $error['year_numeric']="Please enter valid date"; $error_flag=1; } if (!is_numeric(@$_POST['txtcustemamount'])) { $error['amount_numeric']="Only allow numbers"; $error_flag=1; } //---------Null---/ if($custemdate_yy=="") { $error['date']="Please Enter year"; $error_flag=1; } if($custemamount=="") { $error['amount']="Please Enter Amount"; $error_flag=1; } if($custemdescription=="") { $error['description']="Please Enter Description"; $error_flag=1; } if($custemvoucher!="") { $result=Financial::custemvoucherNumbercheck($custemvoucher); if($result=="True") { $error_flag=1; $error['Voucher_number']="voucher number exists."; } } $check_flage==0; if($radiovouchercheck==radiopayment) { $check_flage=1; } else if($radiovouchercheck==radioreceipt) { $check_flage=1; } if($check_flage==0) { $error['voucher_null']="Please Enter voucher"; $error_flag=1; } $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("custemaccountcashentry.php"); exit(); } else { $table_id=Common::getTableID("custemaccount_cashentry","custem_id"); $table_id=$table_id+1; if($radiovouchercheck==radiopayment) { $result= Financial::addcustemaccountentry($custemvoucher,$custemdate,$acc_group,$acc_name,1,$custemamount,0,$custemdescription); $resultledger=Reports::Ledger($acc_group,$acc_name,$custemdate,"Custem Account",$table_id,$custemamount,0,$custemdescription); } else if($radiovouchercheck==radioreceipt) { $result= Financial::addcustemaccountentry($custemvoucher,$custemdate,$acc_group,$acc_name,0,0,$custemamount,$custemdescription); $resultledger=Reports::Ledger($acc_group,$acc_name,$custemdate,"Custem Account",$table_id,0,$custemamount,$custemdescription); } Financial::createAccount($u_id,$p_id,$acc_group,$acc_name); //create account if (($result && $resultledger) =="True") { $message="Registration Completed successfully.."; include("custemaccountcashentry.php"); exit(); } else { $message="Registration Failed.Invalid charactors found"; include("custemaccountcashentry.php"); exit(); } } } ?>