1const farmJS = { 2 init: function() { 3 const self = this; 4 self.uploadFarmImg = function(doc) { 5 if ($("#"+doc+"ImgUpload").val() != "") { 6 $("."+doc+"LoadMoreImg").removeClass("d-none"); 7 var File = $("#"+doc+"ImgUpload").get(0).files[0]; 8 var formData = new FormData(); 9 formData.append("upload_file", File); 10 $.ajax({ 11 type: "POST", 12 enctype: "multipart/form-data", 13 url: "/action/upload/uploadFile", 14 data: formData, 15 cache: false, 16 contentType: false, 17 processData: false, 18 success: function (data) { 19 $("."+doc+"LoadMoreImg").addClass("d-none"); 20 if(data && data.status && data.status=="success") { 21 var count = $("#"+doc+"PhotoCount").val(); 22 var new_count = parseInt(count) + 1; 23 $("#"+doc+"PhotoCount").val(new_count); 24 var docDisplay = doc; 25 if(doc=='pan') { docDisplay = "PAN";} 26 else if(doc=='aadhar') { docDisplay = "Aadhar";} 27 else if(doc=='voter') { docDisplay = "Voter ID";} 28 else if(doc=='idproof') { docDisplay = "Address Proof"; } 29 else if(doc=='farm') { docDisplay = "Farm Photo"; } 30 else if(doc=='agreement') { docDisplay = "Agreement"; } 31 $("#"+doc+"UploadLabel").html("Add More File"); 32 33 var fileUrl = data.url; 34 var ext = fileUrl.split(".")[1]; 35 if(ext=='pdf'){ 36 fileUrl = '/pashushla/static/images/pdf_icon.png'; 37 } 38 $("#"+doc+"PhotoDiv").after('<div class="col-md-6 d-flex justify-content-left" id="'+doc+'PhotoDiv_'+count+'"><div class="form-group align-middle"><input type="hidden" name="'+doc+'FileId[]" id="'+doc+'Photo_'+count+'" value="'+data.id+'"><img src="'+fileUrl+'" class="rounded" alt="" id="panImg" width="220" height="160"><br><label style="cursor:pointer" onclick="return deleteFarmImg(\''+doc+'Photo_'+count+'\', \''+doc+'PhotoDiv_'+count+'\')"><span class="ft-15 upload_label_pm">Delete '+docDisplay+'</span></label></div></div>'); 39 40 41 } else if (data && data.status && data.status=="fail") { 42 utilJS.popupAlert(data.message); 43 } else { 44 utilJS.popupAlert("Something Went Wrong, Try after sometime!"); 45 } 46 }, 47 error: function (XMLHttpRequest, textStatus, errorThrown) { 48 console.log(errorThrown); 49 $("."+doc+"LoadMoreImg").addClass("d-none"); 50 if(errorThrown=='Forbidden'){ utilJS.popupAlert("Access Denied, Please Contact Administrator") }else{ utilJS.popupAlert("Failed To Upload, Please Try Again !"); }; 51 }, 52 }); 53 } 54 } 55 56 self.deleteFarmImg = function(id, tabId) { 57 if(confirm("Are sure to delete photo?","")){ 58 $('#'+id).val(''); 59 $("#"+tabId).removeClass("d-flex"); 60 $("#"+tabId).addClass("d-none"); 61 return true; 62 } else { 63 return false; 64 } 65 } 66 67 self.saveFarmData = function() { 68 validationJS.clearError(); 69 70 var feildList = ["form_number", "name", "dairy_farm_name", "phone", "address", "pincode", "id_card_number"]; 71 for (var i = 0; i < feildList.length; i++) { 72 if ($("#" + feildList[i]).val() == "" || $("#" + feildList[i]).val() == null) { 73 validationJS.raiseMandatoryError("#" + feildList[i]); 74 return false; 75 } 76 } 77 78 if($("input[id^='idproofPhoto_']").length==0){ 79 utilJS.popupAlert("Upload Address Proof"); 80 return false; 81 } 82 83 if($("input[id^='agreementPhoto_']").length==0){ 84 utilJS.popupAlert("Upload Signed PS Agreement"); 85 return false; 86 } 87 88 if ($("#phone").val() != '') { 89 var pat = /^\d*$/; 90 if (!pat.test($("#phone").val())) { 91 validationJS.raiseInputValidationError("#phone"); 92 return false; 93 } 94 95 $("#phone").val(validationJS.removeHeadingZero($("#phone").val())); 96 if ($("#phone").val().length != 10) { 97 $("#phone").addClass("red_border"); 98 $("#phone").focus(); 99 return false; 100 } 101 } 102 103 if ($("#sarpanch_phone").val() != '') { 104 var pat = /^\d*$/; 105 if (!pat.test($("#sarpanch_phone").val())) { 106 validationJS.raiseInputValidationError("#sarpanch_phone"); 107 return false; 108 } 109 110 $("#sarpanch_phone").val(validationJS.removeHeadingZero($("#sarpanch_phone").val())); 111 if ($("#sarpanch_phone").val().length != 10) { 112 $("#sarpanch_phone").addClass("red_border"); 113 $("#sarpanch_phone").focus(); 114 return false;
115 } 116 } 117 118 $("#genEnquiryformbtns").addClass("d-none"); 119 $("#genEnqSubMsg").removeClass("d-none"); 120 $(".loadMoreImg").removeClass("d-none"); 121 $.ajax({ 122 type: $("#genEnquiryForm").attr("method"), 123 url: $("#genEnquiryForm").attr("action"), 124 data: $("#genEnquiryForm").serialize(), 125 success: function (data) { 126 if(data && data.status && data.status=="success") { 127 $("#genEnqSubMsg").addClass("d-none"); 128 $(".loadMoreImg").addClass("d-none"); 129 utilJS.popupAlert(data.message); 130 } else if (data && data.status && data.status=="fail") { 131 utilJS.popupAlert(data.message); 132 $(".loadMoreImg").addClass("d-none"); 133 $("#genEnqSubMsg").addClass("d-none"); 134 $("#genEnquiryformbtns").removeClass("d-none"); 135 } else { 136 utilJS.popupAlert("Something Went Wrong, Try after sometime!"); 137 $(".loadMoreImg").addClass("d-none"); 138 $("#genEnqSubMsg").addClass("d-none"); 139 $("#genEnquiryformbtns").removeClass("d-none"); 140 } 141 }, 142 error: function (XMLHttpRequest, textStatus, errorThrown) { 143 console.log(errorThrown); 144 $(".loadMoreImg").addClass("d-none"); 145 $("#genEnqSubMsg").addClass("d-none"); 146 $("#genEnquiryformbtns").removeClass("d-none"); 147 if(errorThrown=='Forbidden'){ utilJS.popupAlert("Access Denied, Please Contact Administrator") }else{ utilJS.popupAlert("Something Went Wrong, Try after sometime!"); } 148 }, 149 }); 150 } 151 152 self.checkFarmData = function() { 153 $("#genEnquiryformbtns").addClass("d-none"); 154 $("#genEnqSubMsg").removeClass("d-none"); 155 $(".loadMoreImg").removeClass("d-none"); 156 $.ajax({ 157 type: $("#genEnquiryForm").attr("method"), 158 url: "/action/farm/checkFarmData", 159 data: $("#genEnquiryForm").serialize(), 160 success: function (data) { 161 if(data && data.status && data.status=="success") { 162 self.saveFarmData(); 163 } else if (data && data.status && data.status=="fail") { 164 utilJS.popupAlert(data.message); 165 } else { 166 utilJS.popupAlert("Something Went Wrong, Try after sometime!"); 167 } 168 $("#genEnquiryformbtns").removeClass("d-none"); 169 $("#genEnqSubMsg").addClass("d-none"); 170 $(".loadMoreImg").addClass("d-none"); 171 }, 172 error: function (XMLHttpRequest, textStatus, errorThrown) { 173 console.log(errorThrown); 174 $("#genEnquiryformbtns").removeClass("d-none"); 175 $("#genEnqSubMsg").addClass("d-none"); 176 $(".loadMoreImg").addClass("d-none"); 177 if(errorThrown=='Forbidden'){ utilJS.popupAlert("Access Denied, Please Contact Administrator") }else{ utilJS.popupAlert("Something Went Wrong, Try after sometime!"); } 178 }, 179 }); 180 } 181 182 self.setupActionsFarmData = function () { 183 pincodeJS.getPinCode('pincode', 'inquiryPinCodeLabel'); 184 $(".click-closeBtnFarm").unbind('click').click(function () { 185 var adminLogin = $(this).attr("data-admin"); 186 if(adminLogin=='Yes'){ 187 commonJS.loadSearchCollection('farmData'); 188 } else { 189 mainJS.populatePageData('/'); 190 } 191 }); 192 193 $(".change-uploadFile").unbind('change').change(function () { 194 self.uploadFarmImg($(this).attr("data-type")) 195 }); 196 197 $(".click-download").unbind('click').click(function () { 198 commonJS.downloadFun($(this).attr("data-url"), $(this).attr("data-name")); 199 }); 200 201 $(".click-delete").unbind('click').click(function () { 202 self.deleteFarmImg($(this).attr("data-photo"), $(this).attr("data-photoDiv")); 203 }); 204 205 $("#pincode").unbind('change').change(function () { 206 pincodeJS.onChangePinCode('inquiryLocationDiv'); 207 }); 208 209 $("#pincode").unbind('blur').blur(function () { 210 pincodeJS.onChangePinCode('inquiryLocationDiv'); 211 pincodeJS.getPinCode('pincode', 'inquiryPinCodeLabel'); 212 }); 213 214 $(".click-saveFarmData").unbind('click').click(function () { 215 var id = $(this).attr("data-id"); 216 if(id!=""){ 217 self.saveFarmData(); 218 } else { 219 self.checkFarmData(); 220 } 221 222 }); 223 } 224 225 self.setupActionsFarmInfo = function () { 226 $(".click-saveFarmInfo").unbind('click').click(function () { 227 self.saveFarmInfo(); 228 }); 229 230 $('.btn-number-access').unbind('click').click(function(e){ 231 e.preventDefault(); 232 fieldName = $(this).attr('data-field'); 233 type = $(this).attr('data-type'); 234 var input = $("input[id='"+fieldName+"']"); 235 var currentVal = parseInt(input.val()); 236 if (!isNaN(currentVal)) { 237 if(type == 'minus') { 238 if(currentVal > input.attr('min')) { 239 input.val(currentVal - 1).change(); 240 $("#"+fieldName+"_show").val(input.val()); 241 } 242 } else if(type == 'plus') { 243 if(currentVal < input.attr('max')) { 244 input.val(currentVal + 1).change(); 245 $("#"+fieldName+"_show").val(input.val()); 246 } 247 } 248 if(input.val()>0){ 249 $("#nolivestock").prop("checked", false); 250 } 251 } else { 252 input.val(0); 253 } 254 }); 255 256 $("#nolivestock").unbind('click').click(function () { 257 if($("#nolivestock").prop("checked")){ 258 $("[id$='qty_show']").val(0); 259 $("[id$='_qty']").val(0); 260 } 261 }); 262 263 $(".input-number").unbind('change').change(function () { 264 var id = $(this).attr('data-cattle'); 265 if($(this).val()!=''){ 266 $("#"+id).val($(this).val()); 267 } else { 268 $("#"+id).val(0); 269 $(this).val(0); 270 } 271 }); 272 273 $(".input-number").unbind('focus').focus(function () { 274 if($(this).val()=='-'){ 275 $(this).val(''); 276 } 277 }); 278 } 279 280 self.saveFarmInfo = function() { 281 validationJS.clearError(); 282 283 var feildList = ["cow_qty", "buffalo_qty", "goat_qty", "sheep_qty"]; 284 for (var i = 0; i < feildList.length; i++) { 285 if ($("#" + feildList[i]).val() == "" || $("#" + feildList[i]).val() == null) { 286 validationJS.raiseMandatoryError("#" + feildList[i]); 287 return false;
288 } 289 } 290 291 $("#farmInfoSubBtn").addClass("d-none"); 292 $(".loadMoreImg").removeClass("d-none"); 293 $.ajax({ 294 type: $("#farmInfoForm").attr("method"), 295 url: $("#farmInfoForm").attr("action"), 296 data: $("#farmInfoForm").serialize(), 297 success: function (data) { 298 if(data && data.status && data.status=="success") { 299 $("#farmInfoSubBtn").removeClass("d-none"); 300 $(".loadMoreImg").addClass("d-none"); 301 utilJS.popupSuccess(data.message); 302 } else if (data && data.status && data.status=="fail") { 303 utilJS.popupAlert(data.message); 304 $(".loadMoreImg").addClass("d-none"); 305 $("#farmInfoSubBtn").removeClass("d-none"); 306 } else { 307 utilJS.popupAlert("Something Went Wrong, Try after sometime!"); 308 $(".loadMoreImg").addClass("d-none"); 309 $("#farmInfoSubBtn").removeClass("d-none"); 310 } 311 }, 312 error: function (XMLHttpRequest, textStatus, errorThrown) { 313 console.log(errorThrown); 314 $(".loadMoreImg").addClass("d-none"); 315 $("#farmInfoSubBtn").removeClass("d-none"); 316 if(errorThrown=='Forbidden'){ utilJS.popupAlert("Access Denied, Please Contact Administrator") }else{ utilJS.popupAlert("Something Went Wrong, Try after sometime!"); } 317 }, 318 }); 319 } 320 } 321}; 322 323farmJS.init(); for (key in farmJS) { window[key] = farmJS[key];}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.