<script src="https://cdn.lordicon.com/libs/mssddfmo/lord-icon-2.1.0.js"></script>
<div id="main p-0" role="main">
    <!-- <div class="header-bg shadow-sm p-0" style="background: url(https://images.pexels.com/photos/1475033/pexels-photo-1475033.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260)"> -->
        <!-- <div class="header-bg shadow-lg p-0" style="background: url(https://images.pexels.com/photos/1487834/pexels-photo-1487834.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260)"></div> -->
        <div id="content" style=" padding-top: 0px; ">
            <div class="container">
                <div class="row mt-3 justify-content-center">
                    <div class="header_invoice_wrapper shadow">
                        <div class="fs-1 w-25 text-white d-flex align-items-center"><?php echo $this->lang->line('account'); ?> <?php echo $accounts->name;?></div class="fs-1">
                        <div class="new_invoice_btn">
                            <button type="button" class="shadow-lg add_invoice_button" data-bs-toggle="" href="" role="button" aria-expanded="false" aria-controls="" title="<?php echo $this->lang->line('new_account'); ?>">
                                <lord-icon src="https://cdn.lordicon.com/mecwbjnp.json" trigger="loop" delay="1000" colors="primary:#356359,secondary:#00bcd4" style="width:32px;height:32px">
                                </lord-icon>
                                <span class="pt-1 text-dark">
                                    <?php echo $this->lang->line('new_account'); ?>
                                </span>
                            </button>

                            <button type="button" class="shadow-lg excel_exporter" data-bs-toggle="modal" data-bs-target="#ExcelExportModal">
                                <i class="far fa-file-excel "></i>
                                <!-- <lord-icon src="https://cdn.lordicon.com/nocovwne.json" trigger="loop" delay="1000" colors="primary:#356359,secondary:#00bcd4" style="width:32px;height:32px">
                                </lord-icon> -->
                                <!-- <span class="pt-1 text-dark">
                                    Excel
                                </span> -->
                            </button>
                            <button type="button" class="shadow-lg excel_exporter cancel_invoice p-2" style="width: 50px;" data-bs-toggle="modal" id="deleteInvoiceButton" rel-invoice="-1" data-bs-target="#DeleteInvoice">
                                <i class="fas fa-file-pdf text-warning"></i>
                            </button>
                            <button type="button" class="shadow-lg excel_exporter cancel_invoice p-2" style="width: 50px;" data-bs-toggle="modal" id="deleteInvoiceButton" rel-invoice="-1" data-bs-target="#DeleteInvoice">
                                <i class="fas fa-copy text-primary"></i>
                            </button>
                            <button type="button" class="shadow-lg excel_exporter cancel_invoice p-2" style="width: 50px;" data-bs-toggle="modal" id="deleteInvoiceButton" rel-invoice="-1" data-bs-target="#DeleteInvoice">
                                <i class="pt-1 me-1 fas fa-trash-alt text-danger"></i>
                            </button>
                            <button type="button" class="shadow-lg excel_exporter view_invoice p-2" style="width: 50px;" onclick="window.open('<?php echo site_url(); ?>admin/accounts/view/','_blank')">
                                <i class="pt-1 me-1 fas fa-eye text-success"></i>
                            </button>
                        </div>
                    </div>
                    <div class="collapse w-100" id="add_accounts">
                        <div class="date-searchWrapper" style="margin-left: 18px">
                            <div class="card p-3 w-25" style="border-radius: 0 0 20px 20px; float: left;">

                                <form method="POST" action="<?php echo site_url(); ?>admin/accounts/action">
                                    <div>
                                        <div class="form-group">
                                            <input type="text" id="name" name="name" value="" class="form-control">
                                        </div>
                                    </div>
                                    <div>
                                        <div class="form-group">
                                            <select name="type" id="type" class="form-select form-select-lg">
                                                <option value=""><?php echo $this->lang->line('type'); ?></option>
                                                <option value="1"><?php echo $this->lang->line('expenses'); ?></option>
                                                <option value="2"><?php echo $this->lang->line('purchases'); ?></option>
                                            </select>
                                        </div>
                                    </div>
                                    <div>
                                        <button type="submit" class="btn btn-success p-1">
                                            <?php echo $this->lang->line('submit'); ?>
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>

                    </div>
                    <div class="row">
                        <hr class="bg-white mt-5" style="border-radius: 30px; padding: 2px;" />
                        <div class=" table-responsive card card-body w-50">
                            <table class="table table-sm" id="dt_basic2">
                                <thead>
                                    <th>#</th>
                                    <th>#</th>
                                    <th><?php echo $this->lang->line('name'); ?></th>
                                    <th><?php echo $this->lang->line('type'); ?></th>
                                    <th><?php echo $this->lang->line('date'); ?></th>
                                    <th></th>
                                </thead>
                                <tbody>
                                </tbody>
                                <tfoot>
                                    <!-- <tr>
                                        <td colspan="2"></td>
                                        <td><strong><?php echo number_format($balance, 2); ?></strong></td>
                                        <td colspan="3"></td>
                                    </tr> -->
                                </tfoot>
                            </table>
                        </div>
                        <div class="w-25">
                            <div class="card card-body">
                                <h4><?php echo $this->lang->line('for_edit'); ?></h4>
                                <form id="addSupplier-form" novalidate="novalidate" method="POST" action="<?php echo site_url(); ?>admin/accounts/edit">
                                    <input type="hidden" name="accounts_id" id="accounts_id" value="<?php echo $accounts->id; ?>" />
                                    <fieldset>
                                        <div class="row">
                                            <div class="form-group col-lg-6">
                                                <label><?php echo $this->lang->line('name'); ?></label>
                                                <input type="text" name="name" value="<?php echo $accounts->name; ?>" class="form-control" />
                                            </div>

                                            <div class="form-group col-lg-6">
                                                <label><?php echo $this->lang->line('type'); ?></label>
                                                <select class="type" name="type" class="form-select">

                                                    <option <?php if ($accounts->type == 1) {
                                                                echo 'selected="selected"';
                                                            }; ?> value="1"><?php echo $this->lang->line('expenses'); ?></option>

                                                    <option <?php if ($accounts->type == 2) {
                                                                echo 'selected="selected"';
                                                            }; ?> value="2"><?php echo $this->lang->line('purchases'); ?></option>

                                                </select>
                                                </label>
                                            </div>
                                            <div class="form-group col-lg-6">
                                                <label><?php echo $this->lang->line('date_creation'); ?></label>
                                                <input type="text" readonly name="date" value="<?php echo $accounts->dateCreation; ?>" class="form-control" />
                                            </div>

                                            <div class="form-group col-lg-12 mt-2">
                                                <button type="submit" id="edit_account_btn" class="btn w-100 btn-success">
                                                    <?php echo $this->lang->line('save'); ?>
                                                </button>
                                            </div>
                                        </div>
                                    </fieldset>
                                </form>
                            </div>
                        <!-- </div> -->
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.5.2/bootbox.min.js" integrity="sha512-RdSPYh1WA6BF0RhpisYJVYkOyTzK4HwofJ3Q7ivt/jkpW6Vc8AurL1R+4AUcvn9IwEKAPm/fk7qFZW3OuiUDeg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/js/bootstrap-datepicker.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/css/bootstrap-datepicker.css">
    <script>
        $(document).ready(function() {
            (function() {
                var result;
                $.post(root + 'admin/invoices/getInvoiceDate', {}, function(d) {
                    console.log(d);
                    var sdate = d.date;
                    loadDatepicker(sdate);
                }, "json");

                function loadDatepicker(sdate) {
                    console.log(sdate);
                    $('#invoice_date').datepicker({
                        format: 'dd/mm/yyyy',
                        isRTL: true,
                        prevText: '<i class="fa fa-chevron-left"></i>',
                        nextText: '<i class="fa fa-chevron-right"></i>',
                        autoclose: true,
                        keyboardNavigation: true,
                        todayHighlight: true,
                        autoclose: true,
                        startDate: sdate,
                    })
                    // .on('changeDate', function() {
                    //     getMessageDate();
                    // });
                }
            })();
        });
    </script>