<?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%);
}
</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">
  <a class="out-btn" href="logout.php">Sign out</a>
  <div class="content con-1">
    <div class="container-fluid">
     <div class="row dashboard-stats">
  
  <div class="dash-table-header dash1">
   <div class="card-header card-header-warning first-sec">
    <div class="row"></div>
      <div class="col-md-10">
        <h4>Section 185 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> -->
<!-- <table class="table table-bordered table-hover display" id="table_id">-->
<!--  <thead class="thead-dark">-->
<!--   <tr>-->
<!--    <th scope="col">Preparation Date</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(isset($_GET['msg'])){
              if($_GET['msg'] == 4){
          ?>
                <div class="alert alert-success response-msg">
                  <button type="button" class="close" onclick="call_close();" data-dismiss="alert" aria-hidden="true">&times;</button>
                  <strong>Admission Deleted Successfully.</strong>
                </div>
          <?php
              } 
              else if($_GET['msg'] == 5){
          ?>
                <div class="alert alert-success response-msg">
                  <button type="button" class="close" onclick="call_close();" data-dismiss="alert" aria-hidden="true">&times;</button>
                  <strong>Something Went Wrong!!</strong>
                </div>
          <?php
              }
            }
          ?>
  <?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' AND gcdm.section_id='1'  order by gcdm.company_detail_id desc");
                                // 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">Financial Year</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 style="width:20%"><?php echo $company['date']; ?></td>
  <!--<td><?php echo $company['section_name'];?></td>-->
  <td style="width:20%"><?php echo $company['company_name'];?></td>
   <td style="width:20%"><?php echo $company['company_detail_financial_year'];?></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>25/07/2021</td> -->
   <td class="action-icons"><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 if($company['company_detail_status'] == 
                                  '1')
                                  { ?>
  
  
    <?php 
                // if(file_exists('assets/pdfs/'.$company['company_detail_file']) && $company['company_detail_file']!="")
                // {
                    ?>
                  <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>
                    <?php
                // } 
                 ?>
  
  <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 }
    ?>
  <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>


</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>
<script>
  $("#menu-toggle").click(function(e) {
        e.preventDefault();
        $("#wrapper").toggleClass("active");
});
</script>
<script type="text/javascript">
function delete_record(company_detail_id)
  {
    var result = confirm("Want to delete this information?");
    var page = "section-185.php";
    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)
        {
            //alert(msg);
            msg=msg.trim();
           var res = JSON.parse(msg);

            if(res['n'] == 1)
            {
              location.href="section-185.php";
              return false;
            }
            
            else
            {
             console.log("error"); 
              return false;
            }

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



        });

    }
  }
</script>
</body>

</html>
