0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: edit_custemaccountcashentry_ctrl.php
<?php include( "../lib/config.php"); include_once("../model/defaults_mdl.php"); require_once BASE_DIR."/lib/db/connection.php"; require_once "../model/defaultValues_mdl.php"; include("../model/financial_mdl.php"); include("../model/financial_report_mdl.php"); $p_id=@$_SESSION['project_id']; $u_id=@$_SESSION['user_id']; $custemdb_id=$_GET['id']; $sql="select * from custemaccount_cashentry where user_id='$u_id' and project_id='$p_id' and custem_id ='$custemdb_id'"; $sql1=mysql_query($sql); while($row=mysql_fetch_array($sql1)) { //1 $voucher=$row['voucher']; $entry_date=$row['date']; $account_head=$row['groupname']; $account_name=$row['accountname']; $amount=$row['debit']; $amount_receipt=$row['credit']; $description=$row['description']; list($entry_yy, $entry_mm, $entry_dd) = split('[/.-]', $entry_date); }//1 $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_restore=@$_POST['cmbcustemaccname']; $acc_name_restore=$acc_name_array[$accountname_restore]; $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_restore=@$_POST['cmbcustemacgroup']; $acc_group_restore=$acc_group_array[$accounthead_restore]; if(isset($_POST['Update'])) { //35 $error_flag=0; $radiovouchercheck_restore=@$_POST['radio']; $custemdb_id_restore=@$_POST['txtcustemid']; $voucher_restore=@$_POST['txtvoucher']; $amount_restore=@$_POST['txtcustemamount']; $description_restore=@$_POST['txtcustemdesc']; $entry_mm_restore=@$_POST['cmbcustemmm']; $entry_dd_restore=@$_POST['cmbcustemdd']; $entry_yy_restore=@$_POST['txtcustemyy']; $entry_date_restore= $entry_yy_restore."-".$entry_mm_restore."-".$entry_dd_restore; //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 ($entry_date_restore < $verify_date and $verify_date!='') { $message="Cannot submit transactions before verification date"; $error_flag=1; } //verify date......................... if (!is_numeric(@$_POST['txtcustemyy'])) { $error['date']="Please enter valid year"; $error_flag=1; } if($amount_restore=="") { $error['amount_null']="Please Enter Filename"; $error_flag=1; } if (!is_numeric(@$_POST['txtcustemamount'])) { $error['amount_numeric']="Please enter valid year"; $error_flag=1; } if($entry_yy_restore=="") { $error['year_null']="Please Enter year"; $error_flag=1; } if($description_restore=="") { $error['description_null']="Please Enter Description"; $error_flag=1; } $check_flage==0; if($radiovouchercheck_restore==radiopayment) { $check_flage=1; } else if($radiovouchercheck_restore==radioreceipt) { $check_flage=1; } if($check_flage==0) { $error['leavecount_null']="Please Enter voucher"; $error_flag=1; } //if($voucher_restore!="") // { // // $sql="select `voucher` from payment where user_id='$u_id' and project_id='$p_id' and voucher='$voucher_restore' and payment_id <>'$payment_id_restore'" ; // // mysql_query($sql); // if (mysql_affected_rows()>0) // { // $error['Voucher_number']="voucher number exists."; // $error_flag=1; // } // } if($error_flag==1) { $url=$server_ip."/USER/edit_custemaccountcashentry.php"; echo "<script>window.location='$url'</script>"; } else { $ledgertype="Custem Account"; //$table_id=Common::getTableID("custemaccount_cashentry","custem_id"); // $table_id=$table_id+1; if($radiovouchercheck_restore==radiopayment) { $sql= " update `custemaccount_cashentry` set `voucher`= '".$voucher_restore."', `date`='".$entry_date_restore."', `groupname`='".$acc_group_restore."', `accountname`='".$acc_name_restore."', `custemaccount_type`='0', `debit`='".$amount_restore."',`credit`='0' ,`description`='".$description_restore."' where `custem_id`='".$custemdb_id_restore."' "; $result= Financial::updatecustemaccountcashentry($sql); $sql1= " update `ledger` set `group_name`='".$acc_group_restore."' `account_name`='".$acc_name_restore."', `date`='".$entry_date_restore."', `debit`='".$amount_restore."', `credit`= '0', `description`='".$description_restore."' where `ledger_type`='".$ledgertype."' and `type_id`='".$custemdb_id_restore."'"; $result_ledger= Reports::updateLedger($sql1); } else if($radiovouchercheck_restore==radioreceipt) { $sql= " update `custemaccount_cashentry` set `voucher`= '".$voucher_restore."', `date`='".$entry_date_restore."', `groupname`='".$acc_group_restore."', `accountname`='".$acc_name_restore."', `custemaccount_type`='0', `debit`='0',`credit`='".$amount_restore."' ,`description`='".$description_restore."' where `custem_id`='".$custemdb_id_restore."' "; $result= Financial::updatecustemaccountcashentry($sql); $sql1= " update `ledger` set `account_name`='".$acc_name_restore."', `date`='".$entry_date_restore."', `debit`='0',`credit`= '".$amount_restore."',`description`='".$description_restore."' where `ledger_type`='".$ledgertype."' and `type_id`='".$custemdb_id_restore."' and `group_name`= '".$acc_group_restore."' "; $result_ledger= Reports::updateLedger($sql1); } if ($result=="True" && $result_ledger=="True") { $message="Updation Completed successfully.."; $url=$server_ip."/USER/search_custemaccountcashentry.php?message=$message"; echo "<script>window.location='$url'</script>"; } else { $message="Updation Failed.Invalid charactors found"; $url=$server_ip."/USER/search_custemaccountcashentry.php?message=$message"; echo "<script>window.location='$url'</script>"; } }//112 }//2 ?>