<style>
    .table thead tr >th{
        background-color: #4c0870;
        color:#fff;
    }
    /*
    .table thead tr th[class*='sorting_'] {
    color: #FFFFFF;
    }
    */
    /*
    .bg-master-lighter {
    border:none;
    background-color:#fff;
    border-top:1px solid #ddd; 
    }
    */
    /*
    .btn-default{
    border: none;
    background-color: #eee;
    }
    .btn-default:hover{
    background-color:#ed9421 !important;
    color:#fff;
    border: none;
    }
    */
</style>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"> <?php print CommonLanguage::getMessage('cash_drawer_accounts'); ?></div>
            <div class="clearfix"></div>
        </div>
        <div class="panel-body">
            <?php
            echo Forms::FloatingAddButton('4c0870', '#add-cash-drawer-modal', CommonLanguage::getMessage('Add'));
            ?>
            <table class="table table-bordered table-hover demo-table-search" id="tableWithSearch" >
                <thead>
                    <tr>
                        <th class="text-center" style="width:15%" ><?php print CommonLanguage::getMessage('Name'); ?></th>
                        <th class="text-center" style="width:15%" ><?php print CommonLanguage::getMessage('cash_account'); ?></th>
                        <th class="text-center" style="width:15%" ><?php print CommonLanguage::getMessage('Action'); ?></th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
</div>
<div class="modal fade " data-backdrop="static" id="add-cash-drawer-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 fs-20"></i>
                </button>
                <h5 class="add-label h-labels text-left semi-bold hidden"><?php echo CommonLanguage::getMessage('add_cash_drawer');?></h5>
                <h5 class="edit-label h-labels text-left semi-bold hidden"><?php echo CommonLanguage::getMessage('edit_cash_drawer');?></h5>
            </div>
            <div class="modal-body">
                <form id="piece_service_form" method="POST" onsubmit="return false">
                    <input type='hidden' name='piece_service_id' id='piece_service_id'/>
                    <div class="row">
                        <?php echo Forms::AlertDiv('piece_service_alert'); ?>
                        <div class="col-md-12 form-group m-t-10">
                            <label><?php print CommonLanguage::getMessage('title'); ?></label><span class="red-star">*</span>
                            <input type="text"  placeholder="<?php print CommonLanguage::getMessage('title'); ?>" id="" name="" class="form-control " required>
                        </div>
                        <div class="col-md-12 form-group">
                            <label class="labelText"><?php print CommonLanguage::getMessage('cash_account'); ?></label>
                            <span class="red-star">*</span>
                            <span class="fa fa-plus-circle m-l-5 openFrame" data-src="ACC/viewlibrary/1?is_pop=1" style="color:#4c0870;cursor:pointer"></span>
                            <input class=" full-width" id="cash_account" name="cash_account" type="hidden"  />
                        </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 bg-complete white" id="submit_piece_service"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('cashDrawerAccountLoader'); ?>
        </div>
    </div>
</div>
<script>
    var title = <?php echo json_encode(CommonLanguage::getMessage('user_accounts')); ?>,
        Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
            Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>;
            $(function () {
                build_select2($("#cash_account"), ("xhr/accIDSearch?type=cash"))
                //                RebuildDataTable(title, [0, 1], "ACCAjax/UserAccAccounts")
                //        $("#assignBtn").on("click", function () {
                //            $("#assignUserAlert").removeClass('hidden')
                //            var DataArr = {
                //                User_ID: $("#users").val(),
                //                Cash_Account: $("#cash_account").val(),
                //                Cheque_Account: $("#cheque_account").val(),
                //                purchase_account: $("#purchase_account").val(),
                //                sales_account: $("#sales_account").val(),
                //                purchase_shipping: $("#purchase_shipping").val(),
                //                sales_shipping: $("#sales_shipping").val(),
                //                deposite_account: $("#deposit_accounts").val(),
                //                withdrawal_Account: $("#withdrawal_accounts").val(),
                //                Other_Account: $("#Other_Account").val(),
                //                default_class: $("#default_class").val(),
                //                default_depot: $("#default_depot").val(),
                //                default_branch: $("#default_branch").val(),
                //                user_prefix: $("#user_prefix").val(),
                //                max_discount: $("#max_discount").val(),
                //                edit_price : $("#edit_price").is(":checked") ? 1 : 0
                //            }
                //
                //            $.ajax({
                //                url: "ACCAjax/assignUserAccounts",
                //                method: "POST",
                //                dataType: 'json',
                //                data: DataArr,
                //                complete: function (v1, v2) {
                //                    if (v2 == "success" && v1.responseJSON[0] == 'OK') {
                //                        $("#assignUserAlert").attr("class", "alert alert-success").html(v1.responseJSON[1])
                //                        RebuildDataTable(title, [0, 1], "ACCAjax/UserAccAccounts")
                //                        setTimeout(function () {
                //                            $("#assignUserAlert").addClass('hidden')
                //                            $("#assignUserAccount").modal("hide")
                //                        }, 5000)
                //                    } else {
                //                        $("#assignUserAlert").attr("class", "alert alert-danger").html(Failed_Submit)
                //                    }
                //                }
                //            })
                //        })
                //        $("#tableWithSearch tbody").on('click', '.Edit', function () {
                ////            IsEdit = true;
                //            $.ajax({
                //                url: "ACCAjax/getUserAccounts",
                //                method: "GET",
                //                dataType: "JSON",
                //                data: {id: $(this).attr('data-id')},
                //                complete: function (v1, v2) {
                //                    var Data = v1.responseJSON;
                //                    $("#users").val(Data['User_ID']).select2()
                //                    $("#cash_account").val(Data['cash_account_id']).attr("data-select-name", Data['c_name'])
                //                    $("#cheque_account").val(Data['cheque_account_id']).attr("data-select-name", Data['cheque_name'])
                //                    $("#purchase_account").val(Data['purchase_account_id']).attr("data-select-name", Data['p_name'])
                //                    $("#sales_account").val(Data['sales_account_id']).attr("data-select-name", Data['s_name'])
                //                    $("#purchase_shipping").val(Data['pur_ship_account_id']).attr("data-select-name", Data['ps_name'])
                //                    $("#sales_shipping").val(Data['sales_ship_account_id']).attr("data-select-name", Data['ss_name'])
                //                    $("#deposit_accounts").val(Data['deposit_account_id']).select2()
                //                    $("#Other_Account").val(Data['other_account_id']).select2()
                //                    $("#withdrawal_accounts").val(Data['withdrawal_account_id']).select2()
                //                    $("#default_class").val(Data['class_id']).attr("data-select-name", Data['Class_Name'])
                //                    $("#default_depot").val(Data['depot_id']).attr("data-select-name", Data['Depot_Name'])
                //                    $("#default_branch").val(Data['branch_id']).attr("data-select-name", Data['branch_name'])
                //                    $("#user_prefix").val(Data['serial_prefix'])
                //                    $("#max_discount").val(Data['max_discount'])
                //                    $("#edit_price").prop("checked",Data['edit_price'] ==1 ? true : false)
                //                    build_select2($("#cash_account"), ("xhr/accIDSearch?type=cash"))
                //                    build_select2($("#cheque_account"), ("xhr/accIDSearch?type=check"))
                //                    build_select2($("#purchase_account"), ("xhr/accIDSearch?type=purchase"))
                //                    build_select2($("#purchase_shipping"), ("xhr/accIDSearch?type=purchase"))
                //                    build_select2($("#sales_account"), ("xhr/accIDSearch?type=sales"))
                //                    build_select2($("#sales_shipping"), ("xhr/accIDSearch?type=sales"))
                //                    build_select2($("#default_class"), "xhr/PricingClassSearch")
                //                    build_select2($("#default_depot"), "xhr/depotSearch")
                //                    build_select2($("#default_branch"), "xhr/CommonSearch?col_id=branch_id&col_name=branch_name&table=tbl_organization_branches")
                //                    $("#assignUserAccount").modal("show")
                //                }
                //            })
                //
                //        })
            });
</script>
