<?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 dt-info">
                <div class="head padding-bottom">
                    <div class="dt-header">
                        <div class="dt-header-left">
                            <button class="action-buttons blue" id="add-invoice-button">
                                <i class="icon-ic-21"></i>
                                <?php echo $this->user->lang("Add Invoice");?>
                            </button>

                            <div class="dt-filters">
                                <div class="filter-group">
                                    <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>
                                </div>

                                <div class="filter-group">
                                    <label><?php echo $this->user->lang("Date Created");?></label>
                                    <input
                                        class="form-control"
                                        type="date"
                                        name="startdate"
                                        id="startdate"
                                    />
                                    <span class="separator">-</span>
                                    <input
                                        class="form-control"
                                        type="date"
                                        name="enddate"
                                        id="enddate"
                                    />
                                </div>

                                <div class="filter-group">
                                    <label><?php echo $this->user->lang("Show");?></label>
                                    <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>
                                </div>

                                <div id="td-for-userid" class="filter-group" style="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");?>" />
                                </div>
                            </div>
                        </div>

                        <div class="dt-header-right">
                            <div class="filter-group dt-length"></div>
                        </div>
                    </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="dropdown" id="invoiceProcessingActions" data-open="false">
                            <button class="pill" type="button" disabled="disabled">
                                <i class="fas fa-cogs"></i>
                                <?php echo $this->user->lang('Processing'); ?>
                                <i class="fas fa-chevron-down caret"></i>
                            </button>

                            <div class="menu" role="menu">
                                <button class="menu-item" id="inv-process">
                                    <i class="fas fa-play mi-icon"></i>
                                    <?php echo $this->user->lang('Process Invoice(s)'); ?>
                                </button>
                                <button class="menu-item" id="inv-varpayment">
                                    <i class="fas fa-plus-circle mi-icon"></i>
                                    <?php echo $this->user->lang('Add Payment'); ?>
                                </button>
                                <button class="menu-item" id="inv-applycredit">
                                    <i class="fas fa-ticket-alt mi-icon"></i>
                                    <?php echo $this->user->lang('Apply Credit'); ?>
                                </button>

                                <div class="menu-sep"></div>

                                <button class="menu-item" id="inv-markpaid">
                                    <i class="fas fa-check mi-icon"></i>
                                    <?php echo $this->user->lang('Mark Paid'); ?>
                                </button>
                                <button class="menu-item" id="inv-markunpaid">
                                    <i class="fas fa-undo mi-icon"></i>
                                    <?php echo $this->user->lang('Mark Un-Paid'); ?>
                                </button>
                                <button class="menu-item" id="inv-markpending">
                                    <i class="fas fa-clock mi-icon"></i>
                                    <?php echo $this->user->lang('Mark Pending'); ?>
                                </button>
                            </div>
                        </div>

                        <div class="dropdown" id="invoiceSendingActions" data-open="false">
                            <button class="pill" type="button" disabled="disabled">
                                <i class="fas fa-paper-plane"></i>
                                <?php echo $this->user->lang('Sending'); ?>
                                <i class="fas fa-chevron-down caret"></i>
                            </button>

                            <div class="menu" role="menu">
                                <button class="menu-item" id="inv-send">
                                    <i class="fas fa-envelope mi-icon"></i>
                                    <?php echo $this->user->lang('Send Invoice'); ?>
                                </button>
                                <button class="menu-item" id="inv-sendvoid">
                                    <i class="fas fa-envelope-open-text mi-icon"></i>
                                    <?php echo $this->user->lang('Send Voided Invoice'); ?>
                                </button>
                                <button class="menu-item" id="inv-sendcredit">
                                    <i class="fas fa-envelope-open mi-icon"></i>
                                    <?php echo $this->user->lang('Send Credited Invoice'); ?>
                                </button>
                                <button class="menu-item" id="inv-sendrefund">
                                    <i class="fas fa-reply mi-icon"></i>
                                    <?php echo $this->user->lang('Send Refunded Invoice'); ?>
                                </button>

                                <div class="menu-sep"></div>

                                <button class="menu-item" id="inv-sendoverdue">
                                    <i class="fas fa-exclamation-circle mi-icon"></i>
                                    <?php echo $this->user->lang('Send Overdue'); ?>
                                </button>
                                <button class="menu-item" id="inv-sendreceipt">
                                    <i class="fas fa-receipt mi-icon"></i>
                                    <?php echo $this->user->lang('Send Receipt'); ?>
                                </button>
                                <button class="menu-item" id="inv-senddraft">
                                    <i class="fas fa-file-alt mi-icon"></i>
                                    <?php echo $this->user->lang('Send Draft'); ?>
                                </button>
                            </div>
                        </div>

                        <div class="dropdown" id="invoiceRefundActions" data-open="false">
                            <button class="pill" type="button" disabled="disabled">
                                <i class="fas fa-hand-holding-usd"></i>
                                <?php echo $this->user->lang('Refund / Credit'); ?>
                                <i class="fas fa-chevron-down caret"></i>
                            </button>

                            <div class="menu" role="menu">
                                <button class="menu-item" id="inv-refund">
                                    <i class="fas fa-undo mi-icon"></i>
                                    <?php echo $this->user->lang('Refund'); ?>
                                </button>
                                <button class="menu-item" id="inv-credit">
                                    <i class="fas fa-plus mi-icon"></i>
                                    <?php echo $this->user->lang('Credit'); ?>
                                </button>

                                <div class="menu-sep"></div>

                                <button class="menu-item" id="inv-markrefunded">
                                    <i class="fas fa-check mi-icon"></i>
                                    <?php echo $this->user->lang('Mark Refunded'); ?>
                                </button>
                                <button class="menu-item" id="inv-markcredited">
                                    <i class="fas fa-check-double mi-icon"></i>
                                    <?php echo $this->user->lang('Mark Credited'); ?>
                                </button>
                            </div>
                        </div>

                        <div class="dropdown" id="invoiceManageActions" data-open="false">
                            <button class="pill" type="button" disabled="disabled">
                                <i class="fas fa-sliders-h"></i>
                                <?php echo $this->user->lang('Manage'); ?>
                                <i class="fas fa-chevron-down caret"></i>
                            </button>

                            <div class="menu" role="menu">
                                <button class="menu-item" id="inv-merge">
                                    <i class="fas fa-object-group mi-icon"></i>
                                    <?php echo $this->user->lang('Merge'); ?>
                                </button>

                                <button class="menu-item" id="inv-clone">
                                    <i class="fas fa-clone mi-icon"></i>
                                    <?php echo $this->user->lang('Clone'); ?>
                                </button>

                                <div class="menu-sep"></div>

                                <button class="menu-item danger" id="inv-voidinvoices">
                                    <i class="fas fa-ban mi-icon"></i>
                                    <?php echo $this->user->lang('Void'); ?>
                                </button>

                                <button class="menu-item danger" id="inv-deleteinvoices">
                                    <i class="fas fa-trash mi-icon"></i>
                                    <?php echo $this->user->lang('Delete'); ?>
                                </button>
                            </div>
                        </div>

                        <button class="pill" id="inv-recalculate" disabled="disabled">
                            <i class="fas fa-sync-alt"></i>
                            <?php echo $this->user->lang('Recalculate'); ?>
                        </button>

                        <button class="pill warning" id="inv-cancelsub" disabled="disabled">
                            <i class="fas fa-exclamation-triangle"></i>
                            <?php echo $this->user->lang('Cancel Subscription'); ?>
                        </button>
                    </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>