
<?php include 'includes/header.php';
require_once("lib/helper.php"); ?>
<style>
  .form-anf-modal .close-btn{
        padding: 6px 30px;
  }
 .warning-div h6{
     color: #721c24;
    /*background-color: #f8d7da;*/
    border-color: #f5c6cb;
    padding: 15px;
    width: 100%;
    text-transform: inherit !important;
    text-align: right;
    
 }
 #warning {
    font-size: 14px!important;
    margin-left: 0% !important;
    color: #721c24!important;
}
</style>
<script type="text/javascript" src="https://unpkg.com/xlsx@0.15.1/dist/xlsx.full.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<body>

 
<div id="wrapper" class="active">  
      <!-- Sidebar -->
      <?php include 'includes/sidebar.php'; ?>
     <div id="page-content-wrapper">
        <div class="page-content inset">         
        <div class="main">
 <div class="heading-banner">
  <div class="card-header card-header-warning">
   <div class="row captured-data">
     <input type="hidden" id="company_detail_id" name="company_detail_id" value="<?php if(isset($_GET['company_detail_id'])){ echo $_GET['company_detail_id']; } ?>">
     <?php
     $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= '$id'");

        if(isset($_GET['company_detail_id']))
        {
        $company_detail_id=$_GET['company_detail_id'];
              // $resource=$obj->select("*","resource","resource_id='$resource_id'");
        //print_r($company_detail_id);
        $company_detail= $obj->select("*,date_format(str_to_date(company_detail_preparation_date, '%Y-%m-%d'),' %d %M %Y') as preparation_date,date_format(str_to_date(company_detail_cutoff_date, '%Y-%m-%d'),' %m %d %Y') as cutt_off_date","gbca_company_detail_master as gcdm inner join gbca_company_master as gcm on gcdm.company_detail_name = gcm.company_id inner join gbca_section_master as gsm on gcdm.section_id = gsm.section_id ","company_detail_id ='$company_detail_id'");
       //print_r($company_detail);
        $list_of_concern = $obj->select("*","gbca_company_shareholding_master","gbca_company_shareholding_company_id = $company_detail_id and gbca_company_shareholding_status='1' AND gbca_company_shareholding_excel_type='1'");
       // echo "<pre>";print_r($list_of_concern);echo "</pre>";
        $type_of_concern= $obj->select("*","gbca_company_shareholding_master","gbca_company_shareholding_company_id = '$company_detail_id' and gbca_company_shareholding_status='1' AND gbca_company_shareholding_excel_type='2'");
          }  
          ?>
     <div class="col-md-12">
       <h1>
       <?php if(isset($_GET['company_detail_id']))
        {
         echo "Company Name: " .$company_detail[0]['company_name'];  
        }
        else
        {
        echo "Company Name: " .$detail[0]['company_name'];
        }
        ?></h1>
     </div>
     <div class="col-md-6">
       <h5>
        <?php if(isset($_GET['company_detail_id']))
        {
           echo "Section: ".$company_detail[0]['section_name'];  
        }
        else
        {
          
          echo "Section: ".$detail[0]['section_name'];
        }
        ?>
       </h5>
     </div>
     <div class="col-md-6">
       <h5>
        <?php if(isset($_GET['company_detail_id']))
        {
          echo "Date: ".$company_detail[0]['preparation_date'];  
        }
        else
        {
        
        echo "Date: ". date('d F Y');
      }
      ?></h5>
     </div>
     <div class="col-md-6">
       <h5>
        <?php if(isset($_GET['company_detail_id']))
        {
          echo "Made By: ".$company_detail[0]['company_detail_maker_name'];  
        }
        else
        {
          echo "Made By: ".$detail[0]['company_detail_maker_name'];
        }
        ?></h5>
     </div>
     <div class="col-md-6">
       <h5>
        <?php if(isset($_GET['company_detail_id']))
        {
          echo "Checked By: ".$company_detail[0]['company_detail_checker_name'];  
        }
        else
        { 
        echo "Checked By: ".$detail[0]['company_detail_checker_name'];
      }
      ?></h5>
     </div>
   </div>
 </div>
 </div>
 <!-- End Navbar -->
 
 <div class="content wizard-formdiv">
   <div class="container-fluid2">
 
     <div class="row">
       <div class="col-md-12">
        <div class="card">
         <div class="card-body">
           <div class="alert alert-danger errmsg text-center" style="display: none;"></div>  
          <!--<form id="regForm" action="">-->
 
           <div class="tab">
            <input type=hidden id="step" class="step"  value="1">
             <div class="row">
               <div class="col-md-6">
                 <h5 class="form-headings">Basic Details:</h5>
               </div>
             </div>
             <div class="row">
               <div class="col-md-6">
                 <label for="company-name">Type of Company <span class="mandatory-star">*</span></label>
                 <select id="company-select" class="js-states form-control">
                  <option value="">Select</option>
                  <?php
                  if(isset($_GET['company_detail_id']))
                  { 
                   foreach($company_detail as $company_type)
                   {
                    ?> 
                   <option value="private-company"<?=$company_type['company_type_name'] == 'private-company' ? ' selected="selected"' : '';?>>Private Company</option>                  
                   <option value="listed"<?=$company_type['company_type_name'] == 'listed' ? ' selected="selected"' : '';?>>Listed Company</option>                  
                   <option value="public-company"<?=$company_type['company_type_name'] == 'public-company' ? ' selected="selected"' : '';?>>Unlisted Public Company</option>             
                   <option value="gov"<?=$company_type['company_type_name'] == 'gov' ? ' selected="selected"' : '';?>>Government Company (E.g. PSU's)</option>                  
                   <option value="nidhi"<?=$company_type['company_type_name'] == 'nidhi' ? ' selected="selected"' : '';?>>Nidhi Company</option> 
                   <option value="foreign"<?=$company_type['company_type_name'] == 'foreign' ? ' selected="selected"' : '';?>>Foreign Company (incl. Branches and Liasion Office)</option>
                   <option value="non-banking"<?=$company_type['company_type_name'] == 'non-banking' ? ' selected="selected"' : '';?>>Non-Banking Finance Company</option>                 
                   <option value="banking"<?=$company_type['company_type_name'] == 'banking' ? ' selected="selected"' : '';?>>Banking Company</option>                 
                   <option value="non-profit"<?=$company_type['company_type_name'] == 'non-profit' ? ' selected="selected"' : '';?>>Not for Profit Organisation </option>                 
                   <option value="others"<?=$company_type['company_type_name'] == 'others' ? ' selected="selected"' : '';?>>Others</option>
                   <?php
                       }
                     }
                     else
                     {
                      ?>                 
                   <option value="private-company">Private Company</option>                  
                   <option value="listed">Listed Company</option>                  
                   <option value="public-company">Unlisted Public Company</option>             
                   <option value="gov">Government Company (E.g. PSU's)</option>                  
                   <option value="nidhi">Nidhi Company</option> 
                   <option value="foreign">Foreign Company (incl. Branches and Liasion Office)</option>
                   <option value="non-banking">Non-Banking Finance Company</option>                 
                   <option value="banking">Banking Company</option>                 
                   <option value="non-profit">Not for Profit Organisation </option>                 
                   <option value="others">Others</option> 
                   <?php
                     }
                     ?>                  
                 </select>
                 <span class="span_err" id="company-select_err"></span>
               </div>
 
             <!-- </div>
             <div class="row"> -->
             <div class="col-md-6" style="display: none" id="private-div-show">
             <label for="name">Whether the company can be treated as "company in which the public are substantially interested</label>
               <select id="substantial_interest">                
                 <option value=" ">Select</option>
                 <?php
                   if(isset($_GET['company_detail_id'])) 
                   {
                   foreach($company_detail as $substantially_interested)
                   {
                    ?>
                   <option value="Yes"<?=$substantially_interested['company_detail_substantially_interested'] == 'Yes' ? ' selected="selected"' : '';?>>Yes</option>
                   <option value="No"<?=$substantially_interested['company_detail_substantially_interested'] == 'No' ? ' selected="selected"' : '';?>>No</option>
                   <?php
                   }
                 }
                 else
                 {
                  ?>
                  <option value="Yes">Yes</option>
                  <option value="No">No</option>        
                 <?php
                 }
                 ?>                
               </select>
               <a href="#" class="i-btn" data-toggle="modal" data-target="#i-modal"><i class="fa fa-info-circle" aria-hidden="true"></i></a>
               <span class="span_err" id="substantial_interest_err"></span>
           </div>
               <div class="col-md-6" style="display: none" id="hidden-input">
                 <label for="company-name">Other Company Name <span class="mandatory-star">*</span></label>
                 <input type="text" id="other_company_name" value="<?php if(isset($_GET['company_detail_id'])) 
                              {
                               echo $company_detail[0]['company_detail_other_company_name'];  
                              }
                             ?>">
               </div>
             </div>
             <div class="row">
               <div class="col-md-6">
                 <label for="name">Financial Year <span class="mandatory-star">*</span></label>
                 <select id="finan-year" class="js-states form-control" >                
                   <option value="">Select</option>
                   <?php
                         for ($i = 2016; $i <= 2036; $i++)
                         {
                          $year = ($i - 1) . "-" . $i;
                          if(isset($_GET['company_detail_id']))
                          {
                          foreach($company_detail as $financial_year)
                           {
                            ?>   
                          <option value="<?php echo $year; ?>"<?=$financial_year['company_detail_financial_year'] == $year ? ' selected="selected"' : '';?>><?php echo $year; ?></option>
                          <?php 
                        } 
                      }
                      else
                      {
                      ?>
                      <option value="<?php echo $year; ?>"><?php echo $year; ?></option>
                      <?php
                    }
                     }
                      ?>
                 </select>
                 <span class="span_err" id="finan-year_err"></span>
               </div>
               <div class="col-md-6 pr7">
                 <label for="company-name">Cut-off Date for Checking the Compliance <span class="mandatory-star">*</span></label>
                 <input type="date" id="date" name="date" value="<?php if(isset($_GET['company_detail_id']))
                              {
                               echo $company_detail[0]['company_detail_cutoff_date'];  
                              }
                             ?>">
                              <span class="span_err" id="date_err"></span>
               </div>
             </div>
             <!-- <div class="row">
                <div class="col-md-6 pr7">
                    <label for="prep-date">Date of preparation of Checklist <span class="mandatory-star">*</span></label>
                    <input type="date" id="date" name="date">
                </div>
                <div class="col-md-6">
                 <label for="company-name">Name of Maker <span class="mandatory-star">*</span></label>
                 <input type="text">
               </div>
               <div class="col-md-6">
                 <label for="company-name">Name of Checker <span class="mandatory-star">*</span></label>
                 <input type="text">
               </div>
             </div> -->
 
           </div>
           <div class="tab">
            <div class="row">
             <div class="col-md-6">
               <h5 class="form-headings">Shareholding Details</h5>
             </div>
           </div>
           <div class="row">
             <div class="col-md-6">
               <label for="name">List of equity shareholders in the company as on the cut-off date <span class="mandatory-star">*</span></label>
               <input type="file"  id="excel_file"  name="filename" value="upload" accept=".xlsx, .xls, .csv">
                <span class="span_err" id="excel_file_err"></span>
             </div> 
             <div class="col-md-6">
              <a class="am-btn pull-right" href="excel_templates/Shareholding_Details_Template.xlsx" id="export_button"><i class="fa fa-file-excel-o" aria-hidden="true"></i> Export</a>
             </div> 
             <div class="col-md-5">
                <label for="name">Name of Shareholder</label>
                <input type="text" id="name_of_shareholder" name="name_of_shareholder" class="txtOnly" >
                <span class="span_err" id="name_of_shareholder_err"></span>
              </div>
             <div class="col-md-5">
                <label for="name">Shareholding %</label>
                <input type="text" id="shareholding_per" maxlength="3" name="shareholding_per"class="numbers" >
                <span class="span_err" id="shareholding_per_err"></span>
              </div>
              <div class="col-md-2">
                <a href="#" class="accord-ambtn btn2" onclick="addData();">
                Add </a>
              </div>
             <div class="col-md-12">

             <div class="float table-responsive dash-table-stats"> 
 <table class="table table-bordered table-hover display" id="shareholding_details_table">
  <thead class="thead-dark">
  <tr>
    
                  <!-- <th scope="col">Sr. No</th> -->
									<th scope="col" id="Name_Of_Shareholder" >Name Of Shareholder</th>
									<th scope="col" id="Shareholding_In_Percentage">Shareholding In Percentage</th>
									<th></th>
									<th></th>
								</tr>
              </thead>
              <tbody>	
      </tbody>
      </table>
<div class="tb-div">
<h5 class="total-value">Total: <b><span id="area_total"></span></b></h5>
</div>
<div class="warning-div"><h6 class="warning"><b><span id="warning"></span></b></h6></div>
</div>  
						
            </div>        
           </div>
         </div>
         <div class="tab">
 
         <div class="row">
             <div class="col-md-6">
               <h5 class="form-headings">Details of Concerns</h5>
               <a href="#" class="i-btn i-two" data-toggle="modal" data-target="#i-modal2"><i class="fa fa-info-circle" aria-hidden="true"></i></a>
             </div>
           </div>
           <div class="row">
           <div class="col-md-6">
               <label for="name">List of equity shareholders in the company as on the cut-off date <span class="mandatory-star">*</span></label>
               <input type="file" name="excel_file_2" id="excel_file_2" accept=".xlsx, .xls, .csv">
             </div> 
             <div class="col-md-6">
              <a class="am-btn pull-right" href="excel_templates/Concern_Details_Template.xlsx" id="export_button2"><i class="fa fa-file-excel-o" aria-hidden="true"></i> Export</a>
             </div> 
            
             <div class="col-md-12 mt-4">
             
             <div class="float table-responsive dash-table-stats"> 
 <table class="table table-bordered table-hover display" id="type_of_concern_table">
  <thead class="thead-dark">
  <tr>
                  <!-- <th scope="col">Sr. No</th> -->
									<th scope="col" id="Names_Of_Shareholders_Of_Company">Names Of Shareholders Of Company</th>
									<th scope="col" id="Name_Of_Concern">Name Of Concern<a href="#" class="i-three" data-toggle="modal" data-target="#i-modal3"><i class="fa fa-info-circle" aria-hidden="true"></i></a>
                  </th>
									<th scope="col" id="Type_Of_Concern">Type Of Concern</th>
									<th scope="col" id="Shareholding">Shareholding/Voting Power</th>
									<th></th>
									<th></th>
								</tr>
              </thead>
              <tbody>	
               

          </tbody>
          </table>
<!-- <div class="table-footer">
  <p>Showing 1 to 10 of 10 entries</p>
  <ul class="pagination">
   <li><a href="#" class="prev">< Prev</a></li>
   <li class="pageNumber active"><a href="#">1</a></li>
   <li class="pageNumber"><a href="#">2</a></li>
   <li class="pageNumber"><a href="#">3</a></li>
   <li class="pageNumber"><a href="#">4</a></li>
   <li class="pageNumber"><a href="#">5</a></li>
   <li class="pageNumber"><a href="#">6</a></li>
   <li><a href="#" class="next">Next ></a></li>
 </ul>
</div> -->
</div>  
<div id="tempTable" style="display:none"></div>
<div id="tempTable1" style="display:none"></div>

            </div>        
           </div>

 
      </div>
 
  
 
 <div class="buttons-section">
 <div class="step-titles pull-left">
           
              <span class="step"><p>Step 1</p></span>
             <span class="step"><p>Step 2</p></span>
             <span class="step"><p>Step 3</p></span>
 </div>
   <div class="pull-right">
     <!--<button type="button" id="drftBtn" onclick="nextPrev(-1)">Save as Draft</button>-->
     <button type="button" id="drftBtn" onclick="draft(-1)">Save as Draft</button>
     <!--<button type="button" id="prevBtn" onclick="nextPrev(-1)">-->
     <!--  Previous-->
     <!--</button>-->
      <button type="button" id="prevBtn" onclick="prev(-1)">
       Previous
     </button>
     <!--<button type="button" id="nextBtn" onclick="nextPrev(1)" class="next-one">Next</button>-->
     <button type="button" id="nextBtn" class="next-one">Next</button>
     <button type="button" class="sub-one" href="#">Submit</button>
   </div>
 </div>
 <!--</form>-->
 </div>
 </div>
 </div>
 
 </div>
 </div>
 </div>
 


<footer class="footer">
    <div class="container-fluid">
     <p>GBCA & Associates LLP, Chartered Accountants. © 2021 All Rights Reserved. Powered by OneRoof Technologies LLP.</p>
   </div>
   </footer>
   </div>
   

        </div>
      </div>



</div>

<?php include 'includes/footer.php'; ?>
<script src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.23/js/dataTables.bootstrap4.min.js"></script>
<script src="assets/js/section-22e.js"></script>
<script type="text/javascript">
  $(document).ready( function () {
    $('#xyz-table').DataTable();
} );
</script>
<script type="text/javascript">
$(document).ready( function () {
    $('#abc-table').DataTable();
} );
</script>


<!-- menu toggle new -->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>-->
<script>
  $('.collapseToggle').on('click', function() {
	$(".sidebar").toggleClass('sidebar--Collapse');
	$('.main').toggleClass('main--slide');	$('#toggleIcon').toggleClass('rotate');
});
</script>
<!-- menu toggle new -->

<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
<script>
      $("#company-select").select2({
          placeholder: "Select",
          allowClear: true
      });
      $("#finan-year").select2({
          placeholder: "Select",
          allowClear: true
      });
      $("#type_of_concern").select2({
          placeholder: "Select",
          allowClear: true
      });


//   function html_table_to_excel(type)
//     {   
//         // $('table tbody tr').find('td:eq(2)').remove();
//         // $("#Name_Of_Shareholder").html($("#Name_Of_Shareholder").text().split(' ').join('_'));
//         // $("#Shareholding_In_Percentage").html($("#Shareholding_In_Percentage").text().split(' ').join('_'));
//         // var data = document.getElementById('shareholding_details_table');
    
//             var table1 = $("#shareholding_details_table tbody");
//         var HtmlForExport="<table id='temptableforexport1'><tr><th>Name_Of_Shareholder</th><th>Shareholding_In_Percentage</th></tr>";
//         table1.find('tr').each(function(i) {
//         	var $tds = $(this).find('td');
//         	HtmlForExport+="<tr><td>"+$tds.eq(0).text()+"</td><td>"+$tds.eq(1).text()+"</td></tr>";
//         	});
//         HtmlForExport+="</table>";
        
//         $("#tempTable1").html(HtmlForExport);
    
            
//         // var file = XLSX.utils.table_to_book(data, {sheet: "sheet1"});
//         var file = XLSX.utils.table_to_book(document.getElementById('temptableforexport1'), {sheet: "sheet1"});
//         // alert(file);
//         XLSX.write(file, { bookType: type, bookSST: true, type: 'base64' });

//         XLSX.writeFile(file, 'Shareholding Details.' + type);
//         // $("#Name_Of_Shareholder").html($("#Name_Of_Shareholder").text().split('_').join(''));
//         // $("#Shareholding_In_Percentage").html($("#Shareholding_In_Percentage").text().split('_').join(' '));
//         // $('table tbody tr').find('td:eq(2)').append();
//     }

//     const export_button = document.getElementById('export_button');

//     export_button.addEventListener('click', () =>  {
//         html_table_to_excel('xlsx'); 
//     });

//   function html_table_to_excel2(type)
//     {
//         // $('table tbody tr').find('td:eq(4)').remove();
//         // $("#Names_Of_Shareholders_Of_Company").html($("#Names_Of_Shareholders_Of_Company").text().split(' ').join('_'));
//         // $("#List_Of_Concern").html($("#List_Of_Concern").text().split(' ').join('_'));
//         // $("#Type_Of_Concern").html($("#Type_Of_Concern").text().split(' ').join('_'));
//         // $("#Shareholding").html($("#Shareholding").text().split(' ').join('_'));
        
        
//         // var data = document.getElementById('type_of_concern_table');
//         // console.log(data);
//         var table2 = $("#type_of_concern_table tbody");
//         var HtmlForExport="<table id='temptableforexport'><tr><th>Names_Of_Shareholders_Of_Company</th><th>List_Of_Concern</th><th>Type_Of_Concern</th><th>Shareholding</th></tr>";
//         table2.find('tr').each(function(i) {
//         	var $tds = $(this).find('td');
//         	HtmlForExport+="<tr><td>"+$tds.eq(0).text()+"</td><td>"+$tds.eq(1).text()+"</td><td>"+nullEmptyUndefinedreplacespace($tds.eq(2).find("select").val())+"</th><td>"+$tds.eq(3).text()+"</td></tr>";
//         	});
//         HtmlForExport+="</table>";
        
//         $("#tempTable").html(HtmlForExport);
        
//         var file = XLSX.utils.table_to_book(document.getElementById('temptableforexport'), {sheet: "sheet1"});

//         XLSX.write(file, { bookType: type, bookSST: true, type: 'base64' });

//         XLSX.writeFile(file, 'Details Of Concern.' + type);
//         // $("#Names_Of_Shareholders_Of_Company").html($("#Names_Of_Shareholders_Of_Company").text().split('_').join(' '));
//         // $("#List_Of_Concern").html($("#List_Of_Concern").text().split('_').join(' '));
//         // $("#Type_Of_Concern").html($("#Type_Of_Concern").text().split('_').join(' '));
//         // $("#Shareholding").html($("#Shareholding").text().split('_').join(' '));
//     }

    // const export_button2 = document.getElementById('export_button2');

    // export_button2.addEventListener('click', () =>  {
    //     html_table_to_excel2('xlsx');
    // });

        </script>

 <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> -->
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> -->
</body>
</html>
