EVOLUTION-NINJA
Edit File: add_civil_product_details.php
<?php echo view('includes/header');?> <section class="content-header"> <h1>Civil Product Details</h1> </section> <!--- section 1 --> <section class="content"> <!-- Button trigger modal --> <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal"> Add Civil Product Details </button> <!-- Modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Add Civil Product details</h4> </div> <div class="modal-body"> <form id="land_owner" class="form-inline usertype_form" enctype="multipart/form-data"> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4"> Product Name:</label> <div class="col-sm-8"> <input type="text" pattern="[0-9a-zA-Z_-\s]+" class="form-control" name="pro_name" required="required"> </div> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4">Description:</label> <div class="col-sm-8"> <textarea pattern="[0-9a-zA-Z\s]+" class="form-control" name="pro_description" required="required"></textarea> </div> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4">Department:</label> <div class="col-sm-8"> <input type="text" pattern="[0-9a-zA-Z_-\s]+" class="form-control" name="pro_dept" required="required"> </div> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4">Currency:</label> <div class="col-sm-8"> <input type="text" class="form-control" value="INR" readonly name="pro_currency" required="required"> </div> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="col-sm-4 col-md-4"></div> <div class="col-sm-4 col-md-4"> <button type="submit" class="btn btn-primary center-block submit_button submit">Submit</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 6--> </form> </div> </div> </div> </div> <section class="content"> <div id="menu1" class="tab-panecol-sm-12 col-md-12 "> <div class="col-sm-1"></div> <div id = "jaytab3" style="margin-top:3%;margin-left: -28px;" class="col-sm-10 grid"> <div class="grid_div"></div><table id="list3"></table> <div id="pager3"></div> <div id="dialogSelectRow3" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> </div> </section> <!--- section 2 --> </div> <!--- col-sm-8 --> --> <div class="col-sm-0 col-md-1"></div> </section> <!--- section 2 --> <!-- Modal --> <form id="land_owner" class="form-inline update_form" enctype="multipart/form-data"> <div class="modal fade" id="edit_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Update Civil Product details</h4> </div> <div class="modal-body"> <form id="land_owner" class="form-inline update_form" enctype="multipart/form-data"> <input type="hidden" class="edit_id" name="edit_id"> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4"> Product Name:</label> <div class="col-sm-8"> <input type="text" pattern="[0-9a-zA-Z\s]+" class="form-control pro_name" name="pro_name" required="required"> </div> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4">Description:</label> <div class="col-sm-8"> <textarea pattern="[0-9a-zA-Z\s]+" class="form-control pro_description" name="pro_description" required="required"></textarea> </div> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4">Department:</label> <div class="col-sm-8"> <input type="text" pattern="[0-9a-zA-Z\s]+" class="form-control pro_dept" name="pro_dept" required="required"> </div> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4">Currency:</label> <div class="col-sm-8"> <input type="text" class="form-control pro_currency" value="INR" readonly name="pro_currency" required="required"> </div> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="col-sm-4 col-md-4"></div> <div class="col-sm-4 col-md-4"> <button type="submit" class="btn btn-primary center-block submit_button submit">Update</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 6--> </form> </div> </div> </div> </div> </form> <style type="text/css"> .content-wrapper, .right-side { // min-height:900px !important; } a { color: inherit; } .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); } #FrmGrid_list2 { width: 100% !important; } .ui-jqdialog .ui-jqdialog-titlebar { height: 29px !important; background-color: #001a00; color: white; padding-left: 10px; } .fm-button { height: 21px !important; padding: 1px; margin-right: 10px !important; height: 21px !important; width: 50%; margin-top: -7px !important; } .ui-jqdialog-content td.navButton { padding-top: 12px !important; } .ui-jqgrid .ui-jqgrid-titlebar { height: 27px !important; background:#AF0100 !important; color:white !important; } .ui-jqgrid-bdiv { height: 232px !important; } .ui-widget-overlay { z-index:0 !important; } .ui-widget-header { background: #1e7ad7 !important; } .ui-jqgrid-hdiv ui-state-default { width: 873px !important; cursor: default!important } ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight { border: 1px solid #fed22f; background: #ffe45c; } .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { font-weight: bold; color: black; } .ui-jqgrid .ui-jqgrid-bdiv { overflow-y: scroll; //overflow-x: hidden; } .agr_appr { font-weight:bold !important; color:#AF0100; cursor: pointer; } </style> <!-- This is the Javascript file of jqGrid --> <script type="text/ecmascript" src="<?php echo base_url('public/jqgrid/js/jquery.jqGrid.min.js'); ?>"></script> <!-- This is the localization file of the grid controlling messages, labels, etc. <!-- We support more than 40 localizations --> <script type="text/ecmascript" src="<?php echo base_url('public/jqgrid/js/i18n/grid.locale-en.js'); ?>"></script> <!-- A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom --> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/css/jquery-ui.css'); ?>" /> <!-- The link to the CSS that the grid needs --> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/jqgrid/css/ui.jqgrid.css'); ?>" /> <script src="<?php echo base_url('public/assets/js/jquery-ui.js'); ?>" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function (){ jQuery("#list3").jqGrid({ url:"<?php echo site_url('civil-product-list')?>", mtype : "post", datatype: "json", colNames:['SI','Product Name','Description','Department','Currency','EDIT','DELETE'], colModel:[ {name:'id',index:'id', width:50, hidden:true,editable:false,key:true}, {name:'product_name',index:'product_name', width:175, editable:false}, {name:'description',index:'description', width:200, editable:false}, {name:'department',index:'department', width:175, editable:false}, {name:'currency',index:'currency', width:175, editable:false}, {name:' ',index:' ',editable:false,align: "center",editrules:{required: true},search:false, width:175,cellattr: function (rowId, tv, rawObject, cm, rdata) { return ' onclick="reg_fun($(this))" '; },formatter:function (cellvalue, options, rowObject) { return "<input type='button' value='EDIT' \>"; }}, {name:'delete',index:'delete',align: "center",editable:false,search:false,editrules:{required: true}, width:175,cellattr: function (rowId, tv, rawObject, cm, rdata) { return ' onclick="fun_delete($(this))" '; },formatter:function (cellvalue, options, rowObject) { return "<input type='button' value='DELETE' \>"; }}, ], rowNum:20, rowTotal: 2000, rowList : [10,20,30,50,100,500,1000], rownumbers: true, rownumWidth: 40, pager:"#pager3", sortname:'owner_id', viewrecords: true, gridview: true, autowidth: true, sortorder:"asc", shrinkToFit: false, emptyrecords: 'No records to display', // multiselect: true, // multiboxonly: true, loadonce:true, caption:"Civil Product details List", }); $("#list3").jqGrid("setLabel", "rn", "SL"); $("#list3").jqGrid('filterToolbar',{searchOperators : false}); //for multisearch code,remove if not required $("#list3").jqGrid('navGrid','#pager3', {edit:false,add:false,del:false,search:false,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true } ); }); function reg_fun(rowId) { var user_type_id = rowId.closest('tr').attr('id'); var app = $("#list3").jqGrid('getRowData',user_type_id); var id=user_type_id; $.ajax({ type : 'post', url : '<?php echo site_url("get-civil-product-details")?>', data : {'id':id}, success:function(response){ // response=jQuery.parseJSON(response); console.log(response); if(response.result==0) { toastr["error"](response.message); } else { $(".edit_id").val(response.message.id); $(".pro_name").val(response.message.product_name); $(".pro_description").val(response.message.description); $(".pro_dept").val(response.message.department); $(".pro_currency").val(response.message.currency); $("#edit_modal").modal("show"); } } }); } function fun_delete(rowId) { var id = rowId.closest('tr').attr('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(); // test.attr('disabled', 'disabled'); // test.text("Deleting..."); $.ajax({ type : 'post', url : '<?php echo site_url("delete-civil-product-details")?>', data : {id:id}, success:function(response) { // response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { toastr["success"](response.message); $("#list3").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid'); location.reload(); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } $('.usertype_form').submit(function(e){ e.preventDefault(); formdata = new FormData($(this)[0]); $(".submit_button").attr('disabled', 'disabled'); $(".submit_button").text("Submitting..."); $.ajax({ type : 'post', url : '<?php echo site_url("add-civil-product-details")?>', data : formdata, contentType: false, processData: false, success:function(response){ // response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { $("#myModal").modal("hide"); toastr["success"](response.message); $('.usertype_form')[0].reset(); $(".submit_button").text("Submit"); $(".submit_button").removeAttr('disabled'); $("#list3").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid'); } else if(response.result == 2) { toastr["error"](response.message); $(".submit_button").text("Submit"); $(".submit_button").removeAttr('disabled'); } else { toastr["error"](response.message); $(".submit_button").text("Submit"); $(".submit_button").removeAttr('disabled'); } } }); }); $('.update_form').submit(function(e){ e.preventDefault(); formdata = new FormData($(this)[0]); $(".update_button").attr('disabled', 'disabled'); $(".update_button").text("Updating..."); $.ajax({ type : 'post', url : '<?php echo site_url("update-civil-product-details")?>', data : formdata, contentType: false, processData: false, success:function(response){ // response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { $("#edit_modal").modal("hide"); toastr["success"](response.message); $('.update_form')[0].reset(); $(".update_button").text("Submit"); $(".update_button").removeAttr('disabled'); $("#list3").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid'); } else if(response.result==2) { toastr["error"](response.message); $(".update_button").text("Submit"); $(".update_button").removeAttr('disabled'); } else { toastr["error"](response.message); $(".update_button").text("Submit"); $(".update_button").removeAttr('disabled'); } } }); }); </script> <?php echo view('includes/footer');?> <style> .land_owner_a input, .land_owner_aa input, .land_owner_a textarea{ width:100% !important; } </style>