<?php require_once('../auth/auth.php');require_once('../auth/function.php'); ?>
<?php
$gcatid = $_GET['gcatid'];
$g_name= mysqli_fetch_assoc(mysqli_query($conn,"SELECT ac_g_cat_name FROM ac_sub_g_category WHERE ac_g_catid='$gcatid' AND coid='$coid' LIMIT 1"))['ac_g_cat_name'];
?>

<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-1"></div>
            <div class="col-md-10">
                <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"><?php echo language(280); ?> :    <?php echo $g_name;?>    </h3>
                        <div class="card-tools">
                            <button type="button" class="btn btn-tool " data-card-widget="remove">
                            <i class="fas fa-times"></i>
                            </button>
                        </div>
                    </div>
                    <form id="acadd" action="#" method="post" autocomplete="off">
                        <input type="hidden" name="gcatid" value="<?php echo $gcatid;?>" required>
                        <input type="hidden" name="invoice" value="<?php echo invoice("OP");?>" required>
                        <div class="card-body">
                            <div class="col-md-12">
                                <div class="row mt-2">
                                    
                                    <div class="col-md-5">
                                        <div class="form-group">
                                            <label><?php echo language(215);?> </label> <b class="text-danger"> * </b>
                                            <input type="text" name="ac_name" class="form-control form-control-sm" required>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label><?php echo language(110);?></label>
                                            <input type="text" name="ac_alise" class="form-control form-control-sm">
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label><?php echo language(111);?></label>
                                            <input type="number" name="ac_number" class="form-control form-control-sm">
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group">
                                            <label><?php echo language(128);?></label>
                                            <textarea name="ac_details" class="form-control form-control-sm" rows="2">N/A</textarea>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label><?php echo language(112);?></label>
                                            <input type="text" name="ac_email" class="form-control form-control-sm">
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <center><label><?php echo language(129);?></label></center>
                                            <input type="number" name="balance" step="0.001" class="form-control form-control-sm" style="text-align:center;">
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <label><?php echo language(130);?></label>
                                            <select name="ttype" class="form-control select2" style="width: 100%;">
                                                <option selected="selected" value="+"> <?php echo language(217);?> (+)</option>
                                                <option value="-"> <?php echo language(218);?> (-)</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <center><label><?php echo language(131);?></label> <b class="text-danger"> * </b> </center>
                                            <input type="text" name="opdate" class="form-control form-control-sm" onmouseover="lcdate(this)" style="text-align:center;" readonly="true" required="true" value="<?php echo $date;?>">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <center>
                        <div class="card-footer" style="padding: 8px 5px;">
                            <button type="submit" id="save" class="btn btn-success btn-xs"><?php echo language(23);?></button>
                            <button type="reset" class="btn btn-secondary btn-xs"><?php echo language(24);?></button>
                        </div>
                        </center>
                    </form>
                </div>
            </div>
            <div class="col-md-1"></div>
        </div>
    </div>
</section>
<script>
   $(document).ready(function() {
     $('#acadd').on('submit', function(e){
       $('#save').prop('disabled', true);
       $('#save').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> '+'Loading...');
       e.preventDefault();  
       $.post("../accounts/add_accounts_db.php",$(this).serialize(),function(data){
          $('#acadd')[0].reset();
          $('#save').prop('disabled', false);
             $.post('../accounts/add_accounts.php?gcatid=<?php echo $gcatid;?>',{},function(res){
                $('#ac_view').html(res);
             }); 
             toastr.success(Showing, yourdata);
          
     });
    });
   
   });  
</script>

<script>
$('.select2').select2();
</script>