<style>
    .btn-nb{
        background-color: #ddd;  
        width:100%;
        /*padding-right: 1%;*/
        /*padding: 20%;*/
    }
    .setting-title{
        margin: 0;
        font-size: 13px;
        font-weight: bold;
        width: 100px;
        vertical-align: middle;
        display: inline-block;
    }
    .cash-btn{
        padding:4px;
        min-width:90px;
        background-color: #e6e6e6;
    }
    .cash-tr .col-md-3:first-child{
        padding-left:7px !important; 
    }
    #TagsTable td.inputDiv .btn:hover{
        border:none;
    }
    .generate-main-divs{
        margin-top:-25px;
    }
    .cash-cats-div .col-md-2{
        padding-left:0px;
        padding-right:0px;
    }
    #postponed_report_modal .table thead tr th{
        color:black  !important;
    }
    #scanned_cust_name{
        font-size: 20px;
        margin-top: 20px;
        border: 3px solid;
        padding: 10px;
    }
    #inv_rec_modal .my_tr{
        border-bottom: 1px solid rgba(0,0,0,0.07);
        padding:10px;
    }

    #inv_rec_modal .rem{
        color:#eb9220;
        cursor:pointer;
        font-weight:700;
    }
    #inv_rec_modal .balance{
        color:red;
        font-weight:700;
    }
    /*     .btn{
    white-space: normal;
    }*/

</style>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="customer-last-order-modal" >
    <div class="modal-dialog " >
        <div class="modal-content ">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fa-22"></i></button>
                <h4></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12" id="last_orders_div">     
                        <h3 class="semi-bold"><?php echo (CommonLanguage::getMessage('last_orders')); ?></h3>
                        <table class="table table-bordered " id="tbl_last_orders">
                            <thead>
                                <tr>
                                    <th class="text-center"><?php echo CommonLanguage::getMessage('Item'); ?></th>
                                    <th class="text-center"><?php echo CommonLanguage::getMessage('qty'); ?></th>
                                    <th class="text-center"> <?php echo CommonLanguage::getMessage('Price'); ?></th> 
                                    <th class="text-center"> <?php echo CommonLanguage::getMessage('tags'); ?></th> 
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
            </div>
            <?php echo Forms::ModalLoader('customer_last_order_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="product-recipe-modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content ">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fa-22"></i></button>
                <h4></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12" id="product_recipe_div">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
            </div>
            <?php echo Forms::ModalLoader('product_recipe_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="EditDiscount"  data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('discount'); ?></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-4 modal-field-caption"><?php print CommonLanguage::getMessage('discount'); ?>:</div>
                    <div class="col-xs-8">
                        <div class="input-group InputSpinner full-width">
                            <input type="text" id="DiscountInput1" class="form-control" value="0" onblur="InputMustBeAtleastN(this, 0)" />
                            <div class="input-group-btn-vertical">
                                <button class="btn btn-default more"><i class="fa fa-caret-up"></i></button>
                                <button class="btn btn-default"><i class="fa fa-caret-down"></i></button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button type="button" class="btn btn-primary" id = "SubmitDisc"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="tagsModal" data-backdrop="static" data-id="" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <div class="row">
                    <h4 class="text-center"><i class="fa fa-tags"></i> <?php print CommonLanguage::getMessage('criteria') ?></h4>
                </div>
            </div>
            <div class="modal-body">
                <?php echo Forms::AlertDiv('tag_Alert'); ?>
                <div class="row criteria-detail-div">      
                </div>
            </div>
            <div class="modal-footer">
                <div class="col-md-12 row ">
                    <button id="cancelTag" type="submit" data-dismiss="modal" class="btn btn-danger btn-cons"><i class="fa fa-times"></i> <?php print CommonLanguage::getMessage('Close') ?></button>
                    <button id="addTag" type="submit" class="btn bg-complete-light btn-cons"><i class="fa fa-check"></i> <?php print CommonLanguage::getMessage('Save') ?></button>
                </div>
            </div>
            <?php echo Forms::ModalLoader('Criteria_Loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade " style="max-width: 500px;margin: auto;max-height: 100%;" id="expiry-date-modal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog ">
        <div class="modal-content">
            <div class="modal-content">
                <div class="modal-header clearfix text-left">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                    </button>
                    <h5 class="add-label bold"><?php echo CommonLanguage::getMessage('others'); ?></h5>
                </div>
                <div class="modal-body">
                    <form id="expiry-date-form" action="javascript:void(0);">
                        <div class="row">
                            <div class="col-md-12 exp-modal-div">
                                <div class="form-group">
                                    <label class=""><?php echo CommonLanguage::getMessage('Date'); ?></label>
                                    <div id="expiry_date_main_div">
                                        <input class="full-width" id="expiry_date" name="expiry_date" type="hidden" required />
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12 lot-modal-div">
                                <div class="form-group">
                                    <label class=""><?php echo CommonLanguage::getMessage('lot'); ?></label>
                                    <div id="lot_main_div">
                                        <input type="hidden" class="full-width " id="lot_nb" name="lot_nb"   />
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12 serial-modal-div">
                                <div class="form-group">
                                    <label class=""><?php echo CommonLanguage::getMessage('serial'); ?></label>
                                    <div id="serial_main_div">
                                        <input class="full-width " id="serial_nb" name="serial_nb" type="hidden"  />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default " data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                    <button type="button" id="submit_expiry_date" class="btn btn-primary"><?php print CommonLanguage::getMessage('Save'); ?></button>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="reservation-duration-modal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content-wrapper">
            <div class="modal-content">
                <div class="modal-header clearfix text-left">
                    <h5 class="add-label bold"><?php echo CommonLanguage::getMessage('reservation_duration'); ?></h5>
                </div>
                <div class="modal-body">
                    <form id="reservation_duration-form" action="javascript:void(0);">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group col-md-6">
                                    <label ><?php echo CommonLanguage::getMessage('start_time') ?><span class="red-star">*</span></label>
                                    <input type="text" class=" form-control" id="reserve_start_date"  name="reserve_start_date" required/>
                                </div>
                                <div class="form-group col-md-6">
                                    <label><?php echo CommonLanguage::getMessage('end_time') ?><span class="red-star">*</span></label>
                                    <input type="text" class=" form-control" id="reserve_end_date" name="reserve_end_date" required/>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" id="submit_reservation_duration" class="btn btn-primary"><?php print CommonLanguage::getMessage('Save'); ?></button>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="ConfirmDeleteRow" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('Confirm_Delete') ?></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12 m-t-10">
                        <p><?php print CommonLanguage::getMessage('About_Delete_item_row') ?></p>
                        <p><?php print CommonLanguage::getMessage('Proceed_Delete') ?></p>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn btn-danger width-auto" id="Row_Delete"><?php print CommonLanguage::getMessage('delete') ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="InvTypeMpdal"  role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix ">
                <div class="row">
                    <div class="col-md-6">
                        <h5 class="add-label bold text-left"><?php echo CommonLanguage::getMessage('payment'); ?></h5>
                    </div>
                    <div class="col-md-6 pull-right">
                        <label><?php echo CommonLanguage::getMessage('with_print') ?></label>
                        <input type="checkbox" id="inv_with_print" name="inv_with_print" class="pull-right" checked/>
                    </div>
                </div>
            </div>
            <div class="modal-body" style="margin-bottom:-45px;">
                <div class="row">
                    <input type="hidden" name="main_total_value" value =""/>
                    <input type="hidden" name="table_id" value ="<?php echo $destination; ?>"/>
                    <?php echo Forms::AlertDiv('Payment_Alert'); ?>
                    <div class="row">
                        <div class="col-md-6">
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-12 col-lg-12 form-group">
                        <label class="all-caps payment-labels m-b-0" data-type="cash_amount"><i class="fa fa-money "></i>&nbsp;&nbsp;<?php print CommonLanguage::getMessage('cash'); ?></label>
                        <hr class="m-t-0 m-b-0">
                        <table class="table" cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr class="cash-tr">
                                    <td colspan="4">
                                        <div class="col-md-12 cash-cats-div">
                                            <?php foreach ($cash_cat as $cash) { ?>
                                                <div class="col-md-2">
                                                    <button class="btn cash-btn" type="button" data-val = "<?php echo $cash['Cash_Category_Value']; ?>"><?php echo CommonFunctions::public_round_number($cash['Cash_Category_Value']); ?></button> 
                                                </div>
                                            <?php } ?>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 20%;"><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('amount'); ?></span></td>
                                    <td style="width: 30%;">
                                        <input type="number" id="cash_amount" name="cash_amount" onkeyup="CashUnpaidAmount()" onchange="CashUnpaidAmount()" class="form-control payment-inputs" value="0"  />
                                    </td>
                                    <td style="width: 20%;"><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('cash'); ?></span>&nbsp;&nbsp;<strong id="clear-cash-cat"><i class="fa fa-times" style="cursor:pointer;"></i></strong></td>
                                    <td style="width: 30%;">
                                        <input type="number" id="cash_cat_amount" name="cash_cat_amount" class="form-control payment-inputs" value="0" onblur="CashUnpaidAmount(this, 1);" />
                                    </td>
                                </tr>
                                <tr>
                                </tr>
                                <tr>
                                    <td class=text-center colspan="4" style="color:red;font-size:large;">
                                        <strong><?php echo CommonLanguage::getMessage('cash_return') ?>:&nbsp;</strong>
                                        <strong class="cash-return-span">0</strong>&nbsp;<strong class="cash-return-currency"><?php echo $PrimaryCurrency[1] ?></strong>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-sm-12 col-md-12 col-lg-12 form-group generate-main-divs">
                        <label class="all-caps payment-labels m-b-0" data-type="other_amount"><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;<?php print CommonLanguage::getMessage('others'); ?></label>
                        <hr class="m-t-0 m-b-0">
                        <table class="table" cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr>
                                    <td style="width: 30%;"><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('amount'); ?></span></td>
                                    <td style="width: 70%;">
                                        <input type="number" name="other_amount" onkeyup="CashUnpaidAmount()" onchange="CashUnpaidAmount()"  id="other_amount" min="0" class="form-control payment-inputs" value="0"  />
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 30%;"><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('description'); ?></span></td>
                                    <td style="width: 70%;"><textarea id="other_description" name="other_description" class="form-control full-width"></textarea></td>
                                </tr>
                                <tr>
                                    <td ><input name="check_credit" value="1" type="radio" id="check_input_label"/> <label for="check_input_label"> <?php print CommonLanguage::getMessage('check'); ?></label></td>
                                    <td><input name="check_credit" value="2" type="radio" id="credit_input_label"/><label for="credit_input_label">&nbsp;<?php print CommonLanguage::getMessage('credit_card'); ?>
                                        </label> </td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-sm-12 col-md-12 col-lg-12 form-group generate-main-divs">
                        <label class="all-caps"><i class="fa fa-money"></i>&nbsp;&nbsp;<?php print CommonLanguage::getMessage('unpaid_amount'); ?></label>
                        <hr class="m-t-0 m-b-0">
                        <table class="table" cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr>
                                    <td>
                                        <input type="text" class="form-control payment-inputs"  min="0" id="invoice_unpaid_amount" name="invoice_unpaid_amount" readonly/>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="customer_id"   name="customer_id" placeholder="<?php print CommonLanguage::getMessage('search_customer'); ?>"/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <?php if (!empty(smc_session()['default_setting']['hotel_database'])) { ?>
                        <div class="col-sm-12 col-md-12 col-lg-12 form-group generate-main-divs">
                            <label class=""><?php print CommonLanguage::getMessage('reservation'); ?></label>
                            <hr class="m-t-0 m-b-0">
                            <table class="table" cellpadding="0" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td>
                                            <input type="hidden" name="reservation_id" id="reservation_id" class="full-width" />
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    <?php } ?>
                </div>
            </div>
            <div class="modal-footer">
                <button data-dismiss="modal" class="btn btn-danger btn-cons"><i class="fa fa-times"></i> <?php print CommonLanguage::getMessage('Close') ?></button>
                <button id="submit_payment"  class="btn btn-info btn-cons white" type="button"><i class="fa fa-check"></i> <?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
            <?php echo Forms::ModalLoader('Payment_Loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="invoice_desc_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
        <i class="pg-close"></i>
    </button>
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="text-left p-b-5"><span class="semi-bold"><?php print CommonLanguage::getMessage('new_kitchen_note') ?></span></h5>
            </div>
            <div class="modal-body">
                <div class="row">
                    <?php
                    if (!empty($invoice_notes)) {
                        foreach ($invoice_notes as $note) {
                            ?>
                            <div class="col-md-4 p-0 fn-btn">
                                <button type="button" class="btn btn-default w-100 inv_desc_note"><?php echo $note['note_title']; ?></button>
                            </div>
                            <?php
                        }
                    }
                    ?>
                </div>
                <div class="row">
                    <div class="col-md-12  order_note_details">
                        <textarea id="text_note" class="form-control" rows="3" placeholder="<?php print CommonLanguage::getMessage('place_order_note') ?>" style="resize:none;"></textarea>
                        <span id="NoteSpan" class="hidden"></span>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button  type="button" data-dismiss="modal" class="btn btn-danger fs-15"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button id="add_invoice_desc" type="button" class="btn btn-primary fs-15"><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="order_note_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
        <i class="pg-close"></i>
    </button>
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="text-left p-b-5"><span class="semi-bold"><?php print CommonLanguage::getMessage('new_kitchen_note') ?></span></h5>
            </div>
            <div class="modal-body">
                <div class="row">
                    <?php
                    if (!empty($kitchen_notes)) {
                        foreach ($kitchen_notes as $note) {
                            ?>
                            <div class="col-md-4 p-0 fn-btn">
                                <button type="button" class="btn btn-default w-100 kitchen_note"><?php echo $note['note_title']; ?></button>
                            </div>
                            <?php
                        }
                    }
                    ?>
                </div>
                <div class="row">
                    <div class="col-md-12  order_note_details">
                        <textarea id="order_note_description" class="form-control" rows="3" placeholder="<?php print CommonLanguage::getMessage('place_order_note') ?>" style="resize:none;"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button  type="button" data-dismiss="modal" class="btn btn-danger fs-15"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button id="submit_kitchen_note" type="button" class="btn btn-primary fs-15"><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade bs-example-modal-md " id="FunctionsModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:90%">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><i class="pg-close fa-22"></i></span></button>
            </div>
            <div class="modal-body">
                <?php
                if (smc_session()['default_setting']['activate_smart_diner'] == 1 && $permissions->hasPermission('smart_diner') && isset($invoice_details['main_invoice']['Invoice_ID_Auto'])) {
                    if ($permissions->hasPermission('transfer_user')) {
                        ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100" id="" data-toggle="modal" data-target="#transfer_user_modal">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-shopping-cart fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('transfer_user') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('transfer_table')) { ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 key_pad_actions" data-role="TRANSFER" type="1" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-shopping-cart fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('transfer_table') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('transfer_items')) { ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 key_pad_actions" data-role="TRANSFERITEMS" id="" type="2">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-shopping-cart fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('transfer_items') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('split_items')) { ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 key_pad_actions" data-role="SPLITITEMS" type="4">
                                <span class="p-t-5 p-b-5"> 
                                    <i class="fa fa-shopping-cart fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('split_items') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('merge_tables')) { ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 key_pad_actions" data-role="MERGETABLES" type="3">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-shopping-cart fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('merge_tables') ?></span>
                            </button>
                        </div>
                    <?php } ?> 
                    <div class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100 key_pad_actions" id="reprint_order_kitchen">
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-shopping-cart fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('reprint_order') ?></span>
                        </button>
                    </div>
                    <hr>
                    <?php
                } if ($functions_all) {
                    if (empty($destination)) {
                        ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 check_new" id="invoicePOS">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-shopping-cart fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('invoice') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('return_pos') && empty($destination)) { ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 check_new" id="retunPOS">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-refresh fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('return') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('exchange_pos') && empty($destination)) { ?>
                        <div class="btn-group col-4 p-0 fn-btn" style="display: none;">
                            <button type="button" class="btn btn-default w-100 check_new" id="exchange_pos">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-retweet fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('exchange') ?></span>
                            </button>
                        </div>
                    <?php }if ($permissions->hasPermission('order_pos') && empty($destination)) {
                        ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 check_new" id="order_pos">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-retweet fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('order') ?></span>
                            </button>
                        </div>
                        <?php
                    }if ($permissions->hasPermission('pos_request_transfer') && empty($destination)) {
                        ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 check_new" id="request_transfer">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-retweet fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('transfer') ?></span>
                            </button>
                        </div>
                        <?php
                    }
                    if ($permissions->hasPermission('pos_quotation') && empty($destination)) {
                        ?>
                        <div class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100" id="print_order_invoice_no_save">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-retweet fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage('quotation') . (smc_session()['default_setting']['activate_pos_shortcust_keys'] == 1 ? ' (alt+5 or F5)' : '') ?></span>
                            </button>
                        </div>
                        <?php
                    }
                    if ($permissions->hasPermission('actual_pos')) {
                        ?>
                        <div style="display: none;" class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100" id="pos_actual">
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-retweet fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo CommonLanguage::getMessage($is_actual ? 'official' : 'actual') ?></span>
                            </button>
                        </div>
                        <?php
                    }
                }
                if ($permissions->hasPermission('add_deposite')) {
                    ?>
                    <div class="btn-group col-4 p-0 fn-btn" style="display: none;">
                        <button type="button" class="btn btn-default w-100" id="addDeposite" data-type="1">
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-history fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('deposit') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('add_withdrawal')) { ?>
                    <div class="btn-group col-4 p-0 fn-btn" style="display: none;">
                        <button type="button" class="btn btn-default w-100" id="addWitdrawal" data-type="2">
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-user fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('withdrawal') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('add_payment')) { ?>
                    <div class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" id="addPayment" data-type="3">
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-user fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('payment') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('add_receipt')) { ?>
                    <div style="display: none;" class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" id="addReceipt" data-type="3">
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-user fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('receipt') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('add_pos_expense')) { ?>
                    <div class="btn-group col-4 p-0 fn-btn" style="display: none;">
                        <button type="button" class="btn btn-default w-100" id="addExpense"  data-target="#addExpensesModal" data-toggle="modal">
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-user fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('expenditures') ?></span>
                        </button>
                    </div>
                <?php } if ($functions_all) { ?>
                    <div style="display: none;" class="btn-group col-4 p-0 fn-btn <?php echo (!isset($invoice_details['main_invoice']['Invoice_ID_Auto']) && $permissions->hasPermission('park') && empty($destination)) ? "" : "hidden"; ?>">
                        <button type="button" class="btn btn-default w-100" id="addtoPark">
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-pinterest-p fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('park') ?></span>
                        </button>
                    </div>
                    <?php if ($permissions->hasPermission('retrieve_list') && empty($destination)) { ?>
                        <div style="display: none;"  class="btn-group col-4 p-0 fn-btn <?php echo!isset($invoice_details['main_invoice']['Invoice_ID_Auto']) ? "" : "hidden"; ?>">
                            <button type="button" class="btn btn-default w-100" id="retrieveSales" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('retrieve_sale') ?></span>
                            </button>
                        </div>
                    <?php } if (($permissions->hasPermission('delivery') || $permissions->hasPermission('pos_take_away')) && empty($destination)) { ?>
                        <div style="display: none;" class="btn-group col-4 p-0 fn-btn <?php echo!isset($invoice_details['main_invoice']['Invoice_ID_Auto']) ? "" : "hidden"; ?>">
                            <button type="button" class="btn btn-default w-100 common_delivery" id="delivery"  >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('delivery') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('manager_discount')) { ?>
                        <div style="display: none;" class="btn-group col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100" id="manager_discount" data-toggle="modal" data-target="#manager_pass_modal" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('manager_discount') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('pos_invoice_list') && empty($destination)) { ?>
                        <div class="btn-group col-4 p-0 fn-btn <?php echo!isset($invoice_details['main_invoice']['Invoice_ID_Auto']) ? "" : "hidden"; ?>">
                            <button type="button" class="btn btn-default w-100" data-toggle="modal" data-target="#invoice_list_modal" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('invoices') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('pos_delivery_list') && empty($destination)) { ?>
                        <div style="display: none;" class="btn-group col-4 p-0 fn-btn <?php echo!isset($invoice_details['main_invoice']['Invoice_ID_Auto']) ? "" : "hidden"; ?>">
                            <button type="button" class="btn btn-default w-100" data-toggle="modal" data-target="#invoice_delivery_list_modal" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('delivery_list') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('received_delivery') && empty($destination)) { ?>
                        <div style="display: none;"  class="btn-group col-4 p-0 fn-btn <?php echo!isset($invoice_details['main_invoice']['Invoice_ID_Auto']) ? "" : "hidden"; ?>">
                            <button type="button" class="btn btn-default w-100" data-toggle="modal" data-target="#received_delivery_list_modal" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('received_delivery') ?></span>
                            </button>
                        </div>
                    <?php } if ($permissions->hasPermission('pos_return_list') && empty($destination)) { ?>
                        <div class="btn-group col-4 p-0 fn-btn ">
                            <button type="button" class="btn btn-default w-100" data-toggle="modal" data-target="#return_list_modal" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('return_list') ?></span>
                            </button>
                        </div>
                    <?php }if ($permissions->hasPermission('postponed_list') && empty($destination)) { ?>
                        <div style="display: none;" class="btn-group col-4 p-0 fn-btn ">
                            <button type="button" class="btn btn-default w-100" data-toggle="modal" data-target="#postponed_list_modal" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('posponted') ?></span>
                            </button>
                        </div>
                    <?php }if ($permissions->hasPermission('postponed_report') && empty($destination)) {
                        ?>
                        <div style="display: none;"  class="btn-group col-4 p-0 fn-btn ">
                            <button type="button" class="btn btn-default w-100" data-toggle="modal" data-target="#postponed_report_modal" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-pinterest-p fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('postponed_report') ?></span>
                            </button>
                        </div>
                        <?php
                    }
                } if ($permissions->hasPermission('pos_end_of_shift')) {
                    ?>
                    <div class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" id="end_of_shift" data-toggle="modal" data-target="#confirm_end_of_shift" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-pinterest-p fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('end_of_shift') ?></span>
                        </button>
                    </div>
                <?php }if ($permissions->hasPermission('pos_end_of_day')) { ?>
                    <div style="display: none;" class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" id="end_of_day_btn" data-toggle="modal" data-target="#confirm_end_of_day" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-pinterest-p fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('end_of_day') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('pos_customer_invoices')) { ?>
                    <div class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" data-toggle="modal" data-target="#customer_invoices_list" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-pinterest-p fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('customer_invoice_list') ?></span>
                        </button>
                    </div>
                <?php }if ($permissions->hasPermission('pos_drawer_reason')) { ?>
                    <div style="display: none;" class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" title="<?php print CommonLanguage::getMessage('drawer_reason') ?>"  data-toggle="modal" data-target="#drawer_reason_modal" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-list fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('drawer_reason') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('pos_customer_ledger')) { ?>
                    <div style="display: none;" class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" id="customer_ledger_btn" data-toggle="modal" data-target="#customer_ledger_list" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-pinterest-p fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('customer_statement') ?></span>
                        </button>
                    </div>
                <?php }if ($permissions->hasPermission('pos_exchange_list') && empty($destination)) { ?>
                    <div style="display: none;" class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" id="click_exchange" data-toggle="modal" data-target="#exchange_list" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-pinterest-p fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('exchange_list') ?></span>
                        </button>
                    </div>
                <?php }if ($permissions->hasPermission('pos_road_customer_list')) { ?>
                    <div  style="display: none;" class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" data-toggle="modal" data-target="#road_customer_list" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-user fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('road_customer_list') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('reset_cache')) { ?>
                    <div class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" id="reset_cache" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-repeat fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('reset_cache') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('pos_sync_data_from_server') && smc_session()['default_setting']['sync_type'] == 2) { ?>
                    <div class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100 openFrame"  data-src="Inventory/get_data_server?send_data=0&is_pop=1" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-repeat fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('get_server_data') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('pos_receipt_list')) { ?>
                    <div style="display: none;" class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100" id="receipt_list" >
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-money fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('receipt_list') ?></span>
                        </button>
                    </div>
                <?php } if ($permissions->hasPermission('pos_payment_list')) { ?>
                    <div class="btn-group col-4 p-0 fn-btn">
                        <button type="button" class="btn btn-default w-100 " id="payment_list">
                            <span class="p-t-5 p-b-5">
                                <i class="fa fa-money fs-15"></i>
                            </span>
                            <br>
                            <span class="f-s-10 font-montserrat text-uppercase" ><?php print CommonLanguage::getMessage('payment_list') ?></span>
                        </button>
                    </div>
                <?php } ?>
            </div>
            <?php echo Forms::ModalLoader('FunctionsModalDisabler'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="addNoteModal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="text-left bold"><?php print CommonLanguage::getMessage('new_kitchen_note') ?></h5>
            </div>
            <div class="modal-body">
                <input type="hidden" id="is_delivery_field" name="is_delivery_field" />
                <div class="row">
                    <div class="col-md-12  order_note_details">
                        <textarea id="text_note_delivery" class="form-control" rows="3" placeholder="<?php print CommonLanguage::getMessage('place_order_note') ?>" style="resize:none;"></textarea>
                        <span id="NoteSpan" class="hidden"></span>
                    </div>
                    <div class="col-md-6 takeaway_delivary_details">
                        <label><?php print CommonLanguage::getMessage('Date') ?></label>
                        <div class=" bootstrap-timepicker">
                            <input id="delivery_date" type="text" class="form-control" value="<?php echo $today ?>">
                        </div>
                    </div>
                    <div class="col-md-6 takeaway_delivary_details">
                        <label><?php print CommonLanguage::getMessage('time') ?></label>
                        <div class=" bootstrap-timepicker">
                            <input id="timepicker" type="text" class="form-control" value="<?php echo smc_session()['default_setting']['autoprint_past_delivery'] == 1 ? date('h:i A') : '' ?>">
                        </div>
                    </div>
                    <div class="col-md-6 takeaway_delivary_details delivary_details">
                        <label><?php print CommonLanguage::getMessage('delivery_fees') ?></label>
                        <?php if ($permissions->hasPermission('pos_add_delivery_fees')) { ?>
                            <span class="fa fa-plus-circle m-l-5 openFrame" data-src="<?php echo "Inventory/viewDeliveryFees?is_pop=1" ?>" style="color:#8a7dbe;cursor:pointer"></span>
                        <?php } ?>
                        <input type="hidden" id="shipping_id" class="full-width">
                    </div>
                    <div class="col-md-6 <?php echo $permissions->hasPermission('pos_choose_delivery_depot') && !in_array(4, $pos_fields_hide) ? '' : 'hidden'; ?>">
                        <label><?php print CommonLanguage::getMessage('Depot') ?></label>
                        <input type="hidden" id="delivery_depot_id" class="full-width">
                    </div>
                    <div class="col-md-6 <?php echo!in_array(5, $pos_fields_hide) ? '' : 'hidden'; ?>">
                        <label><?php print CommonLanguage::getMessage('driver') ?></label>
                        <?php if ($permissions->hasPermission('pos_add_driver')) { ?>
                            <span class="fa fa-plus-circle m-l-5 openFrame" data-src="<?php echo "Inventory/driver_list?is_pop=1" ?>" style="color:#8a7dbe;cursor:pointer"></span>
                        <?php } ?>
                        <input type="hidden" id="driver_id" class="full-width">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button  type="button" data-dismiss="modal" class="btn btn-danger fs-15"><?php print CommonLanguage::getMessage('Close') ?></button>
                <?php if ($permissions->hasPermission('pos_take_away')) { ?>
                    <button id="AddNote" type="button" class="AddNote btn btn-primary fs-15 take_away"><?php print CommonLanguage::getMessage('take_away') ?></button>
                <?php } if ($permissions->hasPermission('delivery')) { ?>
                    <button id="AddNote" type="button" class="AddNote btn btn-primary fs-15 delivery "><?php print CommonLanguage::getMessage('delivery') ?></button>
                <?php } ?>
            </div>
            <?php echo Forms::ModalLoader('note_loader'); ?>
        </div>
    </div>
</div>

<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="addExpensesModal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content-wrapper">
            <div class="modal-content">
                <div class="modal-header clearfix text-left ">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                    </button>
                    <h4 class="text-left bold"><?php echo CommonLanguage::getMessage('expenditures'); ?></h4>
                </div>
                <div class="modal-body form-group" >
                    <form id="pos-expense-form" action="javascript:void(0);">
                        <div class="row m-t-10">
                            <?php echo Forms::AlertDiv('expenseAlert'); ?>
                            <div class="col-md-12">
                                <label class="labelText"><?php print CommonLanguage::getMessage('choose_supplier') ?><span class="red-star">*</span></label>
                                <select  id="expense_supplier"  class="full-width  " data-init-plugin="select2" required>
                                    <option value=""> <?php print CommonLanguage::getMessage('choose_supplier'); ?></option> 
                                    <?php foreach ($suppliers as $supp): ?>
                                        <option value="<?php echo $supp['Supplier_ID']; ?>"><?php echo $supp['Supplier_Name'] . ' - ' . $supp['Supplier_Phone']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                        </div>
                        <div class="row m-t-10">
                            <div class="col-md-12">
                                <label class="labelText"><?php print CommonLanguage::getMessage('expense_account') ?><span class="red-star">*</span></label>
                                <input class="Expense_Account full-width"  id="Expense_Account" name="Expense_Account" type="hidden"   required />
                            </div>
                        </div>
                        <div class="row m-t-10">
                            <div class="col-md-12 ">
                                <label><?php echo CommonLanguage::getMessage('currency') ?><span class="red-star">*</span></label>
                                <div id="CurrencyIDContainer"  >
                                    <div class="form-group form-material floating ">
                                        <div class="input-group-btn DropDownForForms Closable  " id="CurrencyDropDownExpense">
                                            <button type="button" class="btn btn-primary btn-block dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                                <span><?php echo CommonLanguage::getMessage('select') ?></span>
                                                <input type="hidden" name="Currency_Expense_ID" value="" class="form-control ignore" onkeyup="return false" onkeydown="return false" required/>
                                            </button>
                                            <ul class="dropdown-menu">
                                                <?php echo $CurList ?>
                                                <li class="divider"></li>
                                                <li><a class="LoadMore">More..</a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row m-t-10">
                            <div class="col-md-6 ">
                                <label class="labelText"><?php print CommonLanguage::getMessage('amount') ?><span class="red-star">*</span> <span class="red-star dep-with-total"></span></label>
                                <input type="number" min="1" step="any" id="expense_amount" placeholder="<?php print CommonLanguage::getMessage('amount'); ?>" name="expense_amount" class="form-control " required>
                            </div>
                            <div class="col-md-6 ">
                                <label class="labelText"><?php print CommonLanguage::getMessage('paid_amount') ?></label>
                                <input type="number" min="0" step="any" value="0" id="expense_paid_amount" placeholder="<?php print CommonLanguage::getMessage('paid_amount'); ?>" name="expense_paid_amount" class="form-control " >
                            </div>
                        </div>
                        <div class="row m-t-10">
                            <div class="col-md-12">
                                <label class="labelText"><?php print CommonLanguage::getMessage('note') ?></label>
                                <textarea id="expense_note" class="form-control" rows="4" placeholder="<?php print CommonLanguage::getMessage('place_note') ?>" style="resize:none"></textarea>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button  type="button" data-dismiss="modal" class="btn btn-danger btn-cons"><i class="fa fa-times"></i> <?php print CommonLanguage::getMessage('Close') ?></button>
                    <button id="submitExp" type="submit" class="btn btn-info btn-cons"><i class="fa fa-check"></i> <?php print CommonLanguage::getMessage('Save') ?></button>
                </div>
                <?php echo Forms::ModalLoader('expense_main_loader'); ?>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="CustListModal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg" >
        <div class="modal-content ">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fa-22"></i></button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <div class="table-responsive">
                            <table class="col-md-12 table table-bordered " id="Customertable">
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('customer_name'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('address'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('Phone'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="transfer_user_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <h4 class="modal-title text-center"><?php print CommonLanguage::getMessage('transfer_table_user') ?></h4>
            </div>
            <div class="modal-body">
                <form id="transfer_user_form">
                    <div class="row">
                        <?php echo Forms::AlertDiv('transfer_user_alert'); ?>
                        <input type='hidden' name='table_id' value="<?php echo $destination; ?>"/>
                        <input type='hidden' name='Invoice_ID_Auto' value="<?php echo!empty($invoice_details['main_invoice']['Invoice_ID_Auto']) ? : ''; ?>"/>
                        <div class="col-md-12 m-t-10">
                            <select name="user_id" class="full-width select" data-init-plugin="select2">
                                <?php foreach ($all_users as $user): if (!empty($invoice_details['main_invoice']['Close_ID']) && $invoice_details['main_invoice']['Close_ID'] != $user['User_ID']) : ?>
                                        <option value="<?php echo $user['User_ID']; ?>"><?php echo $user['User_Name']; ?></option>
                                        <?php
                                    endif;
                                endforeach;
                                ?>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button class="btn btn-primary" id="submit_user_transfer"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('transfer_user_disabler'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="ava_rese_tbl_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-14"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div id="ava_rese_div">
                    </div>
                </div>
            </div>
            <?php echo Forms::ModalLoader('ava_rese_tbl_disabler'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="new_address_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-14"></i></button>
                <h4 class="modal-title text-center"><?php print CommonLanguage::getMessage('new_customer_address'); ?></h4>
            </div>
            <div class="modal-body">
                <form id="">
                    <div class="row">
                        <?php echo Forms::AlertDiv('new_address_alert'); ?>
                        <div class="col-md-12 m-t-10">
                            <input type="text" placeholder="<?php print CommonLanguage::getMessage('search_customer'); ?>"  name="customer_id" class="form-control " required>
                            <textarea  placeholder="<?php print CommonLanguage::getMessage('address'); ?>"  name="customer_address" id="current_customer_address" class="form-control m-t-10" required style="resize:none"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button class="btn btn-primary" id="submit_new_address"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('new_address_disabler'); ?>
        </div>
    </div>
</div>

<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="retrieve_list_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
                <div id='RetreiveListAlert'></div>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search" id="retreiveListTable" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:1%" >#</th>
                                        <th class="text-center" style="width:3%" ><?php echo CommonLanguage::getMessage('time'); ?></th>
                                        <th class="text-center" style="width:4%" ><?php echo CommonLanguage::getMessage('customer'); ?></th>
                                        <th class="text-center"><?php echo CommonLanguage::getMessage('address'); ?></th>
                                        <th class="text-center" style="width:4%" ><?php echo CommonLanguage::getMessage('Phone'); ?></th>
                                        <th class="text-center" style="width:4%" ><?php echo CommonLanguage::getMessage('description'); ?></th>
                                        <?php if (!in_array(5, $pos_fields_hide)) { ?>
                                            <th class="text-center" style="width:4%" ><?php echo CommonLanguage::getMessage('driver'); ?></th>

                                        <?php } ?>
                                        <th class="text-center" style="width:4%" ><?php echo CommonLanguage::getMessage('type'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <?php echo Forms::ModalLoader('retrieve_list_modal_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade DontReset" id="scan_cust_qr" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content ">
            <div class="modal-header text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="bold"><?php echo CommonLanguage::getMessage('order_details'); ?></h5>
            </div>
            <div class="modal-body">
                <div id="cust_card_alert"></div>
                <form id="scan_cust_qr-form" action="javascript:void(0);">
                    <?php if ($permissions->hasPermission('scan_customer_card')) { ?>
                        <div class="row form-group ">
                            <div class="col-xs-12 col-md-12 m-b-10">
                                <?php for ($i = 0; $i <= 9; $i++) { ?>
                                    <div class=" col-xs-6 col-sm-4 col-md-1 col-lg-1 p-0"><button type="button" class="btn btn-default btn-nb "><?php echo $i; ?></button></div>
                                <?php } ?>
                                <div class=" col-xs-12 col-sm-8 col-md-2 col-lg-2 p-0"><button type="button" class="btn btn-default btn-nb btn-scan-clear"><?php echo CommonLanguage::getMessage('clear') ?></button></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12 m-b-10">
                                <div class="col-md-6"> 
                                    <label><?php echo CommonLanguage::getMessage('Code') ?><span class="red-star">*</span></label>
                                    <input type="password" id="scanned_cust_id" class="form-control" readonly/>
                                </div>
                                <div class="col-md-6"> 
                                    <button type="button" class="btn  btn-info text-white " id="generate_scan" style="    margin-top: 26px;"><?php echo CommonLanguage::getMessage('generate') ?></button>
                                </div>
                            </div>
                        </div>
                    <?php } if ($permissions->hasPermission('pos_order_delivery_date')) { ?>
                        <div class="row delivery_date_div">
                            <div class="col-md-12 m-b-10">
                                <div class="col-md-6"> 
                                    <label><?php echo CommonLanguage::getMessage('Delivery_Date') ?></label>
                                    <input type="text" id="order_delivery_date" class="form-control"  />
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                    <div class="row">
                        <div class="col-md-12">
                            <div id="scanned_cust_name" class="hidden"></div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger text-white " id="close_fill_scanned_customer" data-dismiss="modal" ><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn  btn-info text-white " id="fill_scanned_customer" ><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade bs-example-modal-md" data-backdrop="static" id="CustomerProceedModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"> </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div id="confirm_change_customer_alert"></div>
                    <div class="col-md-12 ">
                        <p><?php print CommonLanguage::getMessage('confirm_customer_change') ?></p>
                        <p><?php print CommonLanguage::getMessage('proceed_change_price') ?></p>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary yes-btn"  style="width:auto"><?php echo CommonLanguage::getMessage('yes') ?></button>
                <button type="button" class="btn btn-danger  pull-left no-btn"  data-dismiss="modal"><?php echo CommonLanguage::getMessage('no') ?> </button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="manager_pass_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <div id="manager_pass_alert"></div>
                <h4 class="modal-title"><strong><?php print CommonLanguage::getMessage('key'); ?>:</strong>&nbsp;&nbsp;<span id="seed_key" class="bold red-star" ></span></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-4 modal-field-caption"><?php print CommonLanguage::getMessage('password'); ?>:</div>
                    <div class="col-xs-8">
                        <div class="input-group InputSpinner full-width">
                            <input type="password" id="password_input" class="form-control"   />
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button type="button" class="btn btn-primary" id = "SubmitManagerPass"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="invoice_list_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10">
                    <div class="col-md-12">
                        <div  class="col-md-1 ">
                            <label><?php print CommonLanguage::getMessage('invoice_nb'); ?></label>
                            <input id="inv_list_nb"  type="text" class="full-width form-control"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                            <input id="inv_cust"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 <?php echo smc_session()['default_setting']['add_pos_customer'] != 0 ? '' : 'hidden' ?>">
                            <label><?php print CommonLanguage::getMessage('road_customer'); ?></label>
                            <input id="inv_pos_cust"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('payment_status'); ?></label>
                            <select id="invoice_status" class="full-width" multiple data-init-plugin="select2">
                                <!--<option value="all"><?php echo CommonLanguage::getMessage('all') ?></option>-->
                                <option value="0"><?php echo CommonLanguage::getMessage('unpaid') ?></option>
                                <option value="1"><?php echo CommonLanguage::getMessage('partially_paid') ?></option>
                                <option value="2"><?php echo CommonLanguage::getMessage('paid') ?></option>
                                <option value="3"><?php echo CommonLanguage::getMessage('park') ?></option>
                            </select>
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('delivery'); ?></label>
                            <select id="inv_is_delivery" class="full-width" data-init-plugin="select2">
                                <option value="all"><?php echo CommonLanguage::getMessage('all') ?></option>
                                <option value="0"><?php echo CommonLanguage::getMessage('no') ?></option>
                                <option value="1"><?php echo CommonLanguage::getMessage('yes') ?></option>
                            </select>
                        </div>
                        <div  class="col-md-3 pull-right ">
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="inv_list_date" name="inv_list_date" class="form-control" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div  class="col-md-3 ">
                            <label><?php print CommonLanguage::getMessage('due_date'); ?></label>
                            <input id="inv_list_due_date" name="inv_list_due_date" class="form-control" autocomplete="off" />
                        </div>
                        <div  class="col-md-3 <?php echo smc_session()['default_setting']['activate_smart_diner'] ? '' : 'hidden' ?>">
                            <label><?php print CommonLanguage::getMessage('status') ?></label>
                            <select class="full-width" id="smart_status" data-init-plugin="select2">
                                <option value="0" ><?php echo CommonLanguage::getMessage('select') ?></option>
                                <option value="1" ><?php echo CommonLanguage::getMessage('delivery') ?></option>
                                <option value="2" ><?php echo CommonLanguage::getMessage('take_away') ?></option>
                                <option value="3" ><?php echo CommonLanguage::getMessage('tables') ?></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;" >
                            <table class="table table-hover demo-table-search full-width" id="invoiceListTable" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:5%" ><input type="checkbox" class="inv_check_all_td pull-left multi_delete"/>#</th>
                                        <?php if (smc_session()['default_setting']['activate_smart_diner'] == 1) { ?>
                                            <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('table'); ?></th>
                                        <?php } ?>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('customer'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Date'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('due_date'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('total'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('paid_amount'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('remaining'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                                <tfoot>
                                <th >
                                    <?php if ($permissions->hasPermission('pos_multi_inv_delete')) { ?>
                                        <button id="multi_dlt_inv_btn" class="btn btn-danger pull-left"><?php echo CommonLanguage::getMessage('delete') ?></button>
                                    <?php } ?>
                                </th>
                                <?php if (smc_session()['default_setting']['activate_smart_diner'] == 1) { ?>
                                    <th></th>
                                <?php } ?>
                                <th></th><th></th><th></th>
                                <th ><div class="text-center"><strong><span id="total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th ><div class="text-center"><strong><span id="inv_paid_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th ><div class="text-center"><strong><span id="inv_rem_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th></th>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="invoice_delivery_list_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10">
                    <div class="col-md-12">
                        <div  class="col-md-3 ">
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="delivery_list_date" name="delivery_list_date" class="form-control" autocomplete="off"/>
                        </div>
                        <div  class="col-md-1 ">
                            <label><?php print CommonLanguage::getMessage('invoice_nb'); ?></label>
                            <input id="delivery_list_nb"  type="text" class="full-width form-control"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('user'); ?></label>
                            <input id="delivery_user"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                            <input id="delivery_cust"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 <?php echo smc_session()['default_setting']['add_pos_customer'] != 0 ? '' : 'hidden' ?>">
                            <label><?php print CommonLanguage::getMessage('road_customer'); ?></label>
                            <input id="delivery_pos_cust"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('payment_status'); ?></label>
                            <select id="delivery_status" class="full-width" multiple data-init-plugin="select2">
                                <!--<option value="all"><?php echo CommonLanguage::getMessage('all') ?></option>-->
                                <option value="0"><?php echo CommonLanguage::getMessage('unpaid') ?></option>
                                <option value="1"><?php echo CommonLanguage::getMessage('partially_paid') ?></option>
                                <option value="2"><?php echo CommonLanguage::getMessage('paid') ?></option>
                                <option value="3"><?php echo CommonLanguage::getMessage('park') ?></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="invoiceDeliveryListTable" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:5%" ><input type="checkbox" class="inv_check_all_td pull-left multi_delete"/>#</th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('customer'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Delivery_Date'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('address'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('total'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('delivery_fees'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('paid_amount'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                                <tfoot>
                                <th >
                                    <?php if ($permissions->hasPermission('pos_multi_inv_delete')) { ?>
                                        <button id="multi_dlt_delv_btn" class="btn btn-danger pull-left"><?php echo CommonLanguage::getMessage('delete') ?></button>
                                    <?php } ?>
                                </th>
                                <th></th><th></th><th></th>
                                <th ><div class="text-center"><strong><span id="delivery_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th ><div class="text-center"><strong><span id="delivery_fees_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th ><div class="text-center"><strong><span id="delivery_paid_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th></th>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="postponed_list_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10 form-group">
                    <div class="col-md-12">
                        <div  class="col-md-1 ">
                            <label><?php print CommonLanguage::getMessage('invoice_nb'); ?></label>
                            <input id="post_list_nb"  type="text" class="full-width form-control"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                            <input id="post_cust"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 <?php echo smc_session()['default_setting']['add_pos_customer'] != 0 ? '' : 'hidden' ?>">
                            <label><?php print CommonLanguage::getMessage('road_customer'); ?></label>
                            <input id="post_pos_cust"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('payment_status'); ?></label>
                            <select id="post_status" class="full-width" multiple data-init-plugin="select2">
                                <!--<option value="all"><?php echo CommonLanguage::getMessage('all') ?></option>-->
                                <option value="0"><?php echo CommonLanguage::getMessage('unpaid') ?></option>
                                <option value="1"><?php echo CommonLanguage::getMessage('partially_paid') ?></option>
                                <option value="2"><?php echo CommonLanguage::getMessage('paid') ?></option>
                                <option value="3"><?php echo CommonLanguage::getMessage('park') ?></option>
                            </select>
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('delivery'); ?></label>
                            <select id="post_is_delivery" class="full-width" data-init-plugin="select2">
                                <option value="all"><?php echo CommonLanguage::getMessage('all') ?></option>
                                <option value="0"><?php echo CommonLanguage::getMessage('no') ?></option>
                                <option value="1"><?php echo CommonLanguage::getMessage('yes') ?></option>
                            </select>
                        </div>
                        <div  class="col-md-3  ">
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="post_list_date" name="post_list_date" class="form-control" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div  class="col-md-3 ">
                            <label><?php print CommonLanguage::getMessage('posponted_status') ?></label>
                            <select class="full-width" id="posponted_status_filter" data-init-plugin="select2">
                                <option value="" ><?php echo CommonLanguage::getMessage('select') ?></option>
                                <option value="1" ><?php echo CommonLanguage::getMessage('Request') ?></option>
                                <option value="2" ><?php echo CommonLanguage::getMessage('production_line') ?></option>
                                <option value="3" ><?php echo CommonLanguage::getMessage('production_done') ?></option>
                                <option value="4" ><?php echo CommonLanguage::getMessage('delivered') ?></option>
                                <option value="5" ><?php echo CommonLanguage::getMessage('on_request') ?></option>
                                <option value="6" ><?php echo CommonLanguage::getMessage('canceled') ?></option>
                            </select>
                        </div>
                        <div  class="col-md-3 ">
                            <label><?php print CommonLanguage::getMessage('posponted_date'); ?></label>
                            <input id="post_list_due_date" name="post_list_due_date" class="form-control" autocomplete="off" />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('committed') . ' ?'; ?></label>
                            <select id="post_is_committed" class="full-width" data-init-plugin="select2">
                                <option value="all"><?php echo CommonLanguage::getMessage('All') ?></option>
                                <option value="0"><?php echo CommonLanguage::getMessage('no') ?></option>
                                <option value="1"><?php echo CommonLanguage::getMessage('yes') ?></option>
                            </select>
                        </div>
                        <div class="col-md-2">
                            <label><?php echo CommonLanguage::getMessage('choose_branch') ?></label>
                            <input id="current_post_branch_id" type="hidden" class="full-width" name="current_post_branch_id" >
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="postponedListTable" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:2%">#</th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('customer'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Date'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('postponed_date_time'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('note'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('total'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('paid_amount'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('remaining'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('posponted_status'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                                <tfoot>
                                <th></th><th></th><th></th><th></th><th></th>
                                <th ><div class="text-center"><strong><span id="total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th ><div class="text-center"><strong><span id="post_paid_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th ><div class="text-center"><strong><span id="post_rem_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th></th>
                                <th></th>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="postponed_report_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10 form-group">
                    <div  class="col-md-1 ">
                        <label><?php print CommonLanguage::getMessage('invoice_nb'); ?></label>
                        <input id="report_post_list_nb"  type="text" class="full-width form-control"  />
                    </div>
                    <div  class="col-md-2 ">
                        <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                        <input id="report_post_cust"  type="hidden" class="full-width"  />
                    </div>
                    <div  class="col-md-2 <?php echo smc_session()['default_setting']['add_pos_customer'] != 0 ? '' : 'hidden' ?>">
                        <label><?php print CommonLanguage::getMessage('road_customer'); ?></label>
                        <input id="report_post_pos_cust"  type="hidden" class="full-width"  />
                    </div>
                    <div  class="col-md-2 ">
                        <label><?php print CommonLanguage::getMessage('posponted_date'); ?></label>
                        <input id="report_post_date" name="report_post_date" class="form-control" autocomplete="off"/>
                    </div>
                    <div  class="col-md-2  ">
                        <label><?php print CommonLanguage::getMessage('Category'); ?></label>
                        <input id="postponed_category_id" name="postponed_category_id" class="full-width" autocomplete="off" type="hidden"/>
                    </div>
                    <div  class="col-md-2 ">
                        <label><?php print CommonLanguage::getMessage('posponted_status') ?></label>
                        <select class="full-width" id="report_posponted_status_filter" data-init-plugin="select2">
                            <option value="" ><?php echo CommonLanguage::getMessage('select') ?></option>
                            <option value="1" ><?php echo CommonLanguage::getMessage('Request') ?></option>
                            <option value="2" ><?php echo CommonLanguage::getMessage('production_line') ?></option>
                            <option value="3" ><?php echo CommonLanguage::getMessage('production_done') ?></option>
                            <option value="4" ><?php echo CommonLanguage::getMessage('delivered') ?></option>
                            <option value="5" ><?php echo CommonLanguage::getMessage('on_request') ?></option>
                            <option value="6" ><?php echo CommonLanguage::getMessage('canceled') ?></option>

                        </select>
                    </div>
                    <div class="col-md-1 m-t-20 pull-right">
                        <div class="pull-right">
                            <a id="print_postponed_report" class="btn btn-danger" ><i class="fa fa-print"></i><?php echo CommonLanguage::getMessage('print'); ?></a>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-2">
                        <label><?php echo CommonLanguage::getMessage('choose_branch') ?></label>
                        <input id="current_report_branch_id" type="hidden" class="full-width" name="current_report_branch_id" >
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12" id="postponed_report_data">
                    </div>
                </div>
            </div>
            <?php echo Forms::ModalLoader('postponed_report_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="confirm_end_of_shift" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('confirm_end_shift') ?></h4>
                <div id="confirm_shift_alert"></div>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12 m-t-10">
                        <p><?php print CommonLanguage::getMessage('about_end_shift') ?></p>
                        <p><?php print CommonLanguage::getMessage('complete_action') ?></p>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <?php if ($permissions->hasPermission('save_end_shift_pos')) { ?>
                    <button type="button" class="btn btn-info save_shift save"  ><?php print CommonLanguage::getMessage('save_data') ?></button>

                <?php }if ($permissions->hasPermission('save_print_end_shift_pos')) { ?>
                    <button type="button" class="btn btn-info width-auto save_shift save_print" ><?php print CommonLanguage::getMessage('save_print') ?></button>
                <?php } ?>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="customer_invoices_list" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10">
                    <div class="col-md-12">
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                            <input id="cust_inv_filter"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('road_customer'); ?></label>
                            <input id="pos_cust_inv_filter"  type="hidden" class="full-width"  />
                        </div>
                        <div class="  col-md-2" >
                            <label><?php print CommonLanguage::getMessage('user'); ?></label>
                            <input id="created_user" type="hidden" class="full-width"  >
                        </div> 
                        <div class="  col-md-3" >
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="From_To_Date" type="text" class="form-control" name="From_To_Date" >
                        </div> 
                        <div  class="col-md-2 ">
                            <label></label>
                            <button class="btn btn-info " disabled id="print_cust_inv" style="margin-top: 24px;"><?php echo CommonLanguage::getMessage('print') ?></button>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="customer_invoice_table" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:7%" ><?php echo CommonLanguage::getMessage('invoice_nb'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Date'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('total'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('total_paid'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                                <tfoot>
                                <th></th><th></th>
                                <th><span><?php echo CommonLanguage::getMessage('total'); ?>:&nbsp;</span><span id="cust_inv_total">0</span></th>
                                <th><span><?php echo CommonLanguage::getMessage('total_paid'); ?>:&nbsp;</span><span id="cust_inv_total_paid">0</span></th>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="customer_ledger_list" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10">
                    <div class="col-md-12">
                        <div  class="col-md-3 ">
                            <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                            <input id="cust_ledger_filter"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-3 ">
                            <label><?php print CommonLanguage::getMessage('road_customer'); ?></label>
                            <input id="road_cust_ledger_filter"  type="hidden" class="full-width"  />
                        </div>
                        <div class="  col-md-3" >
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="from_to_ledger" type="text" class="form-control" name="from_to_ledger" >
                        </div> 
                        <div class="  col-md-3" style="display:grid;">
                            <label><?php print CommonLanguage::getMessage('ignore_zero_balance'); ?></label>
                            <input id="ignore_zero_balance" type="checkbox"  name="ignore_zero_balance" >
                        </div> 
                        <div  class="col-md-2 ">
                            <label></label>
                            <button class="btn btn-info " disabled id="print_cust_ledger" style="margin-top: 24px;"><?php echo CommonLanguage::getMessage('print') ?></button>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="customer_ledger_table" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:7%" ><?php echo CommonLanguage::getMessage('type'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('invoice_nb'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Date'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('amount'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                                <tfoot>
                                <th></th><th></th><th></th>
                                <th><span id="cust_ledger_balance">0</span></th>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="exchange_list" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10">
                    <div class="col-md-12">
                        <!--                        <div  class="col-md-3 ">
<label><?php print CommonLanguage::getMessage('customer'); ?></label>
<input id="cust_ledger_filter"  type="hidden" class="full-width"  />
</div>-->
                        <div class="  col-md-3" >
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="from_to_exchange" type="text" class="form-control" name="from_to_exchange" >
                        </div> 
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="exchange_list_table" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:7%" ><?php echo CommonLanguage::getMessage('exchange') . ' #'; ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('customer'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Date'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="OnlineframeModal" class="modal  fade" tabindex="-1" role="dialog" style="z-index:10940;">
    <div class="modal-content">
        <div class="modal-body">
            <iframe id="checkNewFrame" src="" width="99.6%;" height="530" frameborder="0"></iframe>
        </div>
        <div class="modal-footer">
            <button class="btn bg-primary white" id="get_orders"><?php echo CommonLanguage::getMessage('get_online_orders'); ?></button>
            <button class="btn bg-default" data-dismiss= "modal"><?php echo CommonLanguage::getMessage('cancel'); ?></button>
        </div>
        <?php echo Forms::ModalLoader('online_loader'); ?>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="ConfirmDeleteInv" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <div id="delete_alert"></div>
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('Confirm_Delete') ?></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12 m-t-10">
                        <p><?php print CommonLanguage::getMessage('about_delete_inv') ?>&nbsp;<span id="inv_nb" class="bold red-star"></span></p>
                        <p><?php print CommonLanguage::getMessage('Proceed_Delete') ?></p>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn btn-danger width-auto" id="inv_delete"><?php print CommonLanguage::getMessage('delete') ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="ConfirmDeleteEx" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <div id="delete_ex_alert"></div>
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('Confirm_Delete') ?></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12 m-t-10">
                        <p><?php print CommonLanguage::getMessage('about_delete_exchange') ?>&nbsp;<span id="ex_nb" class="bold red-star"></span></p>
                        <p><?php print CommonLanguage::getMessage('Proceed_Delete') ?></p>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn btn-danger width-auto" id="ex_delete"><?php print CommonLanguage::getMessage('delete') ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="ConfirmOpenDrawer" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <div id="open_reason_alert"></div>
            </div>
            <div class="modal-body form-group">
                <div class="row">
                    <div class="col-md-12">
                        <label><?php echo CommonLanguage::getMessage('reason') ?><span class="red-star">*</span></label>
                        <textarea name="open_reason" class="form-control" id="open_reason" style="resize: vertical;"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button type="button" class="btn btn-primary" id = "SubmitOpenReason"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="drawer_reason_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10">
                    <div class="col-md-12">
                        <div class="  col-md-3" >
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="reason_date" type="text" class="form-control"  >
                        </div> 
                        <div class="  col-md-3" >
                            <label><?php print CommonLanguage::getMessage('users'); ?></label>
                            <select  id="reason_user"  class="full-width reason_user " data-init-plugin="select2">
                                <option value="0"><?php echo CommonLanguage::getMessage('All'); ?></option>
                                <?php foreach ($users as $user): ?>
                                    <option value="<?php echo $user['User_ID']; ?>"><?php echo $user['User_Name']; ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div> 
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="table-responsive">
                            <table class="table table-hover demo-table-search full-width" id="open_reason_table" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('user'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('open_reason'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('Date'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade DontReset" id="add_posponted_data" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="text-left bold"><?php print CommonLanguage::getMessage('posponted') ?></h5>
            </div>
            <div class="modal-body">
                <form id="postponed_form" action="javascript:void(0);">
                    <div class="row form-group">
                        <div class="col-md-12 ">
                            <label><?php print CommonLanguage::getMessage('Date') ?></label>
                            <span class="red-star">*</span>
                            <input id="postponed_date_time" name="postponed_date_time" type="text" class="form-control" value="" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-12 ">
                            <label><?php print CommonLanguage::getMessage('status') ?></label>
                            <span class="red-star">*</span>
                            <select class="full-width" id="posponted_status" data-init-plugin="select2" required>
                                <option value="" ><?php echo CommonLanguage::getMessage('select') ?></option>
                                <option value="1" ><?php echo CommonLanguage::getMessage('Request') ?></option>
                                <option value="2" ><?php echo CommonLanguage::getMessage('production_line') ?></option>
                                <option value="3" ><?php echo CommonLanguage::getMessage('production_done') ?></option>
                                <option value="4" ><?php echo CommonLanguage::getMessage('delivered') ?></option>
                                <option value="5" ><?php echo CommonLanguage::getMessage('on_request') ?></option>

                            </select>
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-12 <?php echo smc_session()['default_setting']['add_pos_customer'] == 0 || smc_session()['default_setting']['add_pos_customer'] == 2 ? '' : 'hidden' ?>">
                            <label><?php print CommonLanguage::getMessage('customer') ?></label>
                            <span class="red-star">*</span>
                            <input name="postponed_customer_id" id="postponed_customer_id" type="hidden" class="full-width"  />
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-12 <?php echo smc_session()['default_setting']['add_pos_customer'] == 1 || smc_session()['default_setting']['add_pos_customer'] == 2 ? '' : 'hidden' ?>">
                            <label><?php print CommonLanguage::getMessage('road_customer') ?></label>

                            <span class="fa fa-plus-circle m-l-5 " data-toggle="modal" data-target="#addCustomerModal" style="color:#8a7dbe;cursor:pointer"></span>
                            <input name="postponed_pos_customer_id" id="postponed_pos_customer_id" type="hidden" class="full-width"  />
                        </div>
                    </div>
                     <div class="row">
                    <?php
                    if (!empty($postponed_notes)) {
                        foreach ($postponed_notes as $note) {
                            ?>
                            <div class="col-md-4 p-0 fn-btn">
                                <button type="button" class="btn btn-default w-100 post_desc_note"><?php echo $note['note_title']; ?></button>
                            </div>
                            <?php
                        }
                    }
                    ?>
                </div>
                    <div class="row form-group">
                        <div class="col-md-12 ">
                            <!--<label><?php print CommonLanguage::getMessage('note') ?></label>-->
                            <textarea id="postponed_note" name="postponed_note" class="form-control"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button  type="button" data-dismiss="modal" class="btn btn-danger fs-15"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button id="submit_postponed_btn" type="button" class="btn btn-primary fs-15"><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
            <?php echo Forms::ModalLoader('postponed_note_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="choose_cust_type_modal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div id="hide_class3" class="modal-dialog">
        <div class="modal-content-wrapper">
            <div class="modal-content">
                <div class="modal-header clearfix text-left">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                    </button>
                    <h5 class="add-label bold"></h5>
                </div>
                <div class="modal-body">
                    <div class="row add-cust-row">
                        <div class="col-md-6">
                            <button type="button" class="btn btn-primary add_pos_customer   full-width"> <?php echo CommonLanguage::getMessage('road_customer'); ?></button>
                        </div>
                        <div class="col-md-6">
                            <button type="button" class="btn btn-primary  add_nonroad_pos_customer full-width openFrame" data-src="Inventory/CustomerList?is_pop=1&new=1"  ><?php echo CommonLanguage::getMessage('customer_with_account'); ?></button>
                        </div>
                    </div>
                    <div class="row list-cust-row">
                        <div class="col-md-6">
                            <button type="button" class="btn btn-primary   full-width" data-toggle="modal" data-target="#road_customer_list"> <?php echo CommonLanguage::getMessage('road_customer'); ?></button>
                        </div>
                        <div class="col-md-6">
                            <button type="button" class="btn btn-primary  openFrame full-width" data-src="Inventory/CustomerList?is_pop=1"><?php echo CommonLanguage::getMessage('customer_with_account'); ?></button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="road_customer_list" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="road_customer_list_table" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:7%" ><?php echo CommonLanguage::getMessage('Name'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Phone'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('address'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade " id="addCustomerModal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <h4 class="modal-title semi-bold"><?php print CommonLanguage::getMessage('new_customer') ?></h4>
            </div>
            <div class="modal-body">
                <form id="AddCustomerForm"  method="POST" onsubmit="return false">
                    <?php echo Forms::AlertDiv('addCustomerAlert'); ?>
                    <div class="row m-t-10">
                        <div class=" col-md-6 ">
                            <label class="labelText"><?php print CommonLanguage::getMessage('Name'); ?><span class="red-star">*</span></label>
                            <input type="text" placeholder="<?php print CommonLanguage::getMessage('Name'); ?>" id="Customer_Name" name="customer_name" class="form-control " autocomplete="off" required>
                        </div>
                        <div class="col-md-6">
                            <label class="labelText"><?php print CommonLanguage::getMessage('Phone'); ?><span class="red-star">*</span></label>
                            <input type="text" placeholder="<?php print CommonLanguage::getMessage('Phone'); ?>" id="Customer_Phone" name="customer_phone" class="form-control " required>
                        </div>
                    </div>
                    <div class="row m-t-10">
                        <div class=" col-md-12">
                            <div class="col-md-6">
                                <label class="labelText"><?php print CommonLanguage::getMessage('region'); ?>
                                    <?php if ($permissions->hasPermission('pos_add_cust_region')) { ?>
                                        <span class="fa fa-plus-circle m-l-5 openFrame" data-src="<?php echo "Settings/region_list?is_pop=1" ?>" style="color:#3b4752;cursor:pointer"></span>
                                    <?php } ?>
                                </label>
                                <input type="hidden" id="pos_cust_region_id" name="pos_cust_region_id" class="full-width " >
                            </div>
                            <div class="col-md-6">
                                <label class="labelText"><?php print CommonLanguage::getMessage('DOB'); ?></label>
                                <input type="text"  id="customer_dob" name="customer_dob" class="form-control ">
                            </div>
                        </div>
                    </div>
                    <div class="row m-t-10">
                        <div class=" col-md-12" >
                            <label class="labelText"><?php print CommonLanguage::getMessage('address'); ?></label>
                            <textarea  placeholder="<?php print CommonLanguage::getMessage('address'); ?>" id="Customer_Address" name="customer_address" class="form-control " style="resize:none"></textarea>
                        </div>
                    </div>
                    <?php if (smc_session()['default_setting']['activate_allergy_intolerance'] == 1) { ?>
                        <div class="row m-t-10">
                            <div class=" col-md-12" >
                                <label class="labelText"><?php print CommonLanguage::getMessage('allergy'); ?></label>
                                <span class="fa fa-plus-circle m-l-5 openAllergyIntolerance" data-type="1" data-content="<?php print CommonLanguage::getMessage('allergy'); ?>" style="color:#8a7dbe;cursor:pointer"></span>
                                <input type="hidden"  id="allergy_id" name="allergy_id" class="full-width">
                            </div>
                        </div>
                        <div class="row m-t-10">
                            <div class=" col-md-12" >
                                <label class="labelText"><?php print CommonLanguage::getMessage('intolerance'); ?></label>
                                <span class="fa fa-plus-circle m-l-5 openAllergyIntolerance" data-type="2" data-content="<?php print CommonLanguage::getMessage('intolerance'); ?>" style="color:#8a7dbe;cursor:pointer"></span>
                                <input type="hidden"  id="intolerance_id" name="intolerance_id" class="full-width ">
                            </div>
                        </div>
                    <?php } ?>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn btn-info  width-auto" id="addCust"><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="void-item-reason-modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content ">
            <div class="modal-header text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="bold"><?php echo CommonLanguage::getMessage('void_item'); ?></h5>
            </div>
            <div class="modal-body">
                <form id="void-item-form" action="javascript:void(0);">
                    <div class="row">
                        <div class="col-md-12">
                            <input id="item_void_reason" class="full-width" name="item_void_reason" type="hidden" required/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn bg-complete-darker text-white void_item_btn" data-type="1" ><?php print CommonLanguage::getMessage('Save') ?></button>
                <button type="button" class="btn  btn-danger text-white pull-left void_item_btn" data-type="2"><?php print CommonLanguage::getMessage('Damage') ?></button>
            </div>
            <?php echo Forms::ModalLoader('void_item_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="inv_postpone_status_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content ">
            <div class="modal-header text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="bold"><?php echo CommonLanguage::getMessage('change_status'); ?></h5>
            </div>
            <div class="modal-body">
                <div id="change_postpone_alert"></div>
                <form id="change-postpone-form" action="javascript:void(0);">
                    <div class="row form-group">
                        <div class="col-md-12">
                            <label><?php print CommonLanguage::getMessage('posponted_status') ?></label>
                            <select class="full-width" id="change_inv_postpone_status" data-init-plugin="select2">
                                <option value="0" ><?php echo CommonLanguage::getMessage('select') ?></option>
                                <option value="1" ><?php echo CommonLanguage::getMessage('Request') ?></option>
                                <option value="2" ><?php echo CommonLanguage::getMessage('production_line') ?></option>
                                <option value="3" ><?php echo CommonLanguage::getMessage('production_done') ?></option>
                                <option value="4" ><?php echo CommonLanguage::getMessage('delivered') ?></option>
                                <option value="5" ><?php echo CommonLanguage::getMessage('on_request') ?></option>

                            </select> 
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-12">
                            <label><?php print CommonLanguage::getMessage('note') ?></label>
                            <textarea id="status_postponed_note"  name="status_postponed_note"  class="form-control"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger text-white " data-dismiss="modal" ><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn  btn-info text-white " id="change_inv_postpone" ><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
            <?php echo Forms::ModalLoader('change_status_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="product_note_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
        <i class="pg-close"></i>
    </button>
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="text-left p-b-5 bold"><?php print CommonLanguage::getMessage('product_note') ?></h5>
            </div>
            <div class="modal-body">
                <div class="row">
                    <?php
                    if (!empty($product_notes)) {
                        foreach ($product_notes as $note) {
                            ?>
                            <div class="col-md-4 p-0 fn-btn">
                                <button type="button" class="btn btn-default w-100 product_note_item" data-type="<?php echo $note['is_linked']; ?>"><?php echo $note['note_title']; ?></button>
                            </div>
                            <?php
                        }
                    }
                    ?>
                </div>
                <div class="row">
                    <div class="col-md-12  order_note_details">
                        <textarea id="product_note_description" class="form-control" rows="3" placeholder="<?php print CommonLanguage::getMessage('enter_note') ?>" style="resize:none;"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button  type="button" data-dismiss="modal" class="btn btn-danger fs-15"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button id="submit_product_note" type="button" class="btn btn-primary fs-15"><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="return_list_modal"  role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10">
                    <div class="col-md-12">
                        <div  class="col-md-1 ">
                            <label><?php print CommonLanguage::getMessage('return_nb'); ?></label>
                            <input id="ret_list_nb"  type="text" class="full-width form-control"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                            <input id="ret_cust"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-3">
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="ret_list_date" name="ret_list_date" class="form-control" autocomplete="off"/>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="ReturnListTable" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:5%" >#</th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('customer'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Date'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('total'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('paid_amount'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                                <tfoot>
                                <th></th><th></th><th></th>
                                <th ><div class="text-center"><strong><span id="ret_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th ><div class="text-center"><strong><span id="ret_paid_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
                                <th></th>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="request_transfer_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content ">
            <div class="modal-header text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fa-22"></i></button>
                <h4 class="bold"><?php echo CommonLanguage::getMessage('transfer'); ?></h4>
            </div>
            <div class="modal-body">
                <div class="row"> <?php echo Forms::AlertDiv('request_transfer_alert'); ?></div>
                <form id="request_transfer_form" action="javascript:void(0);">
                    <div class="row form-group">
                        <label><?php echo CommonLanguage::getMessage('From'); ?></label>
                        <input type="hidden" id="transfer_depot_from" name="transfer_depot_from" class="full-width" required/>
                    </div>
                    <div class="row form-group">
                        <label><?php echo CommonLanguage::getMessage('To'); ?></label>
                        <input type="hidden" id="transfer_depot_to" name="transfer_depot_to" class="full-width" required/>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger text-white " data-dismiss="modal" ><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn  btn-info text-white " id="submit_request_transfer" ><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
            <?php echo Forms::ModalLoader('request_transfer_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="split_row_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content ">
            <div class="modal-header text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fa-22"></i></button>
                <h4 class="bold"><?php echo CommonLanguage::getMessage('split_item_disc'); ?></h4>
            </div>
            <div class="modal-body">
                <div class="row"> <?php echo Forms::AlertDiv('split_row_alert'); ?></div>
                <div class="row form-group ">
                    <label><?php echo CommonLanguage::getMessage('Quantity'); ?></label>
                    <div class="spinner-icons split-icons">
                        <span class="fa fa-minus" ></span>
                        <input type="number" min="0" step="any" id="split_qty"  class="full-width form-control" />
                        <span class="fa fa-plus" ></span>
                    </div>
                </div>
                <div class="row form-group">
                    <label><?php echo CommonLanguage::getMessage('discount'); ?></label>
                    <input type="number" min="0" max="100" step="any" id="split_disc"  class="full-width form-control" />
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger text-white " data-dismiss="modal" ><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn  btn-info text-white " id="submit_split_row" ><?php print CommonLanguage::getMessage('proceed') ?></button>
            </div>
            <?php echo Forms::ModalLoader('split_row_loader'); ?>
        </div>
    </div>
</div>
<div class="modal fade bs-example-modal-md " data-backdrop="static" id="VoidReasonModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div id="hide_class4" class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><i class="pg-close fa-22"></i></span></button>
            </div>
            <div class="modal-body">
                <input type="hidden" name="void_reason_origin" id="void_reason_origin"/>
                <input type="hidden" name="void_reason_invoice_id" id="void_reason_invoice_id"/>
                <div class="row">
                    <?php foreach ($voidReasonList as $reason) { ?>
                        <div class="col-4 p-0 fn-btn">
                            <button type="button" class="btn btn-default w-100 void_reason" data-id="<?php echo $reason['reason_id']; ?>" >
                                <span class="p-t-5 p-b-5">
                                    <i class="fa fa-shopping-cart fs-15"></i>
                                </span>
                                <br>
                                <span class="f-s-10 font-montserrat text-uppercase"><?php echo $reason['reason_title']; ?></span>
                            </button>
                        </div>
                    <?php } ?>
                </div>
            </div>
            <?php echo Forms::ModalLoader('VoidReasonModalDisabler'); ?>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="received_delivery_list_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10 form-group">
                    <div class="col-md-12">
                        <div  class="col-md-3 ">
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="rec_list_date" name="rec_list_date" class="form-control" autocomplete="off"/>
                        </div>
                        <div  class="col-md-1 ">
                            <label><?php print CommonLanguage::getMessage('invoice_nb'); ?></label>
                            <input id="rec_list_nb"  type="text" class="full-width form-control"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('user'); ?></label>
                            <input id="rec_user"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                            <input id="rec_cust"  type="hidden" class="full-width"  />
                        </div>
                        <div  class="col-md-2 <?php echo smc_session()['default_setting']['add_pos_customer'] != 0 ? '' : 'hidden' ?>">
                            <label><?php print CommonLanguage::getMessage('road_customer'); ?></label>
                            <input id="rec_pos_cust"  type="hidden" class="full-width"  />
                        </div>
                        <!--                        <div  class="col-md-2 ">
<label><?php print CommonLanguage::getMessage('payment_status'); ?></label>
<select id="rec_status" class="full-width" multiple data-init-plugin="select2">
<option value="all"><?php echo CommonLanguage::getMessage('all') ?></option>
<option value="0"><?php echo CommonLanguage::getMessage('unpaid') ?></option>
<option value="1"><?php echo CommonLanguage::getMessage('partially_paid') ?></option>
<option value="2"><?php echo CommonLanguage::getMessage('paid') ?></option>
<option value="3"><?php echo CommonLanguage::getMessage('park') ?></option>
</select>
</div>-->
                    </div>
                    <div class="col-md-12">
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('region'); ?></label>
                            <input id="rec_region_filter"  type="hidden" class="full-width"  />
                        </div> 
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('driver'); ?></label>
                            <input id="rec_driver_filter"  type="hidden" class="full-width"  />
                        </div> 
                        <div  class="col-md-2 ">
                            <label><?php print CommonLanguage::getMessage('received') . '?'; ?></label>
                            <select id="received_status" class="full-width" data-init-plugin="select2">
                                <option value=""><?php echo CommonLanguage::getMessage('All') ?></option>
                                <option value="0"><?php echo CommonLanguage::getMessage('no') ?></option>
                                <option value="1"><?php echo CommonLanguage::getMessage('yes') ?></option>
                            </select>
                            <!--<input id="received_status"  type="hidden" class="full-width"  />-->
                        </div> 
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="received_delivery_list" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:5%" ><input type="checkbox" class="inv_check_all_td pull-left multi_delete"/>#</th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('customer'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('mobile_phone'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Delivery_Date'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('driver_name'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('region'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('address'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('total'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('delivery_fees'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('paid_amount'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('status'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('note'); ?></th>
                                        <th class="text-center" style="width:5%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                                <!--                                <tfoot>
<th >
                                <?php // if ($permissions->hasPermission('pos_multi_inv_delete')) { ?>
<button id="multi_dlt_delv_btn" class="btn btn-danger pull-left"><?php echo CommonLanguage::getMessage('delete') ?></button>
                                <?php // } ?>
</th>
<th></th><th></th><th></th>
<th ><div class="text-center"><strong><span id="delivery_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
<th ><div class="text-center"><strong><span id="delivery_fees_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
<th ><div class="text-center"><strong><span id="delivery_paid_total" style="color:#000;"></span>&nbsp;<span id="currency_symbol" style="color:#000;"><?php echo smc_session()['local_currency_symbol'] ?></span></strong></div></th>
<th></th>
</tfoot>-->
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="rec_note_modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('receive_note') ?></h4>
            </div>
            <div class="modal-body">
                <div class="row form-group">
                    <div class="col-md-12 m-t-10">
                        <label><?php echo CommonLanguage::getMessage('note') ?></label>
                        <textarea id="receive_note" class="form-control" rows="10" style="resize:none;"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info Cancel"  ><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn btn-info width-auto"id="save_rec_note" ><?php print CommonLanguage::getMessage('Save') ?></button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="rec_pay_list_modal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i></button>
                <h4 class="modal-title text-center"></h4>
            </div>
            <div class="modal-body">
                <div class="row m-b-10">
                    <div class="col-md-12">

                        <div class="  col-md-3" >
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="from_to_pay_rec_date" type="text" class="form-control" name="from_to_pay_rec_date" >
                        </div> 
                    </div>
                </div>
                <div class="row">
                    <div id="col-md-12">
                        <div class="" style="overflow-x:auto;">
                            <table class="table table-hover demo-table-search full-width" id="pay_rec_table" >
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:7%" >#</th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Name'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Date'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('description'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('amount'); ?></th>
                                        <th class="text-center" style="width:10%" ><?php echo CommonLanguage::getMessage('Action'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" id="addDepositModal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content-wrapper">
            <div class="modal-content">
                <div class="modal-header ">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                    </button>
                    <h4 class="text-left bold"><i class="fa fa-money"></i> <span id="deposit_title"></span></h4>
                </div>
                <div class="modal-body form-group" >
                    <div class="row ">
                        <input type="hidden" id="pay_rec_id"/>
                        <?php echo Forms::AlertDiv('depositAlert'); ?>
                        <?php if ($permissions->hasPermission('pos_close_invoices')) { ?>
                            <div class="col-md-12 m-t-10 " id="inv_rec_btn">
                                <div class="col-md-6 ">
                                    <button class="btn btn-primary full-width" id="get_cut_inv"><?php echo CommonLanguage::getMessage('get_invoices') ?></button>
                                </div>
                                <?php if ($permissions->hasPermission('pos_auto_close_invoices') && smc_session()['default_setting']['activate_autoclose_rec_pay'] == 1) { ?>
                                    <div class="col-md-6 ">
                                        <button class="btn btn-primary full-width" id="auto_close_inv_btn"><?php echo CommonLanguage::getMessage('auto_close_inv') ?></button>
                                    </div>
                                <?php } ?>
                                <div class="col-md-12 m-t-10  ">
                                    <!--<label><strong></strong></label>-->
                                    <div style="font-size:15px;"><strong><?php echo CommonLanguage::getMessage('total_invoices') ?>:(<span id="inv_rec_total">0</span>&nbsp;<span id="inv_rec_currency_symbol"></span>)</strong></div>
                                </div>

                            </div>

                        <?php } ?>
                        <div class="col-md-12 m-t-10">
                            <label class="labelText"><?php print CommonLanguage::getMessage('choose_account') ?><span class="red-star">*</span>&nbsp;&nbsp;<span id="rec_acc_balance"></span></label>
                            <input class=" full-width" id="search_supplier" name="search_supplier" type="hidden" autocomplete="off" />
                        </div>
                        <div class="col-md-12 m-t-10 pay_cust_div <?php echo smc_session()['default_setting']['add_pos_customer'] == 1 || smc_session()['default_setting']['add_pos_customer'] == 2 ? '' : 'hidden' ?>">
                            <label class="labelText"><?php print CommonLanguage::getMessage('road_customer') ?></label>
                            <input class=" full-width" id="pay_pos_customers" name="pay_pos_customers" type="hidden" autocomplete="off" />
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 ">
                            <label><?php echo CommonLanguage::getMessage('currency') ?><span class="red-star">*</span></label>
                            <div id="CurrencyIDContainer"  >
                                <div class="form-group form-material floating ">
                                    <div class="input-group-btn DropDownForForms Closable  " id="CurrencyDropDownPOS">
                                        <button type="button" class="btn btn-primary btn-block dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                            <span><?php echo CommonLanguage::getMessage('select') ?></span>
                                            <input type="hidden" name="Currency_ID" value="" class="form-control ignore" onkeyup="return false" onkeydown="return false"/>
                                        </button>
                                        <ul class="dropdown-menu">
                                            <?php echo $CurList ?>
                                            <li class="divider"></li>
                                            <li><a class="LoadMore">More..</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php if ($Org_Type == 1) { ?>
                        <div class="row">
                            <div class="col-md-12 ">
                                <label class="labelText"><?php print CommonLanguage::getMessage('amount') ?><span class="red-star">*</span> <span class="red-star dep-with-total"></span></label>
                                <input type="number" min="1" step="any" id="payment_amount" placeholder="<?php print CommonLanguage::getMessage('amount'); ?>" name="payment_amount" class="form-control " required>
                            </div>
                        </div>
                    <?php } if ($Org_Type != 1) { ?>
                        <div class="row is-flex">
                            <form id="DepositForm" method="POST" onsubmit="return false">
                                <div class="col-md-6">
                                    <table class="col-md-12 table table-bordered table-responsive" id="LLTable">
                                        <thead>
                                            <tr >
                                                <th style="width:50%"><?php print CommonLanguage::getMessage('amount') ?></th>
                                                <th style="width:50%"><?php print CommonLanguage::getMessage('qty') ?></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php foreach ($money_tags['LBP'] as $item) { ?>
                                                <tr data-id = "<?php echo $item['Cash_Category_ID'] ?>" data-currency = "<?php echo $item['Currency_ID'] ?>" data-qty="0" data-val="<?php echo $item['Cash_Category_Value'] ?>">
                                                    <td><?php echo $item['Cash_Category_Value'] . ' ' . $item['Currency_Symbol'] ?></td>
                                                    <td><input type="text" class="form-control deposite_input"/></td>
                                                </tr>
                                            <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="col-md-6">
                                    <table class="col-md-12 table table-bordered table-responsive" id="DolarTable">
                                        <thead>
                                            <tr  >
                                                <th style="width:50%"><?php print CommonLanguage::getMessage('amount') ?></th>
                                                <th style="width:50%"><?php print CommonLanguage::getMessage('qty') ?></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php foreach ($money_tags['USD'] as $item) { ?>
                                                <tr data-id = "<?php echo $item['Cash_Category_ID'] ?>" data-currency = "<?php echo $item['Currency_ID'] ?>" data-qty="0" data-val="<?php echo $item['Cash_Category_Value'] ?>">
                                                    <td><?php echo $item['Cash_Category_Value'] . ' ' . $item['Currency_Symbol'] ?></td>
                                                    <td><input type="text" class="form-control deposite_input"/></td>
                                                </tr>
                                            <?php } ?>
                                        </tbody>
                                    </table>
                                    <textarea id="payment_note" class="form-control" rows="4" placeholder="<?php print CommonLanguage::getMessage('place_note') ?>" style="resize:none"></textarea>
                                </div>
                            </form>
                        </div>
                    <?php } else { ?>
                        <div class="row  m-t-10">
                            <div class="col-md-12">
                                <label class="labelText"><?php print CommonLanguage::getMessage('note') ?></label>
                                <textarea id="payment_note" class="form-control" rows="4" placeholder="<?php print CommonLanguage::getMessage('place_note') ?>" style="resize:none"></textarea>
                            </div>
                        </div>
                    <?php } ?>
                </div>
                <div class="modal-footer">
                    <button id="cancelDep" type="submit" data-dismiss="modal" class="btn btn-danger btn-cons">
                        <i class="fa fa-times"></i> <?php print CommonLanguage::getMessage('Close') ?>
                    </button>
                    <button id="submitDep" type="submit" class="btn btn-info btn-cons">
                        <i class="fa fa-check"></i> <?php print CommonLanguage::getMessage('Save') ?>
                    </button>
                </div>
                <?php echo Forms::ModalLoader('dep_with_paym_recpt_loader'); ?>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" style="max-width: 500px;margin: auto;max-height: 100%;" data-backdrop="static" id="inv_rec_modal" data-currency ="" data-customer =" " tabindex="-1" role="dialog" aria-hidden="true"style="width:80%;margin:0 auto">
    <div class="modal-dialog ">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" id="close_modal" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-14"></i></button>
                <h5><span class="semi-bold"><?php print CommonLanguage::getMessage('invoices'); ?></span></h5>
            </div>
            <div class="modal-body form-group" >
                <div id="InvoicesModalAlert"></div>
                <div class="row row_head" style="border-bottom: 1px solid #eb9220;">
                    <div class="col-md-1"><label><?php echo CommonLanguage::getMessage('invoice') ?>&nbsp;#</label></div>
                    <div class="col-md-2"><label><?php echo CommonLanguage::getMessage('Date') ?></label></div>
                    <div class="col-md-2"><label><?php echo CommonLanguage::getMessage('net_total') ?></label></div>
                    <div class="col-md-2"><label><?php echo CommonLanguage::getMessage('remaining') ?></label></div>
                    <div class="col-md-2"><label><?php echo CommonLanguage::getMessage('amount') ?></label></div>
                    <div class="col-md-2"><label><?php echo CommonLanguage::getMessage('balance') ?></label></div>

                </div>
                <div id="inv_rec_body">


                </div>
            </div>
            <div class="modal-footer">
                <div class="">
                    <button class="btn btn-complete pull-right" id="CloseInv" data-dismiss="modal"  > <?php print CommonLanguage::getMessage('continue'); ?> </button>
                    <button class="btn bg-danger white pull-left" id="ClearInv"  > <?php print CommonLanguage::getMessage('clear'); ?>   </button>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade bs-example-modal-md" data-backdrop="static" id="confirm_empty_data_modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"> </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div id="confirm_change_customer_alert"></div>
                    <div class="col-md-12 ">
                        <p><?php print CommonLanguage::getMessage('confirm_empty_data') ?></p>
                        <p><?php print CommonLanguage::getMessage('Proceed_Delete') ?></p>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="empty_data_yes"  style="width:auto"><?php echo CommonLanguage::getMessage('yes') ?></button>
                <button type="button" class="btn btn-danger  pull-left"  data-dismiss="modal"><?php echo CommonLanguage::getMessage('no') ?> </button>
            </div>
        </div>
    </div>
</div>
<?php include 'Views/POS/product_options_modal.php'; ?>
<script>
    var add_with = <?php echo json_encode(CommonLanguage::getMessage('add_withdrawal')); ?>,
            show_delivery_notification = <?php echo json_encode($permissions->hasPermission('show_delivery_notification')); ?>,
            activate_pos_all_accs = <?php echo json_encode(smc_session()['default_setting']['activate_pos_all_accs']); ?>,
            pos_receipt_fill_amount_from_inv = <?php echo json_encode(smc_session()['default_setting']['pos_receipt_fill_amount_from_inv']); ?>,
            activate_autoclose_rec_pay = <?php echo json_encode(smc_session()['default_setting']['activate_autoclose_rec_pay']); ?>,
            stop_auto_close_inv = 0,
            add_dep = <?php echo json_encode(CommonLanguage::getMessage('add_deposite')); ?>,
            add_payment_lang = <?php echo json_encode(CommonLanguage::getMessage('add_payment')); ?>,
            start_date = <?php echo json_encode(smc_session()['start_date']); ?>,
            select = <?php echo json_encode(CommonLanguage::getMessage('select')); ?>,
            cash_customer_arr = <?php echo json_encode($cash_customer_arr); ?>,
            add_receipt_lang = <?php echo json_encode(CommonLanguage::getMessage('add_receipt')); ?>,
            is_road_cust_edit = false, road_cust_to_edit = 0, is_road_cust_update_after_edit = false,
            show_payment_balance = <?php echo json_encode($permissions->hasPermission('show_account_balance_payment')); ?>,
            show_receipt_balance = <?php echo json_encode($permissions->hasPermission('show_account_balance_receipt')); ?>,
            view_end_day_cash = <?php echo json_encode($permissions->hasPermission('view_total_cash_pos_end_day')); ?>,
            view_end_day_sales = <?php echo json_encode($permissions->hasPermission('view_total_sales_pos_end_day')); ?>;
    $(function () {
        $('#order_delivery_date').datetimepicker({format: 'YYYY-MM-DD HH:mm', useCurrent: false});
        build_select2($("#transfer_depot_from,#transfer_depot_to"), "xhr/depotSearch");
        build_select2($("#pay_pos_customers,#road_cust_ledger_filter"), "xhr/CommonSearch?col_id=customer_id&col_name=customer_name&table=tbl_pos_customers");
        build_select2($("#pos_cust_region_id,#rec_region_filter"), "xhr/CommonSearch?col_id=region_id&col_name=region_name&table=tbl_regions");
        build_select2($("#driver_id,#rec_driver_filter"), "xhr/CommonSearch?col_id=driver_id&col_name=driver_name&table=tbl_drivers");
        build_select2($("#created_user"), "xhr/CommonSearch?col_id=User_ID&col_name=User_Name&table=tbl_common_users");
        build_select2($("#postponed_customer_id"), "xhr/customerSearch");

        $("#postponed_customer_id").on("change", function () {
            fill_customer_by_id($(this).val())
        })
        $("#postponed_pos_customer_id").on("change", function () {
            if ($(this).val() != '') {
                $("#postponed_customer_id").val('0').attr('data-select-name', cash_customer_arr['Account_Name'])
                build_select2($("#postponed_customer_id"), "xhr/customerSearch");
                $("#postponed_customer_id").prop("disabled", true);
            } else {
                $("#postponed_customer_id").val('').attr("data-select-name", '')
                build_select2($("#postponed_customer_id"), "xhr/customerSearch");
                $("#postponed_customer_id").prop("disabled", false)

            }
        })


        $("#pay_pos_customers").on("change", function () {
            if (activate_autoclose_rec_pay == 1) {
                get_cust_invoices(0)
            }
            if ($(this).val() != '') {
                $("#search_supplier").val(cash_customer_arr['Account_ID']).attr("data-select-name", cash_customer_arr['Account_Name'] + ' - ' + cash_customer_arr['Account_Code'])
                build_select2($("#search_supplier"), (activate_pos_all_accs == 1 ? "xhr/accIDSearch?type=Payment&Status_ID=1" : "xhr/accIDSearch?type=cust&Status_ID=1"));
                $("#search_supplier").prop("disabled", true);
                var is_receipt = $("#addDepositModal").attr("data-is-receipt");
                if ((is_receipt == 1 && show_receipt_balance) || (is_receipt == 0 && show_payment_balance)) {
                    getAccBalance('#rec_acc_balance')
                }
            } else {
                $("#search_supplier").val('').attr("data-select-name", '')
                build_select2($("#search_supplier"), (activate_pos_all_accs == 1 ? "xhr/accIDSearch?type=Payment&Status_ID=1" : "xhr/accIDSearch?type=cust&Status_ID=1"));
                $("#search_supplier").prop("disabled", false)

            }
        })
        $("#search_supplier").on("change", function () {
            if (activate_autoclose_rec_pay == 1) {
                get_cust_invoices(0)
            }
            if ($(this).val() != '') {
                $("#pay_pos_customers").prop("disabled", true);
                var is_receipt = $("#addDepositModal").attr("data-is-receipt");
                if ((is_receipt == 1 && show_receipt_balance) || (is_receipt == 0 && show_payment_balance)) {
                    getAccBalance('#rec_acc_balance')
                }
            } else {
                $("#pay_pos_customers").prop("disabled", false)
            }
        })
        $('#submit_request_transfer').on('click', function () {
            if (!$("#request_transfer_form").valid())
                return;
            PostInvoice(1, 0, 0, 0, '', '#request_transfer_loader')
        });
        if (show_delivery_notification) {
            RebuildDataTable('Delivery List', [], "POSAjax/getRemindersInv", {}, "#RemindersTable", '', {buttons: []});
            $('#builder .dt-buttons').remove()
            $("#RemindersTable tbody ").on("click", "tr .print", function () {
                var Mydata = {
                    Invoice_ID: $(this).attr("data-id"),
                    Invoice_Status: 0,
                    pending_status: 3,
                    is_edited_invoice: 0
                }
                $('#delivery_notification_loader').removeClass('hidden')
                $.ajax({
                    url: "POSAjax/ChangeDeliveryStatus",
                    data: Mydata,
                    dataType: "json",
                    complete: function (v1, v2) {
                        if (v2 == "success") {
                            if (v1.responseJSON == "OK")
                                RebuildDataTable('Delivery List', [], "POSAjax/getRemindersInv", {}, "#RemindersTable", '', {buttons: []});
                            $('#builder .dt-buttons').remove()
                            $('#delivery_notification_loader').addClass('hidden')
                        }
                    }
                });
            });
            setInterval(function () {
                RebuildDataTable('Delivery List', [], "POSAjax/getRemindersInv", {}, "#RemindersTable", '', {buttons: []});
                $('#builder .dt-buttons').remove()
                setTimeout(function () {
                    var check = $("#RemindersTable tbody tr:first span.checkSpan").attr("data-id")
                    if (check == 1) {
                        $("#builder a.builder-toggle").addClass("animateClass")
                    }
                }, 1000)
            }, 60000);
        }
        $(".btn-nb").on("click", function () {
            var input_val = $("#scanned_cust_id").val(),
                    text = $(this).text(),
                    new_val = input_val + text;
            if (input_val == '' && text == '0')
                return;
            $("#scanned_cust_id").val(new_val)
        })
        $(".btn-scan-clear").on("click", function () {
            $("#scanned_cust_id").val('')
        })
        $("#generate_scan").on("click", function () {
            var cust_val = $("#scanned_cust_id").val();
            if (cust_val == "")
                return;
            fill_scanned_customer(cust_val);
        })
        $("#builder a.builder-toggle").on('click', function () {
            $(this).removeClass('animateClass')
        })
        new Switchery($("#inv_with_print").get(0), {color: $.Pages.getColor("info")});
        $("#drawer_reason_modal").on("shown.bs.modal", function () {
            RebuildDataTable('resaon name', [], "POSAjax/open_reason_list", {}, "#open_reason_table");
        })
        build_select2($("#delivery_depot_id"), "xhr/depotSearch");
        build_select2($("#cust_ledger_filter"), "xhr/customerSearch");
        build_select2($("#cust_inv_filter"), ("xhr/customerSearch"));
        build_select2($("#pos_cust_inv_filter"), ("xhr/poscustomerSearch"));
        build_select2($("input[name=Expense_Account]"), "xhr/accIDSearch?type=Expense");
        build_select2($("#search_supplier"), (activate_pos_all_accs == 1 ? "xhr/accIDSearch?type=Payment&Status_ID=1" : "xhr/accIDSearch?type=supp&Status_ID=1"));
        $('#submit_postponed_btn').on('click', function () {
            if (!$("#postponed_form").valid()) {
                return;
            }
            $('#add_posponted_data').modal('hide');
        });
        $('#postponed_pos_customer_id').on('change', function () {
            if (!$('#postponed_pos_customer_id').val())
                return;
            $('#postponed_note_loader').removeClass('hidden');
            $.ajax({
                url: "POSAjax/searchRoadCustomer?customer_id=" + $('#postponed_pos_customer_id').val(),
                dataType: "json",
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        var response = v1.responseJSON;
                        customerSelectAutocomplete(response);
                        $('#postponed_note_loader').addClass('hidden');
                    }
                }
            });
        });
        $("input[name=From_To_Date],input[name=from_to_ledger]").daterangepicker({
            startDate: start_date
        }, function (start, end, label) {
            window.startledgerDate = start.format("YYYY-MM-DD"),
                    window.endledgerDate = end.format("YYYY-MM-DD")
        });
        $("input[name=from_to_pay_rec_date]").daterangepicker({
            startDate: start_date
        }, function (start, end, label) {
            window.startrecDate = start.format("YYYY-MM-DD"),
                    window.endrecDate = end.format("YYYY-MM-DD")
        });
        $("#cust_ledger_filter,#from_to_ledger,#road_cust_ledger_filter").on("change", function () {
            rebuild_cust_ledger_report();
            //            $("#cust_ledger_filter").val() == '' ? $("#print_cust_ledger").attr("disabled", true) : $("#print_cust_ledger").removeAttr("disabled")
        });
        $("#ignore_zero_balance").on("click", function () {
            rebuild_cust_ledger_report()
        })
        $("#road_customer_list").on("shown.bs.modal", function () {
            RebuildDataTable('<?php echo CommonLanguage::getMessage('road_customer_list') ?>', [], "POSAjax/road_customer_list_ajax", [], "#road_customer_list_table");
        })
        build_select2($("#item_void_reason"), "xhr/searchVoidReason?type=1");
        //        $("#from_to_ledger").on("change", function () {
        //            alert()
        //            rebuild_cust_ledger_report()
        //            $("#cust_ledger_filter").val() == '' ? $("#print_cust_ledger").attr("disabled", true) : $("#print_cust_ledger").removeAttr("disabled")
        //        });
        $("#print_cust_ledger").on("click", function () {
            myurl = "Inventory/pos_customer_ledger?id=" + $("#cust_ledger_filter").val() + '&from_date=' + (window.startledgerDate ? window.startledgerDate : start_date) + '&to_date=' + (window.endledgerDate ? window.endledgerDate : today);
            printPOSExternal(myurl)
        });
        //
        $("#reason_date").daterangepicker({
            ranges: {
                'Today': [moment(), moment()],
                'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                'This Month': [moment().startOf('month'), moment().endOf('month')],
                'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
            },
            startDate: start_date,
            allowEmpty: true,
            //            autoApply: true,
            autoUpdateInput: false,
            locale: {
                cancelLabel: 'Clear'
            }
        }, function (start, end, label) {
        });
        $('#reason_date').on('apply.daterangepicker', function (ev, picker) {
            window.startOpenDate = picker.startDate.format('YYYY-MM-DD'),
                    window.endOpenDate = picker.endDate.format('YYYY-MM-DD');
            $(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
            RebuildDataTable('resaon name', [], "POSAjax/open_reason_list",
                    {from_date: window.startOpenDate, to_date: window.endOpenDate, reason_user: $('#reason_user').val()}, "#open_reason_table")
        });
        $('#reason_date').on('cancel.daterangepicker', function (ev, picker) {
            startOpenDate = ''
            endOpenDate = ''
            $(this).val('');
            RebuildDataTable('resaon name', [], "POSAjax/open_reason_list",
                    {from_date: window.startOpenDate, to_date: window.endOpenDate, reason_user: $('#reason_user').val()}, "#open_reason_table")
        });
        $('#reason_user').on('change', function () {
            RebuildDataTable('resaon name', [], "POSAjax/open_reason_list", {from_date: window.startOpenDate, to_date: window.endOpenDate, reason_user: $('#reason_user').val()}, "#open_reason_table");
        });
        $("#cust_inv_filter,#From_To_Date,#pos_cust_inv_filter,#created_user").on("change", function () {
            //  alert()
            rebuild_cust_inv_report()
            if ($("#cust_inv_filter").val() == '' && $("#pos_cust_inv_filter").val() == '')
                $("#print_cust_inv").attr("disabled", true)
            else
                $("#print_cust_inv").removeAttr("disabled")
        })
        $("#print_cust_inv").on("click", function () {
            myurl = "Inventory/pos_customer_invoices?id=" + $("#cust_inv_filter").val() + '&from_date=' + (window.startDate ? window.startDate : start_date) + '&to_date=' + (window.endDate ? window.endDate : today) + '&pos_customer=' + $('#pos_cust_inv_filter').val();
            printPOSExternal(myurl)
        });
        $(".save_shift").on("click", function () {
            var with_print = $(this).hasClass("save_print") ? 1 : 0;
            $.ajax({
                url: "POSAjax/end_of_shift",
                data: {with_print: with_print, is_actual: is_actual},
                method: "POST",
                dataType: 'JSON',
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        if (v1.responseJSON[0] === 'OK') {
                            $("#confirm_shift_alert").attr("class", "alert alert-success").html(Submitted_Successfully)
                            if (with_print == 1) {
                                myurl = "Inventory/pos_view_end_shift/" + v1.responseJSON[1] + '&is_actual=' + is_actual;
                                printPOSExternal(myurl);
                            }
                            setTimeout(function () {
                                $("#confirm_shift_alert").addClass("hidden")
                                $("#FunctionsModal,#confirm_end_of_shift").modal("hide")
                            }, 1500)
                        } else {
                            $("#confirm_shift_alert").attr("class", "alert alert-danger").html(Failed_Submit)
                        }
                    }
                }
            })
        });
        if (view_end_day_cash || view_end_day_sales) {
            $("#end_of_day_btn").on("click", function () {
                var data = {dep_type: 2, Org_Type: 1, is_actual: is_actual};
                $("#end_day_total_cash").html("");
                $.ajax({
                    url: "POSAjax/getDepositCash?with_sales=1",
                    method: "GET",
                    data: data,
                    dataType: "json",
                    complete: function (v1, v2) {
                        if (v2 == "success") {
                            $("#end_day_total_cash").html(v1.responseJSON['cash']);
                            $("#end_day_total_sales").html(v1.responseJSON['sales']);
                            $("#last_end_of_day").html(v1.responseJSON['last_end_of_day']);
                        }
                    }
                })
            })
        }
        $("#addDeposite,#addWitdrawal").on("click", function () {
            $("#payment_note,#search_supplier").parent().addClass("hidden");
            $(".pay_cust_div").addClass("hidden")
            var modal_type = $(this).attr("data-type");
            $("#addDepositModal").attr("data-type", modal_type);
            $("#inv_rec_btn").addClass("hidden")
            $("#deposit_title").html(modal_type == 1 ? add_dep : add_with);
            $(".dep-with-total").html('');
            $.ajax({
                url: "POSAjax/getDepositCash",
                method: "GET",
                data: {dep_type: modal_type, Org_Type: Org_Type, is_actual: is_actual},
                dataType: "json",
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        if (Org_Type != 1) {
                            cashData = v1.responseJSON['cash'];
                            for (var i = 0; i < cashData.length; i++) {
                                var tr = $("#DepositForm table tr[data-id=" + cashData[i]['Cash_Category_ID'] + "]");
                                tr.attr("data-qty", cashData[i]['Cash_Quantity']);
                                tr.find("input.deposite_input").val(cashData[i]['Cash_Quantity']);
                            }
                        } else {
                            if ((modal_type == 1 && show_total_deposite) || (modal_type == 2 && show_total_withdrawal)) {
                                $(".dep-with-total").html(v1.responseJSON)
                            }
                        }
                    }
                }
            })
            $("#addDepositModal").modal("show")
        })
        $("#addPayment,#addReceipt").on("click", function () {
            var is_receipt = ($(this).attr("id") == 'addPayment') ? 0 : 1;
            var modal_type = $(this).attr("data-type")
            $("#addDepositModal").attr("data-type", modal_type)
            $("#addDepositModal").attr("data-is-receipt", is_receipt)
            if (is_receipt == 1) {
                $("#inv_rec_btn").removeClass("hidden")
            } else {
                $("#inv_rec_btn").addClass("hidden")
            }
            //            console.log(is_receipt)
            $("#search_supplier").val('').attr('data-select-name', '')
            build_select2($("#search_supplier"), ("xhr/accIDSearch?type=" + (activate_pos_all_accs == 1 ? 'Payment' : (is_receipt == 1 ? 'cust' : 'supp')) + "&Status_ID=1"))
            $("#payment_note,#search_supplier").parent().removeClass("hidden")
            $("#payment_amount").val('')
            $("#pay_rec_id").val('')
            $("#payment_amount").attr("data-qty", '')
            $("#deposit_title").html(is_receipt == 1 ? add_receipt_lang : add_payment_lang)
            $(".dep-with-total").html('')
            $("#pay_pos_customers").val("").attr("data-select-name", "")
            $("#search_supplier").prop("disabled", false)
            $("#payment_note").val("")
            $("#CurrencyDropDownPOS button input").val('')
            $("#inv_rec_currency_symbol").text("")
            $("#inv_rec_total").text(0)
            $("#DepositAlert").addClass("hidden")
            $("#inv_rec_modal").attr("data-customer", '')
            $("#inv_rec_modal").attr("data-currency", '')
            $("#inv_rec_modal").attr("data-pos-cust", '')
            $("#inv_rec_body").empty()
            $("#CurrencyDropDownPOS button span").text('<?php echo CommonLanguage::getMessage('Select') ?>')
            if (is_receipt == 1 && (add_road_customer_pos == 1 || add_road_customer_pos == 2)) {
                $(".pay_cust_div").removeClass("hidden")
            } else {
                $(".pay_cust_div").addClass("hidden")
            }
            $("#CurrencyDropDownPOS button input").val('<?php echo smc_session()['local_currency']; ?>')
            $("#CurrencyDropDownPOS button span").text('<?php echo smc_session()['local_currency_name']; ?>' + ' - ' + '<?php echo smc_session()['local_currency_symbol'] ?>')

            $("#addDepositModal").modal("show")
        });
        $("#CurrencyDropDownPOS li > a:not(.LoadMore)").on("click", function () {

            //            alert()
            $("#inv_rec_currency_symbol").text($(this).parents('li').attr("mysymbol"))
            var flag = false;
            $("#inv_rec_body input").each(function () {
                if ($(this).val() != '') {
                    flag = true;
                }
            })
            if (flag) {
                $("#depositAlert").attr("class", " alert alert-danger").empty().html('<?php echo CommonLanguage::getMessage('change_amounts') ?>')
                //                return false;
                //                toastr.error(change_amounts)
            }
            var is_receipt = $("#addDepositModal").attr("data-is-receipt");
            if ((is_receipt == 1 && show_receipt_balance) || (is_receipt == 0 && show_payment_balance)) {
                setTimeout(function () {
                    if (activate_autoclose_rec_pay == 1) {
                        get_cust_invoices(0)
                    }
                    getAccBalance('#rec_acc_balance')
                }, 200)
            }

        })
        $("#auto_close_inv_btn").on("click", function () {
            auto_close_rec_inv()
        })
        $("#payment_amount").on('input', function () {
            var is_receipt = $("#addDepositModal").attr("data-is-receipt");
            if (is_receipt == 1 && stop_auto_close_inv == 0 && activate_autoclose_rec_pay == 1)
                auto_close_rec_inv()
        })
        $("#get_cut_inv").on("click", function () {
            $("#depositAlert").addClass("hidden")
            if ($("#CurrencyDropDownPOS button input").val() == '' || ($("#pay_pos_customers").val() == '' && $("#search_supplier").val() == '')) {
                $("#depositAlert").attr("class", " alert alert-danger").empty().html('<?php echo CommonLanguage::getMessage('check_currency_customer') ?>')
                return false;

            }
            //            console.log('here')
//console.log(($("#inv_rec_modal").attr("data-pos-cust") != ""))
//console.log($("#inv_rec_modal").attr("data-pos-cust").trim() == $("#pay_pos_customers").val().trim())
            if ((($("#inv_rec_modal").attr("data-customer") != "" && $("#inv_rec_modal").attr("data-customer").trim() == $("#search_supplier").val().trim()) || ($("#inv_rec_modal").attr("data-pos-cust") != "" && $("#invoice_modal").attr("data-pos-cust") != "0" && (parseFloat($("#inv_rec_modal").attr("data-pos-cust").trim()) || 0) == (parseFloat($("#pay_pos_customers").val().trim()) || 0)))
                    && ($("#inv_rec_modal").attr("data-currency") != "" && $("#inv_rec_modal").attr("data-currency").trim() == $("#CurrencyDropDownPOS button input").val().trim())
                    ) {
                $("#inv_rec_modal").modal("show")
                //                alert()
                return false
            }
            //               console.log('thereeeeeeee')
            //            alert()

            get_cust_invoices(1);
        })
        $("#ClearInv").on("click", function () {
            $("#inv_rec_body input").val("").trigger("keyup")
        })
        $("#inv_rec_body").on("click", ".rem", function () {
            var input = $(this).parents(".my_tr").find("input");
            input.val(input.attr("data-max")).trigger("keyup")
        })
        $("#inv_rec_body").on("keyup", "input", function () {
            stop_auto_close_inv = 1;
            var symbol = $("#CurrencyDropDownPOS ul li[value=" + $("#CurrencyDropDownPOS button input").val() + "]").attr("mysymbol");
            var amount = parseFloat($(this).val()) || 0,
                    max_amount = parseFloat($(this).attr("data-max"));
            $(this).parents(".my_tr").find(".balance").html(AddCommas(parseFloat(((max_amount - amount) || 0)).toFixed(3)) + ' ' + symbol)

            if (amount > max_amount || amount < 0) {
                $(this).addClass("wrong")

            } else {
                $(this).removeClass("wrong")
            }
            var tr_total = 0, validate = true;
            $("#inv_rec_body input").each(function () {
                tr_total += parseFloat($(this).val()) || 0;
                if ($(this).hasClass("wrong"))
                    validate = false;
            })
            if (!validate) {
                $("#CloseInv").attr("disabled", "disabled")
                $("#close_modal").addClass("hidden")
            } else {
                $("#CloseInv").removeAttr("disabled")
                $("#close_modal").removeClass("hidden")


            }
            if (pos_receipt_fill_amount_from_inv == 1) {
                $('#payment_amount').val(parseFloat(tr_total));
            }
            $("#inv_rec_total").html(AddCommas(parseFloat(tr_total).toFixed(3)))
        })
        $("#submitExp").on("click", function () {
            if (!$("#pos-expense-form").valid()) {
                return;
            }
            if ($('#expense_paid_amount').val() && parseFloat($('#expense_paid_amount').val()) > parseFloat($('#expense_amount').val()) && parseFloat($('#expense_paid_amount').val()) != 0) {
                AddAlert('#expenseAlert', '<?php echo CommonLanguage::getMessage('paid_amount_less_total'); ?>', 'danger')
                $("#addExpensesModal").scrollTop(0)
                return false;
            }
            //            if ($("#expense_supplier").val() == '' || $("#Expense_Account").val() == '' || $("#CurrencyDropDownExpense button input").val() == '' || $("#expense_amount").val() == 0) {
            //                AddAlert('#expenseAlert', Required_Fields, 'danger')
            //                $("#addExpensesModal").scrollTop(0)
            //                return false;
            //            }
            var Data = {
                Expense_Date: today,
                Expense_DueDate: today,
                Supplier_ID: $("#expense_supplier").val(),
                Currency_ID: $("#CurrencyDropDownExpense button input").val(),
                Expense_Note: $("#expense_note").val(),
                Expense_VAT: 0,
                Supplier_Invoice: 0,
                is_actual: is_actual,
                expense_no_vat: $("#expense_amount").val(),
                total_paid: $("#expense_paid_amount").val(),
                expense: []
            }
            Data.expense.push({
                exp_desc: $("#expense_note").val(),
                exp_qty: 1,
                unit_cost: $("#expense_amount").val(),
                total: $("#expense_amount").val(),
                paid_amount: $("#expense_paid_amount").val(),
                exp_acc: $("#Expense_Account").val(),
                vat_percent: 0,
                vat_amount: 0
            });
            console.log(Data)
            //            return
            $('#expense_main_loader').removeClass('hidden')
            $.ajax({
                url: "POSAjax/addExpensePOS",
                data: Data,
                method: 'POST',
                dataType: 'json',
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        if (v1.responseJSON[0] == 'OK') {
                            $("#expenseAlert").attr('class', 'alert alert-success').html(Submitted_Successfully);
                            $('#submitExp').attr('disabled', 'disabled');
                            setTimeout(function () {
                                $("#expenseAlert").addClass('hidden')
                                $("#addExpensesModal").modal('hide')
                                $("#expense_supplier").val(0).select2()
                                $("#expense_note").val('')
                                $("#addExpensesModal input").val('');
                                $('#CurrencyDropDownExpense button span:eq(0)').html(select);
                                $("#Expense_Account").val('').attr('data-select-name', '')
                                build_select2($("input[name=Expense_Account]"), "xhr/accIDSearch?type=Expense");
                                $('#submitExp').removeAttr('disabled');
                            }, 1500)
                            $('#expense_main_loader').addClass('hidden');
                            myurl = "Inventory/pos_view_expense/" + v1.responseJSON[1];
                            printPOSExternal(myurl)
                        } else {
                            $("#expenseAlert").attr('class', 'alert alert-danger').html(v1.responseJSON[0]);
                            $('#expense_main_loader').addClass('hidden')
                        }
                        $("#addExpensesModal").scrollTop(0)
                    }
                }
            })
        });
        $('#cancelDep').on("click", function () {
            $("#payment_amount").val('');
            $("#payment_note").val('');
            $("#search_supplier").val('').attr('data-select-name', '');
            $("#pay_pos_customers").val('').attr('data-select-name', '').trigger("change");
            //build_select2($("#search_supplier"), ("xhr/accIDSearch?type=Payment&Status_ID=1"));
            $("#CurrencyDropDownPOS button input").val("");
            $("#CurrencyDropDownPOS button span").html(select_lang);
        });
        $("#submitDep").on("click", function () {
            var dep_type = $("#addDepositModal").attr("data-type");
            var DepData = {
                dep_type: dep_type,
                is_actual: is_actual,
                Currency_ID: $("#CurrencyDropDownPOS button input").val(),
                Org_Type: Org_Type,
                Deposit: [],
                close_arr: []
            };
            if (dep_type == 3) {
                DepData.Account_Code = $("#search_supplier").val();
                DepData.pay_pos_customers = $("#pay_pos_customers").val();
                DepData.is_receipt = $("#addDepositModal").attr("data-is-receipt");
                DepData.Account_Name = $("#s2id_search_supplier a span:eq(0)").html();
                DepData.Payment_Note = $("#payment_note").val();
                DepData.pay_id = $("#pay_rec_id").val();
                if ($("#search_supplier").val() == 0 && $("#pay_pos_customers").val() == 0) {
                    AddAlert("#depositAlert", Required_Fields, "danger")
                    return false;
                }

                var total = 0;
                if (dep_type == 3) {
                    $(".my_tr").each(function () {
                        var tr = $(this);
                        if (tr.find("input").val() != '' && tr.find("input").val() != 0) {
                            total += parseFloat(tr.find("input").val()) || 0;
                            DepData.close_arr.push({
                                inv_id: tr.attr("data-id"),
                                inv_amount: tr.find("input").val(),
                                inv_currency: tr.attr("data-cur")
                            })
                        }

                    })
                }
                //                console.log(total+'====='+parseFloat($("#payment_amount").val() || 0))
                //                return;
                //                $("#inv_rec_body input").each(function () {
                //                    total += parseFloat($(this).val()) || 0;
                //                })
                if (total > parseFloat($("#payment_amount").val() || 0)) {
                    AddAlert("#depositAlert", Required_Fields, "danger")
                    $("#depositAlert").attr("class", " alert alert-danger").empty().html('<?php echo CommonLanguage::getMessage('check_pay_amounts') ?>')
                    return false;
                }

            }
            if (Org_Type == 1) {
                var amount = $("#payment_amount").val();
                if (!amount || $("#CurrencyDropDownPOS button input").val() == "") {
                    AddAlert("#depositAlert", Required_Fields, "danger")
                    return false;
                }
                if (amount <= 0 || isNaN(parseFloat(amount))) {
                    AddAlert("#depositAlert", "<?php echo CommonLanguage::getMessage('negative_value'); ?>", "danger")
                    return;
                }
                if (dep_type == 3) {
                    DepData.Payment_Amount = amount;
                    DepData.total_payment = amount;
                } else {
                    var qty = parseInt(amount);
                    DepData.Deposit_WithDrawal_Amount = Math.abs(qty);
                    DepData.Deposit_WithDrawal_Amount_To = Math.abs(qty);
                    //                        Cash_Category_ID: 15,
                    //                        Operation: qty > 0 ? '+' : '-',
                    DepData.Currency_To = $("#CurrencyDropDownPOS button input").val();
                    DepData.Currency_From = $("#CurrencyDropDownPOS button input").val();
                    //                    var qty = (dep_type == 1) ? parseInt(amount) - parseInt($("#payment_amount").attr('data-qty')) : parseInt(amount);
                    //                alert(parseInt(amount)+'-'+parseInt($("#payment_amount").attr('data-qty'))+'='+qty);   
                    //                    DepData.Deposit.push({
                    //                        
                    //                                //                        Cash_Category_Value: 1
                    //                    })
                }
            }

            $('#dep_with_paym_recpt_loader').removeClass('hidden')
            $.ajax({
                url: "POSAjax/addDepositeCash",
                method: "POST",
                dataType: "json",
                data: DepData,
                complete: function (v1, v2) {
                    if (v2 == "success" && v1.responseJSON[0] == "OK") {
                        stop_auto_close_inv = 0;
                        $('#submitDep').attr('disabled', 'disabled');
                        var myurl = '';
                        if ($("#addDepositModal").attr("data-type") == 3) {
                            // payment
                            myurl = "Inventory/pos_view_payment/" + v1.responseJSON[1];
                        } else if ($("#addDepositModal").attr("data-type") == 2) {
                            // withdrawal
                            myurl = "Inventory/pos_view_withdrawal/" + v1.responseJSON[1];
                        } else if ($("#addDepositModal").attr("data-type") == 1) {
                            // deposit
                            myurl = "Inventory/pos_view_deposit/" + v1.responseJSON[1];
                        }
                        //if (!sumatra_print)
                        printPOSExternal(myurl)
                        $("#addDepositModal,#FunctionsModal").modal('hide');
                        $("#payment_amount").val('');
                        $("#payment_note").val('');
                        $("#search_supplier").val('').attr('data-select-name', '');
                        $("#pay_pos_customers").val('').attr('data-select-name', '').trigger("change");
                        //build_select2($("#search_supplier"), ("xhr/accIDSearch?type=Payment&Status_ID=1"));
                        $("#CurrencyDropDownPOS button input").val("");
                        $("#CurrencyDropDownPOS button span").html(select_lang);
                        setTimeout(function () {
                            $('#submitDep').removeAttr('disabled');
                        }, 5000);
                        $('#dep_with_paym_recpt_loader').addClass('hidden')
                        AddAlert("#depositAlert", Submitted_Successfully, "success")
                    } else {
                        AddAlert("#depositAlert", Failed_Submit, "danger")
                        $('#dep_with_paym_recpt_loader').addClass('hidden')
                    }
                }
            })
        });
        $("#postponedListTable").on("click", ".change_postpone_status", function () {
            var status = $(this).attr("data-status");
            $("#status_postponed_note").val($('td:eq(4)', $(this).parents('tr')).html())
            $("#change_inv_postpone_status").val(status).select2()
            $("#inv_postpone_status_modal").attr("data-inv", $(this).parents(".Action").attr("data-id"))
            $("#inv_postpone_status_modal").modal("show")
        })
        $("#change_inv_postpone").on("click", function () {
            $("#change_status_loader").removeClass("hidden")
            $("#change_postpone_alert").addClass('hidden');
            $.ajax({
                url: "POSAjax/update_inv_postpone_status",
                method: "POST",
                data: {status: $("#change_inv_postpone_status").val(), id: $("#inv_postpone_status_modal").attr("data-inv"), postponed_note: $('#status_postponed_note').val()},
                complete: function (v1, v2) {
                    if (v2 == 'success') {
                        AddAlert('#change_postpone_alert', Submitted_Successfully, 'success')
                        hideModalAlert('inv_postpone_status_modal', 'change_postpone_alert');
                        //                        $("#change_postpone_alert").attr("class", "alert alert-success").html(Submitted_Successfully)
                        rebuild_post_table();
                    } else {
                        $("#change_postpone_alert").attr("class", "alert alert-danger").html(Failed_Submit)
                    }
                    $("#change_status_loader").addClass("hidden")
                }
            })
        });
        $("#road_customer_list_table").on("click", ".edit_road_customer", function () {
            is_road_cust_edit = true;
            is_road_cust_update_after_edit = false;
            road_cust_to_edit = $(this).attr("data-id");
            fill_road_customer_data()
        })
        $('#customer_ledger_btn').on('click', function () {
            rebuild_cust_ledger_report();
        });
        $("#addCust").on("click", function () {
            $("#addCustomerAlert").addClass("hidden")
            if (!$("#AddCustomerForm").valid()) {
                $("#addCustomerAlert").attr("class", "alert alert-danger").html(Required_Fields)
                return false;
            }
            //            var IsEdit = $("#addCustomerModal").attr("data-edit");
            var Cust_Data = new FormData(document.getElementById("AddCustomerForm"));
            Cust_Data.append("is_edit", (is_road_cust_edit ? 1 : 0))
            if (is_road_cust_edit == 1) {
                Cust_Data.append("customer_id", road_cust_to_edit)
            }
            $.ajax({
                url: "POSAjax/addCustomerInfo",
                method: "POST",
                data: Cust_Data,
                dataType: 'json',
                processData: false,
                contentType: false,
                complete: function (v1, v2) {
                    if (v2 == 'success') {
                        var is_auto_select_cust = false;
                        if (v1.responseJSON[0] == 'OK') {
                            $("#addCustomerAlert").attr("class", "alert alert-success").html(Submitted_Successfully);
                            //in case of new customer or edit selected poc customer not from list then auto select it
                            if (!is_road_cust_edit || is_road_cust_update_after_edit)
                                is_auto_select_cust = true;
                        } else {
                            $("#addCustomerAlert").attr("class", "alert alert-danger").html(v1.responseJSON[0])
                        }
                        $("#addCustomerModal").modal("hide");
                        setTimeout(function () {
                            $("#addCustomerAlert").hide();
                        }, 2500);
                        RebuildDataTable('<?php echo CommonLanguage::getMessage('road_customer_list') ?>', [], "POSAjax/road_customer_list_ajax", [], "#road_customer_list_table");
                        //just in case of new customer and added successfully auto select that customer
                        if (is_auto_select_cust) {
                            customerSelectAutocomplete(v1.responseJSON[2]);
                            //                            $("#CurCustomerInfo").attr("CurCustomerID", 0);
                            //                            $("#CurCustomerInfo").attr("customer-pos-id", v1.responseJSON[1]);
                            //                            $("#CurCustomerInfo").attr("data-is-pos", 1);
                            //                            //
                            //                            var Content = "<div class='row m-t-5'><strong>" + NameLang + ": </strong><span class='Name'>" + $("#Customer_Name").val() + "</span>&nbsp/&nbsp<strong>" + PhoneLang + ": </strong><span class='Phone'>" + $("#Customer_Phone").val() + "</span>&nbsp/&nbsp";
                            //                            Content += "<strong>" + AddressLang + ": </strong><span class='Address'>" + $("#Customer_Address").val() + "</span></div>", allergy_content = '', intolerance_content = '';
                            //                            if ($('#allergy_id').val()) {
                            //                                $('#s2id_allergy_id ul li.select2-search-choice').each(function () {
                            //                                    allergy_content += $('> div', $(this)).html() + ',';
                            //                                });
                            //                            }
                            //                            if ($('#intolerance_id').val()) {
                            //                                $("#s2id_intolerance_id ul li.select2-search-choice").each(function () {
                            //                                    intolerance_content += $('> div', $(this)).html() + ',';
                            //                                });
                            //                            }
                            //                            if (allergy_content != "") {
                            //                                allergy_content = allergy_content.substring(0, allergy_content.length - 1);
                            //                                Content += '&nbsp/&nbsp<strong>' + allergy + ': </strong><span class="Allergy">' + allergy_content + '</span>';
                            //                            }
                            //                            if (intolerance_content != "") {
                            //                                intolerance_content = intolerance_content.substring(0, intolerance_content.length - 1);
                            //                                Content += '&nbsp/&nbsp<strong>' + intolerance + ': </strong><span class="Intolerance">' + intolerance_content + '</span>';
                            //                            }
                            //                            $("#CurCustomerInfo").html(Content);
                        }
                        RebuildPOSDataTable("POSAjax/POSCustomerListRequest", 1, "#Customertable");
                    } else {
                        $("#addCustomerAlert").attr("class", "alert alert-danger").html(Failed_Submit)
                    }
                }
            })
        });
        $("#OrderTable").on("click", ".product_description", function () {
            //        alert()
            if(!pos_return_postponed_change_item && is_return_postponed==1){
                 return;
            }
            if (SelectedTR.attr('data-entry') != '' && SelectedTR.attr("data-entry") != '0' && SelectedTR.attr("data-entry") != undefined && !change_item_row_after_edit) {
                return;
            }
            if (parseFloat(SelectedTR.find("span.qty_span").html() || 0) < 0) {
                SelectedTR.find("td").removeClass("tr-gray tr-white").addClass("tr-return");
            } else {
                SelectedTR.find("td").removeClass("tr-gray tr-return").addClass("tr-white");
            }
            SelectedTR = $(this).parents('tr');
            $('#product_note_description').val(SelectedTR.attr('product-description') ? SelectedTR.attr('product-description') : '')
            $('#product_note_modal').modal('show');
        });
        $('.product_note_item').on('click', function () {
            $('#product_note_description').val($(this).html())
            SelectedTR.attr('is_linked_note', $(this).attr('data-type'))
            $('#submit_product_note').trigger('click')
        });
        $('#submit_product_note').on('click', function () {
            SelectedTR.attr('product-description', $('#product_note_description').val())
            if (SelectedTR.attr('is_linked_note') == 1) {
                $('.prod-desc-icon', SelectedTR).removeClass('note-filled red-star')
                $('.prod-desc-icon', SelectedTR).addClass($('#product_note_description').val() ? 'red-star' : '')
            } else {
                if ($('#product_note_description').val())
                    $('.prod-desc-icon', SelectedTR).addClass('note-filled')
                else
                    $('.prod-desc-icon', SelectedTR).removeClass('note-filled')
            }
            $('#product_note_modal').modal('hide')
        });
        $("#report_post_list_nb").on("keyup", function () {
            rebuild_post_report()
        });
        $('#report_post_cust,#report_posponted_status_filter,#postponed_category_id,#report_post_pos_cust,#current_report_branch_id').on('change', function () {
            rebuild_post_report()
        });
        $('input[name="report_post_date"]').on('apply.daterangepicker', function (ev, picker) {
            window.startPostponedDate = picker.startDate.format('YYYY-MM-DD'),
                    window.endPostponedDate = picker.endDate.format('YYYY-MM-DD');
            $(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
            rebuild_post_report();
        });
        $('input[name="report_post_date"]').on('cancel.daterangepicker', function (ev, picker) {
            startPostponedDate = ''
            endPostponedDate = ''
            $(this).val('');
            rebuild_post_report();
        });
        $("#postponed_report_modal").on("shown.bs.modal", function () {
            rebuild_post_report()
        });
        $('#print_postponed_report').on('click', function () {
            var divToPrint = document.getElementById('postponed_report_data');
            var htmlToPrint = '<style>.table-bordered>thead>tr>th{border: 1px solid rgba(230,230,230,0.7)}.table-bordered>tbody>tr>td{border: 1px solid rgba(230,230,230,0.7)}.table{width:100%;border-spacing:0;border-collapse: collapse;}</style>' + divToPrint.outerHTML;
            newWin = window.open("");
            newWin.document.write(htmlToPrint);
            newWin.print();
            newWin.close();
        })
        $("#received_delivery_list").on("click", ".change_rec", function () {
            var status = $(this).attr("data-status"),
                    inv_id = $(this).parents(".Action").attr("data-id");
            $.ajax({
                url: "POSAjax/change_inv_rec",
                data: {status: status, inv_id: inv_id},
                method: 'post',
                complete: function (v1, v2) {
                    if (v2 == "success" && v1.responseText == 'OK') {
                        toastr.success(Submitted_Successfully)
                        rebuild_received_delivery_table()
                        //                        var response = v1.responseText;
                        //                        $('#postponed_report_data').html(response)
                        //                        $('#postponed_report_loader').addClass('hidden')
                    } else {
                        toastr.error(Failed_Submit)
                    }
                }
            })
        })
        $("#received_delivery_list").on("click", ".change_rec_note", function () {
            $("#receive_note").val($(this).parents("tr").find("td:eq(10)").text())
            $("#rec_note_modal").attr("data-inv", $(this).parents(".Action").attr("data-id"))

        })
        $("#save_rec_note").on("click", function () {
            $.ajax({
                url: "POSAjax/change_inv_rec_note",
                data: {note: $("#receive_note").val(), inv_id: $("#rec_note_modal").attr("data-inv")},
                method: 'post',
                complete: function (v1, v2) {
                    if (v2 == "success" && v1.responseText == 'OK') {
                        toastr.success(Submitted_Successfully)
                        rebuild_received_delivery_table()
                        $("#rec_note_modal").modal('hide')
                    } else {
                        toastr.error(Failed_Submit)
                    }
                }
            })
        })

        $("#receipt_list").on("click", function () {
            rebuild_pay_rec_table(1)
            $("#rec_pay_list_modal").modal("show")
        })
        $("#payment_list").on("click", function () {
            rebuild_pay_rec_table(0)
            $("#rec_pay_list_modal").modal("show")
        })

        $("#pay_rec_table").on("click", ".delete_rec,.delete_pay", function () {

            var entry_value = $(this).parents('.Action').attr('data-id'),
                    is_receipt = $(this).hasClass("delete_rec") ? 1 : 0;
            var data = {
                ids: entry_value,
                is_receipt: is_receipt,
                is_return: 0,
                from_pos: 1
            };
            var alert_before = '';
            if ($(this).attr('data-inv-linked') == 1) {
                alert_before = '<?php echo CommonLanguage::getMessage('pay_linked_inv') ?>';
            }
            IncludeDeleteModal(common_delete_modal, data, function () {
                rebuild_pay_rec_table(is_receipt)
            }, "ACCAjax/delete_payment_receipt", alert_before);
        })
        $("#pay_rec_table").on("click", ".edit_pay_rec", function () {
            $.ajax({
                url: "POSAjax/get_rec_pay_by_id",
                data: {id: $(this).parents(".Action").attr("data-id")},
                dataType: 'json',
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        var data = v1.responseJSON;
                        var is_receipt = data['main']['is_receipt'];
                        $("#addDepositModal").attr("data-type", 3)
                        $("#addDepositModal").attr("data-is-receipt", is_receipt)
                        if (is_receipt == 1) {
                            $("#inv_rec_btn").removeClass("hidden")
                        } else {
                            $("#inv_rec_btn").addClass("hidden")
                        }
                        $("#pay_pos_customers").val(data['main']['pos_customer_id']).attr('data-select-name', data['main']['pos_customer_name'])
                        build_select2($("#pay_pos_customers,#road_cust_ledger_filter"), "xhr/CommonSearch?col_id=customer_id&col_name=customer_name&table=tbl_pos_customers");
                        $("#search_supplier").val(data['main']['Account_ID']).attr('data-select-name', data['main']['Account_Name'])
                        build_select2($("#search_supplier"), ("xhr/accIDSearch?type=" + (activate_pos_all_accs == 1 ? 'Payment' : (is_receipt ? 'cust' : 'supp')) + "&Status_ID=1"))
                        $("#payment_note,#search_supplier").parent().removeClass("hidden")
                        $("#payment_note").val(data['main']['Payment_Note'])
                        $("#payment_amount").val(data['main']['total_amount'])

                        $("#inv_rec_currency_symbol").text(data['main']['Currency_Symbol'])
                        $("#pay_rec_id").val(data['main']['pay_rec_id'])
                        $("#CurrencyDropDownPOS button input").val(data['main']['Currency_ID'])
                        $("#CurrencyDropDownPOS button span").text(data['main']['Currency_Name'] + ' - ' + data['main']['Currency_Code'])
                        $("#deposit_title").html(is_receipt ? '<?php echo CommonLanguage::getMessage('edit_receipt') ?>' : '<?php echo CommonLanguage::getMessage('edit_payment') ?>')
                        $(".dep-with-total").html('')
                        if (is_receipt && (add_road_customer_pos == 1 || add_road_customer_pos == 2)) {
                            $(".pay_cust_div").removeClass("hidden")
                        } else {
                            $(".pay_cust_div").addClass("hidden")
                        }


                        $("#inv_rec_modal").attr("data-customer", data['main']['Account_ID'])
                        $("#inv_rec_modal").attr("data-currency", data['main']['Currency_ID'])
                        $("#inv_rec_modal").attr("data-pos-cust", data['main']['pos_customer_id'])
                        //inv_body
                        $("#inv_rec_body").empty()
                        var TR = '';
                        var symbol = data['main']['Currency_Symbol'],
                                pay_inv = data['pay_inv'];
                        var pay_inv_total = 0;
                        if (pay_inv.length > 0) {
                            for (var i = 0; i < pay_inv.length; i++) {
                                pay_inv_total += (parseFloat(pay_inv[i]['inv_pay_amount']) || 0);
                                TR += '<div class="row m-b-10 my_tr" data-id="' + pay_inv[i]['Invoice_ID_Auto'] + '" data-cur = "' + pay_inv[i]['Invoice_Currency'] + '">' +
                                        '<div class="col-md-1">' + pay_inv[i]['Invoice_ID'] + '</div>' +
                                        '<div class="col-md-2">' + pay_inv[i]['Invoice_Date'] + '</div>' +
                                        '<div class="col-md-2">' + AddCommas(parseFloat(pay_inv[i]['Invoice_Net_Total']).toFixed(3)) + ' ' + symbol + '</div>' +
                                        '<div class="col-md-2 rem" >' + AddCommas((parseFloat(pay_inv[i]['Remaining_Amount']) + parseFloat(pay_inv[i]['inv_pay_amount'])).toFixed(3)) + ' ' + symbol + '</div>' +
                                        '<div class="col-md-2"><input type="text" class="form-control" data-max="' + (parseFloat(pay_inv[i]['Remaining_Amount']) + parseFloat(pay_inv[i]['inv_pay_amount'])) + '" value="' + pay_inv[i]['inv_pay_amount'] + '" /></div>' +
                                        '<div class="col-md-2 balance" >' + AddCommas(parseFloat(pay_inv[i]['Remaining_Amount']).toFixed(3)) + ' ' + symbol + '</div></div>';
                            }
                            $("#inv_rec_total").text(AddCommas(pay_inv_total))
                            TR = $(TR)
                            $("#inv_rec_body").append(TR)

                        }

                        $("#addDepositModal").modal("show")
                    }
                }
            })
        });
        $('#addDepositModal').on('hidden.bs.modal', function () {
            $('#rec_acc_balance').html('')
        })
        $("#product_options_modal #op_main_qty").on("input", function () {
            $("#op_main_div .op-block").each(function () {
                var nb = (parseFloat($(this).attr("data-qty")) || 0) * (parseFloat($("#op_main_qty").val()) || 0);
                $(".span_qty_op", $(this)).text(nb)
            })
        })
        $("#product_options_modal #next_btn").on("click", function () {
            var check_required = false,
                    option_arr = [];
            $("#op_main_div .op-block").each(function () {
                var max = (parseFloat($("#op_main_qty").val()) || 0) * (parseFloat($(this).attr("data-qty")) || 0),
                        is_required = $(this).attr("data-required"),
                        total = 0;
                $(this).find('.op-div').each(function () {
                    var qty = parseFloat($(this).find('input.op-spinner').val()) || 0;
                    total += qty
                    if (qty > 0) {
                        option_arr.push({
                            product_id: $(this).attr("data-id"),
                            option_id: $(this).attr("data-option-id"),
                            uom_id: $(this).attr("data-uom"),
                            qty: qty,
                            //                        product_name: $(this).find('.op-prod-name').text(),
                        })
                    }
                })
                console.log(max + '===' + total)
                if ((is_required == 1 && max != total) || total > max)
                    check_required = true;

            })
            if (check_required) {
                $("#option_alert").attr("class", "alert alert-danger").html('<?php echo CommonLanguage::getMessage('check_required_qty') ?>')
                $("#product_options_modal").scrollTop(0)
                return;
            }
            var ref = $("#product_options_modal").attr("data-ref"),
                    tr = $("#OrderTable tbody tr[data-ref=" + ref + "]"),
                    tr_qty = (parseFloat(tr.find(".InputSpinner > span").text()) || 0) * (parseFloat(tr.attr("data-conv")) || 0);
            tr.attr("data-last-qty", tr_qty)
            tr.attr("data-option-arr", JSON.stringify(option_arr))
            tr.find('.qty_span').text($("#op_main_qty").val())
            UpdateTable($("#OrderTable > tbody:last"));
            $("#product_options_modal").modal("hide")
        });
        $('#pay_rec_table').on('click', '.print_receipt_payment', function () {
            myurl = "Inventory/pos_view_payment/" + $(this).attr('data-id');
            printPOSExternal(myurl)
        });
    });

    function rebuild_post_report() {
        var inv_data = {
            customer_id: $("#report_post_cust").val(),
            inv_list_nb: $("#report_post_list_nb").val(),
            category_id: $("#postponed_category_id").val(),
            postponed_date_from: window.startPostponedDate,
            postponed_date_to: window.endPostponedDate,
            pos_customer: $("#report_post_pos_cust").val(),
            is_actual: is_actual,
            posponted_status: $("#report_posponted_status_filter").val(),
            branch_id: $("#current_report_branch_id").val()
        }
        $('#postponed_report_data').empty()
        $('#postponed_report_loader').removeClass('hidden')
        $.ajax({
            url: "POSAjax/get_postponed_report",
            data: inv_data,
            complete: function (v1, v2) {
                if (v2 == "success") {
                    var response = v1.responseText;
                    $('#postponed_report_data').html(response)
                    $('#postponed_report_loader').addClass('hidden')
                }
            }
        })
    }
    function rebuild_cust_ledger_report() {
        if ($("#cust_ledger_filter").val() == '' && $("#road_cust_ledger_filter").val() == '') {
            $("#customer_ledger_table").DataTable().destroy();
            $("#customer_ledger_table tbody").empty().html('')
            RebuildDataTable('invoices', [], "", {}, "#customer_ledger_table")
            $("#cust_ledger_balance").html('0')
            return;
        }
        var data = {
            customer_id: $("#cust_ledger_filter").val() ? $("#cust_ledger_filter").val() : 0,
            road_customer_id: $("#road_cust_ledger_filter").val(),
            from_date: window.startledgerDate ? window.startledgerDate : start_date,
            to_date: window.endledgerDate ? window.endledgerDate : today,
            ignore_zero: $("#ignore_zero_balance").is(":checked") ? 1 : 0,
            is_actual: is_actual
        }
        $("#cust_ledger_filter").val() == '' ? $("#print_cust_ledger").attr("disabled", true) : $("#print_cust_ledger").removeAttr("disabled")
        $.ajax({
            url: "POSAjax/get_customer_ledger",
            data: data,
            dataType: 'json',
            complete: function (v1, v2) {
                if (v2 == "success") {
                    $("#customer_ledger_table").DataTable().destroy();
                    $("#customer_ledger_table tbody").empty().html(v1.responseJSON[0])
                    RebuildDataTable('invoices', [], "", {}, "#customer_ledger_table")
                    $("#cust_ledger_balance").html(v1.responseJSON[1]['balance'])
                }
            }
        })
    }
    function rebuild_cust_inv_report() {
        if ($("#cust_inv_filter").val() == '' && $("#pos_cust_inv_filter").val() == '') {
            $("#customer_invoice_table").DataTable().destroy();
            $("#customer_invoice_table tbody").empty().html('')
            RebuildDataTable('invoices', [], "", {}, "#customer_invoice_table")
            $("#cust_inv_total").html('0')
            $("#cust_inv_total_paid").html('0')
            return;
        }
        var data = {
            customer_id: $("#cust_inv_filter").val(),
            from_date: window.startDate ? window.startDate : start_date,
            to_date: window.endDate ? window.endDate : today,
            pos_customer: $("#pos_cust_inv_filter").val(),
            is_actual: is_actual,
            created_user: $("#created_user").val(),
        }
        $.ajax({
            url: "POSAjax/get_customer_invoices",
            data: data,
            dataType: 'json',
            complete: function (v1, v2) {
                if (v2 == "success") {
                    $("#customer_invoice_table").DataTable().destroy();
                    $("#customer_invoice_table tbody").empty().html(v1.responseJSON[0])
                    RebuildDataTable('invoices', [], "", {}, "#customer_invoice_table")
                    $("#cust_inv_total").html(v1.responseJSON[1]['total'])
                    $("#cust_inv_total_paid").html(v1.responseJSON[1]['total_paid'])
                }
            }
        })
    }
    function fill_road_customer_data() {
        $.ajax({
            url: "POSAjax/get_road_customer_by_id",
            data: {id: road_cust_to_edit},
            dataType: 'json',
            complete: function (v1, v2) {
                if (v2 == "success") {
                    var data = v1.responseJSON;
                    $("#Customer_Name").val(data['customer_name'])
                    $("#Customer_Phone").val(data['customer_phone'])
                    $("#Customer_Address").val(data['Address'])
                    $("#customer_dob").val(data['customer_dob'])
                    $("#pos_cust_region_id").val(data['region_id']).attr("data-select-name", data['region_name']).trigger("change")
                    if (activate_allergy_intolerance == 1) {
                        $('#intolerance_id').select2('val', [])
                        $('#intolerance_id').data().select2.updateSelection(data['intolerance_id']);
                        $('#allergy_id').select2('val', [])
                        $('#allergy_id').data().select2.updateSelection(data['allergy_id']);
                    }
                    $("#addCustomerModal").modal("show")
                }
            }
        })
    }

    function rebuild_pay_rec_table(is_receipt) {
        var data = {
            is_receipt: is_receipt,
            Date_From: window.startrecDate ? window.startrecDate : start_date,
            Date_To: window.endrecDate ? window.endrecDate : today,
            is_actual: is_actual
        }
        //        $.ajax({
        //            url: "POSAjax/get_return_invoices_total",
        //            data: ret_data,
        //            dataType: 'json',
        //            complete: function (v1, v2) {
        //                if (v2 == "success") {
        RebuildDataTable('payments', [0, 1, 2, 3, 4], "POSAjax/pay_rec_list_ajax", data, "#pay_rec_table");
        //                    $("#ReturnListTable #ret_total").html(AddCommas(parseFloat(v1.responseJSON['net_total'] || 0).toFixed(3)));
        //                    $("#ReturnListTable #ret_paid_total").html(AddCommas(parseFloat(v1.responseJSON['paid_amount'] || 0).toFixed(3)));
        //                }
        //            }
        //        })
    }

    function get_cust_invoices(open_modal) {
        if ($("#CurrencyDropDownPOS button input").val() == '' || ($("#pay_pos_customers").val() == '' && $("#search_supplier").val() == '')) {
            return false;

        }
        $("#submitDep").prop("disabled", true)
        $("#inv_rec_total").html('0')
        $("#inv_rec_modal").attr("data-customer", $("#search_supplier").val())
        $("#inv_rec_modal").attr("data-currency", $("#CurrencyDropDownPOS button input").val())
        $("#inv_rec_modal").attr("data-pos-cust", $("#pay_pos_customers").val())
        $.ajax({
            url: "ACCAjax/getUnpaidInvoicesByCustomer",
            method: "GET",
            data: {is_receipt: 1, account: $("#search_supplier").val(), currency: $("#CurrencyDropDownPOS button input").val(), is_actual: (is_actual ? 1 : 0), pos_customer: $("#pay_pos_customers").val(), type: 'rec'},
            dataType: 'json',
            complete: function (v1, v2) {
                if (v2 == 'success') {
                    $("#inv_rec_body").empty()
                    var data = v1.responseJSON;
                    //inv_body
                    var TR = '';
                    var symbol = $("#CurrencyDropDownPOS ul li[value=" + $("#CurrencyDropDownPOS button input").val() + "]").attr("mysymbol");
                    for (var i = 0; i < data.length; i++) {
                        TR += '<div class="row m-b-10 my_tr" data-id="' + data[i]['Invoice_ID_Auto'] + '" data-cur = "' + data[i]['Invoice_Currency'] + '">' +
                                '<div class="col-md-1">' + data[i]['Invoice_ID'] + '</div>' +
                                '<div class="col-md-2">' + data[i]['Invoice_Date'] + '</div>' +
                                '<div class="col-md-2">' + AddCommas(parseFloat(data[i]['Invoice_Net_Total']).toFixed(3)) + ' ' + symbol + '</div>' +
                                '<div class="col-md-2 rem" >' + AddCommas(parseFloat(data[i]['Remaining_Amount']).toFixed(3)) + ' ' + symbol + '</div>' +
                                '<div class="col-md-2"><input type="text" class="form-control" data-max="' + data[i]['Remaining_Amount'] + '" /></div>' +
                                '<div class="col-md-2 balance" >' + AddCommas(parseFloat(data[i]['Remaining_Amount']).toFixed(3)) + ' ' + symbol + '</div></div>';
                    }
                    TR = $(TR)
                    $("#inv_rec_body").append(TR)
                    if (activate_autoclose_rec_pay == 1 && stop_auto_close_inv == 0)
                        auto_close_rec_inv()
                    if (open_modal == 1)
                        $("#inv_rec_modal").modal("show")
                    $("#submitDep").prop("disabled", false)

                }
            }
        })
    }

    function auto_close_rec_inv() {
        $("#submitDep").prop("disabled", true)
        var amount = parseFloat($('#payment_amount').val()) || 0;
        $("#inv_rec_total").html(AddCommas(parseFloat(amount).toFixed(3)))
        
        $("#inv_rec_body input").each(function () {
            var row_max = parseFloat($(this).attr("data-max")) || 0,
                    temp = parseFloat(Math.min(amount, row_max));
            $(this).val(temp==0?'' : temp);
            amount -= temp;
            if (amount <= 0)
                return false;
        })
        $("#submitDep").prop("disabled", false)

    }

</script>
