<style type="text/css">
    #booth {
        margin: 20px 0px 10px 0px;
      }
      #customerphotogallery{
        margin-top: 10px;
      }
      .deletelink{
        background-color: white;
        color: red;
        padding: 2px;
        position: absolute;
        top: 0px;
        right: 15px;
        font-size: 15px;
      }
      
</style>
<script type="text/javascript">
    $(document).ready(function () {
        var table = $('#customettable').DataTable( {
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "<?php echo base_url('partner/customers/getcustomers') ?>",
            "lengthMenu": [[20, 50, 100], [20, 50, 100]],
            "columnDefs" : [

                {"targets": [ 9 ],"sortable" : false  ,"render": function ( data, type, row ) {
    //                    return '<a class="btn btn-small btn-info shiny fa fa-edit" href="<?php echo base_url('finance/Deposits/editrecord') ?>/' + data + '"><span></span></a>&nbsp;<a class="btn btn-small btn-danger shiny fa fa-trash-o" href="javascript:void(0)" onclick="deletefn(\'' + data + '\')"><span></span></a>';
                        var a   =   "<div style='width:220px;'>";
                        a   =   a+'<a class="btn btn-info shiny btn-xs" onclick="return myFunction(this.id)" data-toggle="modal" data-target="#myModal" id=' + data + ' ' + 'href=#' + ' title="Edit">' + '<i class="fa fa-edit"></i>' + '</a>&nbsp;&nbsp;<a class="btn btn-danger shiny btn-xs" data-toggle="modal" data-target="#confirmmodal" onclick="return confirmFunction(this.id)" id=' + data + ' ' + 'href=#' + ' title="Delete">' + '<i class="fa fa-trash"></i>' + '</a>';
                    <?php
                    if($reccustimgcheck==1){
                    ?>
                        a   =   a+'&nbsp;&nbsp;<a class="btn btn-success shiny btn-xs" data-toggle="modal" data-target="#cameramodal" onclick="return cameraFunction(this.id)" id=' + data + ' ' + 'href=#' + ' title="Take a photo">' + '<i class="fa fa-camera"></i>' + '</a>&nbsp;&nbsp;<a class="btn btn-maroon shiny btn-xs" data-toggle="modal" data-target="#customersimagelist" onclick="return imageListFunction(this.id)" id=' + data + ' ' + 'href=#' + ' title="View photos">' + '<i class="fa fa-picture-o"></i>' + '</a>';
                    <?php
                    }
                    ?>
                    <?php
                    if($reccustmembcheck==1){
                    ?>
                        a   =   a+"&nbsp;&nbsp;<a class='btn btn-yellow shiny btn-xs' data-toggle='modal' data-target='#membersmodal' onclick=membersFunction('"+data+"') href='#' title='Add members'>" + "<i class='fa fa-user'></i></a>";
                    <?php
                    }
                    ?>
                    <?php
                    if($reccustimgcheck==1){
                    ?>
                    a   =   a+'&nbsp;&nbsp;<a class="btn btn-magenta shiny btn-xs" id=' + data + ' ' + 'href='+base_url +'partner/customers/customercardprint/'+data+ ' title="Customer Card Printer">' + '<i class="fa fa-credit-card"></i>' + '</a>';
                    <?php
                    }
                    ?>
                    a   =   a+"</div>";
                return a;
                }},
            ],
        });

        $('#customettable tbody').on('click', '.details-control', function () {
            var tr = $(this).closest('tr');
            var row = table.row( tr );
            if ( row.child.isShown() ) {
                row.child.hide();
                tr.removeClass('shown');
            } else {
                row.child( format(row.data())).show();
                tr.addClass('shown');
            }
        });
    
        function format ( str ) {
            str =    str.toString();
            var res = str.split(",");
            var tbdata;
            $.ajax({
                async: false,
                global: false,
                url: base_url + 'partner/customers/subtablemembers/' + res[9],
                success: function (data) {
                    var obj = jQuery.parseJSON(data);
                    tbdata='<table class="table" style="color: #266292;"><tr><td style="font-weight:bold;">Searchkey</td><td style="font-weight:bold;">Member Name</td><td style="font-weight:bold;">Member Phone</td><td style="font-weight:bold;">Member Address</td></tr>';
                    tbinnerdata='';
                    $.each(obj, function(key,value) {
                      tbinnerdata=tbinnerdata+'<tr><td>'+value.SEARCHKEY+'</td><td>'+value.MEMBER_NAME+'</td><td>'+value.MEMBER_PHONE+'</td><td>'+value.MEMBER_ADDRESS+'</td></tr>';
                    });
                    if(tbinnerdata=='') {
                        tbinnerdata =   '<tr><td colspan="4" style="color:red;">No record found</td></tr>';
                    }
                    tbdata=tbdata+tbinnerdata+'</table>';

                }
            });
            return tbdata;
        }
    });
</script>
<script type="text/javascript">
    var purchaseflag    =   'purchaseinvoice';
    var floatpointnum   =   '<?php echo $this->formatslist->getCurrencyDecimalPonts(); ?>';
</script>
<script type="text/javascript">
    function myFunction(id) {
        // id = $(this).attr('id');
        $.ajax({
            url: base_url + 'partner/customers/editcustomers/' + id,
            success: function (data) {
                var json = $.parseJSON(data);
                for (var i = 0; i < json.length; ++i)
                {
                    $("#id").val(json[i].ID);
                    $("#TAXID").val(json[i].TAXID);
                    $("#name").val(json[i].NAME);
                    $("#searchkey").val(json[i].SEARCHKEY);
                    $("#card").val(json[i].CARD);
                    $("#maxdebt").val(json[i].MAXDEBT);
                    
                    if(json[i].CURDEBT!='' && json[i].CURDEBT!=null) {
                        var CURDEBT =   parseFloat(json[i].CURDEBT);
                        $("#curdebt").val(CURDEBT.toFixed(floatpointnum));
                    } else {
                        $("#curdebt").val('0');
                    }
                    
                    $("#taxcategory").val(json[i].TAXCATEGORY);
                    $("#address").val(json[i].ADDRESS);
                    $("#phone").val(json[i].PHONE);
                    $("#email").val(json[i].EMAIL);
                    $("#fax").val(json[i].FAX);
                    $("#notes").val(json[i].NOTES);
                    if(json[i].VISIBLE==1) {
                        $('#VISIBLE').prop('checked', true);
                    } else {
                        $('#VISIBLE').prop('checked', false);
                    }
                }
            }
        });
    }
    function confirmFunction(id) {
        $("#okid").val(id);
    }
    function cameraFunction(id) {
        $("#camcustid").val(id);
    }
    function deleteImageFunction(id) {
        var r = confirm("Do you Really want to delete this image ?");
        if (r == true) {
            $.ajax({
                url: base_url + 'partner/customers/deletecustomerimage/' + id,
                success: function (data) {
                    var id  = $("#custId").val();
                    imageListFunction(id);
                }
            });
        }
    }
    function addnewrec(){
        $("#id").val('');
        $('#frmcustomer')[0].reset();
        $('#VISIBLE').prop('checked', true);
    }
    function imageListFunction(id) {
        $("#customerphotogallery").html("<img src='<?php echo base_url();?>assets/img/ajax-loader.gif' />");
        $.ajax({
            url: base_url + 'partner/customers/listcustomerimage/' + id,
            success: function (data) {
                
                $("#customerphotogallery").html(data);
            }
        });
    }
    function deleteFunction() {
        id = $("#okid").val();
        $.ajax({
            url: base_url + 'partner/customers/deletecustomers/' + id,
            success: function (data) {
                location.reload(true);
                $("#confirmmodal").hide();
                $("#modal-success").show();
            }
        });
    }

</script>
<!-- Page Content -->
<div class="page-content">
    <!-- Page Header -->
    <div class="page-header position-relative">
        <div class="header-title">
            <h1>
                Customers
            </h1>
        </div>
        <!--Header Buttons-->
        <div class="header-buttons">
            <a class="sidebar-toggler" href="#">
                <i class="fa fa-arrows-h"></i>
            </a>
            <a class="refresh" id="refresh-toggler" href="">
                <i class="glyphicon glyphicon-refresh"></i>
            </a>
            <a class="fullscreen" id="fullscreen-toggler" href="#">
                <i class="glyphicon glyphicon-fullscreen"></i>
            </a>
        </div>
        <!--Header Buttons End-->
    </div>
    <!-- /Page Header -->
    <!-- Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-xs-12 col-md-12">
                <div class="widget">
                    <?php
                    if ($this->session->flashdata('success_msg')) {
                    ?>
                        <div class="alert alert-success">
                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                            <?php echo $this->session->flashdata('success_msg');$this->session->unset_userdata('errormsg'); ?>
                        </div>
                    <?php
                    }
                    ?>
                    <div class="widget-body">
                        <div class="table-toolbar">
                            <div class="form-group"> <a type="button" class="btn btn-success shiny icon-only new" data-toggle="modal" data-target="#myModal" onclick="addnewrec()" href="javascript:void(0);" >
                                    <i class="fa fa-plus"></i>
                                </a>
                            <div class="btn-group">
            <button type="button" class="btn btn-blue shiny" id="backtolist" onclick="location.href = '<?= base_url('partner/customers/payments') ?>'">
                 Payments</button>
                            
        </div>
                                
                            </div>
                            
                            
                            <div id="modal-success" class="modal modal-message modal-success" style="display: none;">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <i class="glyphicon glyphicon-check"></i>
                                        </div>
                                        <div class="modal-title">Deleted successfuly</div>


                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-success" data-dismiss="modal">OK</button>
                                        </div>
                                    </div> <!-- / .modal-content -->
                                </div> <!-- / .modal-dialog -->
                            </div>

            <div id="confirmmodal" class="modal fade" role="dialog">
                <div class="modal-dialog">
                    <!-- Modal content-->
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                            <h4 class="modal-title">Are you sure?</h4>
                        </div>
                        <div class="modal-footer">
                            <input type="hidden" id="okid" value="">
                            <button type="button" class="btn btn-success" onclick="return deleteFunction()">Ok</button>
                            <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                        </div>
                    </div>
                </div>
            </div>

            <div id="membersmodal" class="modal fade" role="dialog">
                <div class="modal-dialog">
                    <!-- Modal content-->
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                            <h4 class="modal-title" id="memheadertitle">Members List</h4>
                            <input type="hidden" id="CMEMB_ID" name="CMEMB_ID" />
                            <div id="tablememberlist"></div>
                            <div id="customermemberform" style="display:none;">
                                <div>
                                    <div class="modal-body">
                                         <div class="row">
                                            <div class="col-md-12">
                                                <input type="hidden" id="CMEDITID" name="CMEDITID" />
                                                <div class="form-group">
                                                    <input type="text" class="form-control" name="CMEMB_SEARCHKEY" id="CMEMB_SEARCHKEY" placeholder="Search Key" />
                                                </div>
                                                <div class="form-group">
                                                    <input type="text" class="form-control" name="CMEMB_MEMBER_NAME" id="CMEMB_MEMBER_NAME" placeholder="Member Name" />
                                                </div>
                                                <div class="form-group">
                                                    <input type="text" class="form-control" name="CMEMB_MEMBER_PHONE" id="CMEMB_MEMBER_PHONE" placeholder="Member Phone" />
                                                </div>
                                                <div class="form-group">
                                                    <textarea class="form-control" name="CMEMB_MEMBER_ADDRESS" id="CMEMB_MEMBER_ADDRESS" placeholder="Member Address" rows="5"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button class="btn btn-success" onclick="savecustmemb()">Submit</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
                            <div id="customersimagelist" class="modal fade" role="dialog">
                                <div class="modal-dialog">
                                    <!-- Modal content-->
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            <h4 class="modal-title">Images list</h4>
                                            <div class="content" id="customerphotogallery">
                                                <img src="<?php echo base_url();?>assets/img/ajax-loader.gif" />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <div id="cameramodal" class="modal fade" role="dialog">
                                <div class="modal-dialog">
                                    <!-- Modal content-->
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            <h4 class="modal-title">Capture the image</h4>
                                        </div>
                                        <div class="modal-header">
                                            <div class="content">
                                                <div id="responsecameradone"></div>
      <div id="booth"></div>
      <div class="col-md-12">
      <img id="displaylogoimg" class="displaylogoimg" style="width: 100%;" />
      </div>
<!--      <button id="btn-go" class="btn btn-success shiny">Start Camera</button> OR -->
      <span class="file-input btn btn-azure btn-file shiny">
          Browse <input type="file" class="browseimg" id="browseimg">
        </span>
      <input type="hidden" name="camcustid" id="camcustid" />
    </div>
    <script src="<?php echo base_url();?>assets/js/jquery.photobooth.js"></script>
    <script type="text/javascript" charset="utf-8">
        $('#cameramodal').on('hidden.bs.modal', function () {
            location.reload();
        });
      $(function() {
        $('#booth').photobooth({
            width: 550,
            height: 400,
            imgPlaceholder: '<?php echo base_url();?>assets/img/logo-solo.png'
        },
            function(control) {
              var capturing = false;
              $('#btn-go').click(function() {
                    $("#booth").show();
                    $("#displaylogoimg").hide();
                    if(capturing) {
                        control.snapshot();
                        var capturedimg =   $('#booth').find('img').attr('src');
                        var camcustid =   $('#camcustid').val();
                        saveimage(capturedimg,camcustid);
                    } else {
                        control.start();
                        $("#responsecameradone").html("");
                        $("#btn-go").html("Take Picture");
                    }
                    capturing = !capturing;
              });
              $('#btn-stop').click(function() {
                    control.stop();
              });
            },
            function() {
                alert('This browser does not support image capture.');  
            });
      });
      
      $("#browseimg").change(function() {
        $("#booth").hide();
        $("#displaylogoimg").show();
        readURL(this,'displaylogoimg');
        });
      function readURL(input,imgid) {
        if (input.files && input.files[0]) {
          var reader = new FileReader();
          reader.onload = function(e) {
            $('#'+imgid).attr('src', e.target.result);
            var capturedimg =   e.target.result;
            var camcustid =   $('#camcustid').val();
            saveimage(capturedimg,camcustid);
          }
          reader.readAsDataURL(input.files[0]);
          
        }
    }
    
    function saveimage(capturedimg,camcustid){
        
        $.ajax({
            method: "POST",
            url: "<?php echo base_url('partner/customers/savecustormersphoto'); ?>",
            dataType: "json",
            data: {
                camcustid:camcustid,
                capturedimg:capturedimg,
            }
        }).done(function (msg1) {
            if(msg1.MSG=='1'){
                $("#responsecameradone").html('<div class="alert alert-success fade in"><i class="fa-fw fa fa-check"></i><strong>Success</strong> Photo has been saved.</div>');
            }else{
                $("#responsecameradone").html("<div class='alert alert-danger fade in'><i class='fa-fw fa fa-check'></i><strong>Failed</strong> Can't save the image.</div>");
            }
            $("#btn-go").html("+ New Picture");
        });
    }
        
    
    </script>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <div id="myModal" class="modal fade" role="dialog">
                  <div class="modal-dialog">

                    <!-- Modal content-->
                    <div class="modal-content">
                        <form action="<?php echo base_url();?>partner/customers/addcustomers" method="post" name="frmcustomer" id="frmcustomer">
                          <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                            <h4 class="modal-title">Add New</h4>
                        </div>
                        <div class="modal-body">
                         <div class="row">
                            <div class="col-md-12">
                                <input type="hidden" id="id" name="id">
                                
                                
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Customer Id </label>
    <div class="col-sm-8 addmargin">
        <input type="text" class="form-control" name="TAXID" id="TAXID" placeholder="Customer Id">
    </div>
    <div class="col-sm-1">
        <i class="fa fa-plus btn" aria-hidden="true" id="reference_id"></i>
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Searchkey </label>
    <div class="col-sm-9 addmargin">
        <input type="text" class="form-control" name="searchkey" id="searchkey" placeholder="Searchkey" />
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Name </label>
    <div class="col-sm-9 addmargin">
        <input type="text" class="form-control" name="name" id="name" placeholder="Name" />
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Card </label>
    <div class="col-sm-9 addmargin">
        <input type="text" class="form-control" name="card" id="card" placeholder="Card" />
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Maximum Debt </label>
    <div class="col-sm-9 addmargin">
        <input type="text" class="form-control" name="maxdebt" id="maxdebt" placeholder="Maxdebt" />
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Current Debt </label>
    <div class="col-sm-9 addmargin">
        <input type="text" class="form-control" name="curdebt" id="curdebt" placeholder="Curdebt" readonly />
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Category </label>
    <div class="col-sm-9 addmargin">
        <select class="form-control" name="taxcategory" id="taxcategory">
            <option value="">Select Category</option>
             <?php foreach($taxcustcat as $taxcustcat_list) { ?>
               <option value="<?php echo $taxcustcat_list->ID; ?>"><?php echo $taxcustcat_list->NAME; ?></option>
             <?php } ?>
          </select>
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Phone </label>
    <div class="col-sm-9 addmargin">
        <input type="text" class="form-control" name="phone" id="phone" placeholder="Phone">
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Email </label>
    <div class="col-sm-9 addmargin">
        <input type="text" class="form-control" name="email" id="email" placeholder="Email">
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Fax </label>
    <div class="col-sm-9 addmargin">
        <input type="text" class="form-control" name="fax" id="fax" placeholder="Fax">
    </div>
</div>
<div class="form-group padding-bottom-50">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;">Notes </label>
    <div class="col-sm-9 addmargin">
        <textarea class="form-control" name="notes" id="notes" placeholder="Notes" rows="5"></textarea>
    </div>
</div>
<div class="form-group padding-bottom-30">
    <label for="inputEmail3" class="col-sm-3 control-label no-padding-right" style="padding-top: 7px;"> </label>
    <div class="col-sm-9 addmargin padding-top-5">
        <label>
        <input type="checkbox" class="inverted VISIBLE" name="VISIBLE" id="VISIBLE" value="1" >
        <span class="text">Visible</span>
        </label>
    </div>
</div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-success">Submit</button>
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
                            
                            
                            
                            <div class="row">
                                
                                <div class="col-md-12 table-responsive">
                                    <table class="table table-striped table-hover table-bordered editable" id="customettable">
                                        <thead>
                                            <tr role="row">
                                                <th>
                                                    <?php
                                                    if($reccustmembcheck==1)
                                                        echo "";
                                                    else
                                                        echo "slno"
                                                    ?>
                                                </th>
                                                <th>
                                                    CUSTOMER ID
                                                </th>
                                                <th>
                                                    SEARCHKEY
                                                </th>
                                                <th>
                                                    NAME
                                                </th>

                                                <th>
                                                    CARD
                                                </th>
                                                <th>
                                                    MAXDEBT
                                                </th>
                                                <th>
                                                    CURDEBT
                                                </th>
                                                <th>
                                                    CATEGORY
                                                </th>
                                                <th>
                                                    ADDRESS
                                                </th>
                                                <th>
                                                    <div style="width:215px;">Action</div>
                                                </th>
                                            </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <!-- /Page Body -->
    </div>
    <!-- /Page Content -->
</div>
<!-- /Page Container -->
<!-- Main Container -->
</div>

<script>
    $( document ).ready(function() {
        $( "#reference_id" ).click(function() {
            
            $.ajax({
                url: base_url + 'partner/customers/latestcustomerId/',
                success: function (data) {
                    $("#TAXID").val(data);
                }
            });
        });
    });
    
    function membersFunction(id){
        $("#memheadertitle").html("Members List");
        $("#tablememberlist").show();
        $("#customermemberform").hide();
        $("#CMEMB_ID").val(id);
        $.ajax({
            url: base_url + 'partner/customers/listmembers/' + id,
            success: function (data) {
                $("#tablememberlist").html(data);
            }
        });
    }
    
    function addnewmembers(){
        $("#memheadertitle").html("Add member");
        $("#tablememberlist").hide();
        $("#CMEMB_SEARCHKEY").val('');
        $("#CMEMB_MEMBER_NAME").val('');
        $("#CMEMB_MEMBER_PHONE").val('');
        $("#CMEMB_MEMBER_ADDRESS").val('');
        $("#customermemberform").show();
    }
    
    function savecustmemb() {
        var ID                      =	$("#CMEDITID").val();
        var CMEMB_ID                =	$("#CMEMB_ID").val();
        var CMEMB_SEARCHKEY         =	$("#CMEMB_SEARCHKEY").val();
        var CMEMB_MEMBER_NAME       =	$("#CMEMB_MEMBER_NAME").val();
        var CMEMB_MEMBER_PHONE      =	$("#CMEMB_MEMBER_PHONE").val();
        var CMEMB_MEMBER_ADDRESS    =	$("#CMEMB_MEMBER_ADDRESS").val();
        $.ajax({
            type: "POST",
            data: {
                ID:ID,
                CMEMB_ID:CMEMB_ID,
                CMEMB_SEARCHKEY:CMEMB_SEARCHKEY,
                CMEMB_MEMBER_NAME:CMEMB_MEMBER_NAME,
                CMEMB_MEMBER_PHONE:CMEMB_MEMBER_PHONE,
                CMEMB_MEMBER_ADDRESS:CMEMB_MEMBER_ADDRESS,
            },
            url: base_url+"partner/customers/addcustmember",                   
            success: function(response){
                var CMEMB_ID    =   $("#CMEMB_ID").val();
                if(response==1){
                    membersFunction(CMEMB_ID);
                }
            }
        });
    }
    
    function editcustmemb(editid) {
        $.ajax({
            type: "POST",
            data: {
                editid:editid
            },
            url: base_url+"partner/customers/editcustmember",
            dataType: "json",
            success: function(response){
                $("#CMEDITID").val(response.ID);
                $("#CMEMB_SEARCHKEY").val(response.SEARCHKEY);
                $("#CMEMB_MEMBER_NAME").val(response.MEMBER_NAME);
                $("#CMEMB_MEMBER_PHONE").val(response.MEMBER_PHONE);
                $("#CMEMB_MEMBER_ADDRESS").val(response.MEMBER_ADDRESS);
                $("#memheadertitle").html("Edit member");
                $("#tablememberlist").hide();
                $("#customermemberform").show();
            }
        });
    }
    
    function deleterecsub(delid){
        var r = confirm("Do you want to delete the record ?");
        if (r == true) {
            $.ajax({
                type: "POST",
                data: {
                    delid:delid
                },
                url: base_url+"partner/customers/deletecustmember/",
                dataType: "json",
                success: function(response){
                    var CMEMB_ID    =   $("#CMEMB_ID").val();
                    membersFunction(CMEMB_ID);
                }
            });
        }
    }
</script>