<?php echo $this->profileheader($this->customer);?>

<div class="resp-tabs-container tab_identifier_parent no-padding">
    <div>
        <div class="client-contact-wrapper" id="profile-fields">
            <div class="cm-holder settings-wrapper dt-info">
    <div class="head">
        <div class="filter-block" style="">
            <table>
                <tr>
                    <td>
                        <button class="action-buttons blue" id="add-invoice-button">
                            <i class="icon-ic-21"></i> <?php echo $this->user->lang("Add Invoice");?>
                        </button>
                    </td>
                    <td>
                        <select id='filterByDate'>
                            <option value='billdate'><?php echo $this->user->lang("Bill Date");?></option>
                            <option value='datepaid'><?php echo $this->user->lang("Date Paid");?></option>
                            <option value='sentdate'><?php echo $this->user->lang("Sent Date");?></option>
                            <option value='datecreated'><?php echo $this->user->lang("Date Created");?></option>
                        </select>
                    </td>
                    <td>
                        <input class="form-control" type="date" name="startdate" id="startdate" />
                    </td>
                    <td>
                        -
                    </td>
                    <td>
                        <input class="form-control" type="date" name="enddate" id="enddate" />
                    </td>
                    <td>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <?php echo $this->user->lang("Show");?>
                        <select id="filterByStatus">
                            <option value='0' <?php echo ($this->filter == 0) ? "selected": "";?>><?php echo $this->user->lang("Overdue");?></option>
                            <option value='6' <?php echo ($this->filter == 6) ? "selected": "";?>><?php echo $this->user->lang("Paid");?></option>
                            <option value='1' <?php echo ($this->filter == 1) ? "selected": "";?>><?php echo $this->user->lang("Unpaid");?></option>
                            <option value='4' <?php echo ($this->filter == 4) ? "selected": "";?>><?php echo $this->user->lang("Pending");?></option>
                            <option value='5' <?php echo ($this->filter == 5) ? "selected": "";?>><?php echo $this->user->lang("Draft");?></option>
                            <option value='2' <?php echo ($this->filter == 2) ? "selected": "";?>><?php echo $this->user->lang("All");?></option>
                            <option value='-3' <?php echo ($this->filter == -3) ? "selected": "";?>><?php echo $this->user->lang("Unsent");?></option>
                            <option value='-2' <?php echo ($this->filter == -2) ? "selected": "";?>><?php echo $this->user->lang("Failed");?></option>
                        </select>
                    </td>
                    <td id="td-for-userid" style="width:100px;display:none">
                        <input type="text" id="invoice-userid" name="invoice-userid" class="form-control" value="<?php echo $this->customer->getId(); ?>" placeholder="<?php echo $this->user->lang("User Id");?>" />
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <div class="dt-wrapper pull-top">
        <div class="table-responsive">
            <table id="invoices-list" class="display" style="width:100%">
                <thead>
                    <tr>
                        <th style="text-align: center">
                            <input type="checkbox" id="checkAll">
                        </th>
                        <th></th>
                        <th class=""><?php echo $this->user->lang('Invoice #'); ?></th>
                        <th class=""><?php echo $this->user->lang('Created'); ?></th>
                        <th class=""><?php echo $this->user->lang('Due'); ?></th>
                        <th class="width4"><?php echo $this->user->lang('Client Name'); ?></th>
                        <th class=""><?php echo $this->user->lang('Balance Due'); ?></th>
                        <th class=""><?php echo $this->user->lang('Total'); ?></th>
                        <th class=""><?php echo $this->user->lang('Status'); ?></th>
                    </tr>
                </thead>
            </table>
        </div>
        <div class="table-actions">
            <div class="btn-toolbar mb-3" role="toolbar" aria-label="Actions">

                <div class="btn-group me-2" role="group">
                    <button type="button" class="btn btn-outline-primary dropdown-toggle d-none" data-bs-toggle="dropdown" aria-expanded="false">
                        <?php echo $this->user->lang('Processing'); ?>
                    </button>
                    <ul class="dropdown-menu">
                        <li><button class="dropdown-item d-none" id="inv-process"><?php echo $this->user->lang('Process Invoice(s)'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-varpayment"><?php echo $this->user->lang('Add Payment'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-applycredit"><?php echo $this->user->lang('Apply Credit'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-markpaid"><?php echo $this->user->lang('Mark Paid'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-markunpaid"><?php echo $this->user->lang('Mark Un-Paid'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-markpending"><?php echo $this->user->lang('Mark Pending'); ?></button></li>
                    </ul>
                </div>

                <div class="btn-group me-2" role="group">
                    <button type="button" class="btn btn-outline-primary dropdown-toggle d-none" data-bs-toggle="dropdown" aria-expanded="false">
                        <?php echo $this->user->lang('Sending'); ?>
                    </button>
                    <ul class="dropdown-menu">
                        <li><button class="dropdown-item d-none" id="inv-send"><?php echo $this->user->lang('Send Invoice'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-sendvoid"><?php echo $this->user->lang('Send Voided Invoice'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-sendcredit"><?php echo $this->user->lang('Send Credited Invoice'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-sendrefund"><?php echo $this->user->lang('Send Refunded Invoice'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-sendoverdue"><?php echo $this->user->lang('Send Overdue'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-sendreceipt"><?php echo $this->user->lang('Send Receipt'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-senddraft"><?php echo $this->user->lang('Send Draft'); ?></button></li>
                    </ul>
                </div>

                <div class="btn-group me-2" role="group">
                    <button type="button" class="btn btn-outline-primary dropdown-toggle d-none" data-bs-toggle="dropdown" aria-expanded="false">
                        <?php echo $this->user->lang('Refund / Credit'); ?>
                    </button>
                    <ul class="dropdown-menu">
                        <li><button class="dropdown-item d-none" id="inv-refund"><?php echo $this->user->lang('Refund'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-credit"><?php echo $this->user->lang('Credit'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-markrefunded"><?php echo $this->user->lang('Mark Refunded'); ?></button></li>
                        <li><button class="dropdown-item d-none" id="inv-markcredited"><?php echo $this->user->lang('Mark Credited'); ?></button></li>
                    </ul>
                </div>

                <div class="btn-group me-2">
                    <button class="btn btn-outline-secondary d-none" id="inv-recalculate"><?php echo $this->user->lang('Recalculate'); ?></button>
                </div>

                <div class="btn-group me-2">
                    <button class="btn btn-outline-secondary d-none" id="inv-merge"><?php echo $this->user->lang('Merge'); ?></button>
                </div>

                <div class="btn-group me-2">
                    <button class="btn btn-outline-secondary d-none" id="inv-clone"><?php echo $this->user->lang('Clone'); ?></button>
                </div>

                <div class="btn-group me-2">
                    <button class="btn btn-outline-danger d-none" id="inv-voidinvoices"><?php echo $this->user->lang('Void'); ?></button>
                    <button class="btn btn-outline-danger d-none" id="inv-deleteinvoices"><?php echo $this->user->lang('Delete'); ?></button>
                </div>

                <div class="btn-group">
                    <button class="btn btn-outline-warning d-none" id="inv-cancelsub"><?php echo $this->user->lang('Cancel Subscription'); ?></button>
                </div>
            </div>
        </div>
    </div>
</div>
        </div>
    </div>
</div>

<script>
    var viewinvoices = viewinvoices || {};
    viewinvoices.viewingFromProfile = true;

    $('#add-invoice-button').on('click', function(){
        window.location.href = 'index.php?controller=invoice&fuse=billing&view=invoice&frmClientID=' + clientexec.customerId;
    });
</script>
<script src="../templates/admin/views/billing/invoice/invoices.js"></script>