EVOLUTION-NINJA
Edit File: owner_list.php
<?php $this->load->view('includes/header.php')?> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/css/grid_style.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/css/jquery-ui.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/jqgrid/css/ui.jqgrid.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/jqgrid/css/ui.jqgrid-bootstrap.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/jqgrid/css/ui.jqgrid-bootstrap-ui.css'); ?>" /> <script type="text/ecmascript" src="<?php echo base_url('assets/jqgrid/js/jquery.jqGrid.min.js'); ?>"></script> <script type="text/ecmascript" src="<?php echo base_url('assets/jqgrid/js/i18n/grid.locale-en.js'); ?>"></script> <script src="<?php echo base_url('assets/js/jquery-ui.js'); ?>" type="text/javascript"></script> <div class="content-wrapper"> <section class="content-header"> <h1 style="text-align: center; padding-top: 1%;">Land Owner List<small></small> </h1> </section> <section class="content"> <div class="row" class="regis-block"> <div class="col-md-offset-2 col-sm-offset-1 col-sm-10 col-md-8"> </div> </div> <div class="col-sm-1"></div> <div class="col-sm-10"> <div id="jaytab3" style="margin-top:6%;" > <div class="grid_div"></div> <table id="list2"> </table> <div id="pager3"></div> <div id="dialogSelectRow3" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> </div> <div class="col-sm-5"></div> </div> <!-- /.row --> </section> <!-- /.content --> <div class="modal fade" id="edit_modal" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="ModalLabel">Edit Owner</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <form class="forms-sample update_form"> <input type="hidden" class="form-control id" name="id"/> <div class="modal-body"> <div class="form-group" > <label for="exampleInputUsername1">Name</label> <input type="text" class="form-control name" name="name" required> </div> <div class="form-group" > <label for="exampleInputUsername1"> Contact Number</label> <input type="text" class="form-control contact_no" name="contact_no" required> </div> <div class="form-group" > <label for="exampleInputUsername1">Layout Name</label> <input type="text" class="form-control layout_name" name="layout_name" required> </div> <div class="form-group" > <label for="exampleInputUsername1">PAN/Aadhar No</label> <input type="text" class="form-control pan_adhar" name="pan_no" required> </div> <div class="form-group" > <label for="exampleInputUsername1">Email</label> <input type="email" class="form-control email" name="email_id" required> </div> <div class="form-group" > <label for="exampleInputUsername1">Address</label> <input type="text" class="form-control address" name="address" required> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary submit">Submit</button> <button type="button" class="btn btn-light" data-dismiss="modal">Close</button> </div> </form> </div> </div> </div> </div> <style type="text/css"> pre { background-color: transparent; border: 1px solid transparent; line-height: 1.6; text-align: justify; } .form-control:focus, input[type="Submit"]:focus, input[type="button"]:focus { border-color: #FF0000; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 0.6); } </style> <script type="text/javascript"> CallGrid(); function CallGrid() { jQuery("#list2").jqGrid({ url:"<?php echo site_url('get-owner-list')?>", mtype : "get", datatype: "json", colNames:['ID','Name','Contact Number','Layout Name','PAN/Aadhar No','Email Id','Address','Action'], colModel:[ {name:'id',index:'id', width:100, hidden:true,editable:false}, {name:'name',index:'name', width:150, hidden:false,editable:false}, {name:'contact_no',index:'contact_no', width:100, hidden:false,editable:false}, {name:'layout_name',index:'layout_name', width:200, hidden:false,editable:false}, {name:'pan_adhar',index:'pan_adhar',editable:false, width:200}, {name:'email',index:'email',editable:false, width:100}, {name:'address',index:'address',editable:false, width:100}, {name:'',index:'',search:false, width:60, editable:false,formatter: function (cellvalue, options, rowObject) { var retVal = ""; var retVal = ' <a data-toggle="tooltip" title="Edit" class="" href="javascript:void(0);"><span class="fa fa-pencil" onclick="fun_edit($(this))" style="color:blue;"></span></a> <a data-toggle="tooltip" title="Delete" onclick="fun_delete($(this))"; href="javascript:void(0);"><span class="fa fa-trash" style="color:red;"></span></a>'; return retVal; }}, ], rowNum:20, rowTotal: 2000, rowList : [20,30], rownumbers: true, //rownumWidth: 60, pager:"#pager2", sortname:'id', viewrecords: true, gridview: true, autowidth: true, sortorder:"asc", shrinkToFit: true, loadonce:true, autoencode: true, caption:"Customer List", //Subgrid1... subGrid: false, }); $("#list2").jqGrid("setLabel", "rn", "SL"); $("#list2").jqGrid('filterToolbar',{searchOperators : false}); //for multisearch code,remove if not required $("#list2").jqGrid('navGrid','#pager2', {edit:false,add:false,del:false,search:false,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true, closeAfterDelete:true, closeAfterEdit:true }, ); } function fun_edit(rowId) { var id = rowId.closest('tr').attr('id'); $.ajax({ url:"<?php echo site_url("Edit-owner-list")?>", type:"POST", data:{id:id}, success:function(response) { response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { $("#edit_modal").modal("show"); $(".id").val(response.message.id); $(".name").val(response.message.name); $(".contact_no").val(response.message.contact_no); $(".layout_name").val(response.message.layout_name); $(".pan_adhar").val(response.message.pan_adhar); $(".email").val(response.message.email); $('.address').val(response.message.address); } else { toastr["error"](response.message); $(".update").attr("disabled", true); } } }); } function fun_delete(rowId) { var id = rowId.closest('tr').attr('id'); var id = id; swal({ title: "Are you sure?", text: "You will not be able to recover this data!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, delete it!", cancelButtonText: "No, cancel plz!", closeOnConfirm: false, closeOnCancel: false }, function(isConfirm){ if (isConfirm) { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $.ajax({ url:"<?php echo site_url("delete-owner-list")?>", type:"POST", data:{id:id}, success:function(response) { response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { toastr["success"]("Deleted successfully"); $("#list2").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid'); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } $('.update_form').submit(function(e){ e.preventDefault(); formdata = new FormData($(this)[0]); $(".update").text("Updating..."); $(".update").attr("disabled", true); $.ajax({ type : 'post', url : '<?php echo site_url("update-owner-details")?>', data : formdata, contentType: false, processData: false, success:function(response){ response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { swal({ title: "Are you sure?", text: "Updated Succesfully", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, Upadte it!", closeOnConfirm: true, closeOnCancel: false }, function(isConfirm) { if (isConfirm) { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $('.update').removeAttr("disabled"); $(".update").text("Update"); $("#edit_modal").modal("hide"); location.reload(); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } else { $('.update').removeAttr("disabled"); $(".update").text("Update"); } } }); }); </script> <?php $this->load->view('includes/footer.php')?> <style type="text/css"> .regis-block{ padding: 15px; background: #fff; } .regist-button{ text-align: center; padding-top: 20px; } </style>