		<?php  

		require_once("../lib/db_functions.php");
        // require_once("../pdf_genrator/dompdf/autoload.inc.php");
        // namespace Dompdf;
           require_once 'dompdf/autoload.inc.php';
          use Dompdf\Dompdf;
           $dompdf = new Dompdf();
        // require_once 'adminpanel/dompdf/autoload.inc.php';

		$response = array();  
	     
        $step = $obj->data_filter($_POST['step1']);
         $prev = $obj->data_filter($_POST['prev']);
      
        $company_edit_id = $obj->data_filter($_POST['company_edit_id']);
        
		$type_company     = $obj->data_filter($_POST['company-select']);
		$other            = $obj->data_filter($_POST['other']); 
		$financ_year      = $obj->data_filter($_POST['financ_year']);
		$cut_off             = $obj->data_filter(date("Y-m-d",strtotime($_POST['datepicker'])));
		
		$lending          = $obj->data_filter($_POST['lending']);
		$prevailing       = $obj->data_filter($_POST['prevailing']);
		$borrow_date         = $obj->data_filter(date("Y-m-d",strtotime($_POST['cut'])));
        
		$banks            = $obj->data_filter($_POST['banks']); 
		$nbfc             = $obj->data_filter($_POST['nbfc']);
		$foreign          = $obj->data_filter($_POST['foreign']);
		$indian_comp      = $obj->data_filter($_POST['indian_comp']);
		$llp              = $obj->data_filter($_POST['llp']); 
		$financ_inst      = $obj->data_filter($_POST['financ_inst']);
		$total            = $obj->data_filter($_POST['total']);
  
		$equity           = $obj->data_filter($_POST['equity']);
		$capital          = $obj->data_filter($_POST['capital']);
		$total_cap        = $obj->data_filter($_POST['total_cap']); 
		$twice_cap        = $obj->data_filter($_POST['twice_cap']);
		$repayment        = $obj->data_filter($_POST['repayment']);
		$shareholders     = $obj->data_filter($_POST['share-holding']);
		$specify_sharehold= $obj->data_filter($_POST['specify']);

	 
	if($company_edit_id != "")
	{
	   setcookie($cookie_name, $cookie_value, time() - (60 * 60), "/");
	   
	    $_SESSION["company_edit_id"] = $company_edit_id;
	   
	  if($step==1)
	  {
	     $status='1';
	     $section_arr = $obj_dba_func->set_185('',$company_edit_id,$type_company,$lending,$prevailing,$financ_year,$cut_off,$other,$status);
	  
        if($section_arr['n'] == 1)
		{
			
			
                    // not applicable pdf ;
                   
               $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= $company_edit_id ");
           
              $section=$detail[0]["section_name"];
              $company=trim($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 .='<!DOCTYPE html><html><head> <style>table{width: 100%;}th, td{padding: 10px;}th{background: rgb(37,71,150); color: #fff;}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; text-align: center;"><img src="https://gbcacompliance.oneroof.tech/new/assets/img/logo.png" style="height: 70px;" alt="logo"></td></tr><tr style="border:none"> <td style="border:none"> <h3 style="color:#483D8B; text-align: center;"><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 style="width: 7%;">Sr. No.</th> <th style="width: 42%;">Parties</th> <th style="width: 42%;">Nature of relation</th> </tr>';
                 
                  if(is_array($company_arr))
                  {
                      $i = 1;
                  foreach($company_arr as $company1)
                  {
                 
                 $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 42%;">Parties</th> <th style="width: 42%;">Nature of relation</th> </tr>';
                 
                  if(is_array($loan_arr))
                  {
                      $i = 1;
                  foreach($loan_arr as $loan)
                  {
                 
                     $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Remark</th> </tr>';
                    
                     if(is_array($wholly_arr))
                  {
                      $i = 1;
                  foreach($wholly_arr as $wholly)
                  {
                  
                    
                        $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Condition</th> </tr>';
                  
                  if(is_array($parties_arr))
                  {
                      $i = 1;
                  foreach($parties_arr as $parties)
                  {
                   $res .='<tr><td></td><td></td><td></td><td></td></tr></table></body></html>';
               
                    $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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Transaction Type</th> </tr>';
                  
                  if(is_array($given_arr))
                  {
                      $i = 1;
                  foreach($given_arr as $given)
                  {
                   $res .='<tr><td>'.$i.'</td><td></td><td></td><td></td></tr></table></body></html>';
               
                    $i++;
                  }
                  }else
                  {
                      
                        $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
                  
                  $res .='</table><br/>'; 
		         $paper = 'A4';
				$orientation = 'orientation';
                $company= str_replace(" ","_",$company);
				$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_edit_id,$filename);
                
                   $response['n']   = 3;
					$response['msg'] = "not applicable";
                // not applicable pdf end  ; 
		
		
		
	   }
	   else
	   {
	     
			$response['n']   = 0;
			$response['msg'] = "step1 success";   
	   }
	  }
	  else if($step==2)
	  {
	       $status='1';
	    $update_adm = $obj_dba_func->set_borrowing('',$company_edit_id,$banks,$nbfc,$financ_inst,$indian_comp,$llp,$foreign,$total,$equity,$capital,$total_cap,$twice_cap,$repayment,$shareholders,$specify_sharehold,$status);
         
	 	   if($update_adm['n'] == 1)
		{    
	
                  
               $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= $company_edit_id ");
           
              $section=$detail[0]["section_name"];
              $company=trim($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 .='<!DOCTYPE html><html><head> <style>table{width: 100%;}th, td{padding: 10px;}th{background: rgb(37,71,150); color: #fff;}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; text-align: center;"><img src="https://gbcacompliance.oneroof.tech/new/assets/img/logo.png" style="height: 70px;" alt="logo"></td></tr><tr style="border:none"> <td style="border:none"> <h3 style="color:#483D8B; text-align: center;"><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 style="width: 7%;">Sr. No.</th> <th style="width: 42%;">Parties</th> <th style="width: 42%;">Nature of relation</th> </tr>';
                 
                  if(is_array($company_arr))
                  {
                      $i = 1;
                  foreach($company_arr as $company1)
                  {
                 
                 $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 42%;">Parties</th> <th style="width: 42%;">Nature of relation</th> </tr>';
                 
                  if(is_array($loan_arr))
                  {
                      $i = 1;
                  foreach($loan_arr as $loan)
                  {
                 
                     $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Remark</th> </tr>';
                    
                     if(is_array($wholly_arr))
                  {
                      $i = 1;
                  foreach($wholly_arr as $wholly)
                  {
                  
                    
                        $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Condition</th> </tr>';
                  
                  if(is_array($parties_arr))
                  {
                      $i = 1;
                  foreach($parties_arr as $parties)
                  {
                   $res .='<tr><td></td><td></td><td></td><td></td></tr></table></body></html>';
               
                    $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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Transaction Type</th> </tr>';
                  
                  if(is_array($given_arr))
                  {
                      $i = 1;
                  foreach($given_arr as $given)
                  {
                   $res .='<tr><td>'.$i.'</td><td></td><td></td><td></td></tr></table></body></html>';
               
                    $i++;
                  }
                  }else
                  {
                      
                        $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
                  
                  $res .='</table><br/>'; 
		         $paper = 'A4';
				$orientation = 'orientation';
                $company= str_replace(" ","_",$company);
				$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_edit_id,$filename);
                
                   $response['n']   = 3;
					$response['msg'] = "not applicable";
                // not applicable pdf end  ; 
		
		}
		else
		{
           $response['n']   = 0;
		   $response['msg'] = "step2 success";  
		}
	  }

	
  }
  
	else
	{
	 
	  	if(isset($_COOKIE["company_detail_id"]))
	{
	   if($step==1)
	   {
	       unset($_SESSION["company_edit_id"]);
	      $company_detail_id=$_COOKIE["company_detail_id"];
	      $status='1';
		$section_arr = $obj_dba_func->set_185($company_detail_id,'',$type_company,$lending,$prevailing,$financ_year,$cut_off,$other,$status);
     	
     
        if($section_arr['n'] == 1)
		{
			
		    
                    // not applicable pdf ;
                     $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=trim($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 .='<!DOCTYPE html><html><head> <style>table{width: 100%;}th, td{padding: 10px;}th{background: rgb(37,71,150); color: #fff;}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; text-align: center;"><img src="https://gbcacompliance.oneroof.tech/new/assets/img/logo.png" style="height: 70px;" alt="logo"></td></tr><tr style="border:none"> <td style="border:none"> <h3 style="color:#483D8B; text-align: center;"><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 style="width: 7%;">Sr. No.</th> <th style="width: 42%;">Parties</th> <th style="width: 42%;">Nature of relation</th> </tr>';
                 
                  if(is_array($company_arr))
                  {
                      $i = 1;
                  foreach($company_arr as $company1)
                  {
                 
                 $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 42%;">Parties</th> <th style="width: 42%;">Nature of relation</th> </tr>';
                 
                  if(is_array($loan_arr))
                  {
                      $i = 1;
                  foreach($loan_arr as $loan)
                  {
                 
                     $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Remark</th> </tr>';
                    
                     if(is_array($wholly_arr))
                  {
                      $i = 1;
                  foreach($wholly_arr as $wholly)
                  {
                  
                    
                        $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Condition</th> </tr>';
                  
                  if(is_array($parties_arr))
                  {
                      $i = 1;
                  foreach($parties_arr as $parties)
                  {
                   $res .='<tr><td></td><td></td><td></td><td></td></tr></table></body></html>';
               
                    $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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Transaction Type</th> </tr>';
                  
                  if(is_array($given_arr))
                  {
                      $i = 1;
                  foreach($given_arr as $given)
                  {
                   $res .='<tr><td>'.$i.'</td><td></td><td></td><td></td></tr></table></body></html>';
               
                    $i++;
                  }
                  }else
                  {
                      
                        $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
                  
                  $res .='</table><br/>'; 
		         $paper = 'A4';
				$orientation = 'orientation';
                $company= str_replace(" ","_",$company);
				$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);
                
                   $response['n']   = 3;
					$response['msg'] = "not applicable";
                // not applicable pdf end  ; 
		
		
		}
		else
		{
		 	$response['n']   = 0;
			$response['msg'] = $section_arr['msg'];   
		}
	   
	  }
	   else if($step==2)
	   {
	         $company_detail_id=$_COOKIE["company_detail_id"];
	         $status='1';
	      $update_adm = $obj_dba_func->set_borrowing($company_detail_id,'',$banks,$nbfc,$financ_inst,$indian_comp,$llp,$foreign,$total,$equity,$capital,$total_cap,$twice_cap,$repayment,$shareholders,$specify_sharehold,$status);
           
      
         
	 	   if($update_adm['n'] == 1)
		  {
		     
          	
		    
                    // not applicable pdf ;
                     $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=trim($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 .='<!DOCTYPE html><html><head> <style>table{width: 100%;}th, td{padding: 10px;}th{background: rgb(37,71,150); color: #fff;}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; text-align: center;"><img src="https://gbcacompliance.oneroof.tech/new/assets/img/logo.png" style="height: 70px;" alt="logo"></td></tr><tr style="border:none"> <td style="border:none"> <h3 style="color:#483D8B; text-align: center;"><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 style="width: 7%;">Sr. No.</th> <th style="width: 42%;">Parties</th> <th style="width: 42%;">Nature of relation</th> </tr>';
                 
                  if(is_array($company_arr))
                  {
                      $i = 1;
                  foreach($company_arr as $company1)
                  {
                 
                 $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 42%;">Parties</th> <th style="width: 42%;">Nature of relation</th> </tr>';
                 
                  if(is_array($loan_arr))
                  {
                      $i = 1;
                  foreach($loan_arr as $loan)
                  {
                 
                     $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Remark</th> </tr>';
                    
                     if(is_array($wholly_arr))
                  {
                      $i = 1;
                  foreach($wholly_arr as $wholly)
                  {
                  
                    
                        $res .='<tr><td></td><td></td><td></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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Condition</th> </tr>';
                  
                  if(is_array($parties_arr))
                  {
                      $i = 1;
                  foreach($parties_arr as $parties)
                  {
                   $res .='<tr><td></td><td></td><td></td><td></td></tr></table></body></html>';
               
                    $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 style="width: 7%;">Sr. No.</th> <th style="width: 39%;">Parties</th> <th style="width: 39%;">Nature of relation</th> <th style="width: 15%;">Transaction Type</th> </tr>';
                  
                  if(is_array($given_arr))
                  {
                      $i = 1;
                  foreach($given_arr as $given)
                  {
                   $res .='<tr><td>'.$i.'</td><td></td><td></td><td></td></tr></table></body></html>';
               
                    $i++;
                  }
                  }else
                  {
                      
                        $res .='<tr><td  colspan="4" style="text-align:center">No record found.</td></tr>';    
                  }
                  
                  $res .='</table><br/>'; 
		         $paper = 'A4';
				$orientation = 'orientation';
                $company= str_replace(" ","_",$company);
				$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);
                
                   $response['n']   = 3;
					$response['msg'] = "not applicable";
                // not applicable pdf end  ; 
		
             
		  }
		  else
		  {
		    $response['n']   = 0;
			$response['msg'] =  $update_adm['msg']; 
		  }
	   }
	  

}
		 
	else
	{
		
			$response['n']   = 0;
			$response['msg'] ="COOKIES NOT SET";
		
	}  
	}

		//setcookie("company_detail_id", "", time()-3600);

  

	echo json_encode($response);
	?>