2323 lines
72 KiB
PHP
2323 lines
72 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
require APPPATH . '/third_party/mpdf/mpdf.php';
|
|
/**
|
|
* Class : cashbook (Cash Book Controller)
|
|
* cashbook Class to control all Cash Book related operations.
|
|
* @author : Venba Info Tech - Gandhimathi
|
|
* @version : 1.1
|
|
* @since : 27 November 2017
|
|
*/
|
|
class cashbook extends BaseController
|
|
{
|
|
/**
|
|
* default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('cashbook_model');
|
|
$this->isLoggedIn();
|
|
$this->load->helper(array('form','url'));
|
|
$this->load->library('upload');
|
|
$this->CompanyName = $this->global['CompanyName'];
|
|
|
|
}
|
|
|
|
/**
|
|
* To list income expense details
|
|
*/
|
|
function incomeExpenseList()
|
|
{
|
|
|
|
$aid = $this->uri->segment(3);
|
|
$str = $this->uri->segment(4);
|
|
if(!empty($aid)){
|
|
|
|
if(!empty($str))
|
|
{
|
|
|
|
$data['company'] = $this->cashbook_model->getCompany();
|
|
$data['data'] = $this->cashbook_model->getIncomeExpenseList($aid);
|
|
$data['PaymentDetails'] = $this->cashbook_model->viewpaymentdetails($aid);
|
|
$totalamt = $data['data'][0]->total;
|
|
$data['amtinwords'] = $this->convertNumber($totalamt);
|
|
$mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 3, 0, 0, 0);
|
|
$mpdf->SetHTMLHeader($HtmlHeading);
|
|
$html = $this->load->view('cashbookpdf',$data,true);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
|
|
$mpdf->list_indent_first_level = 1;
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
$mpdf->WriteHTML($html);
|
|
$filename = "cashbook.pdf";
|
|
$mpdf->Output($filename,I);
|
|
}
|
|
else
|
|
{
|
|
|
|
$data['data'] = $this->cashbook_model->getIncomeExpenseList($aid);
|
|
$data['PaymentDetails'] = $this->cashbook_model->viewpaymentdetails($aid);
|
|
//$this->global['pageTitle'] = 'Resico : Cash Book: View Income Expense ';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Cash Book - View Income Expense ';
|
|
$this->loadViews("viewIndIncomeExpense", $this->global, $data , NULL);
|
|
|
|
}
|
|
}else{
|
|
// $data['list'] = $this->cashbook_model->getIncomeExpenseList();
|
|
// $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing';
|
|
|
|
// $this->loadViews("income_expense_list", $this->global, $data , NULL);
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Cash Master Listing';
|
|
|
|
if ($this->input->post('btn_submit')) {
|
|
|
|
$fromdt = $this->input->post('from_date');
|
|
$todt = $this->input->post('to_date');
|
|
$ab=$this->input->post('financialyear');
|
|
|
|
$fromyear=substr($ab,0,-5);
|
|
$toyear=substr($ab,5,5);
|
|
|
|
|
|
$data['finyear']=$this->cashbook_model->finyear();
|
|
$data['list'] = $this->cashbook_model->getIncomeExpense($fromyear,$toyear,$fromdt,$todt);
|
|
|
|
}
|
|
else{
|
|
//$data['list'] = $this->cashbook_model->getIncomeExpenseList();
|
|
//$data['list'] = $this->cashbook_model->getreceiptpaymentlist();
|
|
//$this->global['pageTitle'] = 'Resico : Cash Book: Listing';
|
|
$this->global['pageTitle'] = $this->CompanyName.': Receipt and Payment Details';
|
|
if (date('m') <= 3) {
|
|
$preyear = (date('Y')-1);
|
|
$currentyear = date('Y');
|
|
} else {
|
|
$preyear = date('Y') ;
|
|
$currentyear = (date('Y') + 1);
|
|
}
|
|
|
|
$data['list'] = $this->cashbook_model->getIncomeExpense($preyear,$currentyear);
|
|
$data['finyear']=$this->cashbook_model->finyear();
|
|
}
|
|
$this->loadViews("income_expense_list", $this->global, $data , NULL);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
function bankreceipt()
|
|
{
|
|
|
|
$aid = $this->uri->segment(3);
|
|
$str = $this->uri->segment(4);
|
|
if(!empty($aid)){
|
|
|
|
if(!empty($str))
|
|
{
|
|
|
|
$data['company'] = $this->cashbook_model->getCompany();
|
|
$data['data'] = $this->cashbook_model->getIncomeExpenseList($aid);
|
|
$totalamt = $data['data'][0]->total;
|
|
$data['amtinwords'] = $this->convertNumber($totalamt);
|
|
$mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 3, 0, 0, 0);
|
|
$mpdf->SetHTMLHeader($HtmlHeading);
|
|
$html = $this->load->view('cashbookpdf',$data,true);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
|
|
$mpdf->list_indent_first_level = 1;
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
$mpdf->WriteHTML($html);
|
|
$filename = "bankreceipt.pdf";
|
|
$mpdf->Output($filename,I);
|
|
}
|
|
else
|
|
{
|
|
|
|
$data['data'] = $this->cashbook_model->getIncomeExpenseList($aid);
|
|
//print_r($data['dropdownvalues']);die();
|
|
$this->global['pageTitle'] = $this->CompanyName.': View Income Expense ';
|
|
$this->loadViews("viewIndIncomeExpense", $this->global, $data , NULL);
|
|
|
|
}
|
|
|
|
}else{
|
|
// $data['list'] = $this->cashbook_model->getIncomeExpenseList();
|
|
// $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing';
|
|
|
|
// $this->loadViews("income_expense_list", $this->global, $data , NULL);
|
|
$this->global['pageTitle'] = $this->CompanyName.': Cash Master Listing';
|
|
|
|
if ($this->input->post('btn_submit')) {
|
|
|
|
$fromdt = $this->input->post('from_date');
|
|
$todt = $this->input->post('to_date');
|
|
$ab=$this->input->post('financialyear');
|
|
|
|
$fromyear=substr($ab,0,-5);
|
|
$toyear=substr($ab,5,5);
|
|
|
|
|
|
$data['finyear']=$this->cashbook_model->finyear();
|
|
$data['list'] = $this->cashbook_model->getIncomeExpense($fromyear,$toyear,$fromdt,$todt);
|
|
|
|
}
|
|
else{
|
|
|
|
if (date('m') <= 3) {
|
|
$preyear = (date('Y')-1);
|
|
$currentyear = date('Y');
|
|
} else {
|
|
$preyear = date('Y') ;
|
|
$currentyear = (date('Y') + 1);
|
|
}
|
|
|
|
$data['list'] = $this->cashbook_model->getIncomeExpense($preyear,$currentyear);
|
|
$data['finyear']=$this->cashbook_model->finyear();
|
|
}
|
|
$this->loadViews("income_expense_list", $this->global, $data , NULL);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* To load add incomeexpense screen
|
|
*/
|
|
function addNewIncomeExpenseLoad()
|
|
{
|
|
$data['dropdownvalues'] = $this->cashbook_model->getAccounTypes();
|
|
$data['getsupplier'] = $this->cashbook_model->getsupplier();
|
|
//$this->global['pageTitle'] = 'Resico : Cash Book: Add New Income Expense ';
|
|
$this->global['pageTitle'] = $this->CompanyName.': Cash Book: Add New Income Expense ';
|
|
$this->loadViews("addnewIncomeExpense", $this->global, $data , NULL);
|
|
}
|
|
function autocomplete()
|
|
{
|
|
//$this->load->model('model','cashbook_model');
|
|
$mer = $this->input->get('query');
|
|
$query= $this->cashbook_model->checkMerchant($mer);
|
|
echo json_encode($query);
|
|
|
|
}
|
|
function getSupplierDtls()
|
|
{
|
|
$s = $this->input->post('id');
|
|
$supp = $this->cashbook_model->getsupp_dtls($s);
|
|
echo json_encode($supp);
|
|
}
|
|
|
|
function bankfileview()
|
|
{
|
|
$data['bankdetails']=$this->cashbook_model->getBankDetails();
|
|
$this->global['pageTitle'] = $this->CompanyName.': Bank Report - File Upload';
|
|
$data['bankbalance'] = $this->cashbook_model->getbalancedetails();
|
|
$data['cleareddebitbalance'] = $this->cashbook_model->cleareddebitbalance();
|
|
$data['clearedcreditbalance'] = $this->cashbook_model->clearedcreditbalance();
|
|
$this->loadViews("bankingfile", $this->global, $data , NULL);
|
|
}
|
|
|
|
function bankfileupload()
|
|
{
|
|
$document = null;
|
|
|
|
$fs = 0;
|
|
if(!empty($_FILES['userfile']['name']))
|
|
{
|
|
//echo "FILE AVAILABLE";
|
|
$config['file_name'] = $_FILES['userfile']['name'];
|
|
$myFIle = $config['file_name'];
|
|
|
|
$config['upload_path'] = 'uploads/banking/';
|
|
$path = $config['upload_path'];
|
|
//$filename = $config['file_name'];
|
|
$document = $path.$filename;
|
|
//echo $document;
|
|
$fs = $this->uploadFile1();
|
|
$document = $path.$fs;
|
|
$created_by = $this->session->userdata('userId');
|
|
|
|
$openingbalance=0;
|
|
$closingbalance=0;
|
|
$inputFileName = $_FILES['userfile']['tmp_name'];
|
|
require_once APPPATH .'third_party/PHPExcel/IOFactory.php';
|
|
$objTpl = PHPExcel_IOFactory::load($inputFileName);
|
|
$sheet = $objTpl->getActiveSheet();//->toArray(null, true,true,true);
|
|
|
|
$highestRow = $sheet->getHighestRow();
|
|
$highestColumn = $sheet->getHighestColumn();
|
|
|
|
|
|
$highestRow4=$highestRow-4;
|
|
|
|
|
|
$bank = $this->input->post('bankbranchname');
|
|
$fileupload= array('Bankname'=>$bank,'document'=>$document);
|
|
|
|
$res = $this->cashbook_model->bankfile($fileupload);
|
|
for($x=21;$x<=$highestRow4;$x++){
|
|
|
|
if($x == 21){
|
|
|
|
$openingbalance=$sheet->getCell('H'.$x)->getValue();
|
|
|
|
}
|
|
if($x == $highestRow4){
|
|
|
|
$closingbalance=$sheet->getCell('H'.$highestRow4)->getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
$t=$sheet->getCell('A'.$x)->getValue();
|
|
$dat= str_replace('/','-',$t);
|
|
|
|
if (empty($dat))
|
|
{
|
|
$Date1 = NULL;
|
|
}
|
|
else
|
|
{
|
|
$Date1 = strtotime( $dat);
|
|
$Date1 = date("Y-m-d ", $Date1);
|
|
}
|
|
|
|
|
|
|
|
$s=$sheet->getCell('B'.$x)->getValue();
|
|
$dat1= str_replace('/','-',$s);
|
|
|
|
|
|
|
|
if (empty($dat1))
|
|
{
|
|
$Date2 = NULL;
|
|
}
|
|
else
|
|
{
|
|
|
|
$Date2 = date('Y-m-d',strtotime($dat1));
|
|
|
|
}
|
|
|
|
|
|
$chqno = $sheet->getCell('C'.$x)->getValue();
|
|
$narration = $sheet->getCell('D'.$x)->getValue();
|
|
$cod =$sheet->getCell('E'.$x)->getValue();
|
|
$debit =$sheet->getCell('F'.$x)->getValue();
|
|
|
|
$credit=$sheet->getCell('G'.$x)->getValue();
|
|
$balance=$sheet->getCell('H'.$x)->getValue();
|
|
|
|
// $IsActive=0;
|
|
$filedataupload= array('reportdate'=>$Date1,'valuedate'=>$Date2,'chequeNo'=>$cod,'Narration'=>$narration,'Cod'=> $chqno,'Debit'=>$debit,'Credit'=>$credit,'cbalancetocleared'=>$credit,'Balance'=>$balance,'Bankname'=>$bank);
|
|
|
|
|
|
|
|
$res = $this->cashbook_model->bankfiledata($filedataupload);
|
|
}
|
|
$balance= array('filename'=>$config['file_name'],'created_by'=>$created_by,'openingbalance'=>$openingbalance,'closingbalance'=>$closingbalance);
|
|
$bal = $this->cashbook_model->balance($balance);
|
|
|
|
|
|
if( $res == 1 ){
|
|
echo "<script>alert('Saved Successfully!');window.location.href='Bankingstatement';</script>";
|
|
}
|
|
else
|
|
{
|
|
echo "<script>alert('Saved unsuccessfully!');window.location.href='Bankingstatement';</script>";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* To store added incomeexpense datas
|
|
*/
|
|
//function addIncomeExpense()
|
|
function addReceipt()
|
|
{
|
|
|
|
$bankid = $this->input->post('bakid');
|
|
$remaindebitamount=$this->input->post('remaindebitamount');
|
|
$remaincreditamount=$this->input->post('remaincreditamount');
|
|
//$amount = $this->input->post('bankamount');//need to ask
|
|
$bankamounttype = $this->input->post('type');
|
|
$totalbankamount = $this->input->post('totalbankamount');
|
|
$alreadypaid=$this->input->post('alreadydebitpaid');
|
|
$directamount = $this->input->post('totalamount');
|
|
//$debitamount=$this->input->post('debitamount');// need to ask
|
|
$alreadycreditpaid=$this->input->post('alreadycreditpaid');
|
|
$bankorcash=$this->input->post('borc');
|
|
$total=$directamount+$alreadypaid;
|
|
$ctotal=$directamount+$alreadycreditpaid;
|
|
$updateBalancetocleared= $remaindebitamount-$directamount;
|
|
$updatecbalancetocleared= $remaincreditamount-$directamount;
|
|
|
|
|
|
$accounttype = 'RECEIPT';
|
|
$accountcode = $this->input->post('accode');
|
|
$date = $this->input->post('Date');
|
|
$date = date_create($date);//,'Y-m-d');
|
|
$date = date_format($date,'Y-m-d');
|
|
$towhome = $this->input->post('towhome');
|
|
$supplier = $this->input->post('supplier');
|
|
|
|
$gsttoggle = $this->input->post('gsttoggle');
|
|
$invoiceno = null;
|
|
$merchantname = null;
|
|
$mergstno = null;
|
|
$hsn = null;
|
|
$beforegst = null;
|
|
$sgst = null;
|
|
$cgst = null;
|
|
$igst = null;
|
|
$subdescription = null;
|
|
if(!empty($gsttoggle))
|
|
{
|
|
$invoiceno = $this->input->post('Invoiceno');
|
|
$merchantname = $this->input->post('merchant');
|
|
$mergstno = $this->input->post('Merchantgst');
|
|
$hsn = $this->input->post('hsn');
|
|
$beforegst = $this->input->post('valuebeforegST');
|
|
$sgst = $this->input->post('SGST');
|
|
$cgst = $this->input->post('CGST');
|
|
$igst = $this->input->post('IGST');
|
|
}
|
|
|
|
$totalamount = $this->input->post('totalamount');
|
|
// $cashbookamount=$this->input->post('totalamount1');
|
|
// $totalamount=$directamount+$cashbookamount;
|
|
|
|
$description = $this->input->post('description');
|
|
if(empty($description)){$description = 'NA';}
|
|
$document = null;
|
|
|
|
$fs = 0;
|
|
if(!empty($_FILES['myfile']['name']))
|
|
{
|
|
|
|
$config['file_name'] = $_FILES['myfile']['name'];
|
|
$config['upload_path'] = 'uploads/cashbook/';
|
|
$path = $config['upload_path'];
|
|
$document = $path.$filename;
|
|
$fs = $this->uploadFile();
|
|
$document = $path.$fs;
|
|
|
|
}
|
|
if($bankorcash=='Bank')
|
|
{
|
|
$option='Bank';
|
|
}
|
|
else
|
|
{
|
|
$option='Cash';
|
|
}
|
|
$balance=$totalbankamount-$totalamount;
|
|
$IsActive=1;
|
|
$created_by = $this->session->userdata('userId');
|
|
//$addincomexpense = array('type'=>$accounttype,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$towhome,'invoice_no'=>$invoiceno,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$totalamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by,'subdescription'=>$subdescription);
|
|
$addincomexpense = array('type'=>$accounttype,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$towhome,'Supplier_id'=>$supplier,'invoice_no'=>$invoiceno,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$totalamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by,'cashtype'=>$option,'bankid'=>$bankid,'totalbankamount'=>$totalbankamount,'balance'=>$balance,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'amounttype'=>$amounttype,'IsActive'=>$IsActive);
|
|
if($balance=='0')
|
|
{
|
|
$stat='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$stat='OPEN';
|
|
}
|
|
$creditbalance=$totalbankamount-$ctotal;
|
|
//echo $creditbalance;
|
|
//die();
|
|
if($creditbalance==0)
|
|
{
|
|
$statu='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$statu='OPEN';
|
|
}
|
|
// $debitbalance=$totalbankamount-$total;
|
|
// if($debitbalance==0)
|
|
|
|
// {
|
|
// $statu1='CLOSE';
|
|
// }
|
|
// else
|
|
// {
|
|
// $statu1='OPEN';
|
|
// }
|
|
// $isactive=1;
|
|
// //$clearbalance=$totalbankamount-
|
|
// if($amounttype=='CREDIT')
|
|
// {
|
|
$cashbookstatus1= array('cclearbalance'=>$ctotal,'cbalancetocleared'=>$updatecbalancetocleared,'cstatus'=>$statu);
|
|
//print_r($cashbookstatus1);
|
|
//die();
|
|
$res1 = $this->cashbook_model->cashcreditupdate($cashbookstatus1,$bankid);
|
|
// }
|
|
// else
|
|
// {
|
|
// $cashbookstatus = array('Clearbalance'=>$total,'Balancetocleared'=>$updateBalancetocleared,'Status'=>$statu1);
|
|
// $res23 = $this->cashbook_model->cashbankupdate($cashbookstatus,$bankid);
|
|
|
|
// }
|
|
|
|
|
|
|
|
$res = $this->cashbook_model->saveIncomeExpense($addincomexpense);
|
|
if( $res >= 1 ){
|
|
|
|
|
|
if($bankorcash=='Bank')//Redirct To Bank Report Screen
|
|
{
|
|
|
|
|
|
echo "<script>alert('Saved Successfully!');
|
|
</script>";
|
|
redirect('Bankingstatement','refresh');
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
//Redirct To Listing Screen
|
|
echo "<script>alert('Saved Successfully!');
|
|
window.location.href='incomeExpenseList';</script>";
|
|
}
|
|
}
|
|
|
|
}
|
|
// $res = $this->cashbook_model->saveIncomeExpense($addincomexpense);
|
|
// if( $res >= 1 ){
|
|
// echo "<script>alert('Saved Successfully!');
|
|
// window.location.href='incomeExpenseList';</script>";
|
|
// }
|
|
|
|
// }
|
|
|
|
/**
|
|
* To store added Cashbook's Payment datas
|
|
*/
|
|
function addPayment()
|
|
{
|
|
|
|
|
|
$bankid = $this->input->post('hideBankID');
|
|
$remaindebitamount=$this->input->post('hideRemainDebitAmount');
|
|
//$remaincreditamount=$this->input->post('remaincreditamount');
|
|
//$amount = $this->input->post('bankamount');//need to ask
|
|
$amounttype = $this->input->post('hideBAtype');
|
|
$totalbankamount = $this->input->post('hideTotalBankAmount');
|
|
$alreadypaid=$this->input->post('hideAlreadyDebitPaid');
|
|
$directamount = $this->input->post('Paymenttotalamount');
|
|
//$debitamount=$this->input->post('debitamount');// need to ask
|
|
//$alreadycreditpaid=$this->input->post('alreadycreditpaid');
|
|
$bankorcash=$this->input->post('hideborc');
|
|
$total=$directamount+$alreadypaid;
|
|
//$ctotal=$directamount+$alreadycreditpaid;
|
|
$updateBalancetocleared= $remaindebitamount-$directamount;
|
|
//$updatecbalancetocleared= $remaincreditamount-$directamount;
|
|
// if($amounttype==CREDIT)
|
|
// {
|
|
// $type=RECEIPT;
|
|
// $bankamounttype=CREDIT;
|
|
// }
|
|
// else
|
|
// {
|
|
$type=PAYMENT;
|
|
$bankamounttype=DEBIT;
|
|
// }
|
|
|
|
$count = $this->input->post('hidecounter');
|
|
$constantcount = $this->input->post('hideconstant');
|
|
|
|
$accounttype = 'PAYMENT';
|
|
$date = $this->input->post('PaymentDate');
|
|
$date = date_create($date);//,'Y-m-d');
|
|
$date = date_format($date,'Y-m-d');
|
|
$paidto = $this->input->post('PaymentPaidto');
|
|
$supplier = $this->input->post('Paymentsupplier');
|
|
$vouchercode = $this->input->post('Paymentvouchercode');
|
|
|
|
|
|
|
|
|
|
//echo $count.$consantcount;
|
|
//$gsttoggle = $this->input->post('gsttoggle');
|
|
//$invoiceno = null;
|
|
$merchantname = null;
|
|
$mergstno = null;
|
|
$hsn = null;
|
|
$beforegst = null;
|
|
$sgst = null;
|
|
$cgst = null;
|
|
$igst = null;
|
|
|
|
$merchantname = $this->input->post('Paymentmerchant');
|
|
$mergstno = $this->input->post('PaymentMerchantgst');
|
|
$hsn = $this->input->post('Paymenthsn');
|
|
$beforegst = $this->input->post('PaymentvaluebeforegST');
|
|
$sgst = $this->input->post('PaymentSGST');
|
|
$cgst = $this->input->post('PaymentCGST');
|
|
$igst = $this->input->post('PaymentIGST');
|
|
|
|
// $cashbookamount=$this->input->post('totalamount1');
|
|
// $totalamount=$directamount+$cashbookamount; where its comes from
|
|
//$totalamount = $this->input->post('Paymenttotalamount');
|
|
$description = $this->input->post('Paymentdescription');
|
|
|
|
|
|
if(empty($description)){$description = 'NA';}
|
|
|
|
$document = null;
|
|
|
|
$fs = 0;
|
|
|
|
if(!empty($_FILES['myfile']['name']))
|
|
{
|
|
|
|
$config['file_name'] = $_FILES['myfile']['name'];
|
|
$config['upload_path'] = 'uploads/cashbook/';
|
|
$path = $config['upload_path'];
|
|
$document = $path.$filename;
|
|
$fs = $this->uploadFile();
|
|
$document = $path.$fs;
|
|
|
|
}
|
|
$created_by = $this->session->userdata('userId');
|
|
|
|
|
|
if($count == 1)
|
|
{
|
|
|
|
$array = $this->input->post('mydata1');
|
|
if(!empty($array)){
|
|
$array[] = $this->input->post($varname);
|
|
$index = 0;
|
|
foreach($array as $key=>$value){
|
|
$index++;
|
|
if($index == 1){
|
|
$Paymentaccode = $value;
|
|
}
|
|
if($index == 2){
|
|
$subdescription = $value;
|
|
}
|
|
}}
|
|
|
|
|
|
if($bankorcash=='Bank')
|
|
{ $option='Bank'; }
|
|
else { $option='Cash'; }
|
|
$balance=$totalbankamount-$totalamount;
|
|
$IsActive=1;
|
|
|
|
$addPayments = array('type'=>$accounttype,'account_code'=>$Paymentaccode,'date'=>$date,'towhom'=>$paidto,'Supplier_id'=>$supplier,'invoice_no'=>$vouchercode,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$directamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by,'paymentsubdesc'=>$subdescription,'cashtype'=>$option,'bankid'=>$bankid,'totalbankamount'=>$totalbankamount,'balance'=>$balance,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'amounttype'=>$amounttype,'IsActive'=>$IsActive);
|
|
$res = $this->cashbook_model->saveIncomeExpense($addPayments);
|
|
|
|
if($balance=='0')
|
|
{
|
|
$stat='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$stat='OPEN';
|
|
}
|
|
// $creditbalance=$totalbankamount-$ctotal;
|
|
// //echo $creditbalance;
|
|
// //die();
|
|
// if($creditbalance==0)
|
|
// {
|
|
// $statu='CLOSE';
|
|
// }
|
|
// else
|
|
// {
|
|
// $statu='OPEN';
|
|
// }
|
|
$debitbalance=$totalbankamount-$total;
|
|
if($debitbalance==0)
|
|
|
|
{
|
|
$statu1='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$statu1='OPEN';
|
|
}
|
|
$isactive=1;
|
|
|
|
// if($amounttype=='CREDIT')
|
|
// {
|
|
// $cashbookstatus1= array('cclearbalance'=>$ctotal,'cbalancetocleared'=>$updatecbalancetocleared,'cstatus'=>$statu);
|
|
//print_r($cashbookstatus1);
|
|
//die();
|
|
// $res1 = $this->cashbook_model->cashcreditupdate($cashbookstatus1,$bankid);
|
|
// }
|
|
// else
|
|
// {
|
|
$cashbookstatus = array('Clearbalance'=>$total,'Balancetocleared'=>$updateBalancetocleared,'Status'=>$statu1);
|
|
$res23 = $this->cashbook_model->cashbankupdate($cashbookstatus,$bankid);
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$accountcode = '999';
|
|
$subdescription = 'Multiple';
|
|
|
|
if($bankorcash=='Bank')
|
|
{ $option='Bank'; }
|
|
else { $option='Cash'; }
|
|
$balance=$totalbankamount-$totalamount;
|
|
$IsActive=1;
|
|
|
|
$addPayments = array('type'=>$accounttype,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$paidto,'Supplier_id'=>$supplier,'invoice_no'=>$vouchercode,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$directamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by,'paymentsubdesc'=>$subdescription,'cashtype'=>$option,'bankid'=>$bankid,'totalbankamount'=>$totalbankamount,'balance'=>$balance,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'amounttype'=>$amounttype,'IsActive'=>$IsActive);
|
|
$res = $this->cashbook_model->saveIncomeExpense($addPayments);
|
|
|
|
if($balance=='0')
|
|
{
|
|
$stat='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$stat='OPEN';
|
|
}
|
|
// $creditbalance=$totalbankamount-$ctotal;
|
|
// //echo $creditbalance;
|
|
// //die();
|
|
// if($creditbalance==0)
|
|
// {
|
|
// $statu='CLOSE';
|
|
// }
|
|
// else
|
|
// {
|
|
// $statu='OPEN';
|
|
// }
|
|
$debitbalance=$totalbankamount-$total;
|
|
if($debitbalance==0)
|
|
|
|
{
|
|
$statu1='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$statu1='OPEN';
|
|
}
|
|
$isactive=1;
|
|
|
|
// if($amounttype=='CREDIT')
|
|
// {
|
|
// $cashbookstatus1= array('cclearbalance'=>$ctotal,'cbalancetocleared'=>$updatecbalancetocleared,'cstatus'=>$statu);
|
|
//print_r($cashbookstatus1);
|
|
//die();
|
|
// $res1 = $this->cashbook_model->cashcreditupdate($cashbookstatus1,$bankid);
|
|
// }
|
|
// else
|
|
// {
|
|
$cashbookstatus = array('Clearbalance'=>$total,'Balancetocleared'=>$updateBalancetocleared,'Status'=>$statu1);
|
|
$res23 = $this->cashbook_model->cashbankupdate($cashbookstatus,$bankid);
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
$Paymentaccode = '';
|
|
$subdescription = '';
|
|
$Paymentamount = '';
|
|
|
|
|
|
for($i=1;$i<=$constantcount;$i++){
|
|
|
|
$varname = 'mydata'.$i;
|
|
//alert($varname);
|
|
$temp = $this->input->post($varname);
|
|
if(!empty($temp)){
|
|
$g[] = $this->input->post($varname);
|
|
//echo "sd";
|
|
//print_r($g);
|
|
//die();
|
|
}
|
|
else{}
|
|
}
|
|
|
|
foreach($g as $arr){
|
|
// $Paymentaccode = $arr->Paymentaccode;
|
|
// $subdescription = $arr->subdescription;
|
|
// $Paymentamount = $arr->Paymentamount;
|
|
|
|
$index = 0;
|
|
foreach($arr as $key=>$value){
|
|
$index++;
|
|
// echo "*************";
|
|
// echo $key;
|
|
// echo $value;
|
|
// echo "*************";
|
|
if($index == 1){
|
|
$Paymentaccode = $value;
|
|
}
|
|
if($index == 2){
|
|
$subdescription = $value;
|
|
}
|
|
if($index == 3){
|
|
$Paymentamount = $value;
|
|
|
|
}
|
|
|
|
}
|
|
//insert;
|
|
$addPaymentDetails = array('Payment_id'=>$res,'Account_code'=>$Paymentaccode,'Account_description'=>$subdescription,'Amount'=>$Paymentamount);
|
|
//print_r($addPaymentschild);
|
|
|
|
//$child = $this->cashbook_model->paymentdetails($addPaymentschild);
|
|
$child = $this->cashbook_model->addpaymentdetails($addPaymentDetails);
|
|
//addupdatepaymentdetails($addPaymentschild,$res);
|
|
//echo $child;
|
|
//echo $paymentcode;
|
|
}
|
|
|
|
}//new else
|
|
// if( $res >= 1 ){
|
|
// echo "<script>alert('Saved Successfully!');
|
|
// window.location.href='incomeExpenseList';</script>";
|
|
// }
|
|
if( $res >= 1 ){
|
|
|
|
|
|
if($bankorcash=='Bank')//Redirct To Bank Report Screen
|
|
{
|
|
|
|
|
|
echo "<script>alert('Saved Successfully!');
|
|
</script>";
|
|
redirect('Bankingstatement','refresh');
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
//Redirct To Listing Screen
|
|
echo "<script>alert('Saved Successfully!');
|
|
window.location.href='incomeExpenseList';</script>";
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public function cashpayment()
|
|
{
|
|
$bankdate = $this->input->post('bankdate');
|
|
$bankid = $this->input->post('bankid');
|
|
$amount = $this->input->post('bankamount');
|
|
$amounttype = $this->input->post('type');
|
|
$forstatus = $this->input->post('forstatus');
|
|
$alreadypaid=$this->input->post('alreadypaid');
|
|
$alreadycreditpaid=$this->input->post('alreadycreditpaid');
|
|
$debitamount=$this->input->post('debitamount');
|
|
$creditamount=$this->input->post('creditamount');
|
|
$total=$amount+$alreadypaid;
|
|
|
|
$option=Bank;
|
|
if($amounttype==0)
|
|
{
|
|
$type=RECEIPT;
|
|
$bankamounttype=CREDIT;
|
|
}
|
|
else
|
|
{
|
|
$type=PAYMENT;
|
|
$bankamounttype=DEBIT;
|
|
}
|
|
|
|
$bankcash1 = array('cdate'=>$bankdate,'mid'=>$bankid,'btype'=>$type,'amount'=>$alreadypaid,'boption'=>$option,'mappingamount'=>$forstatus,'totalamount'=>$amount,'amounttype'=>$bankamounttype,'alreadycreditpaid'=>$alreadycreditpaid);
|
|
//print_r($bankcash1);
|
|
//die();
|
|
// $res1 = $this->cashbook_model->addcashbook($bankcash1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* To store Cashbook revalant file and images
|
|
*/
|
|
function uploadFile()
|
|
{
|
|
|
|
$pathinfo = pathinfo($_FILES['myfile']['name']);
|
|
$config['upload_path'] = 'uploads/cashbook/';
|
|
$config['allowed_types'] = 'png|jpg|jpeg|pdf';
|
|
$config['file_name'] = $_FILES['myfile']['name'];
|
|
|
|
//Load upload library and initialize configuration
|
|
$this->load->library('upload',$config);
|
|
$this->upload->initialize($config);
|
|
|
|
if($this->upload->do_upload('myfile'))
|
|
{
|
|
$uploadData = $this->upload->data();
|
|
$uploadfilename = $uploadData['file_name'];
|
|
return $uploadfilename;
|
|
|
|
}
|
|
else
|
|
{
|
|
$error = array('error' => $this->upload->display_errors());
|
|
$uploadfilename = '';
|
|
print_r($error);
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* To load view Income Expense screen
|
|
*/
|
|
function uploadFile1()
|
|
{
|
|
|
|
//echo "INSIDE UPLOAFD";
|
|
|
|
//$this->load->library('upload')
|
|
$pathinfo = pathinfo($_FILES['userfile']['name']);
|
|
$config['upload_path'] = 'uploads/banking/';
|
|
$config['allowed_types'] = 'png|jpg|jpeg|xlsx';
|
|
$config['file_name'] = $_FILES['userfile']['name'];
|
|
// $config['overwrite'] = true;
|
|
|
|
//Load upload library and initialize configuration
|
|
$this->load->library('upload',$config);
|
|
$this->upload->initialize($config);
|
|
|
|
|
|
if($this->upload->do_upload('userfile'))
|
|
{
|
|
$uploadData = $this->upload->data();
|
|
$uploadfilename = $uploadData['file_name'];
|
|
return $uploadfilename;
|
|
|
|
}
|
|
else
|
|
{
|
|
$error = array('error' => $this->upload->display_errors());
|
|
$uploadfilename = '';
|
|
// print_r($error);
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
function viewIE()
|
|
{
|
|
|
|
$aid = $this->uri->segment(3);
|
|
$data['data'] = $this->cashbook_model->getAccounutInfo();
|
|
//$this->global['pageTitle'] = 'Resico : Cash Book: View Income Expense ';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Cash Book: View Income Expense ';
|
|
$this->loadViews("viewIndIncomeExpense", $this->global, $data , NULL);
|
|
|
|
}
|
|
|
|
/**
|
|
* Index Page for this controller(default function of the class)
|
|
*/
|
|
public function index()
|
|
{
|
|
//$this->global['pageTitle'] = 'Resico : Cashbook Details';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Cashbook Details';
|
|
$this->loadViews("cashbooklisting", $this->global, NULL , NULL);
|
|
|
|
}
|
|
|
|
public function cashbookList()
|
|
{
|
|
|
|
|
|
$this->load->model('cashbook_model');
|
|
//$data['dropdownvalues1'] = $this->cashbook_model->getAccounTypes1();
|
|
$data['cashbook'] = $this->cashbook_model->Selectcash();
|
|
|
|
//$this->global['pageTitle'] = 'Resico : Cashbook Listing';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Cashbook Listing';
|
|
$this->loadViews("cashbooklisting", $this->global, $data, NULL);
|
|
|
|
}
|
|
|
|
public function AdvanceList()
|
|
{
|
|
|
|
$aid = $this->uri->segment(3);
|
|
$str = $this->uri->segment(4);
|
|
if(!empty($aid)){
|
|
|
|
if(!empty($str))
|
|
{
|
|
//echo "PDF";
|
|
$data['company'] = $this->cashbook_model->getCompany();
|
|
|
|
$data['data'] = $this->cashbook_model->getAdvanceList($aid);
|
|
//$pic1 = $data['company'][0]->ProfilePic;
|
|
//echo $pic1;
|
|
//$pic = base_url().'uploads/images'.$pic1;
|
|
//echo $pic;
|
|
//die();
|
|
$totalamt = $data['data'][0]->total;
|
|
$data['amtinwords'] = $this->convertNumber($totalamt);
|
|
$mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 3, 0, 0, 0);
|
|
$mpdf->SetHTMLHeader($HtmlHeading);
|
|
$html = $this->load->view('cashbookpdf',$data,true);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
|
|
$mpdf->list_indent_first_level = 1;
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
$mpdf->WriteHTML($html);
|
|
$filename = "cashbook.pdf";
|
|
$mpdf->Output($filename,I);
|
|
}
|
|
else
|
|
{
|
|
|
|
$data['data'] = $this->cashbook_model->getAdvanceList($aid);
|
|
//print_r($data['dropdownvalues']);die();
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Cash Book: View Income Expense ';
|
|
$this->loadViews("viewIndIncomeExpense", $this->global, $data , NULL);
|
|
|
|
}
|
|
|
|
}else{
|
|
// $data['list'] = $this->cashbook_model->getIncomeExpenseList();
|
|
// $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing';
|
|
|
|
// $this->loadViews("income_expense_list", $this->global, $data , NULL);
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Cash Book: Advance List';
|
|
|
|
if ($this->input->post('btn_submit')) {
|
|
|
|
$fromdt = $this->input->post('from_date');
|
|
$todt = $this->input->post('to_date');
|
|
$ab=$this->input->post('financialyear');
|
|
|
|
$fromyear=substr($ab,0,-5);
|
|
$toyear=substr($ab,5,5);
|
|
|
|
|
|
$data['finyear']=$this->cashbook_model->finyear();
|
|
$data['list'] = $this->cashbook_model->getAdvance($fromyear,$toyear,$fromdt,$todt);
|
|
|
|
}
|
|
else{
|
|
|
|
if (date('m') <= 3) {
|
|
$preyear = (date('Y')-1);
|
|
$currentyear = date('Y');
|
|
} else {
|
|
$preyear = date('Y') ;
|
|
$currentyear = (date('Y') + 1);
|
|
}
|
|
|
|
$data['list'] = $this->cashbook_model->getAdvance($preyear,$currentyear);
|
|
$data['finyear']=$this->cashbook_model->finyear();
|
|
}
|
|
$this->loadViews("Advancelist", $this->global, $data , NULL);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public function cashbookdtl()
|
|
{
|
|
|
|
|
|
$id = $this->input->post('id');
|
|
$tablevalue = json_decode($id,true);
|
|
foreach($tablevalue as $tv)
|
|
{
|
|
if(!empty($tv['AccountCodeType'])){
|
|
$acc_type = $tv['AccountCodeType'];
|
|
$acc_code = $tv['AccountCode'];
|
|
$acc_name = $tv['AccountName'];
|
|
$acc_pname = $tv['ParentAccountName'];
|
|
$acc_categories = $tv['Categories'];
|
|
$acc_desc = $tv['Description'];
|
|
$acc_state = $tv['Status'];
|
|
if(strtoupper($acc_state) == 'YES')
|
|
{
|
|
$acc_status = 1;
|
|
}
|
|
else{
|
|
$acc_status = 0;
|
|
}
|
|
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$acc_createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
$cashbookdatas = array('type'=>$acc_type,'code'=>$acc_code,'name'=>$acc_name,'description'=>$acc_desc,'status'=>$acc_status,'created_on'=>$acc_createddt);
|
|
/** accountname and category fields aree not available so that comment */
|
|
//$cashbookdatas = array('type'=>$acc_type,'code'=>$acc_code,'name'=>$acc_name,'accountname'=>$acc_pname,'categories'=>$acc_categories,'description'=>$acc_desc,'status'=>$acc_status,'created_on'=>$acc_createddt);
|
|
|
|
$result = $this->cashbook_model->Cashbook($cashbookdatas);
|
|
}
|
|
}
|
|
|
|
echo "Successfully Saved!";
|
|
|
|
}
|
|
/**
|
|
* For edit cashbook screen
|
|
*/
|
|
public function editcashbook($sid)
|
|
{
|
|
|
|
if($sid == '')
|
|
{
|
|
$cash = $_GET['sid'];
|
|
}
|
|
else
|
|
{
|
|
$cash = $sid;
|
|
}
|
|
|
|
|
|
$this->load->model('cashbook_model');
|
|
|
|
//$data['DepDetails'] = $this->cashbook_model->viewdepartment($cash);
|
|
/** this array for single entry both recepit and payment datas*/
|
|
$data['RecepitPayment'] = $this->cashbook_model->viewdepartment($cash);
|
|
/** this array for paymentmaster mutilpe datas */
|
|
$data['PaymentMultiple'] = $this->cashbook_model->viewpaymentmaster($cash);
|
|
/** this array for paymentchild datas */
|
|
$data['PaymentDetails'] = $this->cashbook_model->viewpaymentdetails($cash);
|
|
/** this array for dropdown value(account name)*/
|
|
$data['dropdownvalues'] = $this->cashbook_model->getAccounTypes();
|
|
$data['getsupplier'] = $this->cashbook_model->getsupplier();
|
|
//$this->global['pageTitle'] = 'Resico : Edit Cashbook';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Edit Cashbook';
|
|
$this->loadViews("editincomeexpenses", $this->global,$data, NULL);
|
|
|
|
}
|
|
public function deletefile()
|
|
{
|
|
$cashfile = $this->input->post('id');
|
|
$cashid = $this->input->post('ide');
|
|
$filedata= $this->cashbook_model->deletefile($cashid,$cashfile);
|
|
echo $filedata;
|
|
}
|
|
function Removepaymentdetails(){
|
|
|
|
$id = $this->input->post('id');
|
|
$deletedata = $this->cashbook_model->deletepaymentdetails($id);
|
|
echo $deletedata;
|
|
}
|
|
function updateReceipt()
|
|
{
|
|
$id1=$this->input->post('id1');
|
|
// $myradio1= $this->input->post('myradio');
|
|
// $option='';
|
|
// if($myradio1==1)
|
|
// {
|
|
$option=RECEIPT;
|
|
// }
|
|
// else
|
|
// {
|
|
// $option=PAYMENT;
|
|
// }
|
|
|
|
$ans1 = $this->input->post('ans');
|
|
$Date1 = $this->input->post('Date');
|
|
|
|
$date = date_create($Date1);//,'Y-m-d');
|
|
$date = date_format($date,'Y-m-d');
|
|
$accountcode1 = $this->input->post('accode');
|
|
|
|
$towhome1 = $this->input->post('towhome');
|
|
$supplier = $this->input->post('supplier');
|
|
$Invoiceno1 = $this->input->post('Invoiceno');
|
|
$merchant1 = $this->input->post('merchant');
|
|
$Merchantgst1 = $this->input->post('Merchantgst');
|
|
$hsn1 = $this->input->post('hsn');
|
|
$valuebeforegST1 = $this->input->post('valuebeforegST');
|
|
$SGST1 = $this->input->post('SGST');
|
|
$CGST1 = $this->input->post('CGST');
|
|
$IGST1 = $this->input->post('IGST');
|
|
$totalamount1 = $this->input->post('totalamount');
|
|
$description1 = $this->input->post('description');
|
|
$deleteflag = $this->input->post('deleteflag');
|
|
$oldfile = $this->input->post('oldfile');
|
|
$amounttype = $this->input->post('amounttype');
|
|
$bankid=$this->input->post('bankid');
|
|
$normalid=$this->input->post('normalid');
|
|
$bankamount=$this->input->post('bankamount');
|
|
$gsttoggle = $this->input->post('gsttoggle');
|
|
$document =null;
|
|
|
|
|
|
$fs = 0;
|
|
if(!empty($_FILES['myfile']['name']))
|
|
{
|
|
|
|
$config['file_name'] = $_FILES['myfile']['name'];
|
|
$config['upload_path'] = 'uploads/cashbook/';
|
|
$path = $config['upload_path'];
|
|
$fs = $this->uploadFile();
|
|
$document = $path.$fs;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
if($deleteflag == 0)
|
|
{
|
|
$document = $oldfile;
|
|
}
|
|
else if($deleteflag == 1)
|
|
{
|
|
$document = null;
|
|
}
|
|
}
|
|
//$updateaccount = array('type'=>$option,'account_code'=>$accountcode1,'date'=>$date,'towhom'=>$towhome1,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'description'=>$description1,'document'=>$document);
|
|
$updateaccount = array('type'=>$option,'account_code'=>$accountcode1,'date'=>$date,'towhom'=>$towhome1,'Supplier_id'=>$supplier,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'description'=>$description1,'document'=>$document);
|
|
|
|
$res = $this->cashbook_model->updatedepartment($updateaccount,$id1);
|
|
$cashbookamount=$this->cashbook_model->cashbookamount($bankid);
|
|
$invoiceamount=$this->cashbook_model->invoiceamonut($bankid);
|
|
$poamount=$this->cashbook_model->poamonut($bankid);
|
|
foreach($invoiceamount as $ia)
|
|
{
|
|
$invam=$ia->amountreceived;
|
|
}
|
|
foreach($poamount as $pa)
|
|
{
|
|
$poamnt=$pa->amountpaid;
|
|
}
|
|
foreach($cashbookamount as $ca)
|
|
{
|
|
$cashamnt=$ca->total;
|
|
}
|
|
if($bankamount==$cashamnt)
|
|
{
|
|
$status='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$status='OPEN';
|
|
}
|
|
//print_r($invoiceamount);
|
|
if($amounttype=='CREDIT')
|
|
{
|
|
$updatecredit=$invam+$cashamnt;
|
|
$cashbookstatus1= array('cclearbalance'=>$updatecredit,'cstatus'=>$status);
|
|
//print_r($cashbookstatus1);
|
|
//die();
|
|
|
|
$res1 = $this->cashbook_model->cashcreditupdate($cashbookstatus1,$bankid);
|
|
}
|
|
|
|
else
|
|
{
|
|
$updatedepit=$poamnt+$cashamnt;
|
|
$cashbookstatus = array('Clearbalance'=>$updatedepit,'Status'=>$status);
|
|
// print_r($cashbookstatus);
|
|
//die();
|
|
$res = $this->cashbook_model->cashbankupdate($cashbookstatus,$bankid);
|
|
|
|
}
|
|
|
|
|
|
//if( $res == 1 ){
|
|
// echo "<script>alert('Saved Successfully!');window.location.href='ViewIncomeExpense';</script>";
|
|
//}
|
|
|
|
echo "<script>alert('Saved Successfully!');
|
|
window.location.href='incomeExpenseList';
|
|
</script>";
|
|
}
|
|
|
|
|
|
|
|
function updatePayment()
|
|
{
|
|
$id1=$this->input->post('id1');
|
|
$count = $this->input->post('hidecounter');//hide value
|
|
$constantcount = $this->input->post('hideconstant');//hide value
|
|
$option=PAYMENT;
|
|
$ans1 = $this->input->post('ans');
|
|
$Date1 = $this->input->post('PaymentDate');
|
|
$date = date_create($Date1);//,'Y-m-d');
|
|
$date = date_format($date,'Y-m-d');
|
|
|
|
$towhome1 = $this->input->post('PaymentPaidto');
|
|
$supplier = $this->input->post('Paymentsupplier');
|
|
$Invoiceno1 = $this->input->post('Paymentvouchercode');
|
|
$merchant1 = $this->input->post('Paymentmerchant');
|
|
$Merchantgst1 = $this->input->post('PaymentMerchantgst');
|
|
$hsn1 = $this->input->post('Paymenthsn');
|
|
$valuebeforegST1 = $this->input->post('PaymentvaluebeforegST');
|
|
$SGST1 = $this->input->post('PaymentSGST');
|
|
$CGST1 = $this->input->post('PaymentCGST');
|
|
$IGST1 = $this->input->post('PaymentIGST');
|
|
$totalamount1 = $this->input->post('Paymenttotalamount');
|
|
$description1 = $this->input->post('Paymentdescription');
|
|
$deleteflag = $this->input->post('deleteflag');
|
|
$oldfile = $this->input->post('oldfile');
|
|
$amounttype = $this->input->post('amounttype');
|
|
$bankid=$this->input->post('bankid');
|
|
$normalid=$this->input->post('normalid');
|
|
$bankamount=$this->input->post('bankamount');
|
|
$gsttoggle = $this->input->post('gsttoggle');
|
|
$document =null;
|
|
|
|
|
|
$fs = 0;
|
|
if(!empty($_FILES['myfile']['name']))
|
|
{
|
|
|
|
$config['file_name'] = $_FILES['myfile']['name'];
|
|
$config['upload_path'] = 'uploads/cashbook/';
|
|
$path = $config['upload_path'];
|
|
$fs = $this->uploadFile();
|
|
$document = $path.$fs;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
if($deleteflag == 0)
|
|
{
|
|
$document = $oldfile;
|
|
}
|
|
else if($deleteflag == 1)
|
|
{
|
|
$document = null;
|
|
}
|
|
}
|
|
|
|
if($count == 1)
|
|
{
|
|
|
|
$array = $this->input->post('mydata1');
|
|
if(!empty($array)){
|
|
$array[] = $this->input->post($varname);
|
|
$index = 0;
|
|
foreach($array as $key=>$value){
|
|
$index++;
|
|
if($index == 1){
|
|
$Paymentaccode = $value;
|
|
}
|
|
if($index == 2){
|
|
$subdescription = $value;
|
|
}
|
|
}}
|
|
|
|
|
|
$UpdatePayment = array('type'=>$option,'account_code'=>$Paymentaccode,'date'=>$date,'towhom'=>$towhome1,'Supplier_id'=>$supplier,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'description'=>$description1,'document'=>$document,'paymentsubdesc'=>$subdescription,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'description'=>$description1,'document'=>$document);
|
|
$res = $this->cashbook_model->updatepaymentmaster($UpdatePayment,$id1);
|
|
$cashbookamount=$this->cashbook_model->cashbookamount($bankid);
|
|
$invoiceamount=$this->cashbook_model->invoiceamonut($bankid);
|
|
$poamount=$this->cashbook_model->poamonut($bankid);
|
|
foreach($invoiceamount as $ia)
|
|
{
|
|
$invam=$ia->amountreceived;
|
|
}
|
|
foreach($poamount as $pa)
|
|
{
|
|
$poamnt=$pa->amountpaid;
|
|
}
|
|
foreach($cashbookamount as $ca)
|
|
{
|
|
$cashamnt=$ca->total;
|
|
}
|
|
if($bankamount==$cashamnt)
|
|
{
|
|
$status='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$status='OPEN';
|
|
}
|
|
//print_r($invoiceamount);
|
|
if($amounttype=='CREDIT')
|
|
{
|
|
$updatecredit=$invam+$cashamnt;
|
|
$isactive=0;
|
|
$cashbookstatus1= array('cclearbalance'=>$updatecredit,'cstatus'=>$status,'IsActive'=>$isactive);
|
|
//print_r($cashbookstatus1);
|
|
//die();
|
|
|
|
$res1 = $this->cashbook_model->cashcreditupdate($cashbookstatus1,$bankid);
|
|
}
|
|
|
|
else
|
|
{
|
|
$updatedepit=$poamnt+$cashamnt;
|
|
$cashbookstatus = array('Clearbalance'=>$updatedepit,'Status'=>$status);
|
|
// print_r($cashbookstatus);
|
|
//die();
|
|
$res = $this->cashbook_model->cashbankupdate($cashbookstatus,$bankid);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$accountcode = '999';
|
|
$subdescription0 = 'Multiple';
|
|
$UpdatePayment = array('type'=>$option,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$towhome1,'Supplier_id'=>$supplier,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'description'=>$description1,'document'=>$document,'paymentsubdesc'=>$subdescription0,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'description'=>$description1,'document'=>$document);
|
|
$res = $this->cashbook_model->updatepaymentmaster($UpdatePayment,$id1);
|
|
|
|
$cashbookamount=$this->cashbook_model->cashbookamount($bankid);
|
|
$invoiceamount=$this->cashbook_model->invoiceamonut($bankid);
|
|
$poamount=$this->cashbook_model->poamonut($bankid);
|
|
foreach($invoiceamount as $ia)
|
|
{
|
|
$invam=$ia->amountreceived;
|
|
}
|
|
foreach($poamount as $pa)
|
|
{
|
|
$poamnt=$pa->amountpaid;
|
|
}
|
|
foreach($cashbookamount as $ca)
|
|
{
|
|
$cashamnt=$ca->total;
|
|
}
|
|
if($bankamount==$cashamnt)
|
|
{
|
|
$status='CLOSE';
|
|
}
|
|
else
|
|
{
|
|
$status='OPEN';
|
|
}
|
|
//print_r($invoiceamount);
|
|
if($amounttype=='CREDIT')
|
|
{
|
|
$updatecredit=$invam+$cashamnt;
|
|
$isactive=0;
|
|
$cashbookstatus1= array('cclearbalance'=>$updatecredit,'cstatus'=>$status,'IsActive'=>$isactive);
|
|
//print_r($cashbookstatus1);
|
|
//die();
|
|
|
|
$res1 = $this->cashbook_model->cashcreditupdate($cashbookstatus1,$bankid);
|
|
}
|
|
|
|
else
|
|
{
|
|
$updatedepit=$poamnt+$cashamnt;
|
|
$cashbookstatus = array('Clearbalance'=>$updatedepit,'Status'=>$status);
|
|
// print_r($cashbookstatus);
|
|
//die();
|
|
$res = $this->cashbook_model->cashbankupdate($cashbookstatus,$bankid);
|
|
|
|
}
|
|
|
|
|
|
for($i=1;$i<=$constantcount;$i++){
|
|
|
|
$varname = 'mydata'.$i;
|
|
$temp = $this->input->post($varname);
|
|
if(!empty($temp)){
|
|
$g[] = $this->input->post($varname);
|
|
}
|
|
else{}
|
|
|
|
}
|
|
|
|
//print_r($g); echo "<br>****************************";
|
|
|
|
foreach($g as $arr){
|
|
|
|
$insert = count($arr);
|
|
//echo $insert;
|
|
|
|
if($insert == 3){
|
|
|
|
//print_r($arr); echo "<br>*********THREE insert************";
|
|
$index = 0;
|
|
foreach($arr as $key=>$value){
|
|
$index++;
|
|
// echo "*************";
|
|
// echo $key;
|
|
// echo $value;
|
|
// echo "*************";
|
|
|
|
if($index == 1){
|
|
$Payment_accode = $value;
|
|
}
|
|
if($index == 2){
|
|
$sub_description = $value;
|
|
}
|
|
if($index == 3){
|
|
$Payment_amount = $value;
|
|
}
|
|
|
|
|
|
}
|
|
if($Payment_accode != -1)
|
|
{
|
|
|
|
$addPaymentsdetails = array('Payment_id'=>$id1,'Account_code'=>$Payment_accode,'Account_description'=>$sub_description,'Amount'=>$Payment_amount);
|
|
|
|
|
|
$child = $this->cashbook_model->addpaymentdetails($addPaymentsdetails);
|
|
|
|
}
|
|
|
|
}
|
|
else if($insert == 4){
|
|
// print_r($arr); echo "<br>*********FOUR update************";
|
|
$index = 0;
|
|
foreach($arr as $key=>$value){
|
|
$index++;
|
|
|
|
if($index == 1){
|
|
$Paymentaccode = $value;
|
|
}
|
|
if($index == 2){
|
|
$subdescription = $value;
|
|
}
|
|
if($index == 3){
|
|
$Paymentamount = $value;
|
|
}
|
|
if($index == 4){
|
|
$hidekey = $value;
|
|
}
|
|
|
|
}
|
|
|
|
$UpdatePaymentsdetails = array('Payment_id'=>$id1,'Account_code'=>$Paymentaccode,'Account_description'=>$subdescription,'Amount'=>$Paymentamount);
|
|
|
|
$child = $this->cashbook_model->updatepaymentdetails($UpdatePaymentsdetails,$hidekey);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "<script>alert('Saved Successfully!');
|
|
window.location.href='incomeExpenseList';
|
|
</script>";
|
|
;
|
|
}
|
|
|
|
public function bankdata()
|
|
{
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Statement';
|
|
|
|
if($this->input->post('btn_submit'))
|
|
{
|
|
//$this->global['pageTitle'] = $this->CompanyName.' : bankstatement';
|
|
$ab=$this->input->post('financialyear');
|
|
|
|
$fa=substr($ab,0,-5);
|
|
$aa=substr($ab,5,5);
|
|
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
}
|
|
|
|
$data['finyear']=$this->cashbook_model->report_finyear();
|
|
$data['bankreport'] = $this->cashbook_model->bankstatement($fdate,$tdate,$fa,$aa);
|
|
|
|
$this->loadViews("bankstatement", $this->global, $data,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bankdebitdata()
|
|
{
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Debit Report';
|
|
if ($this->input->post('btn_submit'))
|
|
{
|
|
$Supplierid = $this->input->post('SupplierName');
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
//$data['cash'] = $_GET['sid'];
|
|
//$data['bankid'] = $_GET['d'];
|
|
$data['bankdepit'] = $this->cashbook_model->debitbankstatemet($Supplierid,$fdate,$tdate);
|
|
}
|
|
|
|
$data['getsupplier'] = $this->cashbook_model->getsupplier();
|
|
$this->loadViews("bankdebit",$this->global,$data,NULL);
|
|
//die();
|
|
|
|
}
|
|
public function bankinvoice()
|
|
{
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Invoice Report';
|
|
if ($this->input->post('btn_submit'))
|
|
{
|
|
$Customer = $this->input->post('Customer');
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
$data['bankinvoicedata'] = $this->cashbook_model->bankinvoice($Customer,$fdate,$tdate);
|
|
//$data['supplier'] = $this->cashbook_model->getsupplier();
|
|
}
|
|
$data['getcustomer'] = $this->cashbook_model->getcustomer();
|
|
|
|
$this->loadViews("bankinvoice", $this->global,$data,NULL);
|
|
|
|
}
|
|
function IGRFilelist()
|
|
{
|
|
$igrno= $this->input->post('igrno');
|
|
$pono =$this->input->post('pono');
|
|
$igrsingle = $this->cashbook_model->igrmastersingle($igrno,$pono);
|
|
$igrmultiple =$this->cashbook_model->igrmastermultiple($igrno,$pono);
|
|
$data = array_merge($igrsingle,$igrmultiple);
|
|
echo json_encode($data);
|
|
|
|
|
|
}
|
|
public function filelist()
|
|
|
|
{
|
|
$igrno= $this->input->post('igrno');
|
|
$pono =$this->input->post('pono');
|
|
$data = $this->cashbook_model->debitimage($igrno,$pono);
|
|
|
|
echo json_encode($data);
|
|
|
|
}
|
|
|
|
public function mappingpo()
|
|
{
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Debited Settlements';
|
|
$SupplierName = $this->input->post('SupplierName');
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
$bankid= $_GET['d'];
|
|
$data['clearbalance']= $_GET['clearbalance'];
|
|
if($data['clearbalance']==0)
|
|
{
|
|
echo "<script>alert('No Mapped Amount!')</script>";
|
|
redirect('Bankingstatement','refresh');
|
|
}
|
|
else
|
|
{
|
|
$data['balancetoclear'] =$_GET['balancetoclear'];
|
|
$data['mappingcashbook']=$this->cashbook_model->mappingcash($SupplierName,$fdate,$tdate,$bankid);
|
|
$data['mapping'] = $this->cashbook_model->debitpolist($bankid);
|
|
$data['paidcbook'] = $this->cashbook_model->cashbookamount($bankid);
|
|
$data['paidpoamount'] = $this->cashbook_model->poamonut($bankid);
|
|
$data['supplier'] = $this->cashbook_model->getsupplier();
|
|
$this->loadViews("banksettlement", $this->global,$data,NULL);
|
|
}
|
|
|
|
}
|
|
public function mappinginvoice()
|
|
{
|
|
|
|
|
|
//$this->global['pageTitle'] = 'Siddharth : Cashbook Listing';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Credited Settlements';
|
|
$SupplierName = $this->input->post('SupplierName');
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
$bankid= $_GET['d'];
|
|
$data['clearbalance']=$_GET['cb'];
|
|
// if($data['clearbalance']==0)
|
|
// {
|
|
// echo "<script>alert('No Mapped Amount!')</script>";
|
|
// redirect('Bankingstatement','refresh');
|
|
// }
|
|
// else
|
|
// {
|
|
$data['balancetoclear']=$_GET['btc'];
|
|
$data['mappingcashbook']=$this->cashbook_model->mappingcash($SupplierName,$fdate,$tdate,$bankid);
|
|
$data['mappingiv'] = $this->cashbook_model->creditinvoicelist($bankid);
|
|
$data['paidcbook'] = $this->cashbook_model->cashbookamount($bankid);
|
|
$data['invoiceramount'] = $this->cashbook_model->invoiceamonut($bankid);
|
|
$data['supplier'] = $this->cashbook_model->getsupplier();
|
|
//redirect('Bankingstatement','refresh');
|
|
$this->loadViews("bankinvoicesettlement", $this->global,$data,NULL);
|
|
//}
|
|
}
|
|
public function mappingdebit()
|
|
{
|
|
|
|
|
|
// $this->global['pageTitle'] = 'Siddharth : mappingdebit';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Debited Details';
|
|
$SupplierName = $this->input->post('SupplierName');
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
$igrLTno = $_GET['igrLTno'];
|
|
//$data['debitmapping'] = $this->cashbook_model->debitlistpo($SupplierName,$fdate,$tdate,$igrLTno);
|
|
$data['debitmapping'] = $this->cashbook_model->debitlistpo($igrLTno);
|
|
$this->loadViews("bankposettlement", $this->global,$data,NULL);
|
|
|
|
}
|
|
public function mappingcredit()
|
|
{
|
|
|
|
|
|
// $this->global['pageTitle'] = 'Siddharth : mappingcredit';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Credited Details ';
|
|
$SupplierName = $this->input->post('SupplierName');
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
$invno= $_GET['sid'];
|
|
$data['creditmapping'] = $this->cashbook_model->creditlistinv($invno);
|
|
$this->loadViews("bankinvoisettle", $this->global,$data,NULL);
|
|
|
|
}
|
|
|
|
public function receipt()
|
|
{
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Store Debited Details';
|
|
|
|
$check = $this->input->post('check');
|
|
$rw = $this->input->post('rw');
|
|
$date = $this->input->post('podate');
|
|
$date = date_create($date);
|
|
$date = date_format($date,'Y-m-d');
|
|
$pono = $this->input->post('pono');
|
|
$igrno=$this->input->post('igrno');
|
|
$igrlineitem=$this->input->post('igrlineitem');
|
|
|
|
$sname = $this->input->post('sname');
|
|
$tot = $this->input->post('tot');
|
|
$rowcount = $this->input->post('rc');
|
|
$totalpaidamount= $this->input->post('tpv');
|
|
$bankdebitamountamount= $this->input->post('bda');
|
|
$bankid =$this->input->post('bi');
|
|
$alreadypaid = 0;
|
|
//echo $earlypaid;
|
|
$alreadypaid = $this->cashbook_model->getalreadypaid($bankid);
|
|
if(empty($alreadypaid))
|
|
{
|
|
$aPay=0;
|
|
}
|
|
else
|
|
{
|
|
foreach($alreadypaid as $ap)
|
|
{
|
|
$aPay = $ap->Clearbalance;
|
|
}
|
|
}
|
|
|
|
if($check == 1)
|
|
{
|
|
$clearedblnce=($totalpaidamount+$aPay);
|
|
$balancetocleared=($bankdebitamountamount-$totalpaidamount);
|
|
$check =1;
|
|
}
|
|
//echo $balancetocleared;
|
|
//die();
|
|
if($balancetocleared>0)
|
|
{
|
|
$status='OPEN';
|
|
}
|
|
else
|
|
{
|
|
$status='CLOSE';
|
|
}
|
|
$active=1;
|
|
$bankdata = array('Clearbalance'=>$clearedblnce,'Balancetocleared'=>$balancetocleared,'Status'=>$status);
|
|
|
|
if($check == 1)
|
|
{
|
|
$res = $this->cashbook_model->bankupdate($bankdata,$bankid);
|
|
}
|
|
$earlypaid = 0;
|
|
//echo $earlypaid;
|
|
$earlypaid = $this->cashbook_model->getearlyamount($igrlineitem);
|
|
if(empty($earlypaid))
|
|
{
|
|
$ePay=0;
|
|
}
|
|
else
|
|
{
|
|
foreach($earlypaid as $ep)
|
|
{
|
|
$ePay = $ep->Amountpaid;
|
|
}
|
|
}
|
|
|
|
$ip=$this->input->post('aa');
|
|
$balancetopay=($tot-($ip+$ePay));
|
|
|
|
|
|
$amtpaid= ($ip+$ePay);
|
|
$IsActive=1;
|
|
|
|
$podata1 = array('Podate'=>$date,'PONO'=>$pono,'IGRNO'=>$igrno,'Suppliername'=>$sname,'Totalpoamount'=>$tot,'Amountpaid'=>$ip,'Balancetopay'=>$balancetopay,'mid'=>$bankid,'IGRLineItemNo'=>$igrlineitem,'IsActive'=>$IsActive);
|
|
|
|
$podata = array('Podate'=>$date,'PONO'=>$pono,'IGRNO'=>$igrno,'Suppliername'=>$sname,'Totalpoamount'=>$tot,'Amountpaid'=>$amtpaid,'Balancetopay'=>$balancetopay,'mid'=>$bankid,'IGRLineItemNo'=>$igrlineitem);
|
|
//die();
|
|
|
|
$result3 = $this->cashbook_model->getpono($igrlineitem);
|
|
|
|
$resultn = $this->cashbook_model->mappingpo($podata1);
|
|
if(count($result3)<=0)
|
|
{
|
|
|
|
$result = $this->cashbook_model->podata($podata);
|
|
|
|
}
|
|
else
|
|
{
|
|
//echo "update";
|
|
$result3 = $this->cashbook_model->poupdate($podata,$igrlineitem);
|
|
|
|
}
|
|
if($rw == $rowcount)
|
|
{
|
|
echo "Saved Successfully!";
|
|
}
|
|
|
|
|
|
|
|
if($balancetopay==0)
|
|
{
|
|
$igrstatus=AMOUNT_PAIDIGR;
|
|
}
|
|
else
|
|
{
|
|
$igrstatus=PARTIALLY_PAIDIGR;
|
|
}
|
|
$igrdetails=array('BankStatus'=>$igrstatus);
|
|
$result1 = $this->cashbook_model->igrdetailstatus($igrdetails,$igrlineitem);
|
|
//$result1 = $this->cashbook_model->poamountstatus($pomaster,$pono);
|
|
$this->loadViews("bankstatement", $this->global,$data, NULL);
|
|
}
|
|
public function invoiceamount1()
|
|
{
|
|
//$this->global['pageTitle'] = 'Siddharth : Cashbook Listing';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Store Credited Details';
|
|
$check = $this->input->post('check');
|
|
$rw = $this->input->post('rw');
|
|
|
|
$date = $this->input->post('date');
|
|
$date = date_create($date);//,'Y-m-d');
|
|
$date = date_format($date,'Y-m-d');
|
|
$invid = $this->input->post('invid');
|
|
$cname = $this->input->post('cname');
|
|
$invamount = $this->input->post('invamount');
|
|
$invoicereceived = $this->input->post('ir');
|
|
$rowcount = $this->input->post('rc');
|
|
$totalpaidamount= $this->input->post('tpv');
|
|
$bankcreditamount= $this->input->post('bda');
|
|
$invoicetext=$this->input->post('invrec');
|
|
$bankid =$this->input->post('bi');
|
|
$alreadyreceived = 0;
|
|
//echo $earlypaid;
|
|
$alreadyreceived = $this->cashbook_model->getalreadyreceived($bankid);
|
|
if(empty($alreadyreceived))
|
|
{
|
|
$arec=0;
|
|
}
|
|
else
|
|
{
|
|
foreach($alreadyreceived as $ar)
|
|
{
|
|
$arec = $ar->cclearbalance;
|
|
}
|
|
}
|
|
|
|
if($check == 1)
|
|
{
|
|
//echo $arec;
|
|
if($totalpaidamount>0)
|
|
{
|
|
$clearedblnce=($totalpaidamount+$arec);
|
|
}
|
|
else
|
|
{
|
|
//$clearedblnce=-$totalpaidamount-(-$arec);
|
|
$clearedblnce=$totalpaidamount+$arec;
|
|
}
|
|
$balancetoreceived =($bankcreditamount-$totalpaidamount);
|
|
$check =1;
|
|
}
|
|
//echo $balancetocleared;
|
|
//die();
|
|
if($balancetoreceived>0)
|
|
{
|
|
$status='OPEN';
|
|
}
|
|
else
|
|
{
|
|
$status='CLOSE';
|
|
}
|
|
|
|
|
|
$active=1;
|
|
$bankdata = array('cclearbalance'=>$clearedblnce,'cbalancetocleared'=>$balancetoreceived,'cstatus'=>$status);
|
|
|
|
if($check == 1)
|
|
{
|
|
$res = $this->cashbook_model->bankcreditupdate($bankdata,$bankid);
|
|
}
|
|
$earlyreceived = 0;
|
|
//echo $earlypaid;
|
|
$earlyreceived = $this->cashbook_model->getearlyamountcredit($invid);
|
|
if(empty($earlyreceived))
|
|
{
|
|
$eRec=0;
|
|
}
|
|
else
|
|
{
|
|
foreach($earlyreceived as $ec)
|
|
{
|
|
$eRec = $ec->amountreceived;
|
|
}
|
|
}
|
|
//echo $eRec;
|
|
$ip=$this->input->post('ar');
|
|
$balancetoreceived1=($invamount-($ip+$eRec));
|
|
$amtpaid= ($ip+$eRec);
|
|
|
|
$updateamount=($totalpaidamount+$eRec);
|
|
$IsActive=1;
|
|
$invoicedata1 = array('indate'=>$date,'invoiceno'=>$invid,'customername'=>$cname,'totinvoiceamount'=>$invamount,'balancetoreceived'=>$balancetoreceived1,'amountreceived'=>$amtpaid,'bankid'=>$bankid);
|
|
|
|
$invoicedata = array('indate'=>$date,'invoiceno'=>$invid,'customername'=>$cname,'totinvoiceamount'=>$invamount,'balancetoreceived'=>$balancetoreceived1,'amountreceived'=>$ip,'bankid'=>$bankid,'IsActive'=>$IsActive);
|
|
|
|
// //print_r ($invoicedata);
|
|
// //die();
|
|
$result3 = $this->cashbook_model->invoiceupdate($invid);
|
|
$resultn = $this->cashbook_model->mappinginvoice($invoicedata);
|
|
|
|
if(count($result3)<=0)
|
|
{
|
|
//echo "insert";
|
|
$result = $this->cashbook_model->invoicedata($invoicedata1);
|
|
|
|
}
|
|
else
|
|
{
|
|
//echo "update";
|
|
$result3 = $this->cashbook_model->invoiceupdate1($invoicedata1,$invid);
|
|
|
|
}
|
|
if($balancetoreceived1==0)
|
|
{
|
|
$status=AMOUNT_RECEIVED;
|
|
|
|
}
|
|
else
|
|
{
|
|
$status=PARTIALLY_RECEIVED;
|
|
}
|
|
$invoicemaster= array('receivedstatus'=>$status);
|
|
|
|
$result1 = $this->cashbook_model->invoiceamountstatus($invoicemaster,$invid);
|
|
|
|
echo "<script>alert('Saved Successfully!');window.location.href='Bankingstatement';</script>";
|
|
|
|
}
|
|
public function amountpaid()
|
|
{
|
|
|
|
//$this->global['pageTitle'] = 'Siddharth : amountpaid';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Amount Payment Details';
|
|
if ($this->input->post('btn_submit'))
|
|
{
|
|
$SupplierName = $this->input->post('SupplierName');
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
$data['bankdebit'] = $this->cashbook_model->debitpolistfilter($SupplierName,$fdate,$tdate);
|
|
}
|
|
$data['amountpaid'] = $this->cashbook_model->paided();
|
|
$data['supplier'] = $this->cashbook_model->getsupplier();
|
|
$this->loadViews("bankamountpaid", $this->global,$data, NULL);
|
|
|
|
}
|
|
public function amountreceived()
|
|
{
|
|
|
|
|
|
// $this->load->model('cashbook_model');
|
|
//$this->global['pageTitle'] = 'Siddharth : Cashbook Listing';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Received Amount Details';
|
|
if ($this->input->post('btn_submit'))
|
|
{
|
|
$Customer = $this->input->post('Customer');
|
|
$fdate = $this->input->post('from_date');
|
|
$tdate = $this->input->post('to_date');
|
|
|
|
$data['bankcredit'] = $this->cashbook_model->creditinvoicelistfilter($Customer,$fdate,$tdate);
|
|
}
|
|
$data['getcustomer'] = $this->cashbook_model->getcustomer();
|
|
$data['amountreceived'] = $this->cashbook_model->received();
|
|
$this->loadViews("bankamountreceived", $this->global,$data, NULL);
|
|
|
|
}
|
|
public function cashbanking()
|
|
{
|
|
$this->global['pageTitle'] = $this->CompanyName.': Bank Statement(Income and Expenses)';
|
|
$data['dropdownvalues'] = $this->cashbook_model->getAccounTypes();
|
|
//$data['cashbanking'] = $this->cashbook_model->newcashbook();
|
|
$data['getsupplier'] = $this->cashbook_model->getsupplier();
|
|
|
|
$this->loadViews("bankcashnew", $this->global,$data,NULL);
|
|
|
|
}
|
|
public function Deletemappingporeport()
|
|
{
|
|
|
|
$totalamount =$this->input->post('Totalpoamount');
|
|
$Amount = $this->input->post('paidamount');
|
|
$id=$this->input->post('mappingid');
|
|
$igrno = $this->input->post('IGRItemNo');
|
|
$Bankid = $this->input->post('bankid');
|
|
$balancetoclear=$this->input->post('balancetobankingclear');
|
|
$clearedbalance=$this->input->post('clearbalance');
|
|
$updateamount=$clearedbalance-$Amount;
|
|
$updatebalancetoclear=$Amount+$balancetoclear;
|
|
$data['$bankmappingamount'] = $this->cashbook_model->gettotalbankmappingpo($igrno);
|
|
$amountpaid=$data['$bankmappingamount'][0]->Amountpaid;
|
|
//$data['$totallineitemamount']=$this->cashbook_model->gettotallineitem($igrno);
|
|
|
|
if($amountpaid==$totalamount)
|
|
{
|
|
$BankStatus=NO_PAIDIGR;
|
|
}
|
|
else
|
|
{
|
|
$BankStatus=PARTIALLY_PAIDIGR;
|
|
}
|
|
|
|
$result= $this->cashbook_model->IgrDetailsStatusUpdate($igrno,$BankStatus);
|
|
$result1= $this->cashbook_model->deletemapping($Bankid,$updateamount,$updatebalancetoclear);
|
|
//for update mapping amount in t_bankmappingpo table//
|
|
$balancetopay=$this->input->post('balancetopay');
|
|
$totalbalancetopay=$Amount+$balancetopay;
|
|
$updatebankpoamount=$totalamount-$totalbalancetopay;
|
|
//$updateamount=0;
|
|
$IsActive=0;
|
|
$result2= $this->cashbook_model->deleteBankmappingpo($id,$IsActive);
|
|
//for update mapping amount inT_Bankporeport table//
|
|
//die();
|
|
$result3= $this->cashbook_model->updateBankporeportpo($igrno,$totalbalancetopay,$updatebankpoamount,$Bankid);
|
|
$this->loadViews("bankstatement", $this->global,$data, NULL);
|
|
}
|
|
public function Deletemappingpo()
|
|
{
|
|
$totalamount = $_GET['totalpoamount'];
|
|
$Bankid = $_GET['bankid'];
|
|
$Amount = $_GET['amount'];
|
|
$igrno = $_GET['igrno'];
|
|
$balancetoclear=$_GET['balancetoclear'];
|
|
//for T_Bankreport IsActive//
|
|
$bankdebit=$_GET['debit'];
|
|
$mapped= $Amount+$balancetoclear;
|
|
if( $bankdebit==$mapped)
|
|
{
|
|
//$active=0;
|
|
}
|
|
else
|
|
{
|
|
//$active=1;
|
|
}
|
|
|
|
/////////////////
|
|
|
|
$id=$_GET['id'];
|
|
|
|
$bankamount=$_GET['bankamount'];
|
|
$updateamount=$bankamount-$Amount;
|
|
$updatebalancetoclear=$Amount+$balancetoclear;
|
|
$data['$bankmappingamount'] = $this->cashbook_model->gettotalbankmappingpo($igrno);
|
|
$amountpaid=$data['$bankmappingamount'][0]->Amountpaid;
|
|
//if($Amount==)
|
|
|
|
//$data['$totallineitemamount']=$this->cashbook_model->gettotallineitem($igrno);
|
|
|
|
|
|
if($amountpaid==$totalamount)
|
|
{
|
|
$BankStatus=NO_PAIDIGR;
|
|
}
|
|
else
|
|
{
|
|
$BankStatus=PARTIALLY_PAIDIGR;
|
|
}
|
|
|
|
$result= $this->cashbook_model->IgrDetailsStatusUpdate($igrno,$BankStatus);
|
|
$result1= $this->cashbook_model->deletemapping($Bankid,$updateamount,$updatebalancetoclear);
|
|
|
|
//for update mapping amount in t_bankmappingpo table//
|
|
$balancetopay=$_GET['balancetopay'];
|
|
$totalbalancetopay=$Amount + $balancetopay;
|
|
$IsActive=0;
|
|
$updatebankpoamount=$totalamount-$totalbalancetopay;
|
|
$result2= $this->cashbook_model->deleteBankmappingpo($id,$IsActive);
|
|
//for update mapping amount inT_Bankporeport table//
|
|
$result3= $this->cashbook_model->updateBankporeportpo($igrno,$totalbalancetopay,$updatebankpoamount,$Bankid);
|
|
|
|
|
|
if(count($result2)>0)
|
|
{
|
|
redirect('Bankingstatement','refresh');
|
|
}
|
|
|
|
}
|
|
public function deletemappingiv()
|
|
{
|
|
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report - Delete Mapping Invoice';
|
|
$credit= $this->input->post('credit');
|
|
$invoiceno = $this->input->post('invoiceno');
|
|
$bankid = $this->input->post('bankid');
|
|
$mappingid=$this->input->post('mappingid');
|
|
$amountreceived = $this->input->post('amountreceived');
|
|
$bankingclear = $this->input->post('bankingclear');
|
|
$bankingbalclear = $this->input->post('bankingbalclear');
|
|
$totinvoiceamount = $this->input->post('totinvoiceamount');
|
|
$balancetoreceived = $this->input->post('balancetoreceived');
|
|
$updatebalancetoclear=$amountreceived+$bankingbalclear;
|
|
if($amountreceived<0)
|
|
{
|
|
//$updateclearbalance=$bankingclear+$amountreceived;
|
|
$updateclearbalance=$bankingclear-($amountreceived);//450-(-250)
|
|
}
|
|
else
|
|
{
|
|
$updateclearbalance=$bankingclear-$amountreceived;//450-650
|
|
//$updateclearbalance=$bankingclear-$amountreceived;
|
|
}
|
|
|
|
//update Isactive field in T_Bankreport //////
|
|
$mapped=$balancetoreceived+$amountreceived;
|
|
if($credit==$mapped)
|
|
{
|
|
$active=0;
|
|
}
|
|
else
|
|
{
|
|
$active=1;
|
|
}
|
|
$bankstatement=array('cbalancetocleared'=>$updatebalancetoclear,'cclearbalance'=>$updateclearbalance,'IsActive'=>$active);
|
|
$result1= $this->cashbook_model->updatebankreportiv($bankid,$bankstatement);
|
|
if($totinvoiceamount==$amountreceived)
|
|
{
|
|
$receivedstatus=NO_RECEIVED;
|
|
}
|
|
else
|
|
{
|
|
$receivedstatus=PARTIALLY_RECEIVED;
|
|
}
|
|
$IsActive=0;
|
|
//$data['$latestamount'] = $this->cashbook_model->getlatestamount($invoiceno);
|
|
//print_r($data['$latestamount']);
|
|
//die();
|
|
//$balancetoreceived1=$data['$latestamount'][0]->balancetoreceived;
|
|
$updatebalancetoreceived=$balancetoreceived+$amountreceived;
|
|
$updateamountreceived=$totinvoiceamount-$updatebalancetoreceived;
|
|
$result3= $this->cashbook_model->updatebankinvoicereport($invoiceno,$bankid,$updatebalancetoreceived,$updateamountreceived);
|
|
if(count($result3)>0)
|
|
{
|
|
$result1=$this->cashbook_model->UpdateIpinvoiceStatus($invoiceno,$receivedstatus);
|
|
$result2= $this->cashbook_model->deletemappinginvoice($mappingid,$IsActive);
|
|
}
|
|
$this->loadViews("bankstatement", $this->global,$data, NULL);
|
|
|
|
// if(count($result2)>0)
|
|
// {
|
|
// redirect('Bankingstatement','refresh');
|
|
// }
|
|
|
|
}
|
|
|
|
public function Deletemappingcashbook()
|
|
{
|
|
$bankamount=$_GET['bankamount'];
|
|
$Bankid = $_GET['bankid'];
|
|
$Amount = $_GET['amount'];
|
|
$accountname = $_GET['accountname'];
|
|
$id=$_GET['id'];
|
|
$IsActive=0;
|
|
$balancetoclear=$_GET['balancetoclear'];
|
|
$clearbalance =$bankamount-$Amount;
|
|
$updatebankamount= $Amount+$balancetoclear;
|
|
// $data['$accountcode'] = $this->cashbook_model->getaccountcode($accountname);
|
|
// $accountcode=$data['$accountcode'][0]->code;
|
|
$result=$this->cashbook_model->deletecashbookdata($Bankid,$updatebankamount,$clearbalance,$IsActive);
|
|
$result1=$this->cashbook_model->StatusUpadateCashbook($id,$IsActive);
|
|
if(count($result1)>0)
|
|
{
|
|
redirect('Bankingstatement','refresh');
|
|
}
|
|
|
|
}
|
|
public function Deletemappingcashbookcredit()
|
|
{
|
|
$bankamount=$_GET['bankamount'];
|
|
$Bankid = $_GET['bankid'];
|
|
$Amount = $_GET['amount'];
|
|
$accountname = $_GET['accountname'];
|
|
$id=$_GET['id'];
|
|
$IsActive=0;
|
|
$balancetoclear=$_GET['balancetoclear'];
|
|
$clearbalance =$_GET['clearbalance'];
|
|
$updateclearbalance=$clearbalance-$Amount;
|
|
$updatebalancetoclear=$balancetoclear+$Amount;
|
|
// $data['$accountcode'] = $this->cashbook_model->getaccountcode($accountname);
|
|
// $accountcode=$data['$accountcode'][0]->code;
|
|
$result=$this->cashbook_model->deletecashbookdatacredit($Bankid,$updateclearbalance,$updatebalancetoclear);
|
|
$result1=$this->cashbook_model->StatusUpadateCashbook($id,$IsActive);
|
|
if(count($result1)>0)
|
|
{
|
|
// $this->loadViews("Bankingstatement", $this->global,$result1, NULL);
|
|
//echo "<script>alert('Deleted Successfully!');window.location.href='Bankingstatement';</script>";
|
|
redirect('Bankingstatement','refresh');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* To covert number into words
|
|
*/
|
|
public function convertNumber($amt){
|
|
|
|
$ShowPaise='0';
|
|
$totalAmt=explode(".",$amt);
|
|
$number = $totalAmt[0];
|
|
$no = $number;
|
|
|
|
if(!empty($totalAmt[1]) && $totalAmt[1]!=0){
|
|
$point = $totalAmt[1];
|
|
$ShowPaise='1';
|
|
}
|
|
else{
|
|
$point=0;
|
|
$ShowPaise='0';
|
|
}
|
|
|
|
$hundred = null;
|
|
$digits_1 = strlen($no);
|
|
|
|
$i = 0;
|
|
$str = array();
|
|
$words = array('0' => '', '1' => 'One', '2' => 'Two',
|
|
'3' => 'three', '4' => 'Four', '5' => 'Five', '6' => 'Six',
|
|
'7' => 'seven', '8' => 'eight', '9' => 'nine',
|
|
'10' => 'ten', '11' => 'eleven', '12' => 'twelve',
|
|
'13' => 'thirteen', '14' => 'fourteen',
|
|
'15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
|
|
'18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',
|
|
'30' => 'thirty', '40' => 'fourty', '50' => 'fifty',
|
|
'60' => 'sixty', '70' => 'seventy',
|
|
'80' => 'eighty', '90' => 'ninety','06'=>'Zero Six','01'=>'Zero One','02'=>'Zero Two'
|
|
,'03'=>'Zero Three','04'=>'Zero Four','05'=>'Zero Five','07'=>'Zero Seven','08'=>'Zero Eight','09'=>'Zero Nine');
|
|
|
|
$words1 = array('2' => 'twenty',
|
|
'3' => 'thirty', '4' => 'fourty',
|
|
'5' => 'fifty', '6' => 'sixty', '7' => 'seventy',
|
|
'8' => 'eighty', '9' =>'ninety');
|
|
|
|
$words12 = array('11' => 'eleven',
|
|
'12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen',
|
|
'15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
|
|
'18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',);
|
|
|
|
$digits = array('', 'hundred', 'thousand', 'lakh', 'crore');
|
|
|
|
while ($i < $digits_1) {
|
|
$divider = ($i == 2) ? 10 : 100;
|
|
$number = floor($no % $divider);
|
|
$no = floor($no / $divider);
|
|
$i += ($divider == 10) ? 1 : 2;
|
|
if ($number) {
|
|
$plural = (($counter = count($str)) && $number > 1) ? 's' : null;
|
|
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
|
|
$str [] = ($number < 21) ?
|
|
$words[$number] . " " . $digits[$counter] . $plural . " " . $hundred:
|
|
$words[floor($number / 10) * 10]. " " . $words[$number % 10] . " ". $digits[$counter] . $plural . " " . $hundred;
|
|
}
|
|
else $str[] = null;
|
|
|
|
}
|
|
$str = array_reverse($str);
|
|
$result = implode('', $str);
|
|
if($point>=1 && $point<=10)
|
|
{
|
|
$points = ($point) ? " " . $words[$point] : " ";
|
|
}
|
|
else if($point>=11 && $point<=20)
|
|
{
|
|
$points = ($point) ? " " . $words12[$point] : " ";
|
|
}
|
|
else
|
|
{
|
|
$points = ($point) ? " " . $words1[$point / 10] . " " . $words[$point = $point % 10] : '';
|
|
}
|
|
|
|
if($ShowPaise=='0'){
|
|
$amountInWords = "Rupees " . $result." Only";
|
|
}
|
|
else{
|
|
|
|
$amountInWords = "Rupees " . $result ." Paise ". $points." Only";
|
|
}
|
|
|
|
return $amountInWords;
|
|
}
|
|
|
|
/**
|
|
*To get Payment Datas form ajax
|
|
*/
|
|
function ViewPaymentDetails()
|
|
{
|
|
|
|
$paymentid= $this->input->post('id');
|
|
$data = $this->cashbook_model->viewpaymentdetails($paymentid);
|
|
echo json_encode($data);
|
|
|
|
}
|
|
|
|
public function addNewSupplierCash()
|
|
{
|
|
$this->load->model('supplier_model');
|
|
$suppliername = $this->input->post('suppliername');
|
|
$contact = $this->input->post('contact');
|
|
$alternatecont = $this->input->post('alternatecont');
|
|
$email = $this->input->post('email');
|
|
$Address = $this->input->post('Address');
|
|
|
|
$suparray = array('suppliername'=>$suppliername,'Address'=>$Address,'ContactNumber'=>$contact,'AlternateContactNumber'=>$alternatecont,'EmailAddress'=>$email );
|
|
|
|
$result = $this->supplier_model->addNewsupplier($suparray);
|
|
if($result > 0)
|
|
{
|
|
|
|
echo "New Supplier Created successfully!";
|
|
redirect('addnewIncomeExpense','refresh');
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
echo "Supplier Record Not Created!";
|
|
redirect('addnewIncomeExpense','refresh');
|
|
}
|
|
}
|
|
|
|
|
|
public function getAllSupplier()
|
|
{
|
|
$suplist = $this->cashbook_model->getsupplier();
|
|
echo json_encode($suplist);
|
|
}
|
|
|
|
}
|
|
?>
|