<?php include 'includes/header.php'; ?>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.23/css/dataTables.bootstrap4.min.css">
<style type="text/css">
  .add-form-btn {
    position: absolute;
    right: 0px;
    background: #e68f39;
    padding: 10px 0 10px 20px;
    border-radius: 4px;
    margin-top: 6%;
    font-size: 15px;
    box-shadow: 0 4px 20px 0 rgb(0 0 0 / 14%), 0 7px 10px -5px rgb(230 143 57 / 40%);
}
th:nth-child(8), td:nth-child(8){
  width: 11%;
}

</style>
<body>
 

<div id="wrapper" class="active">  
      <!-- Sidebar -->
            <!-- Sidebar -->
            <?php include 'includes/sidebar.php'; ?>

          
      <!-- Page content -->
      <div id="page-content-wrapper">
        <div class="page-content inset">
        <div class="main pt-4">
  <a class="out-btn" href="logout.php">Sign out</a>
  <div class="content">
    <div class="container-fluid">
     <div class="row dashboard-stats">
  
      <div class="col-md-3 col-6">
       <div class="card">
        <div class="card-header card-header-warning card-header-icon">
         <div class="card-icon">
          <i class="nc-icon nc-simple-remove"></i>
        </div>
        <div class="widget-numbers">
                                    <?php
                                     $company_pending_arr = $obj->select("COUNT(DISTINCT gbca.company_detail_id) as total ","gbca_company_detail_master as gbca","gbca.company_detail_status = '0' ");
                                    
                                      $company_pending = $company_pending_arr[0]['total'];
                                     
                                     ?>
                                  </div>             
         <h3 class="card-title"><?php echo $company_pending ?></h3> 
          </div>
      <div class="card-body">
       <p>Pending</p>
     </div>
   </div>
  </div>
  
  <div class="col-md-3 col-6">
   <div class="card">
    <div class="card-header card-header-warning card-header-icon">
     <div class="card-icon">
      <i class="nc-icon nc-check-2" style="background: linear-gradient(
       60deg
       ,#66bb6a,#43a047);box-shadow: 0 4px 20px 0 rgb(0 0 0 / 14%), 0 7px 10px -5px rgb(76 175 80 / 40%);"></i>
     </div> 
     <div class="widget-numbers">
                                    <?php
                                     $company_complete_arr = $obj->select("COUNT( DISTINCT company_detail_id ) as total"," gbca_company_detail_master","company_detail_status='1'");
                                    
                                      $company_complete = $company_complete_arr[0]['total'];
                                     
                                     ?>

                                  </div>             
     <h3 class="card-title"><?php echo  $company_complete ?></h3>
   </div>
   <div class="card-body">
    <p>Completed</p>
  </div>
  </div>
  </div>
 
   <div class="col-md-3 col-6">
    <div class="card">
     <div class="card-header card-header-warning card-header-icon">
      <div class="card-icon">
       <i class="nc-icon nc-paper-2" style="background: linear-gradient( 
        60deg
        ,#ffa726,#fb8c00);
        box-shadow: 0 4px 20px 0 rgb(0 0 0 / 14%), 0 7px 10px -5px rgb(255 152 0 / 40%);"></i>
      </div>  
       <div class="widget-numbers">
                                    <?php
                                     $section_185_arr = $obj->select("COUNT(*) as total"," gbca_company_detail_master","section_id='1' AND company_detail_status!='2'");
                                    
                                      $section_185 = $section_185_arr[0]['total'];
                                     
                                     ?>
                                   <!-- <h3><?php echo $company_pending ?></h3> -->
                                  </div>             
     <h3 class="card-title"><?php echo  $section_185 ?></h3>
    </div>
    <div class="card-body">
     <p>Companies in Sec 185</p>
   </div>
  </div>
  </div>
  
  <div class="col-md-3 col-6">
   <div class="card">
    <div class="card-header card-header-warning card-header-icon">
     <div class="card-icon">
      <i class="nc-icon nc-paper-2" style="background: linear-gradient(
       60deg
       ,#26c6da,#00acc1);box-shadow: 0 4px 20px 0 rgb(0 0 0 / 14%), 0 7px 10px -5px rgb(0 188 212 / 40%);"></i>
     </div>

     <div class="widget-numbers">
                                    <?php
                                     $section_185_arr = $obj->select("COUNT(*) as total"," gbca_company_detail_master","section_id='2' AND company_detail_status!='2'");
                                    
                                      $section_185 = $section_185_arr[0]['total'];
                                     
                                     ?>
                                   <!-- <h3><?php echo $company_pending ?></h3> -->
                                  </div>             
     <h3 class="card-title"><?php echo  $section_185 ?></h3>
   </div>
   <div class="card-body">
    <p>Companies in Sec 2(22)(e)</p>
  </div>
  </div>
  </div>
  </div>
  
  
  <div class="dash-table-header">
   <div class="card-header card-header-warning">
    <div class="row"></div>
      <div class="col-md-10">
        <h4>All Section Status</h4>
      </div>
    </div>
  </div>
   </div>
  
   <div class="container table-responsive dash-table-stats"> 
  <!-- <a href="#" class="am-btn-dash" data-toggle="modal" data-target="#add-newform" rel="tooltip" title="" data-original-title="Add New Form"><i class="fa fa-plus" aria-hidden="true"></i></a> -->

 <?php
 $company_arr = $obj->select("*,date_format(str_to_date(company_detail_preparation_date, '%Y-%m-%d'),' %d %M %Y') as date","gbca_company_detail_master as gcdm inner join gbca_section_master as gsm on gcdm.section_id = gsm.section_id inner join gbca_company_master as gcm on gcdm.company_detail_name = gcm.company_id  ","company_detail_status != '2' order by gcdm.company_detail_id desc");
                                // $company_arr = $obj->select("gcdm.*,sub.*,gsm.*","gbca_company_detail_master as gcdm inner join gbca_section_master as gsm on gcdm.section_id = gsm.section_id INNER JOIN gbca_sub_company_mapping as sub ON gcdm.company_detail_id=sub.company_detail_id ","");
                                // echo "<pre>";print_r($company_arr);echo "</pre>";exit;
                                
                                ?>
 <table class="table table-bordered table-hover display" id="table_id">
  <thead class="thead-dark">
   <tr>
    <th scope="col">SR.No</th>
    <th scope="col">Preparation Date</th>
    <th scope="col">Section</th>
    <th scope="col">Company Name</th>
    <th scope="col">Maker</th>
    <th scope="col">Checker</th>
    <th scope="col">Status</th>
    <!--<th scope="col">Last Edited On</th>-->
    <th scope="col">Action</th>
  </tr>
</thead>
<tbody>
   <?php

    if(is_array($company_arr))
    {
      $i = 1;
      foreach($company_arr as $company)
      {
        ?>
 <tr>
  <td><?php echo $i; ?></td>
  <!-- <td><?php echo $company['company_detail_id']; ?></td> -->
  <td><?php echo $company['date']; ?></td>
  <td><?php echo $company['section_name'];?></td>
  <td><?php echo $company['company_name'];?></td>
  <td><?php echo $company['company_detail_maker_name'];?></td>
  <td><?php echo $company['company_detail_checker_name'];?></td>
  <td><?php if($company['company_detail_status'] == 
                                  '0') { echo "Pending"; }
                                  else {
                                    echo "Completed";
                                  }?></td>
  <!--<td><?php //echo $company['company_detail_updated_date'];?></td>-->

  <td class="action-icons">
  <?php if($company['section_id'] == '1')
  {
  ?>
  <a href="section-a.php?company_edit_id=<?php echo $company['company_detail_id']; ?>"><i class="fa fa-pencil" aria-hidden="true" rel="tooltip" title="" data-original-title="Edit"></i>
  </a>
  <?php 
  }
  else
  {
  ?>
   <a href="section-list-222E.php?company_detail_id=<?php echo $company['company_detail_id']; ?>"><i class="fa fa-pencil" aria-hidden="true" rel="tooltip" title="" data-original-title="Edit"></i>
  </a> 
  <?php   }  ?>
 <?php if($company['company_detail_status'] =='1'){ ?>
 <?php 
        if(file_exists('pdffiles/'.$company['company_detail_document']) && $company['company_detail_document']!="")
        {
                    ?>
  <a href="pdffiles/<?php echo $company['company_detail_document'];?>" target="_blank"><i class="fa fa-eye" aria-hidden="true" rel="tooltip" title="" data-original-title="View"></i></a>
  <a href="pdffiles/<?php echo $company['company_detail_document'];?>" download><i class="fa fa-download" aria-hidden="true" rel="tooltip" title="" data-original-title="Download"></i>
  </a>
  <?php
    }
    else
    {
        
    }
    }  ?>
  <a href="#"onclick="javascript:delete_record(<?php echo $company['company_detail_id']; ?>);"><i class="fa fa-trash" aria-hidden="true" rel="tooltip" title="" data-original-title="Remove"></i>
  </a>
  </td>
  <?php
  $i++;
    }
    } ?>
  </tr>
</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>
  
  </div>
  <footer class="footer">
   <div class="container-fluid">
    <p>GBCA & Associates, Chartered Accountants. © 2021 All Rights Reserved. Powered by OneRoof Technologies LLP.</p>
  </div>
  </footer>
  </div>
 
  </div>
  
        </div>
      </div>
<!-- Wrapper -->

<!-- <div id="social-share">
  <ul class="social-itens open">
    <li>
      <button class="btn-share social-item-2">
	  	<a data-toggle="modal" data-target="#add-newform">
		  <i class="fa fa-plus" aria-hidden="true"></i>
		</a>
        <span class="btn-share-text">Add New Form</span>
      </button>
    </li>
  </ul>
</div> -->

<!-- Sticky icon  -->
<div class="float-sm">
  <div class="fl-fl float-pn">
  <i class="fa fa-plus" aria-hidden="true"></i>
    <a href="" data-toggle="modal" data-target="#add-newform">Add New Form</a>
  </div>
</div>
 <!-- Sticky icon end  -->

<?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 type="text/javascript">
  $(document).ready( function () {
    $('#table_id').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/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>
<script type="text/javascript">
function delete_record(company_detail_id)
  {
    var result = confirm("Want to delete this information?");
    if (result) {
      var formdata= new FormData();
      formdata.append('company_detail_id',company_detail_id);


      $.ajax({

        type:"post",
        data: formdata,
        processData: false,
        contentType: false,
        url:"ajax/company_delete.php",
        success:function(msg)
        {
             msg=msg.trim();
             //alert(msg);
           var res = JSON.parse(msg);

            if(res['n'] == 1)
            {
              location.reload();
            }
            
            else
            {
              alert("error");
              return false;
            }

          },
          error:function(b)
          {
            console.log("error");  
            return false; 
          }



        });

    }
  }
</script>