<?php require_once('../auth/auth.php'); ?>
<?php
    $company_query= mysqli_query($conn,"SELECT co_name,owner_name,co_phone,co_email,co_address,co_logo,a.ac_name FROM accounts a LEFT JOIN company c ON(a.coid=c.coid) WHERE a.coid='$coid'  ") or die (mysql_error());
    $inac= mysqli_fetch_assoc($company_query);
    $ac_name        = $inac['ac_name'];
    $co_name        = $inac['co_name'];
    $owner_name     = $inac['owner_name'];
    $co_address     = $inac['co_address'];
    $co_phone       = $inac['co_phone'];
    $co_email       = $inac['co_email'];
    $co_logo        = $inac['co_logo'];	
?>
<section class="content">
   <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
            <div class="card-header" style="padding: 3px 8px;">
               <h3 class="card-title">Deactived Accounts List</h3>
                <div class="card-tools"><span id="sdf"></span>
                  <button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fas fa-times"></i></button>
                </div>
            </div>    	
            <div class="card-body p-1">
                <table id="trbl_table" class="ttable" cellpadding="0" cellspacing="0">
                  <thead>
                    <tr>                  	
                        <th rowspan="3" colspan="5">
                         <div style="width:12%;float:left;">
                            <img class="profile-user-img img-fluid img-circle" src="../../dist/img/a.png" style="width:80px;height:77px;">
                        </div>
                        <div style="padding-left:2px;float:left;">
                         <sss style="font-size:18px;font-weight: 600;"><?php echo $co_name;?></sss><br>
                         <sss><?php echo $owner_name;?></sss><br>
                         <sss><?php echo $co_address;?></sss><br>
                         <sss><?php echo $co_phone;?></sss> # 
                         <sss><?php echo $co_email;?></sss>
                        </div>
                        </th> 
                        <th colspan="1" class="text-center" style="font-size:13px;">All Branch</th>
                    </tr> 
                    <tr>                   	
                       <th colspan="1" class="text-center" style="font-size:13px;">Deactived List  </th> 
                    </tr>
                    <tr>                   	
                       <th colspan="1" class="text-center" style="font-size:13px;"><?php echo date('d/m/Y', strtotime($date));?> </th>
                    </tr>                                     	
                    <tr class="sticky-top">
                        <th class="text-center" style="width:5%;">S/l</th>
                        <th style="width:35%;">Account Name</th>
                        <th class="text-center" style="width:20%;">Address </th>
                        <th class="text-center" style="width:10%;">Number</th>
                        <th class="text-center" style="width:10%;">Balance</th>
                        <th class="text-center" style="width:20%;">Status</th>
                    </tr>
                </thead>
                <tbody id="colview">
                    <?php
                        $account_query= mysqli_query($conn,"SELECT * FROM accounts WHERE acid AND coid='$coid' AND active=0  ") or die (mysql_error());
                        $i=0;
                        $ac_balanced_total=0;
                        while ($rowac= mysqli_fetch_array ($account_query) ){
                            $ac_balanced =$rowac['balance'];
                            $ac_balanced_total +=$rowac['balance'];
                            $acid        = $rowac['acid'];
                            $status     =$rowac['active'];
                            $gcatid     =$rowac['gcatid'];
                            $ac_g_cat_name=mysqli_fetch_assoc(mysqli_query($conn,"SELECT ac_g_cat_name FROM ac_sub_g_category 
                                WHERE ac_g_catid='$gcatid'"))['ac_g_cat_name'];  
                    ?>
                    <tr onclick="vprofile('<?php echo $rowac['acid']?>')">
                        <td  style="font-size: 11.5px;width:10%;text-align: center;"><?php echo ++$i ?></td>
                        <td  style="font-size: 11.5px"><?php echo $rowac['ac_name'] ?> , <?php echo $rowac['ac_alise'] ?>   >>   <?php echo $ac_g_cat_name ?></td>
                        <td  style="font-size: 11.5px"><?php echo $rowac['ac_details']?></td>
                        <td  style="font-size: 11.5px"> <?php echo $rowac['ac_number']?></td>
                        <?php if ($ac_balanced >0) { ?>
                            <td  style="font-size: 11.5px;width:15%;text-align: right; color: green;">  <?php echo $ac_balanced ?>  </td> <?php }else { ?>  <td  style="font-size: 11.5px;width:15%;text-align: right;color:red;"> <?php echo $ac_balanced ?> 
                           </td>
                        <?php } ?>
                        <td  style="font-size: 11.5px;width:15%;text-align: center;color:red;"> <?php if ($status==0) {echo "Deactive";} ?> </td>
                    </tr>
                    <?php } ?>
                </tbody>
                <tfoot>                               	
                    <tr>
                        <th class="text-right" colspan="4">Closing Balance</th>
                        <th class="text-right"><dt id="sumdrb"><?php echo $ac_balanced_total ?></dt></th>
                        <th class="text-right"><dt id="sumdrb"></dt></th>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
   </div>
  </div>
</div>
</section>

<script type="text/javascript">
  function vprofile(acid){    
    $("#modal-xl").modal({backdrop: "static"});
    pagecall('../accounts/ac_profile.php?acid='+acid,'#xlmdview');   
}  
toastr.success(Showing, '<?php echo "All Deactive Account View " ?>');
</script>