function share_map_listing(e,t){"undefined"!=typeof share_lists&&share_lists.destroy(),share_lists=$("#share_table_listing").DataTable({lengthMenu:[[10,20,50,-1],[10,20,50,"All"]],aoColumns:[{data:"first_name",name:"first_name"},{data:"name",name:"name"},{data:"action",name:"action",orderable:!1,searchable:!1}],pageLength:10,order:[[1,1,"asc"]],processing:!0,serverSide:!0,ajax:baseURL+"/superadmin/farm/share/lists/"+e+"/"+t,fnDrawCallback:function(e){}})}function report_listing(e,t){"undefined"!=typeof report_lists&&report_lists.destroy(),report_lists=$("#report_table_listing").DataTable({lengthMenu:[[10,20,50,-1],[10,20,50,"All"]],aoColumns:[{data:"name",name:"name"},{data:"section_name",name:"section_name"},{data:"action",name:"action",orderable:!1,searchable:!1}],pageLength:10,order:[[1,1,"asc"]],processing:!0,serverSide:!0,ajax:baseURL+"/superadmin/farm/report/lists/"+e+"/"+t,fnDrawCallback:function(e){$("#report_table_listing tbody").sortable({stop:updateIndexReport}).disableSelection()}})}function custom_files_listing(e,t){"undefined"!=typeof custom_files_lists&&custom_files_lists.destroy(),custom_files_lists=$("#custom_files_table_listing").DataTable({lengthMenu:[[10,20,50,-1],[10,20,50,"All"]],aoColumns:[{data:"name",name:"name"},{data:"section_name",name:"section_name"},{data:"action",name:"action",orderable:!1,searchable:!1}],pageLength:10,order:[[1,1,"asc"]],processing:!0,serverSide:!0,ajax:baseURL+"/superadmin/farm/custom_files/lists/"+e+"/"+t,fnDrawCallback:function(e){$("#custom_files_table_listing tbody").sortable({stop:updateIndexCustomFiles}).disableSelection()}})}function validateForm(e){e.validate({errorElement:"span",errorClass:"help-inline",focusInvalid:!1,rules:{},messages:{}})}function updateIndexReport(){var e=new Array;$("#report_table_listing tbody").find("tr").each(function(t){var a=$(this).find(".report-id").val();e[t]=a,t++}),$.ajax({type:"POST",url:baseURL+"/superadmin/farm/report/order",data:{data_id:e,_token:jQuery('[name="_token"]').val()}}).done(function(e){alert("Order set successfully.")})}function updateIndexCustomFiles(){var e=new Array;$("#custom_files_table_listing tbody").find("tr").each(function(t){var a=$(this).find(".custom-files-id").val();e[t]=a,t++}),$.ajax({type:"POST",url:baseURL+"/superadmin/farm/custom_files/order",data:{data_id:e,_token:jQuery('[name="_token"]').val()}}).done(function(e){alert("Order set successfully.")})}function ajaxRequest(e,t,a,s,n){jQuery.ajax({url:baseURL+e,type:t,dataType:a,data:s}).done(function(e){n(e)}).fail(function(e){var e=JSON.parse(e.responseText),t="
";$.each(e,function(e,a){t+="- "+a+"
"}),t+="
",showMsg("error",t)}).always(function(){})}function showMsg(e,t){"add"==e?swal("Added!",t,"success"):"update"==e?swal("Updated!",t,"success"):"deleted"==e?swal("Deleted!",t,"success"):"success"==e?swal({title:"Success!",text:t,html:!0,type:"success"}):swal({title:"Error!",text:t,html:!0,type:"error"})}var share_lists,report_lists,custom_files_lists,$report_farm=jQuery("#report_form"),$custom_files_farm=jQuery("#custom_files_form");jQuery(document).ready(function(){share_map_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val()),$("#report_id").val(""),report_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val()),custom_files_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val());var e=jQuery("#share_form");validateForm(e),jQuery("#assign_share_btn").click(function(){e.validate().form()&&ajaxRequest("/superadmin/farm/share/save/"+jQuery('[name="farm_id"]').val(),"post","json",e.serialize(),function(e){showMsg("success","Share successfully."),$("#projects-task-modal").modal("toggle"),share_map_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val())})}),validateForm($custom_files_farm),jQuery("#assign_custom_files_btn").click(function(){$custom_files_farm.validate().form()&&ajaxRequest("/superadmin/farm/custom_files/save","post","json",$custom_files_farm.serialize(),function(e){showMsg("success",e.message),$("#custom_files-modal").modal("toggle"),custom_files_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val()),$("#custom_file_farm_section_id").val("").change(),$("#custom_file_name").val("")})}),validateForm($report_farm),jQuery("#assign_report_btn").click(function(){$report_farm.validate().form()&&ajaxRequest("/superadmin/farm/report/save/"+jQuery('[name="farm_id"]').val(),"post","json",$report_farm.serialize(),function(e){showMsg("success",e.status),$("#report-modal").modal("toggle"),report_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val()),$("#report_id").val(""),$("#farm_section_id").val("").change(),$("#db_report_url").val(""),$("#report_name").val("")})}),$("#share_table_listing").on("click","a.delete-row",function(e){e.preventDefault();var t=jQuery(this).attr("data-id");swal({title:"Are you sure?",text:"You will not be able to recover this data.",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes, delete it!",cancelButtonText:"No, cancel plx!",closeOnConfirm:!0,closeOnCancel:!0},function(e){e&&$.ajax({url:baseURL+"/superadmin/farm/share/delete",data:{id:t,_token:jQuery('[name="_token"]').val()},method:"post",dataType:"json",success:function(){share_map_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val()),showMsg("deleted","Farm sharing deleted successfully.")}})})}),$("#report_table_listing").on("click","a.delete-row",function(e){e.preventDefault();var t=jQuery(this).attr("data-id");swal({title:"Are you sure?",text:"You will not be able to recover this data.",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes, delete it!",cancelButtonText:"No, cancel plx!",closeOnConfirm:!0,closeOnCancel:!0},function(e){e&&$.ajax({url:baseURL+"/superadmin/farm/report/delete",data:{id:t,_token:jQuery('[name="_token"]').val()},method:"post",dataType:"json",success:function(){report_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val()),$("#report_id").val(""),$("#farm_section_id").val("").change(),$("#db_report_url").val(""),$("#report_name").val(""),showMsg("deleted","Report deleted successfully.")}})})}),$("#custom_files_table_listing").on("click","a.delete-row",function(e){e.preventDefault();var t=jQuery(this).attr("data-id");swal({title:"Are you sure?",text:"You will not be able to recover this data.",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes, delete it!",cancelButtonText:"No, cancel plx!",closeOnConfirm:!0,closeOnCancel:!0},function(e){e&&$.ajax({url:baseURL+"/superadmin/farm/custom_files/delete",data:{id:t,_token:jQuery('[name="_token"]').val()},method:"post",dataType:"json",success:function(){custom_files_listing(jQuery('[name="farmer_id"]').val(),jQuery('[name="farm_id"]').val()),$("#custom_file_farm_section_id").val("").change(),$("#custom_file_name").val(""),showMsg("deleted","Custom Files deleted successfully.")}})})})}),$("#report_table_listing").on("click","a.edit-row",function(e){e.preventDefault();var t=jQuery(this).attr("data-id");$("#report_id").val(t),ajaxRequest("superadmin/farm/report/edit/"+t,"get","json",{},function(e){$("#farm_section_id").val(e.data.farm_section_id).change(),$("#db_report_url").val(e.data.url),$("#report_name").val(e.data.name),$("#report-modal").modal("toggle")})}),jQuery("#add_custom_files").click(function(){Dropzone.forElement("#DropZoneAreaCustomFiles").removeAllFiles(!0),jQuery('[name="upload_custom_files[]"]').remove(),$("#custom_file_farm_section_id").val("").change(),$("#custom_file_name").val("")}),$("#custom_files_table_listing").on("click","a.edit-row",function(e){e.preventDefault();var t=jQuery(this).attr("data-id");$("#custom_files_id").val(t),Dropzone.forElement("#DropZoneAreaCustomFiles").removeAllFiles(!0),jQuery('[name="upload_custom_files[]"]').remove(),ajaxRequest("superadmin/farm/custom_files/edit/"+t,"get","json",{},function(e){$("#custom_file_farm_section_id").val(e.data.farm_section_id).change(),$("#custom_file_name").val(e.data.name),$("#custom_files-modal").modal("toggle")})}),!function(e,t,a){"use strict";var s=a(t.body),n=a(".site-menubar");site.menubar={top:!0,opened:!1,init:function(){this.change()},hide:function(){s.removeClass("menubar-open"),this.opened=!1},open:function(){s.addClass("menubar-open"),this.opened=!0},toggle:function(){!0===this.opened?this.hide():this.open()},change:function(){/xs|sm/.test(Breakpoints.current().name)?(this.switchLeft(),this.sticky.disable()):(this.switchTop(),this.sticky.enable())},switchLeft:function(){!0===this.top&&s.removeClass("menubar-top").addClass("menubar-left"),this.top=!1},switchTop:function(){!1===this.top&&s.removeClass("menubar-left").addClass("menubar-top"),this.top=!0},sticky:{enabled:!1,sticky:null,offset:64,enable:function(){this.enabled||"function"!=typeof Waypoint.Sticky||(this.sticky=new Waypoint.Sticky({element:n,offset:this.offset}),this.enabled=!0)},disable:function(){this.enabled&&this.sticky.destroy(),this.enabled=!1,this.sticky=null}},menu:{slideSpeed:500,toggleOnClick:function(e){/xs|sm/.test(Breakpoints.current().name)&&e.parent().toggleClass("open").find("> .submenu").slideToggle(this.slideSpeed).end().siblings().removeClass("open").find("> .submenu").slideUp(this.slideSpeed)}}}}(window,document,jQuery),!function(e,t,a){"use strict";var s=a(t.body),n=a(".site-navbar");site.navbar={init:function(){!/xl/.test(Breakpoints.current().name)&&this.searchForm.clone()},change:function(){/xl/.test(Breakpoints.current().name)?this.searchForm.remove():this.searchForm.clone()},searchForm:{cloned:!1,clone:function(){this.cloned||(n.find(".navbar-search").clone().appendTo("body"),this.cloned=!0)},remove:function(){s.find("> .navbar-search").remove(),this.cloned=!1}}}}(window,document,jQuery),!function(e,t,a){"use strict";a.extend(e.site,{init:function(){void 0!==site.menubar&&void 0!==site.navbar&&(site.navbar.init(),site.menubar.init(),a(t).on("click",".hamburger",function(e){a(this).toggleClass("is-active")}),a(t).on("click",'[data-toggle="menubar"]',function(e){site.menubar.toggle()}),a(t).on("click",".submenu-toggle",function(e){site.menubar.menu.toggleOnClick(a(this)),e.preventDefault()}),a(t).on("click",'[data-toggle="collapse"]',function(e){var t=a(e.target);t.is('[data-toggle="collapse"]')||(t=t.parents('[data-toggle="collapse"]')),"site-navbar-collapse"===a(t.attr("data-target")).attr("id")&&a("body").toggleClass("navbar-collapse-in"),e.preventDefault()}),a(t).on("click",'[data-toggle="navbar-search"]',function(e){a(".navbar-search").toggleClass("show"),e.preventDefault()}),Breakpoints.on("change",function(){site.navbar.change(),site.menubar.change(),a('[data-toggle="menubar"]').toggleClass("is-active",site.menubar.opened)})),void 0!==a.settings&&void 0!==a.customizer&&(a.settings.extend({navbar:{type:"light",skin:"bg-white"},menubar:{top:!0,type:"light",skin:"bg-white"}}),a.settings.init(),a.customizer.init(),a(t).on("change, click",'[data-toggle="theme"]',function(e){a.customizer.setTheme(this)}),a(t).on("click","#customizerSaveButton",function(){var e=a(this);a.customizer.save(),e.closest("section").append('Your Settings Saved!
'),setTimeout(function(){e.closest("section").find("div.flash-msg").fadeOut()},2e3)}),a(t).on("click","#customizerResetButton",function(){a.customizer.reset()})),!/xs|sm/.test(Breakpoints.current().name)&&a(".scroll-container").perfectScrollbar(),this.initHeaderCharts(),this.initPlugins()}})}(window,document,jQuery),$(function(){site.init()});