<?php require_once('../auth/auth.php');?>
<?php 
 $invoice   = $_POST['invoice'];
 $acid      = $_POST['acid'];

  $jur = mysqli_query($conn,"SELECT a.acid,a.ac_name,t.dr_acid,t.cr_acid,t.amount FROM transaction t LEFT JOIN accounts a ON(a.acid=(IF(t.dr_acid > 0, t.dr_acid, t.cr_acid))) WHERE t.coid='$coid' AND t.invoice='$invoice' AND t.active=1 AND t.dr_acid != '$acid' AND t.cr_acid != '$acid' ORDER BY a.acid ASC") or die(mysqli_error($conn));
      $jurdata = [];
    while($jurv= mysqli_fetch_assoc($jur)){
      $jurdata[]=$jurv;
    }
?>

<script id="script">
  $(document).ready(function () {
      var jurdata = '';
      $.each(<?php echo json_encode($jurdata)?>, function (key, jvalue) {

      var crdr = (jvalue.dr_acid > 0)?' Dr':' Cr';        

        jurdata += '<dt><span><a href="#" onclick="jprofile('+jvalue.acid+')">'+jvalue.ac_name+'</a></span><span class="float-right">'+bden.format(Number(jvalue.amount))+crdr+'</span></dt>';
      });
        $('#id<?php echo $invoice;?>').append(jurdata);
        $('#script').remove();
        toastr.success(Showing, yourdata);
  });
</script>
<script>
  function jprofile(acid){
    // $("#modal-xl").modal({backdrop: "static"});    
    pagecall('../accounts/ac_profile.php?acid='+acid,'#ac_view');   
       }    
</script>