Backups Created:
/home/japatmex/public_html/wp-content/edit-wolf.php
Savvy
W
olf -
MANAGER
Edit File: srvrservices_tab_prices.php
<style type="text/css"> .alertStyle { padding: 20px; background-color: #f44336; color: white; opacity: 0; transition: opacity 0.6s; margin-bottom: 15px; text-align: left; font-size: 14px; } .alertStyle.warning {background-color: #ff9800;} .closebtn { margin-left: 15px; color: white; font-weight: bold; float: right; font-size: 22px; line-height: 20px; cursor: pointer; transition: 0.3s; } .closebtn:hover { color: black; } </style> <?php if ($count > 0) { ?> <input type="hidden" name="hdPackPrice" value="<?php echo($price); ?>"/> <input type="hidden" name="hdPackTitle" value="<?php echo($packageTitle); ?>"/> <div class="form-group row"> <label class="col-lg-3 text-right control-label"><?php echo $this->lang->line('BE_LBL_651'); ?>:</label> <div class="col-lg-5"> <input type="text" class="form-control" placeholder="Enter Cost Price" name="txtCostPrice" id="txtCostPrice" maxlength="10" value="<?php echo roundMe($costPrice); ?>"/> </div> </div> <input type="hidden" name="totalCurrencies" value="<?php echo $count; ?>"/> <div class="form-group row"> <?php $margins = array(); if ($onlyAPIId > 0 && $extNetworkId > 0 /*&& ($apiType == '4' || $apiType == '6' || $apiType == '2')*/) { ?> <label class="col-lg-3 text-right control-label">Get Cost Price From API : <img style="display:none;" id="imgCPLdr" src="<?php echo base_url('assets/images/loading.gif') ?>" border="0" alt="Please wait..."/> </label> <div class="col-lg-5"> <input type="hidden" name="chkFetchCPr" value="0"> <input data-id="<?php echo $id; ?>" type="checkbox" class="chkSelect" name="chkFetchCPr" id="chkFetchCPr" <?php if ($costPrFrmAPI == '1') echo 'checked'; ?> /> </div> <?php $rw = fetch_currency_data(); $DEFAULT_CURRENCY = $rw->CurrencyAbb; $PRICES = array(); $rsPrices = fetch_service_api_pricing(2, $id, $onlyAPIId); foreach ($rsPrices as $row) { $PRICES[$row->ServiceId][$row->GroupId] = $row->PriceMargin . '|' . $row->MarginType; } $rsGroups = fetch_price_plans(); foreach ($rsGroups as $row) { $PLANS[$row->PricePlanId] = stripslashes($row->PricePlan); } $defaultPrice = '0'; $defaultMarginType = ''; if (isset($PRICES[$id][0]) && $PRICES[$id][0] != '') { $val = $PRICES[$id][0]; $arr = explode('|', $val); if (isset($arr[0]) && is_numeric($arr[0])) $defaultPrice = roundMe($arr[0]); if (isset($arr[1]) && is_numeric($arr[1])) { $defaultMarginType = $arr[1] == '0' ? '' : '%'; } } $strPriceMargins = ''; $icon = 'upload'; if (sizeof($PLANS) > 0) { foreach ($PLANS as $key => $value) { $priceVal = '0'; $marginTypeVal = ''; if (isset($PRICES[$id][$key]) && $PRICES[$id][$key] != '') { $val = $PRICES[$id][$key]; $arr = explode('|', $val); if (isset($arr[0]) && is_numeric($arr[0])) $priceVal = roundMe($arr[0]); if (isset($arr[1]) && is_numeric($arr[1])) $marginTypeVal = $arr[1] == '0' ? '' : '%'; } $symbol = $priceVal >= 0 ? "+" : "-"; $strPriceMargins .= '<div><strong>' . $value . '</strong> ' . $symbol . ' ' . $priceVal . $marginTypeVal . ' ' . $DEFAULT_CURRENCY . '</div>'; if ($priceVal > 0 || $defaultPrice > 0) $icon = 'chevron-down'; } } ?> <div class="alertStyle warning" style="display:none;"> <span class="closebtn">×</span> Please note that you have 'Get Cost Price From API' option clicked, so this 'Save' button will not work. Please use 'Update' button above or uncheck 'Get Cost Price From API' option and then use 'Save' button. </div> <div class="col-lg-12"> <div class="collapse <?php if ($costPrFrmAPI == '1') echo 'show'; ?>" id="collapseList_<?php echo $id; ?>"> <div class="form-group row align-items-center"> <div class="col-lg-3"></div> <div class="col-lg-5"> <div class="table-responsive"> <br /> <table class="table table-striped table-bordered table-advance table-hover" id="tblDisc123"> <tbody> <tr> <td><strong>Default</strong></td> <td><input class="form-control" placeholder="Price Margin" maxlength="10" value="<? echo $defaultPrice;?>" type="text" id="txtPrice0" name="txtPrice0" /></td> <td> <select id="marginType0" name="marginType0" class="form-control "><!-- select2me --> <option value="0" <? if($defaultMarginType == '' || $defaultMarginType == '0') echo 'selected';?> >Flat</option> <option value="1" <? if($defaultMarginType == '%' || $defaultMarginType == '1') echo 'selected';?> >Percentage</option> </select> </td> <?php if($costPrFrmAPI) { if($defaultMarginType == '' || $defaultMarginType == '0') { $margins[0] = ((float) onlyFloatVal($costPrice) + (float) onlyFloatVal($defaultPrice)); }else{ $margins[0] = ((float) onlyFloatVal($costPrice) + (((float) onlyFloatVal($costPrice) / 100) * (float) onlyFloatVal($defaultPrice))); } } ?> </tr> <?php $z = 1; foreach($rsGroups as $row) { $val = ''; $priceVal = ''; $marginTypeVal = ''; if(isset($PRICES[$id][$row->PricePlanId]) && $PRICES[$id][$row->PricePlanId] != '') { $val = $PRICES[$id][$row->PricePlanId]; $arr = explode('|', $val); if(isset($arr[0]) && is_numeric($arr[0])) $priceVal = roundMe($arr[0]); if(isset($arr[1]) && is_numeric($arr[1])) $marginTypeVal = $arr[1]; } ?> <tr> <td><strong><?php echo stripslashes($row->PricePlan);?></strong></td> <td> <input class="form-control" placeholder="Price Margin" maxlength="10" value="<? echo $priceVal;?>" type="text" name="txtPrice<? echo $z;?>" id="txtPrice<? echo $z;?>" /> <input type="hidden" name="groupId<? echo $z;?>" id="groupId<? echo $z;?>" value="<? echo $row->PricePlanId; ?>" /> </td> <td> <select id="marginType<? echo $z;?>" name="marginType<? echo $z;?>" class="form-control "><!-- select2me --> <option value="0" <? if($marginTypeVal == '0') echo 'selected';?> >Flat</option> <option value="1" <? if($marginTypeVal == '1') echo 'selected';?> >Percentage</option> </select> </td> <?php if($costPrFrmAPI) { if($marginTypeVal == '' || $marginTypeVal == '0') { $margins[$row->PricePlanId] = ((float) onlyFloatVal($costPrice) + (float) onlyFloatVal($priceVal)); }else{ $margins[$row->PricePlanId] = ((float) onlyFloatVal($costPrice) + (((float) onlyFloatVal($costPrice) / 100) * (float) onlyFloatVal($priceVal))); } } ?> </tr> <?php $z++; } ?> </tbody> </table> </div> </div> <div class="col-lg-12"></div> <div class="col-lg-3"></div> <div class="col-lg-5 text-center"> <input type="hidden" id="serviceId" name="serviceId" value="<? echo $id; ?>" /> <input type="hidden" id="srvcAPIId" name="srvcAPIId" value="<? echo $onlyAPIId; ?>" /> <input type="hidden" id="sType" name="sType" value="2" /> <input type="hidden" id="ttlGroups" name="ttlGroups" value="<? echo count($rsGroups); ?>" /> <button type="button" <?php if($IS_DEMO) echo 'disabled="disabled"';?> class="btn ThemeGreenBtn mt-2" id="btnSavePrice" name="btnSavePrice">Update</button> </div> </div> </div> </div> <?php } ?> </div> <?php if ($id > 0) { ?> <label class="col-lg-3 text-right control-label">Cost price in other currencies:</label> <?php } $index = 0; $strCurrHdrs = ''; $PACK_PRICES_OTHER = array(); $PACK_OTHER_CURR_PRICES = array(); $CURR_CONV_RATES = array(); // d($rsCurrencies); foreach ($rsCurrencies as $row) { $strCurrHdrs .= "<th>" . $row->CurrencyAbb . "</th>"; if ($row->DefaultCurrency != '1') { $currencyPrice = ''; $currencyPrice1 = 0; if ($id > 0) { # commented by hassan: default price issue if ($row->Price == NULL || $row->Price == '')// set as per conversion rate { $currencyPrice1 = roundMe($price * $row->ConversionRate, 2, '.', ''); } else { $currencyPrice1 = number_format($row->Price, 2, '.', ''); } $currencyPrice = roundMe($price * $row->ConversionRate, 2, '.', ''); $PACK_PRICES_OTHER[$row->CurrencyId] = $currencyPrice; $PACK_OTHER_CURR_PRICES[$row->CurrencyId] = $currencyPrice1; $CURR_CONV_RATES[$row->CurrencyId] = $row->ConversionRate; } ?> <div class="form-group row"> <label class="col-lg-3 text-right control-label"><?php echo $row->CurrencyAbb; ?>:</label> <div class="col-lg-5"> <input type="hidden" name="currencyId<?php echo $index; ?>" value="<?php echo $row->CurrencyId; ?>"/> <input type="text" readonly class="form-control" placeholder="Enter Price" maxlength="10" name="txtCurrPrice<?php echo $index; ?>" id="txtCurrPrice<?php echo $index; ?>" value="<?php echo roundMe($currencyPrice); ?>"/> <input type="hidden" name="converstionRate<?php echo $index; ?>" id="converstionRate<?php echo $index; ?>" value="<?php echo $row->ConversionRate; ?>"/> </div> </div> <?php $index++; } else { $DEFAULT_CURRENCY_ID = $row->CurrencyId; } } if($chkCnvrtPrice>0){ $chkCnvrtPrice_class = 'checked'; }else{ $chkCnvrtPrice_class = ''; } ?> <input type="hidden" id="totalCurrencies" name="totalCurrencies" value="<?php echo $index; ?>"/> <?php if ($strCurrHdrs != '') { ?> <div class="form-group row"> <div class="col-lg-12"> <div class="table-responsive"> <table cellspacing="1" cellpadding="1" width="100%" border="0"> <tr> <td width="2%" style="font-size:20px;"> <input <?php echo $chkCnvrtPrice_class; ?> type="checkbox" class="chkSelect" name="chkCnvrtPrice" value="1" id="chkCnvrtPrice"/><span><label for="chkCnvrtPrice"></label></span><br/> <input <?php echo $chkCnvrtPrice_class; ?> type="checkbox" value="1" class="chkSelect" name="chkCustomPrice" id="chkCustomPrice"/><span><label for="chkCustomPrice"></label></span> </td> <td width="80%" style="font-size:20px;"> <b><?php echo $this->lang->line('BE_LBL_406'); ?></b><br/> <b><?php echo $this->lang->line('otherCurrenciesPrice'); ?></b> </td> <td > <?php //echo base_url($this->config->item('apanel_name').'/services/server_qty_bulk?id=' . $id); ?> <a href="javascript:void(0)" class="btn fancybox ThemeGreenBtn" data-toggle="modal" data-target="#modal_default" title="Add Quantity Range">Add Quantity Range</a> </td> </tr> </table> </div> </div> </div> <!-- Modal --> <div id="modal_default" class="modal fade" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Add Quantity Range</h5> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="col-12 text-right mb-2 mt-2"> <button type="button" <?php if ($IS_DEMO) echo 'disabled="disabled"'; ?> class="btn ThemeColorButton" id="btnAdd" name="btnAdd">Add New Record </button> </div> <div class="col-lg-12" style="overflow-x: scroll"> <div class="table-responsive"> <table class="table table-striped table-bordered table-advance table-hover" id="tblDisc"> <thead> <tr class="bg-primary"> <th nowrap="nowrap">Min Quantity</th> <th nowrap="nowrap">Max Quantity</th> <th>Price</th> <?php echo $strGroupHdrs; ?> <th></th> </tr> </thead> <tbody id="tblDiscGroups"> <?php if ($rsBulkPrices) { foreach ($rsBulkPrices as $row) { ?> <tr> <td><?php echo $row->MinQty; ?></td> <td><input class="form-control" placeholder="Maximum Quantity" maxlength="10" value="<?php echo $row->MaxQty; ?>" type="text" name="txtMaxQty[]"/></td> <td><input type="text" placeholder="Price" class="form-control" maxlength="10" name="txtQtyPrice[]" value="<?php echo($row->Price); ?>"/></td> <? $i = 1; foreach ($arrGroups as $value) { $nm = 'txtGPrice'. $i .'[]'; $idNm = 'hdGrpId'. $i .'[]'; $index = $row->MinQty . '-' . $row->MaxQty . '-' . $value; $val = ''; if (isset($GROUP_PRICES[$index]) && $GROUP_PRICES[$index] != '') $val = $GROUP_PRICES[$index]; ?> <td> <input style="60px" type="text" placeholder="Price" class="form-control" maxlength="10" name="<?php echo $nm; ?>" value="<?php echo $val; ?>"/> <input type="hidden" name="<?php echo $idNm; ?>" value="<?php echo $value; ?>"/> </td> <? $i++; } ?> <?php if(count($row) == 1){ d ?> <td style="text-align:center"> <a href="javascript:void(0);" class="remCF" id="<?php echo $sid.'-'.$row->MaxQty; ?>"> <i class="fa icon-trash btn-delete" data-toggle="tooltip" data-placement="top" title="Delete"></i> </a> </td> </tr> <?php } else{ ?> <td style="text-align:center"> <a href="javascript:void(0);" class="remCF" id="<?php echo $sid.'-'.$row->MaxQty; ?>"> <i class="fa icon-trash btn-delete" data-toggle="tooltip" data-placement="top" title="Delete"></i> </a> </td> </tr> <?php } ?> <?php } } else { $colSpan = 4 + $totalGroups; echo '<tr id="trNR"><td colspan="' . $colSpan . '"><strong>No Bulk Prices Found!</strong></td></tr>'; } $newRow = '<td style="text-align:center;">-</td><td><input class="form-control" placeholder="Max Quantity" maxlength="10" type="text" name="txtMaxQty[]" /></td><td><input style="width: 60px" type="text" class="form-control" maxlength="10" name="txtQtyPrice[]" placeholder="Price" value="' . $price . '" /></td>' . $strHGroupFlds . '<td style="text-align:center"><a href="javascript:void(0);" class="remCF"><i class="fa icon-trash btn-delete" data-toggle="tooltip" data-placement="top" title="Delete"></i></a></td>'; ?> </tbody> </table> </div> </div> <div class="col-lg-12 mt-2 mb-2"> <input type="hidden" id="QtyPackageId" name="id" value="<?php echo $id; ?>"/> <input type="hidden" id="ttlGroups" name="ttlGroups" value="<?php echo $totalGroups; ?>"/> <input type="hidden" id="newRow" name="newRow" disabled="disabled" value='<tr><?php echo $newRow; ?></tr>'/> <button name="tab" value="2" type="submit" <?php if ($IS_DEMO) echo 'disabled="disabled"'; ?> class="btn ThemeGreenBtn" name="btnBulkPrices">Submit </button> </div> </div> </div> </div> <!--model end --> <div class="form-group row"> <div class="col-lg-12"> <div class="table-responsive"> <table class="table table-striped table-bordered table-advance table-hover"> <thead> <tr class="bg-primary"> <th><?php echo $this->lang->line('BE_LBL_228'); ?></th> <?php echo $strCurrHdrs; ?> </tr> </thead> <tbody> <?php $rsGroups = fetch_price_plans(); $totalGroups = count($rsGroups); $PLAN_PRICES_PER_PACK = getPlansPricesForService($id, 2); $CURRENCY_RATES = array(); $rsCurrRates = fetch_currency_by_id(); // d($margins); foreach ($rsCurrRates as $rw) { $CURRENCY_RATES[$rw->CurrencyId] = $rw->ConversionRate; } ?> <tr> <td>Default</td> <td> <?php $marginDefaultPrice = (float) onlyFloatVal((isset($margins[0]) ? $margins[0] : $price)); $percision = strlen(substr(strrchr($marginDefaultPrice, "."), 1)); ?> <input type="text" onblur="savePrices();" name="txtPrice" value="<?php echo roundMe($marginDefaultPrice, ($percision ?: 2), '.', ''); ?>" class="form-control rateCal" id="txtPrice"> </td> <?php $k = 0; foreach($PACK_OTHER_CURR_PRICES as $key => $value) { ?> <td> <input type="text" onblur="savePrices();" name="csCurrPrice<?php echo $k; ?>" value="<?php echo roundMe($value, 2, '.', ''); ?>" class="form-control rateCalEle" id="csCurrPrice<?php echo $k; ?>"> </td> <?php $k++;} ?> </tr> <?php $rsGroups = fetch_price_plans(); $totalGroups = count($rsGroups); $PLAN_PRICES_PER_PACK = getPlansPricesForService($id, 2); //echo $this->db->last_query();die; $CURRENCY_RATES = array(); $rsCurrRates = fetch_currency_by_id(); foreach ($rsCurrRates as $rw) { $CURRENCY_RATES[$rw->CurrencyId] = $rw->ConversionRate; } $i = 0; foreach ($rsGroups as $row) { if (isset($PLAN_PRICES_PER_PACK[$row->PricePlanId][$DEFAULT_CURRENCY_ID])) { $packPrice = $PLAN_PRICES_PER_PACK[$row->PricePlanId][$DEFAULT_CURRENCY_ID]; } else { $packPrice = roundMe($price); } ?> <tr> <td><?php echo stripslashes($row->PricePlan); ?></td> <td> <?php $marginDefaultPrice = (float) onlyFloatVal((isset($margins[$row->PricePlanId]) ? $margins[$row->PricePlanId] : onlyFloatVal($packPrice))); $percision = strlen(substr(strrchr($marginDefaultPrice, "."), 1)); ?> <input type="hidden" name="planId<?php echo $i; ?>" value="<?php echo $row->PricePlanId; ?>"/> <input type="text" data-id="<?php echo $i; ?>" onblur="savePrices();" onkeyup="convertCurrPrices(this)" id="txtPrice<?php echo $i; ?>_0" name="txtPrice<?php echo $i; ?>_0" value="<?php echo roundMe($marginDefaultPrice, ($percision ?: 2), '.', ''); ?>" class="form-control rateCal"> </td> <? $z = 0; // echo '<pre>'; // print_r($PLAN_PRICES_PER_PACK); // echo '</pre>'; foreach ($PACK_PRICES_OTHER as $key => $value) { $percision = strlen(substr(strrchr($marginDefaultPrice, "."), 1)); ?> <td> <input type="hidden" name="otherCurrencyId<?php echo $i; ?>_<?php echo $z + 1; ?>" value="<?php echo $key; ?>"/> <input type="hidden" id="cRt<?php echo $i; ?>_<?php echo $z + 1; ?>" name="cRt<?php echo $i; ?>_<?php echo $z + 1; ?>" value="<?php echo $CURR_CONV_RATES[$key]; ?>"/> <input type="text" onblur="savePrices();" name="txtOtherPrice<?php echo $i; ?>_<?php echo $z + 1; ?>" id="txtOtherPrice<?php echo $i; ?>_<?php echo $z + 1; ?>" value="<?php if(array_key_exists($row->PricePlanId, $PLAN_PRICES_PER_PACK) && array_key_exists($key, $PLAN_PRICES_PER_PACK[$row->PricePlanId])){ echo roundMe($PLAN_PRICES_PER_PACK[$row->PricePlanId][$key]); } else { echo roundMe($marginDefaultPrice * $CURRENCY_RATES[$key], 2, '.', ''); } ?>" class="form-control rateCalEle"> </td> <? $z++; } ?> </tr> <?php $i++; } ?> </tbody> </table> </div> </div> </div> <input type="hidden" value="<?php echo $totalGroups; ?>" name="totalGroups" id="totalGroups"/> <input type="hidden" value="<?php echo count($PACK_PRICES_OTHER); ?>" name="currencyCount" id="currencyCount"/> <input type="hidden" value="<?php echo $DEFAULT_CURRENCY_ID; ?>" name="defaultCurrId"/> <input type="hidden" value="0" name="hdSavePrices" id="hdSavePrices"/> <?php } ?> <div class="form-group row text-right"> <div class="col-lg-12"> <button name="tab" value="2" type="submit" <?php if ($IS_DEMO) echo 'disabled="disabled"'; ?> class="btn ThemeColorButton" onclick="return costFromApi()"><?php echo $this->lang->line('BE_LBL_72'); ?></button> </div> </div> <br/><br/> <?php if ($id > 0) { ?> <div class="form-group row"> <label class="control-label text-right col-lg-3">User Notes:</label> <div class="col-lg-5"> <textarea class="form-control" id="txtUserNotes" name="txtUserNotes" rows="6"></textarea> </div> </div> <div class="form-group row"> <?php $price_data = fetch_price_plan_data(); ?> <label class="control-label text-right col-lg-3"><?php echo $this->lang->line('BE_LBL_18') ?>:</label> <div class="col-lg-5"> <select name="uNplanId" id="uNplanId" class="form-control select2me" data-placeholder="Select..."> <option value="0"><?php echo $this->lang->line('BE_LBL_407'); ?></option> <?php FillCombo(0, $price_data); ?> </select> </div> </div> <div class="form-group row"> <label class="control-label col-lg-3"></label> <div class="col-lg-4"> <button type="button" <?php if ($IS_DEMO) echo 'disabled="disabled"'; ?> class="btn ThemeColorButton" id="btnPriceEml"><i class="fa fa-envelope"> </i> Send Service Credit Information To Users </button> <img style="display:none;" id="imgEmlLdr" src="<?php echo base_url('assets/images/loading.gif'); ?>" border="0" alt="Please wait..."/> </div> </div> <?php } ?> <?php } ?> <script type="text/javascript"> $(".deleteServerQtyRange").click(function(){ var id = this.id; $.ajax({ type: 'post', url: base_url+apanel_name+"/services/deleteWhereId/"+id, data: 'id='+this.id, success: function (response) { alert(response); } }); }); function costFromApi() { if($('[name="chkFetchCPr"]').is(':checked')) { var close = document.getElementsByClassName("closebtn"); for (i = 0; i < close.length; i++) { var div = close[i].parentElement; div.style.opacity = "1"; div.style.display = "block"; $("#chkFetchCPr").effect("pulsate", { times:14 }, 10000); setTimeout(function(){ div.style.opacity = "0"; div.style.display = "none"; $('html, body').animate({ scrollTop: $("#chkCnvrtPrice").offset().top }, 2000); }, 10000); $('html, body').animate({ scrollTop: $("#txtCostPrice").offset().top }, 500); } return false; } return true; } $(function(){ $("#btnSavePrice").click(function(){ var allOkay = true; $('div.dynamic-errors').remove(); var groups = $('#ttlGroups').val(); var checkPriceFetch = 0; if($("#chkFetchCPr").prop('checked')){ checkPriceFetch = 1; }else{ checkPriceFetch = 0; } var prices = $.trim($('#txtPrice0').val()); if(!prices) { $('#txtPrice0').after('<div class="dynamic-errors">This field is required!</div>'); allOkay = false; } var plans = $.trim($('#serviceId').val()); var marginType = $.trim($('#marginType0').val()); for(var a=1; a<= groups; a++) { if($.trim($('#txtPrice'+a).val()) && isFloat($('#txtPrice'+a).val())) { prices = prices + ',' + $.trim($('#txtPrice'+a).val()); plans = plans + ',' + $.trim($('#groupId'+a).val()); marginType = marginType + ',' + $('#marginType'+a).val(); }else{ $('#txtPrice'+a).after('<div class="dynamic-errors">This field is required!</div>'); allOkay = false; } } if(allOkay) { var $this = $(this); $this.text('...'); $this.attr('disabled', true); $.post(base_url+apanel_name+"/services/ajxpriceswithapi", { chkFetchCPr:checkPriceFetch, srvcAPIId:$('#srvcAPIId').val(), serviceId:$('#serviceId').val(), sType:2, plans:plans, prices:prices, marginType:marginType, dPrice:$.trim($('#txtPrice0').val()), dMT:$.trim($('#marginType0').val()), costPrice: ($('#txtCostPrice').length ? $('#txtCostPrice').val() : 0), purpose:'save' }, function(response){ if(response) { showStickyErrorToast(response, '', 'success'); setTimeout(function(){ window.location.reload(); }, 1000); } }).always(function(){ $this.text('Update'); $this.attr('disabled', false); }); } }); }) </script>