<?php
	include_once('../config.php'); 
	require(ABS_PATH.'/dashboard/fpdf/fpdf.php');
	
	
	     
                    
            $stmt=$conn->prepare("select *  from  moneytransfer  where  DebitCredit_id=:DebitCredit_id    ");   
            $stmt->bindValue(':DebitCredit_id',   $_REQUEST['id'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $DebitCredit_id = $stmt->fetch(PDO::FETCH_OBJ); 
            
            
           
            
            $stmt=$conn->prepare("select  *   from  UI__Receipt where cdId =:cdId ");   
            $stmt->bindValue(':cdId', $_REQUEST['id'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $FResult = $stmt->fetch(PDO::FETCH_OBJ); 
            
           
            
            $stmt=$conn->prepare("select  *   from   UI__Rgst  where cuurentId =:custId ");   
            $stmt->bindValue(':custId', $_SESSION['userId'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ); 
             
             
            
            $stmt=$conn->prepare("select   custId from   UI__DebitCredit  where id =:custId ");   
            $stmt->bindValue(':custId', $_REQUEST['id'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $custId = $stmt->fetch(PDO::FETCH_OBJ);       
            
            
            if($DebitCredit_id->pay2All2==1) 
            {
            
            $stmt=$conn->prepare("select  *  from  UI__TxnFailUsersPay2 where cdId =:cdId ");   
            $stmt->bindValue(':cdId', $_REQUEST['id'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $acceptStats = $stmt->fetch(PDO::FETCH_OBJ); 
            }else
            {
         
                $stmt=$conn->prepare("select  *  from  UI__TxnFailUsers where cdId =:cdId ");   
                $stmt->bindValue(':cdId', $_REQUEST['id'] , PDO::PARAM_STR);  
                $stmt->execute(); 
                $acceptStats = $stmt->fetch(PDO::FETCH_OBJ); 
                

            }
            
            
            $stmt=$conn->prepare("select dailyMonthly  from UI__Rgst  where  cuurentId=:custId    ");   
            $stmt->bindValue(':custId',  $_SESSION['userId'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $dailyMonthly = $stmt->fetch(PDO::FETCH_OBJ); 
            
            $accountSet = 0;  
            if($dailyMonthly->dailyMonthly==1)
                $accountSet = 1; 
                    
                    $Payment_Type = "Money Transfer";	
                    $Bank = "Bank Transfer";
                    
                    $stmt=$conn->prepare("select  status from  UI__TxnFailUsers  where cdId=:cdId ");   
                    $stmt->bindValue(':cdId',  ($_REQUEST['id']) , PDO::PARAM_STR);  
                    $stmt->execute(); 	 
                    $UI__TxnFailUsers = $stmt->fetch(PDO::FETCH_OBJ);
                    
                    
                    
                    $stmt=$conn->prepare("select  addDel from  UI__DebitCredit where id =:id ");   
                    $stmt->bindValue(':id',  ($_REQUEST['id']-1) , PDO::PARAM_STR);  
                    $stmt->execute(); 	
                    $UI__DebitCredit = $stmt->fetch(PDO::FETCH_OBJ);
                    $tpaid= $UI__DebitCredit->addDel;
                    
                    $stmt=$conn->prepare("select  byw from  UI__DebitCredit where id =:id ");   
                    $stmt->bindValue(':id',  $_REQUEST['id'] , PDO::PARAM_STR);  
                    $stmt->execute(); 
                    if($stmt->rowCount()>0)   
                    {
                    $nmSelect = $stmt->fetch(PDO::FETCH_OBJ);
                    $receiver = $nmSelect->byw;
                    
                    /*$stmt=$conn->prepare("select  nm  from  UI__Rgst where cuurentId =:cuurentId ");   
                    $stmt->bindValue(':cuurentId', $nmSelect->custId , PDO::PARAM_STR);  
                    $stmt->execute();  
                    $nmSelect = $stmt->fetch(PDO::FETCH_OBJ);  
                    $receiver = $nmSelect->nm;*/
                    }else
                    $receiver = ""; 
                    
                    if($UI__TxnFailUsers->status==0)  
                        $staus = "Processing";
                    else $staus = "Successful";    
         
     
      {
            class PDF extends FPDF
            {
                // Page header
                function Header()
                {
                    $this->SetFont('Arial','B',13);
                    // Move to the right
                   // $this->Cell(50);
                    // Title
                    
                    
                    $this->Cell(130,10,'Payment Receipt',3,1,'C');
                    // Line break
                    $this->Ln(10);
                }
            }
        	$pdf = new PDF();
        	
        	//$pdf = new FPDF();	
        	$pdf->AddPage();
        	$pdf->SetFont('Arial','',10);
        
            
            
            
            $pdf->Cell(75,10,'Payment Type', 1,0);
            $pdf->Cell(75,10,$Payment_Type, 1,1);
        
            
            $pdf->Cell(75,10,'Bank', 1,0);
            $pdf->Cell(75,10,$Bank, 1,1);
         
         
         
            $pdf->Cell(75,10,'To', 1,0);
            $pdf->Cell(75,10,$FResult->Topay, 1,1);
            
            $pdf->Cell(75,10,'Receiver', 1,0);
            $pdf->Cell(75,10,$receiver, 1,1);
            
            $stmt=$conn->prepare("select byw  from  UI__DebitCredit where id =:id ");   
            $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $nmSelect = $stmt->fetch(PDO::FETCH_OBJ);    
             
            
            
            $pdf->Cell(75,10,'By UserId', 1,0);
            $pdf->Cell(75,10, $nmSelect->byw, 1,1);
            
            $pdf->Cell(75,10,'By Name', 1,0);
            $pdf->Cell(75,10,$UI__Rgst->nm, 1,1);
            
            $pdf->Cell(75,10,'Deduction', 1,0);
            $pdf->Cell(75,10,$tpaid, 1,1);
            
            $pdf->Cell(75,10,'Amount Paid', 1,0);
            $pdf->Cell(75,10,$FResult->amountPaid, 1,1);
            
            $pdf->Cell(75,10,'UTR', 1,0);
            $pdf->Cell(75,10,'XXXX', 1,1);
            
            $pdf->Cell(75,10,'Satus', 1,0);
            $pdf->Cell(75,10,$staus, 1,1);
            
             $pdf->Cell(75,10,'Date', 1,0);
            $pdf->Cell(75,10,$FResult->Tdate, 1,1);
            
            

        	$pdf->Ln();
            $pdf->Output();
            
        }   