<?php

 session_start();
require_once('lib/db_functions.php');  
$output = '';
if( isset($_GET['status']) ){
  $status = $obj->data_filter($_GET['status']); 
  if(!preg_match('/^[0-1]{1}$/', $status)){}
  else
  {
    
    if(isset($_SESSION["company_edit_id"]))
    {
        
      $id=$_SESSION["company_edit_id"];
      $company_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 1 THEN 'Holding Companies'
    WHEN sub_company_type_id = 2 THEN 'Subsidiary Companies'
    WHEN sub_company_type_id = 3 THEN 'Wholly Owned Subidiary Companies'
    WHEN sub_company_type_id = 4 THEN 'Managing Director'
    WHEN sub_company_type_id = 5 THEN 'Whole time directors'
    WHEN sub_company_type_id = 6 THEN 'Director of an Company'
    WHEN sub_company_type_id = 7 THEN 'Relative of directors'
    WHEN sub_company_type_id = 8 THEN 'Partner of directors in any firm (incl. LLP)'
     WHEN sub_company_type_id = 9 THEN 'Firm (incl. LLP) in which director is a partner'
    WHEN sub_company_type_id = 10 THEN 'Firm (incl. LLP) in which relative of director is a partner'
    WHEN sub_company_type_id = 11 THEN 'Private Companies in which director is a director'
    WHEN sub_company_type_id = 12 THEN 'Private Companies in which director is a Member'
    WHEN sub_company_type_id = 13 THEN 'Director of holding company'
    WHEN sub_company_type_id = 14 THEN 'Companies / LLPs wherein director either singly or jointly with other directors of lending company has 25%'
    WHEN sub_company_type_id = 15 THEN 'any directors of lending company'
    WHEN sub_company_type_id = 16 THEN 'Given Loan to'
    WHEN sub_company_type_id = 17 THEN 'Loan Represented as Book debt'
    WHEN sub_company_type_id = 18 THEN 'Guarantee Given in respect of Loan taken by'
    ELSE 'Security Provided to'
END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$id AND (sub_company_type_id=6 OR sub_company_type_id=7 OR sub_company_type_id=8 OR sub_company_type_id=10 OR sub_company_type_id=13)");
                              // echo "<pre>";print_r($company_arr);echo "</pre>";
                             // print_r($company_arr);
                          $loan_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 2 THEN 'Subsidiary Companies'ELSE 'Security Provided to' END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$id AND sub_company_type_id=2");

                            $wholly_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 3 THEN 'Wholly Owned Subidiary Companies'ELSE 'Security Provided to' END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$id AND sub_company_type_id=3");

    $parties_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 1 THEN 'Holding Companies'
    WHEN sub_company_type_id = 2 THEN 'Subsidiary Companies'
    WHEN sub_company_type_id = 3 THEN 'Wholly Owned Subidiary Companies'
    WHEN sub_company_type_id = 4 THEN 'Managing Director'
    WHEN sub_company_type_id = 5 THEN 'Whole time directors'
    WHEN sub_company_type_id = 6 THEN 'Director of an Company'
    WHEN sub_company_type_id = 7 THEN 'Relative of directors'
    WHEN sub_company_type_id = 8 THEN 'Partner of directors in any firm (incl. LLP)'
     WHEN sub_company_type_id = 9 THEN 'Firm (incl. LLP) in which director is a partner'
    WHEN sub_company_type_id = 10 THEN 'Firm (incl. LLP) in which relative of director is a partner'
    WHEN sub_company_type_id = 11 THEN 'Private Companies in which director is a director'
    WHEN sub_company_type_id = 12 THEN 'Private Companies in which director is a Member'
    WHEN sub_company_type_id = 13 THEN 'Director of holding company'
    WHEN sub_company_type_id = 14 THEN 'Companies / LLPs wherein director either singly or jointly with other directors of lending company has 25%'
    WHEN sub_company_type_id = 15 THEN 'any directors of lending company'
    WHEN sub_company_type_id = 16 THEN 'Given Loan to'
    WHEN sub_company_type_id = 17 THEN 'Loan Represented as Book debt'
    WHEN sub_company_type_id = 18 THEN 'Guarantee Given in respect of Loan taken by'
    ELSE 'Security Provided to'
END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$id AND (sub_company_type_id=4 OR sub_company_type_id=5 OR sub_company_type_id=11 OR sub_company_type_id=12 OR sub_company_type_id=14 OR sub_company_type_id=15)");

                             
                               $given_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 1 THEN 'Holding Companies'
    WHEN sub_company_type_id = 2 THEN 'Subsidiary Companies'
    WHEN sub_company_type_id = 3 THEN 'Wholly Owned Subidiary Companies'
    WHEN sub_company_type_id = 4 THEN 'Managing Director'
    WHEN sub_company_type_id = 5 THEN 'Whole time directors'
    WHEN sub_company_type_id = 6 THEN 'Director of an Company'
    WHEN sub_company_type_id = 7 THEN 'Relative of directors'
    WHEN sub_company_type_id = 8 THEN 'Partner of directors in any firm (incl. LLP)'
     WHEN sub_company_type_id = 9 THEN 'Firm (incl. LLP) in which director is a partner'
    WHEN sub_company_type_id = 10 THEN 'Firm (incl. LLP) in which relative of director is a partner'
    WHEN sub_company_type_id = 11 THEN 'Private Companies in which director is a director'
    WHEN sub_company_type_id = 12 THEN 'Private Companies in which director is a Member'
    WHEN sub_company_type_id = 13 THEN 'Director of holding company'
    WHEN sub_company_type_id = 14 THEN 'Companies / LLPs wherein director either singly or jointly with other directors of lending company has 25%'
    WHEN sub_company_type_id = 15 THEN 'any directors of lending company'
    WHEN sub_company_type_id = 16 THEN 'Given Loan to'
    WHEN sub_company_type_id = 17 THEN 'Loan Represented as Book debt'
    WHEN sub_company_type_id = 18 THEN 'Guarantee Given in respect of Loan taken by'
    ELSE 'Security Provided to'
END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$id AND (sub_company_type_id=16 OR sub_company_type_id=17 OR sub_company_type_id=18 OR sub_company_type_id=19)");
                  
    
               $detail=$obj->select( "*","gbca_company_detail_master as gbca RIGHT JOIN gbca_company_master as mas ON gbca.company_detail_name=mas.company_id RIGHT JOIN gbca_section_master as sec ON gbca.section_id=sec.section_id ","company_detail_id= $id ");
          
              $section=$detail[0]["section_name"];
              $company=$detail[0]["company_name"];
              $preparation=date("d F Y");
              $maker=$detail[0]["company_detail_maker_name"];
              $checker=$detail[0]["company_detail_checker_name"];
              $today_date=date('d M Y');
              $date=$detail[0]["company_detail_preparation_date"];
           
              $time=time();              
                  
                  
                    // print_r('applicable');
                
               $detail=$obj->select( "*","gbca_company_detail_master as gbca RIGHT JOIN gbca_company_master as mas ON gbca.company_detail_name=mas.company_id RIGHT JOIN gbca_section_master as sec ON gbca.section_id=sec.section_id ","company_detail_id= $id ");
           
              $section=$detail[0]["section_name"];
              $company=$detail[0]["company_name"];
              $preparation=date("d F Y");
              $maker=$detail[0]["company_detail_maker_name"];
              $checker=$detail[0]["company_detail_checker_name"];
              $today_date=date('d M Y');
              $date=$detail[0]["company_detail_preparation_date"];
           
              $time=time();
                // $res='';
                     $res .='<!DOCTYPE html><html><head><style>table{width:100%;}th, td{padding:10px;}th{background: rgba(20,133,204,0.2);}table, th, td{border: 1px solid black; border-collapse: collapse; text-align:left;}</style></head><body><table style="border:none"><tr style="border:none"> <td style="border:none"><img src="https://gbcacompliance.oneroof.tech/new/assets/img/logo.png" style="height: 70px;" alt="logo"></td><td style="border:none"><h3 style="color:#483D8B;"><u>Report Card for Eligibility Test of Section 185 of the Companies Act, 2013</u></h3></td></tr></table><br/><table style="border:none"><tr style="border:none"><td style="border:none"><b> Company Name: </b>'. $company.'</td><td style="border:none"><b>Preparation Date: </b>'.$date.'</td></tr><tr style="border:none"> <td style="border:none"><b>Made By: </b>'. $maker.'</td><td style="border:none"><b>Checked By: </b>'. $checker.'</td></tr></table><br/>';
               
               
                 $res .='<p>A. List of Parties to whom the company cannot advance any Loan or Provide any Security and Give any guarantee in respect of loan taken by such party</p><table> <tr><th>Sr. No.</th><th>Parties</th><th>Nature of relation</th></tr>';
                 
                  if(is_array($company_arr))
                  {
                      $i = 1;
                  foreach($company_arr as $company1)
                  {
                 
                 $res .='<tr><td>'.$i.'</td><td>'.$company1["sub_company_type_name"].'</td><td>'.$company1["sub_company_name"].'</td></tr>';
                 
                   $i++;
                  }
                  }else
                  {
                    $res .='<tr><td colspan="3" style="text-align:center">No record found.</td></tr>';  
                  }
                 
                 $res .='</table><br/><p>B. List of Parties to whom the company cannot advance any Loan but can Provide any Security or Give any guarantee in respect of loan taken by such party</p><table> <tr><th>Sr. No.</th><th>Parties</th><th>Nature of relation</th></tr>';
                 
                  if(is_array($loan_arr))
                  {
                      $i = 1;
                  foreach($loan_arr as $loan)
                  {
                 
                     $res .='<tr><td>'.$i.'</td><td>'.$loan["sub_company_type_name"].'</td><td>'.$loan["sub_company_name"].'</td></tr>';
                     
                      $i++;
                  }
                  }else
                  {
                    $res .='<tr><td colspan="3" style="text-align:center">No record found.</td></tr>';   
                  }
                     
                    $res .='</table><br/><p>C. List of Parties to whom the company can advance Loan or Provide any Security or Give any guarantee in respect of loan taken by such party without any conditions</p><table><tr><th>Sr. No.</th> <th>Parties</th><th>Nature of relation</th><th>Remark</th></tr>';
                    
                     if(is_array($wholly_arr))
                  {
                      $i = 1;
                  foreach($wholly_arr as $wholly)
                  {
                  
                    
                        $res .='<tr><td>'.$i.'</td><td>'.$wholly["sub_company_type_name"].'</td><td>'.$wholly["sub_company_name"].'</td><td></td></tr>';
                        $i++;
                  }
                  }else
                  {
                     $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
    
                  $res .='</table><br/><p>D. List of Parties to whom the company can advance Loan or Provide any Security or Give any guarantee in respect of loan taken by such party provided certain conditions are met. <br>(If such conditions are not met, the transaction shall be treated as non-compliant)</p><table><tr> <th>Sr. No.</th> <th>Parties</th> <th>Nature of relation</th><th>Condition</th></tr>';
                  
                  if(is_array($parties_arr))
                  {
                      $i = 1;
                  foreach($parties_arr as $parties)
                  {
                   $res .='<tr><td>'.$i.'</td><td>'.$parties["sub_company_type_name"].'</td><td>'.$parties["sub_company_name"].'</td><td></td></tr>';
               
                    $i++;
                  }
                  }
                  else
                  {
                      
                        $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
                  
                      $res .='</table><br/><p>E. List of Parties with whom the company has already undertaken specified transactions which require due attention of the management as the same may either be not in compliance with the provisions or may require to fulfill one or the other condition to comply with the provisions of Sec 185 of the Companies Act, 2013 <br> (unless the borrower is Wholly Owned Subsidiary).</p><table><tr> <th>Sr. No.</th> <th>Parties</th> <th>Nature of relation</th><th>Transaction Type</th></tr>';
                  
                  if(is_array($given_arr))
                  {
                      $i = 1;
                  foreach($given_arr as $given)
                  {
                   $res .='<tr><td>'.$i.'</td><td>'.$given["sub_company_type_name"].'</td><td>'.$given["sub_company_transaction_relation"].'</td><td>'.$given["sub_company_name"].'</td></tr>';
               
                    $i++;
                  }
                  }else
                  {
                      
                        $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
                  
                  $res .='</table></body></html><br/>'; 
		 
		  // $paper = 'A4';
				// $orientation = 'orientation';

				$filename =$company.'_'.$time.'.pdf';
				
    }
    else
    {
        
        $company_detail_id=$_COOKIE["company_detail_id"]; 
    $company_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 1 THEN 'Holding Companies'
    WHEN sub_company_type_id = 2 THEN 'Subsidiary Companies'
    WHEN sub_company_type_id = 3 THEN 'Wholly Owned Subidiary Companies'
    WHEN sub_company_type_id = 4 THEN 'Managing Director'
    WHEN sub_company_type_id = 5 THEN 'Whole time directors'
    WHEN sub_company_type_id = 6 THEN 'Director of an Company'
    WHEN sub_company_type_id = 7 THEN 'Relative of directors'
    WHEN sub_company_type_id = 8 THEN 'Partner of directors in any firm (incl. LLP)'
     WHEN sub_company_type_id = 9 THEN 'Firm (incl. LLP) in which director is a partner'
    WHEN sub_company_type_id = 10 THEN 'Firm (incl. LLP) in which relative of director is a partner'
    WHEN sub_company_type_id = 11 THEN 'Private Companies in which director is a director'
    WHEN sub_company_type_id = 12 THEN 'Private Companies in which director is a Member'
    WHEN sub_company_type_id = 13 THEN 'Director of holding company'
    WHEN sub_company_type_id = 14 THEN 'Companies / LLPs wherein director either singly or jointly with other directors of lending company has 25%'
    WHEN sub_company_type_id = 15 THEN 'any directors of lending company'
    WHEN sub_company_type_id = 16 THEN 'Given Loan to'
    WHEN sub_company_type_id = 17 THEN 'Loan Represented as Book debt'
    WHEN sub_company_type_id = 18 THEN 'Guarantee Given in respect of Loan taken by'
    ELSE 'Security Provided to'
END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$company_detail_id AND (sub_company_type_id=6 OR sub_company_type_id=7 OR sub_company_type_id=8 OR sub_company_type_id=10 OR sub_company_type_id=13)");
                              // echo "<pre>";print_r($company_arr);echo "</pre>";
                             // print_r($company_arr);
                          $loan_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 2 THEN 'Subsidiary Companies'ELSE 'Security Provided to' END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$company_detail_id AND sub_company_type_id=2");

                            $wholly_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 3 THEN 'Wholly Owned Subidiary Companies'ELSE 'Security Provided to' END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$company_detail_id AND sub_company_type_id=3");

    $parties_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 1 THEN 'Holding Companies'
    WHEN sub_company_type_id = 2 THEN 'Subsidiary Companies'
    WHEN sub_company_type_id = 3 THEN 'Wholly Owned Subidiary Companies'
    WHEN sub_company_type_id = 4 THEN 'Managing Director'
    WHEN sub_company_type_id = 5 THEN 'Whole time directors'
    WHEN sub_company_type_id = 6 THEN 'Director of an Company'
    WHEN sub_company_type_id = 7 THEN 'Relative of directors'
    WHEN sub_company_type_id = 8 THEN 'Partner of directors in any firm (incl. LLP)'
     WHEN sub_company_type_id = 9 THEN 'Firm (incl. LLP) in which director is a partner'
    WHEN sub_company_type_id = 10 THEN 'Firm (incl. LLP) in which relative of director is a partner'
    WHEN sub_company_type_id = 11 THEN 'Private Companies in which director is a director'
    WHEN sub_company_type_id = 12 THEN 'Private Companies in which director is a Member'
    WHEN sub_company_type_id = 13 THEN 'Director of holding company'
    WHEN sub_company_type_id = 14 THEN 'Companies / LLPs wherein director either singly or jointly with other directors of lending company has 25%'
    WHEN sub_company_type_id = 15 THEN 'any directors of lending company'
    WHEN sub_company_type_id = 16 THEN 'Given Loan to'
    WHEN sub_company_type_id = 17 THEN 'Loan Represented as Book debt'
    WHEN sub_company_type_id = 18 THEN 'Guarantee Given in respect of Loan taken by'
    ELSE 'Security Provided to'
END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$company_detail_id AND (sub_company_type_id=4 OR sub_company_type_id=5 OR sub_company_type_id=11 OR sub_company_type_id=12 OR sub_company_type_id=14 OR sub_company_type_id=15)");

                             
                               $given_arr = $obj->select("*,CASE
    WHEN sub_company_type_id = 1 THEN 'Holding Companies'
    WHEN sub_company_type_id = 2 THEN 'Subsidiary Companies'
    WHEN sub_company_type_id = 3 THEN 'Wholly Owned Subidiary Companies'
    WHEN sub_company_type_id = 4 THEN 'Managing Director'
    WHEN sub_company_type_id = 5 THEN 'Whole time directors'
    WHEN sub_company_type_id = 6 THEN 'Director of an Company'
    WHEN sub_company_type_id = 7 THEN 'Relative of directors'
    WHEN sub_company_type_id = 8 THEN 'Partner of directors in any firm (incl. LLP)'
     WHEN sub_company_type_id = 9 THEN 'Firm (incl. LLP) in which director is a partner'
    WHEN sub_company_type_id = 10 THEN 'Firm (incl. LLP) in which relative of director is a partner'
    WHEN sub_company_type_id = 11 THEN 'Private Companies in which director is a director'
    WHEN sub_company_type_id = 12 THEN 'Private Companies in which director is a Member'
    WHEN sub_company_type_id = 13 THEN 'Director of holding company'
    WHEN sub_company_type_id = 14 THEN 'Companies / LLPs wherein director either singly or jointly with other directors of lending company has 25%'
    WHEN sub_company_type_id = 15 THEN 'any directors of lending company'
    WHEN sub_company_type_id = 16 THEN 'Given Loan to'
    WHEN sub_company_type_id = 17 THEN 'Loan Represented as Book debt'
    WHEN sub_company_type_id = 18 THEN 'Guarantee Given in respect of Loan taken by'
    ELSE 'Security Provided to'
END as sub_company_name","gbca_sub_company_mapping","company_detail_id=$company_detail_id AND (sub_company_type_id=16 OR sub_company_type_id=17 OR sub_company_type_id=18 OR sub_company_type_id=19)");
                  
     $sub_id=$_COOKIE["company_detail_id"];
               $detail=$obj->select( "*","gbca_company_detail_master as gbca RIGHT JOIN gbca_company_master as mas ON gbca.company_detail_name=mas.company_id RIGHT JOIN gbca_section_master as sec ON gbca.section_id=sec.section_id ","company_detail_id= $sub_id ");
           
              $section=$detail[0]["section_name"];
              $company=$detail[0]["company_name"];
              $preparation=date("d F Y");
              $maker=$detail[0]["company_detail_maker_name"];
              $checker=$detail[0]["company_detail_checker_name"];
              $today_date=date('d M Y');
              $date=$detail[0]["company_detail_preparation_date"];
           
              $time=time();              
                  
                  
                    // print_r('applicable');
                 $sub_id=$_COOKIE["company_detail_id"];
               $detail=$obj->select( "*","gbca_company_detail_master as gbca RIGHT JOIN gbca_company_master as mas ON gbca.company_detail_name=mas.company_id RIGHT JOIN gbca_section_master as sec ON gbca.section_id=sec.section_id ","company_detail_id= $sub_id ");
           
              $section=$detail[0]["section_name"];
              $company=$detail[0]["company_name"];
              $preparation=date("d F Y");
              $maker=$detail[0]["company_detail_maker_name"];
              $checker=$detail[0]["company_detail_checker_name"];
              $today_date=date('d M Y');
              $date=$detail[0]["company_detail_preparation_date"];
           
              $time=time();
                // $res='';
                     $res .='<!DOCTYPE html><html><head><style>table{width:100%;}th, td{padding:10px;}th{background: rgba(20,133,204,0.2);}table, th, td{border: 1px solid black; border-collapse: collapse; text-align:left;}</style></head><body><table style="border:none"><tr style="border:none"> <td style="border:none"><img src="https://gbcacompliance.oneroof.tech/new/assets/img/logo.png" style="height: 70px;" alt="logo"></td><td style="border:none"><h3 style="color:#483D8B;"><u>Report Card for Eligibility Test of Section 185 of the Companies Act, 2013</u></h3></td></tr></table><br/><table style="border:none"><tr style="border:none"><td style="border:none"><b> Company Name: </b>'. $company.'</td><td style="border:none"><b>Preparation Date: </b>'.$date.'</td></tr><tr style="border:none"> <td style="border:none"><b>Made By: </b>'. $maker.'</td><td style="border:none"><b>Checked By: </b>'. $checker.'</td></tr></table><br/>';
               
               
                 $res .='<p>A. List of Parties to whom the company cannot advance any Loan or Provide any Security and Give any guarantee in respect of loan taken by such party</p><table> <tr><th>Sr. No.</th><th>Parties</th><th>Nature of relation</th></tr>';
                 
                  if(is_array($company_arr))
                  {
                      $i = 1;
                  foreach($company_arr as $company1)
                  {
                 
                 $res .='<tr><td>'.$i.'</td><td>'.$company1["sub_company_type_name"].'</td><td>'.$company1["sub_company_name"].'</td></tr>';
                 
                   $i++;
                  }
                  }else
                  {
                    $res .='<tr><td colspan="3" style="text-align:center">No record found.</td></tr>';  
                  }
                 
                 $res .='</table><br/><p>B. List of Parties to whom the company cannot advance any Loan but can Provide any Security or Give any guarantee in respect of loan taken by such party</p><table> <tr><th>Sr. No.</th><th>Parties</th><th>Nature of relation</th></tr>';
                 
                  if(is_array($loan_arr))
                  {
                      $i = 1;
                  foreach($loan_arr as $loan)
                  {
                 
                     $res .='<tr><td>'.$i.'</td><td>'.$loan["sub_company_type_name"].'</td><td>'.$loan["sub_company_name"].'</td></tr>';
                     
                      $i++;
                  }
                  }else
                  {
                    $res .='<tr><td colspan="3" style="text-align:center">No record found.</td></tr>';   
                  }
                     
                    $res .='</table><br/><p>C. List of Parties to whom the company can advance Loan or Provide any Security or Give any guarantee in respect of loan taken by such party without any conditions</p><table><tr><th>Sr. No.</th> <th>Parties</th><th>Nature of relation</th><th>Remark</th></tr>';
                    
                     if(is_array($wholly_arr))
                  {
                      $i = 1;
                  foreach($wholly_arr as $wholly)
                  {
                  
                    
                        $res .='<tr><td>'.$i.'</td><td>'.$wholly["sub_company_type_name"].'</td><td>'.$wholly["sub_company_name"].'</td><td></td></tr>';
                  }
                  }else
                  {
                     $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
    
                  $res .='</table><br/><p>D. List of Parties to whom the company can advance Loan or Provide any Security or Give any guarantee in respect of loan taken by such party provided certain conditions are met. <br>(If such conditions are not met, the transaction shall be treated as non-compliant)</p><table><tr> <th>Sr. No.</th> <th>Parties</th> <th>Nature of relation</th><th>Condition</th></tr>';
                  
                  if(is_array($parties_arr))
                  {
                      $i = 1;
                  foreach($parties_arr as $parties)
                  {
                   $res .='<tr><td>'.$i.'</td><td>'.$parties["sub_company_type_name"].'</td><td>'.$parties["sub_company_name"].'</td><td></td></tr>';
               
                    $i++;
                  }
                  }
                  else
                  {
                      
                        $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
                  
                      $res .='</table><br/><p>E. List of Parties with whom the company has already undertaken specified transactions which require due attention of the management as the same may either be not in compliance with the provisions or may require to fulfill one or the other condition to comply with the provisions of Sec 185 of the Companies Act, 2013 <br> (unless the borrower is Wholly Owned Subsidiary).</p><table><tr> <th>Sr. No.</th> <th>Parties</th> <th>Nature of relation</th><th>Transaction Type</th></tr>';
                  
                  if(is_array($given_arr))
                  {
                      $i = 1;
                  foreach($given_arr as $given)
                  {
                   $res .='<tr><td>'.$i.'</td><td>'.$given["sub_company_type_name"].'</td><td>'.$given["sub_company_transaction_relation"].'</td><td>'.$given["sub_company_name"].'</td></tr>';
               
                    $i++;
                  }
                  }else
                  {
                      
                        $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
                  
                  $res .='</table></body></html><br/>'; 
		 
		  // $paper = 'A4';
				// $orientation = 'orientation';

				$filename =$company.'_'.$time.'.pdf';
				// $dompdf->set_paper($paper,$orientation);
				// $dompdf->load_html($res);
				// $dompdf->render();
				// $output = $dompdf->output();
				// $file_to_save = '../pdffiles/'.$filename;
				// file_put_contents($file_to_save, $output);
				// $file = $file_to_save;
				// $file_size = filesize($file);
				// $handle = fopen($file, "r");
				// $content = fread($handle, $file_size);
				// fclose($handle);
                
               	// $destination_url = '../pdffiles/';
                	
                // $documents = $obj_dba_func->store_pdf($company_detail_id,$filename); 

                
  }
  
  }
} 
else{}  

header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename='.$filename.'.xls');  
header("Pragma: no-cache");  
header("Expires: 0");

// header("Content-Type: application/pdf");
// header("Cache-Control: max-age=0");
// header("Accept-Ranges: none");
// header("Content-Disposition: attachment; filename=\"google_com.pdf\"");   

echo $res; 

function show_contact2($val){
  return ($val == '')?'NA':$val;
}
 
function show_emergency_contact($val){
  return ($val == '')?'NA':$val;
} 

function show_father_name($val){
  return ($val == '')?'NA':$val;
} 

function show_father_phone($val){
  return ($val == '')?'NA':$val;
}  

function show_mother_name($val){
  return ($val == '')?'Na':$val;
} 

function show_mother_phone($val){
  return ($val == '')?'NA':$val;
} 

function show_spouse_name($val){
  return ($val == '')?'NA':$val;
}

function show_spouse_phone($val){
  return ($val == '')?'':$val;
} 

function show_communication_addr($val){
  return ($val == '')?'':$val;
} 

function show_x_doc($val){
  return ($val == '')?'No':'Yes';
} 

function show_xii_doc($val){
  return ($val == '')?'No':'Yes';
} 

function show_transfer_doc($val){
  return ($val == '')?'No':'Yes';
} 

function show_proof($val){
  return ($val == '')?'No':'Yes';
} 

function show_photo($val){
  return ($val == '')?'No':'Yes';
} 

function show_sign($val){
  return ($val == '')?'No':'Yes';
}
?>