--cshtml
@{
Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
<style>
.modal-dialog {
width: 75%;
}
.ui-jqgrid {
position: relative;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
-ms-touch-action: none;
touch-action: none;
}
.ui-jqgrid > .ui-jqgrid-view {
position: relative;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
left: 0;
top: 0;
padding: 0;
font-size: 11px;
}
</style>
<style>
.checkbox label:after,
.radio label:after {
content: '';
display: table;
}
legend.scheduler-border {
display: inline-block;
}
.checkbox {
position: relative;
display: block;
margin: -10px 0px;
}
.checkbox .cr,
.radio .cr {
position: relative;
display: inline-block;
border: 1px solid #a9a9a9;
border-radius: .25em;
width: 1.5em;
height: 1.5em;
float: left;
margin-right: .5em;
margin-left: 0px;
margin-top: 0px;
}
.radio .cr {
border-radius: 50%;
}
.checkbox .cr .cr-icon,
.radio .cr .cr-icon {
position: absolute;
font-size: .8em;
line-height: 0;
top: 50%;
left: 20%;
}
.radio .cr .cr-icon {
margin-left: 0.04em;
}
.checkbox label input[type="checkbox"],
.radio label input[type="radio"] {
display: none;
}
.checkbox label input[type="checkbox"] + .cr > .cr-icon,
.radio label input[type="radio"] + .cr > .cr-icon {
transform: scale(3) rotateZ(-20deg);
opacity: 0;
transition: all .3s ease-in;
}
.checkbox label input[type="checkbox"]:checked + .cr > .cr-icon,
.radio label input[type="radio"]:checked + .cr > .cr-icon {
transform: scale(1) rotateZ(0deg);
opacity: 1;
}
.checkbox label input[type="checkbox"]:disabled + .cr,
.radio label input[type="radio"]:disabled + .cr {
opacity: .5;
}
.radio label, .checkbox label {
padding-left: 0px;
}
</style>
<script src="@Url.Content("~/Scripts/MsoScripts/Transactions/SubscriberPackageInfo.js")"></script>
<script>
var appElement = document.querySelector('[ ng-controller=SubscriberPackageInfoCtrl]');
function SearchSTBR() {
JqCustomSearch($("#globalSTBRSearchText").val(), $("#MainGridPackageDetails"))
}
function Search() {
JqCustomSearch($("#globalSearchText").val(), $("#grdPackageDetails"))
}
function ViewRow(row) {
;
var appElement = document.querySelector('[ ng-controller=SubscriberPackageInfoCtrl]');
var $http = angular.element(appElement).injector().get('$http');
var $scope = angular.element(appElement).scope();
var rowdata = jQuery("#MainGridPackageDetails").jqGrid('getRowData', row);
if (rowdata.discounteverymonth != null && rowdata.discounteverymonth != undefined && rowdata.discounteverymonth != "") {
if (rowdata.discounteverymonth == "t") {
rowdata.discounteverymonth = "YES"
}
else {
rowdata.discounteverymonth = "NO"
}
}
if (rowdata.vchfreeeverymonth != null && rowdata.vchfreeeverymonth != undefined && rowdata.vchfreeeverymonth != "") {
if (rowdata.vchfreeeverymonth == "F") {
$scope.freedurationeverymonth = "NO";
}
else {
$scope.freedurationeverymonth = "YES";
}
}
if (rowdata.packagetype == "ISP") {
if (rowdata.vchisptype == "UNLIMITED") {
$scope.INVISABLESTBTYPE = false;
$scope.INVISABLECABLETYPE = true;
$scope.INVISABLECABLETYPEUNLIMIT = false;
}
else {
$scope.INVISABLESTBTYPE = false;
$scope.INVISABLECABLETYPE = true;
$scope.INVISABLECABLETYPEUNLIMIT = true;
}
}
else if (rowdata.packagetype == "CABLE") {
$scope.INVISABLECABLETYPE = false;
$scope.INVISABLESTBTYPE = true;
$scope.INVISABLECABLETYPEUNLIMIT = false;
}
else {
if (rowdata.vchisptype == "UNLIMITED") {
$scope.INVISABLECABLETYPEUNLIMIT = false;
$scope.INVISABLECABLETYPE = true;
$scope.INVISABLESTBTYPE = true;
}
else {
$scope.INVISABLECABLETYPEUNLIMIT = true;
$scope.INVISABLECABLETYPE = true;
$scope.INVISABLESTBTYPE = true;
}
}
$scope.registrationid = rowdata.vchregistrationid;
$scope.subscribername = rowdata.vchsubscribername;
$scope.mobilenumber = rowdata.vchmobilenumber;
$scope.connectionid = rowdata.vchconnectionid;
$scope.packagetype = rowdata.packagetype;
$scope.connectiontype = rowdata.connectiontype;
$scope.packagename = rowdata.packagename;
$scope.stbtype = rowdata.stbtype;
$scope.numberofchannels = rowdata.numnoofchannnels;
$scope.isptype = rowdata.vchisptype;
$scope.gbmonth = rowdata.vchgb;
$scope.speed = rowdata.speed;
$scope.gblimit = rowdata.gblimit;
$scope.reduced = rowdata.reducedspeed;
$scope.duration = rowdata.numduration;
$scope.packageamount = rowdata.packageamount;
$scope.discountamount = rowdata.discountamount;
$scope.discounforeverymonth = rowdata.discounteverymonth;
$scope.totalamountafterdiscount = rowdata.numTotalAmount;
$scope.activationdate = rowdata.activationdatee;
$scope.expirydate = rowdata.expairydatee;
$scope.freeduration = rowdata.numfremonth;
$('#myModal1').modal('show');
$scope.$apply();
}
app.directive('validNumberr', function () {
return {
require: '?ngModel',
link: function (scope, element, attrs, ngModelCtrl) {
if (!ngModelCtrl) {
return;
}
ngModelCtrl.$parsers.push(function (val) {
if (angular.isUndefined(val)) {
var val = '';
}
var clean = val.replace(/[^0-9\.,]/g, '');
var decimalCheck = clean.split('.');
if (!angular.isUndefined(decimalCheck[1])) {
decimalCheck[1] = decimalCheck[1].slice(0, 2);
clean = decimalCheck[0] + '.' + decimalCheck[1];
}
if (val !== clean) {
ngModelCtrl.$setViewValue(clean);
ngModelCtrl.$render();
}
return clean;
});
element.bind('keypress', function (event) {
if (event.keyCode === 32) {
event.preventDefault();
}
});
}
};
});
</script>
<div ng-controller="SubscriberPackageInfoCtrl" ng-init="DatepickerEnableStatus();LoadSubscirberData();GetPackagesDetails();GetPageLoaddata();Getpvdate();">
<div class="page-content">
<div class="row">
<div class="col-xs-12 col-sm-12">
<form name="subscriberpackageinfo" novalidate class="form-horizontal">
<div class="col-md-12">
<div>
<h5 class="widget-title red dark-10 no-padding " style="font-size:16px; font-weight:600; margin:5px 0px;">
<i class="ace-icon fa fa-user"></i>
SUBSCRIBER PACKAGE INFO
</h5>
<div class="form-group">
<label class=" col-sm-2 control-label FullWidth">
Subscriber Name <span style="color: Red">*</span> :
</label>
<div class="col-sm-6 FullWidth">
<ui-select name="productname" id="productname" required ng-model="SubscriberPackageInfoCtrl.v.selected.vchsubscribername" on-select=" Subscriber_Change(SubscriberPackageInfoCtrl.v.selected)" title="Select Subscriber Name" ng-disabled="isdisabled">
<ui-select-match placeholder="Select Subscriber Name">{{$select.selected.vchsubscribername}}</ui-select-match>
<ui-select-choices repeat="v in subscriber | propsFilter: {vchsubscribername: $select.search,vchregistrationid: $select.search,vchmobilenumber: $select.search}">
<div ng-bind-html="v.vchsubscribername | highlight: $select.search"></div>
<small>
Subscriber Id: <span ng-bind-html="v.vchregistrationid | highlight: $select.search" style="font-family: Verdana; font-weight: bold; color: #FF6E33"></span>
Mobile No.:<span ng-bind-html="v.vchmobilenumber | highlight: $select.search" style="font-family: Verdana; font-weight: bold; color: #FF6E33"></span>
</small>
</ui-select-choices>
</ui-select>
<span class="error" ng-show="(subscriberpackageinfo.productname.$dirty || submitted) && subscriberpackageinfo.productname.$error.required">
Subscriber Name Required
</span>
</div>
<label class=" col-sm-2 control-label FullWidth">
Date<span style="color: Red">*</span> :
</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="Date" ng-model="SPI.datdate" placeholder="Enter Date" data-date-format="dd/mm/yyyy"
class="form-control" id="Date" required ng-disabled="DateEnableStatus" />
<span class="error" ng-show="(subscriberpackageinfo.Date.$dirty || submitted) && subscriberpackageinfo.Date.$error.required">
Date Required
</span>
</div>
</div>
<div class='form-group'>
<label class=" col-sm-2 control-label FullWidth">Registration ID :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtRegistrationId" ng-model="SPI.vchregistrationid" id="txtRegistrationId" disabled />
</div>
<label class=" col-sm-2 control-label FullWidth" ng-show="false">Subscriber Name :</label>
<div class="col-sm-2 FullWidth" ng-show="false">
<input type="text" name="txtSuscriberName" ng-model="SPI.suscribername" id="txtSuscriberName" disabled />
</div>
<label class=" col-sm-2 control-label FullWidth">Mobile No. :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtMobileNo" ng-model="SPI.mobilenumber" id="txtMobileNo" disabled />
</div>
<label class=" col-sm-2 control-label FullWidth">
Connection ID <span style="color: Red">*</span> :
</label>
<div class="col-sm-2 FullWidth">
<select name="ConnectionId" ng-model="SPI.vchconnectionid" ng-options="c.vchconnectionid as c.vchconnectionid for c in lstconnectionid" ng-change="getPackageTypes(SPI);" class="form-control" data-index="1" required>
<option value="">Select Connection ID</option>
</select>
<span class="error" ng-show="(subscriberpackageinfo.ConnectionId.$dirty || submitted) && subscriberpackageinfo.ConnectionId.$error.required">
Connection ID Required
</span>
</div>
</div>
<div class="form-group">
<label class=" col-sm-2 control-label FullWidth">
Type of Package <span style="color: Red">*</span> :
</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtPackageType" ng-model="SPI.PackageType" id="txtPackageType" disabled />
<input type="text" name="txtPackageTypeID" ng-model="SPI.PackageTypeID" id="txtPackageTypeID" ng-show="false" />
</div>
<label class=" col-sm-2 control-label FullWidth">
Package Name<span style="color: Red">*</span> :
</label>
<div class="col-sm-2 FullWidth">
<select name="PackageName" ng-model="SPI.vchpackageid" ng-options="c.vchpackageid as c.vchpackagename for c in SubscribersPackagesList" ng-change="getPackageDurationDetails(SPI);" class="form-control" data-index="1" required>
<option value="">Select Package Name</option>
</select>
<span class="error" ng-show="(subscriberpackageinfo.PackageName.$dirty || submitted) && subscriberpackageinfo.PackageName.$error.required">
Package Name Required
</span>
</div>
<label class=" col-sm-2 control-label FullWidth">Duration<span style="color: Red">*</span> :</label>
<div class="col-sm-2 FullWidth">
<select name="NumDuration" ng-model="SPI.numdurationid" ng-options="c.numdurationid as c.numduration for c in lstDuration" ng-change="getAmtChannnelDetails(SPI);" class="form-control" data-index="1" required>
<option value="">Select Duration Details</option>
</select>
<span class="error" ng-show="(subscriberpackageinfo.NumDuration.$dirty || submitted) && subscriberpackageinfo.NumDuration.$error.required">
Duration Details Required
</span>
</div>
</div>
<div class='form-group' ng-show="cabletype">
<label class=" col-sm-2 control-label FullWidth">STB Type :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtNoofChannels" ng-model="SPI.vchstbtype" id="txtNoofChannels" disabled />
</div>
<label class=" col-sm-2 control-label FullWidth">No. Of Channels :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtNoofChannels" ng-model="SPI.numnoofchannnels" id="txtNoofChannels" disabled />
</div>
</div>
<div class='form-group' ng-show="isptype">
<label class=" col-sm-2 control-label FullWidth">ISP Type:</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtGB" ng-model="SPI.vchisptype" id="txtMobileNo" disabled />
</div>
<label class=" col-sm-2 control-label FullWidth">GB/Month:</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtGB" ng-model="SPI.vchgb" id="txtMobileNo" disabled />
</div>
<label class=" col-sm-2 control-label FullWidth">Speed :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtSpeed" ng-model="SPI.vchspeed" id="txtSpeed" disabled />
</div>
</div>
<div class='form-group'>
<label class=" col-sm-2 control-label FullWidth">Package Amount :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtPackageAmount" ng-model="SPI.numamount" style="text-align:right" id="txtPackageAmount" disabled ng-change="CalculateData()" ng-blur="CalculateData();" ng-keydown="CalculateData();" ng-mouseleave="CalculateData();" ng-click="CalculateData();" ng-keypress="CalculateData();" ng-keyup="CalculateData();" />
</div>
<label class=" col-sm-2 control-label FullWidth">Description :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtDescription" ng-model="SPI.vchnarration" id="txtDescription" placeholder="Enter Description" class="form-control" capitalize maxlength="250" />
@*<span class="error" ng-show="(subscriberpackageinfo.txtDescription.$dirty || submitted ) && subscriberpackageinfo.txtDescription.$error.required">
Description Required
</span>*@
</div>
<label class=" col-sm-2 control-label FullWidth">Discount :</label>
<div class="col-sm-2 FullWidth">
<input type="text" class="form-control" placeholder="Enter Discount Amount" name="txtDiscount" maxlength="5" ng-model="SPI.numDiscount" valid-numberr style="text-align:right;" id="txtDiscount" ng-change="CalculateData();SetCurrency(SPI.numDiscount);" ng-blur="CalculateData();" />
<span class="error">{{SPI.alertdiscountamount}}</span>
</div>
</div>
<div class='form-group'>
<label class=" col-sm-2 control-label FullWidth no-padding">Discount For Every Month :</label>
<div class="col-sm-2 FullWidth">
<div class="checkbox" style="width:auto; float:left;">
<label>
<input type="checkbox" value="" ng-model="SPI.chkDiscountType">
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
</label>
</div>
</div>
<label class=" col-sm-2 control-label FullWidth">Total Amount after Discount :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtTotalAfterDiscount" style="text-align:right" ng-model="SPI.numTotalAmount" id="txtTotalAfterDiscount" disabled />
<span class="error">{{SPI.alertTotalamount}}</span>
</div>
<label class=" col-sm-2 control-label FullWidth">Connection Type :</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtConnectionType" ng-model="SPI.vchconnectiontype" id="txtConnectionType" disabled />
</div>
</div>
<div class='form-group' ng-show="Freedatacontrls">
<label class=" col-sm-2 control-label FullWidth no-padding">Free For Every Month :</label>
<div class="col-sm-2 FullWidth">
<div class="checkbox" style="width:auto; float:left;">
<label>
<input type="checkbox" value="" ng-model="SPI.chkFreeDiscountType">
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
</label>
</div>
</div>
<label class=" col-sm-2 control-label FullWidth">Free Month:</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="txtFreemonth" ng-required="SPI.chkFreeDiscountType" style="text-align:left" ng-model="SPI.Freemonth" ng-blur="FreeMonthvalidate();" id="txtFreemonth" />
<span class="error" ng-show="(subscriberpackageinfo.txtFreemonth.$dirty || submitted) && subscriberpackageinfo.txtFreemonth.$error.required">
Free Month Required
</span>
</div>
</div>
<div class='form-group'>
<label class=" col-sm-2 control-label FullWidth">Activation Date<span style="color:red">*</span>:</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="ActivationDate" readonly ng-model="SPI.dataactivationdate" placeholder="Enter Date" data-date-format="dd/mm/yyyy"
class="form-control" id="ActivationDate" required ng-change="getActivationDate(SPI);" />
<span class="error" ng-show="(subscriberpackageinfo.ActivationDate.$dirty || submitted) && subscriberpackageinfo.ActivationDate.$error.required">
Activation Date Required
</span>
</div>
<label class=" col-sm-2 control-label FullWidth">Expiry Date:</label>
<div class="col-sm-2 FullWidth">
<input type="text" name="ExpiryDate" ng-model="SPI.datExpirydate" data-date-format="dd/mm/yyyy"
class="form-control" id="ExpiryDate" disabled />
</div>
</div>
<div class="form-group">
<div class="pull-right" style="padding-right:40px;">
<div class="pull-right">
<button class="btn btn-success" data-index="2" type="button" ng-click="AddPackageDetailstoGrid(SPI)">
<i class="ace-icon fa fa-plus bigger-110"></i>Add
</button>
<button class="btn orange" id="Reset" type="button" ng-click="ClearData()">
<i class="ace-icon fa fa-undo bigger-110"></i>Clear
</button>
</div>
</div>
</div>
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" style="background-color: #5499C7">
<button type="button" ng-click="BoostClear()" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" style="align-content:center" id="myModalLabel">Subscriber Package Details</h4>
</div>
<div class="modal-body">
<div class="form-group">
<span class="col-sm-4 control-labe">Registration ID : <span style="color:red">{{registrationid}}</span></span>
<span class="col-sm-4 control-labe">Subscriber Name : <span style="color:red">{{subscribername}}</span></span>
<span class="col-sm-4 control-labe">Mobile No. : <span style="color:red">{{mobilenumber}}</span></span>
</div>
<div class="form-group">
<span class="col-sm-4 control-labe">Connection ID : <span style="color:red">{{connectionid}}</span></span>
<span class="col-sm-4 control-labe">Package Type : <span style="color:red">{{packagetype}}</span></span>
<span class="col-sm-4 control-labe">Connection Type : <span style="color:red">{{connectiontype}}</span></span>
</div>
<div class="form-group">
<span class="col-sm-4 control-labe">Package Name : <span style="color:red">{{packagename}}</span></span>
<span class="col-sm-4 control-labe" ng-show="INVISABLESTBTYPE">STB Type : <span style="color:red">{{stbtype}}</span></span>
<span class="col-sm-4 control-labe" ng-show="INVISABLESTBTYPE">No. of Channels : <span style="color:red">{{numberofchannels}}</span></span>
</div>
<div class="form-group">
<span class="col-sm-4 control-labe" ng-show="INVISABLECABLETYPE">ISP Type : <span style="color:red">{{isptype}}</span></span>
<span class="col-sm-4 control-labe" ng-show="INVISABLECABLETYPE">GB/Month : <span style="color:red">{{gbmonth}}</span></span>
<span class="col-sm-4 control-labe" ng-show="INVISABLECABLETYPE">Speed(MBPS) : <span style="color:red">{{speed}}</span></span>
</div>
<div class="form-group">
<span class="col-sm-4 control-labe" ng-show="INVISABLECABLETYPEUNLIMIT">GB Limit : <span style="color:red">{{gblimit}}</span></span>
<span class="col-sm-4 control-labe" ng-show="INVISABLECABLETYPE">Reduced Speed(MBPS) : <span style="color:red">{{reduced}}</span></span>
<span class="col-sm-4 control-labe">Duration(In Months) : <span style="color:red">{{duration}}</span></span>
</div>
<div class="form-group">
<span class="col-sm-4 control-labe">Package Amount : <span style="color:red">{{packageamount}}</span></span>
<span class="col-sm-4 control-labe">Discount Amount : <span style="color:red">{{discountamount}}</span></span>
<span class="col-sm-4 control-labe">Discount for Every Month : <span style="color:red">{{discounforeverymonth}}</span></span>
</div>
<div class="form-group">
<span class="col-sm-4 control-labe">Total Amount after Discount : <span style="color:red">{{totalamountafterdiscount}}</span></span>
<span class="col-sm-4 control-labe" data-date-format="dd/mm/yyyy">Activation Date : <span style="color:red">{{activationdate}}</span></span>
<span class="col-sm-4 control-labe" data-date-format="dd/mm/yyyy">Expiry Date : <span style="color:red">{{expirydate}}</span></span>
</div>
<div class="form-group">
<span class="col-sm-4 control-labe">Free Duration(In Months) : <span style="color:red">{{freeduration}}</span></span>
<span class="col-sm-4 control-labe">Free Duration for Every Month : <span style="color:red">{{freedurationeverymonth}}</span></span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<table id="grdPackageDetails"></table>
<div id="grid-pagerPackageDetails"></div>
</div>
<div class="form-group">
<div class="pull-right" style="padding-right:40px;">
<div class="pull-right">
<button class="btn btn-success" data-index="2" type="button" ng-click="SaveSubsriberPackageDetails(SPI)">
<i class="ace-icon fa fa-plus bigger-110"></i>Save
</button>
<button class=" btn btn-danger" type="button" ng-click="ResetData()">
<i class="fa fa-times"></i>Reset
</button>
</div>
</div>
</div>
<div class="form-group">
<table id="MainGridPackageDetails"></table>
<div id="grid-pagerMainPackageDetails"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
$(function () {
//$('.Search-Select').searchable();
$("#Date").datepicker();
$('#Date').datepicker();
$("#ActivationDate").datepicker();
});
</script>
<style>
.ui-datepicker-calendar, .ui-datepicker-year {
display: none;
}
.modal-dialog {
width: 75%;
}
.ui-jqgrid .ui-jqgrid-htable th div {
height: 43px;
overflow: hidden;
padding-top: 11px;
position: relative;
vertical-align: text-top;
white-space: normal !important;
}
.ui-state-default.ui-jqgrid-hdiv {
height: 44px;
}
.ui-jqgrid tr.jqgrow td {
white-space: normal !important;
/*height: auto;
padding-top: 3px;
vertical-align: text-top;*/
}
</style>
@*<script>
$(function () {
//$('#Activationdate1').datepicker({
// onSelect: function (selectedDate) {
// alert(selectedDate);
// }
//});
//$("#Activationdate1").datepicker({
//});
});
</script>*@
@*<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.19.custom.min.js"></script>*@
@*<script>
$(function () {
;
$("#Activationdate1").datepicker({
//startdate:'+0d',.
endDate: '+0d',
onSelect: function (selectedDate) {
alert("2");
}
// minDate: '-1',
// maxDate: '+1M',
// onSelect: function (selectedDate) {
// ;
// var option = this.id == "Activationdate1" ? "minDate" : "maxDate",
// instance = $(this).data("datepicker"),
// date = $.datepicker.parseDate(
// instance.settings.dateFormat ||
// $.datepicker._defaults.dateFormat,
// selectedDate, instance.settings);
// dates.not(this).datepicker("option", option, date);
// }
});
//$('#Activationdate1').datepicker('setEndDate', 'today');
});
</script>*@
-- jsfile
var app = angular.module('RMS');
app.controller('SubscriberPackageInfoCtrl', function ($scope, $http, $rootScope) {
$rootScope.FormName = "Subscriber Packages Info";
$rootScope.ModuleName = "MSO Transactions";
var pim = this;
$scope.SPI = {};
$scope.submitted = false;
$scope.isFormValid = false;
//$scope.Disableactivationdate = true;
$scope.SPI.chkDiscountType = false;
$scope.isptype = true;
$scope.Freedatacontrls = false;
$scope.cabletype = true;
$scope.SPI.chkFreeDiscountType = false;
var res = window.location.pathname.split("/");
var baseurl = window.location.protocol + "//" + window.location.host;
if (res.length > 3) {
for (i = 1; i < res.length - 2; i++)
baseurl = baseurl + "/" + res[i];
}
$scope.$watch('subscriberpackageinfo.$valid', function (newValue) {
$scope.isFormValid = newValue;
});
$scope.Getpvdate = function () {
;
var url = baseurl + "/CableTransactions/GetDate";
$http({
url: url,
method: "get"
}).success(function (data) {
;
$scope.billdate = data;
});
}
function GetFormatedDate(date) {
;
try {
if (date != "" && date != null && date != "Invalid Date") {
var parts = date.split("/");
return new Date(parts[2], parts[1] - 1, parts[0]);
}
else
return null;
} catch (e) {
alert(e.message);
}
}
function GetFormatedExpirydateDate(date, duration) {
;
try {
if (date != "" && date != null && date != "Invalid Date") {
var parts = date.split("/");
return new Date(parts[2], ((parts[1] - 1) + parseInt(duration)), parts[0] - 1);
}
else
return null;
} catch (e) {
alert(e.message);
}
}
function GetSelectedDate(date) {
;
try {
// var get_year = date.getFullYear() + 1;
if (date != "" && date != null && date != "Invalid Date") {
var dt = date.getDate();
if (parseInt(dt) < 10)
dt = "0" + dt;
return dt + '/' + (parseInt(date.getMonth()) + 1) + '/' + date.getFullYear();
}
else
return null;
} catch (e) {
alert(e.message);
}
}
$scope.getActivationDate = function () {
;
var DR = GetFormatedDate($scope.SPI.dataactivationdate);
//$scope.SPI.numduration
//DR = str.replace(/\//g, " ");
if ($scope.freemopnthss == undefined || $scope.freemopnthss == "" || $scope.freemopnthss == null) {
$scope.freemopnthss = 0;
}
var fremonthAndduration = $scope.SPI.numduration + $scope.freemopnthss;
var InstallationDate = GetFormatedDate($scope.InstallationDate);
if (InstallationDate != null && DR != null) {
if ((InstallationDate) <= (DR)) {
var duratiion = GetFormatedExpirydateDate($scope.SPI.dataactivationdate, fremonthAndduration);
$scope.SPI.datExpirydate = GetSelectedDate(duratiion);
}
else {
;
alert("Activation Date Should be Greater Than or Equal to the Installation Date " + $scope.InstallationDate);
$scope.SPI.dataactivationdate = null;
$scope.SPI.dataactivationdate = [];
}
}
}
$scope.DatepickerEnableStatus = function () {
var url = baseurl + "/Login/GetDatepickerEnableStatus";
$http({
url: url,
method: "get"
}).success(function (data) {
if (data.Status != null) {
if (data.Status === "Y") {
$scope.DateEnableStatus = false;
} else {
$scope.DateEnableStatus = true;
}
}
else {
$scope.DateEnableStatus = true;
}
if (data.ServerDate != null) {
$scope.SPI.datdate = data.ServerDate;
$scope.SPI.dataactivationdate = data.ServerDate;
$scope.SPI.datExpirydate = data.ServerDate;
var date1 = $scope.SPI.datdate;
$(function () {
;
// alert("1");
$("#Date").datepicker("setEndDate", date1);
});
}
});
}
$scope.LoadSubscirberData = function () {
var url = baseurl + "/CableTransactions/GetSubscriberNamesByConnection";
$http({
url: url,
method: "get"
}).success(function (data) {
$scope.subscriber = data;
//console.log(data);
});
}
$scope.Subscriber_Change = function (subschaged) {
var found = false;
var val = subschaged.vchsubscribername.vchregistrationid;
angular.forEach($scope.subscriber, function (tag) {
if (val.indexOf(tag.vchregistrationid) != -1) {
$scope.SPI.vchregistrationid = subschaged.vchsubscribername.vchregistrationid;
$scope.SPI.suscribername = subschaged.vchsubscribername.vchsubscribername;
$scope.SPI.mobilenumber = subschaged.vchsubscribername.vchmobilenumber;
$scope.lstconnectionid = null;
$scope.SPI.vchconnectiontype = null;
//$scope.SPI.suscribername = null;
//$scope.SPI.mobilenumber = null;
$scope.SubscribersPackagesList = null;
$scope.lstconnectionid = null;
$scope.lstDuration = null;
$scope.SPI.dataactivationdate = null;
$scope.SPI.datExpirydate = null;
$scope.SPI.PackageType = null;
$scope.SPI.PackageTypeID = null;
}
});
var url = baseurl + "/CableTransactions/getConnectionIDs";
$http.post(url, { registrationid: $scope.SPI.vchregistrationid }).success(function (data) {
$scope.lstconnectionid = data;
// console.log(data);
});
return found;
}
$scope.getPackageTypes = function () {
;
var ConnectionId = $scope.SPI.vchconnectionid;
$scope.SubscribersPackagesList = null;
$scope.SPI.txtPackageType = null;
$scope.SPI.txtPackageTypeID = null;
$scope.lstDuration = null;
$scope.SPI.chkFreeDiscountType = false;
$scope.SPI.Freemonth = null;
if (($scope.lstconnectionid != null || $scope.lstconnectionid !== undefined)) {
for (var i = 0; i < $scope.lstconnectionid.length; i++) {
if (($scope.lstconnectionid[i].vchconnectionid === ConnectionId)) {
;
$scope.SPI.PackageType = $scope.lstconnectionid[i].vchtypeofpackage;
$scope.SPI.PackageTypeID = $scope.lstconnectionid[i].PackageTypeId;
$scope.SPI.vchconnectiontype = $scope.lstconnectionid[i].vchconnectiontype;
$scope.InstallationDate = ($scope.lstconnectionid[i].datInstallationDate);
//alert($scope.InstallationDate);
if ($scope.SPI.vchconnectiontype == "PREPAID") {
$scope.Freedatacontrls = true;
}
else {
$scope.Freedatacontrls = false;
$scope.freemopnthss = 0;
}
if ($scope.SPI.PackageType === "CABLE") {
$scope.isptype = false;
$scope.cabletype = true;
}
else if ($scope.SPI.PackageType === "ISP") {
$scope.isptype = true;
$scope.cabletype = false;
}
else if ($scope.SPI.PackageType === "COMBO") {
$scope.isptype = true;
$scope.cabletype = true;
}
}
}
var url = baseurl + "/CableTransactions/bindPackageDetails";
$http({ url: url, method: 'post', data: { PackageTypeID: $scope.SPI.PackageTypeID, connectionid: $scope.SPI.vchconnectionid, registrationid: $scope.SPI.vchregistrationid } }).success(function (data) {
if (data.length != 0) {
$scope.SubscribersPackagesList = data;
}
});
}
$scope.CalculateData();
}
$scope.getPackageDurationDetails = function () {
$scope.lstDuration = null;
//$scope.SPI.numnoofchannnels = null;
//$scope.SPI.vchgb = null;
//$scope.SPI.vchspeed = null;
//$scope.SPI.numamount = null;
//$scope.SPI.numTotalAmount = null;
//$scope.lstDuration = null;
$scope.SPI.chkFreeDiscountType = false;
$scope.SPI.Freemonth = null;
$scope.SPI.vchstbtype = "";
$scope.SPI.vchisptype = "";
$scope.SPI.vchpackagename = $.grep($scope.SubscribersPackagesList, function (c) {
return c.vchpackageid == $scope.SPI.vchpackageid;
})[0].vchpackagename;
var url = baseurl + "/CableTransactions/bindPackageDurationDetails";
$http({ url: url, method: 'post', data: { PackageId: $scope.SPI.vchpackageid, vchconnectiontype: $scope.SPI.vchconnectiontype } }).success(function (data) {
;
if (data.length != 0) {
$scope.lstDuration = data;
$scope.SPI.vchisptype = data[0].vchisptype;
$scope.SPI.vchstbtype = data[0].vchstbtype;
}
});
}
$scope.getAmtChannnelDetails = function () {
;
$scope.SPI.numDiscount = null;
$scope.SPI.chkDiscountType = false;
$scope.SPI.vchnarration = null;
$scope.SPI.numnoofchannnels = null;
$scope.SPI.vchgb = null;
$scope.SPI.vchspeed = null;
$scope.SPI.numamount = null;
$scope.SPI.numTotalAmount = null;
$scope.SPI.dataactivationdate = null;
$scope.SPI.datExpirydate = null;
var DurationId = $scope.SPI.numdurationid;
$scope.SPI.numduration = $.grep($scope.lstDuration, function (c) {
return c.numdurationid == $scope.SPI.numdurationid;
})[0].numduration;
if (($scope.lstDuration != null || $scope.lstDuration !== undefined)) {
for (var i = 0; i < $scope.lstDuration.length; i++) {
if (($scope.lstDuration[i].numdurationid === DurationId)) {
$scope.SPI.numnoofchannnels = $scope.lstDuration[i].numnoofchannnels;
$scope.SPI.vchgb = $scope.lstDuration[i].vchgb;
$scope.SPI.vchspeed = $scope.lstDuration[i].vchspeed;
var numamt = $scope.lstDuration[i].numamount;
$scope.SPI.numamount = $scope.CurrencyFormat(numamt);
}
}
}
$scope.CalculateData();
}
$scope.CalculateData = function () {
;
var pkgamtt = $scope.SPI.numamount;
if (pkgamtt == null || pkgamtt == undefined || pkgamtt == "" || pkgamtt == 0) {
pkgamtt = "0";
}
var pkgamout1 = pkgamtt.replace(/[^0-9\.]+/g, "");
var discountamount1 = $scope.SPI.numDiscount;
if (discountamount1 == null || discountamount1 == undefined || discountamount1 == "" || discountamount1==0) {
discountamount1 = "0";
}
var discountamount = discountamount1.replace(/[^0-9\.]+/g, "");
if (parseInt(discountamount) > 0 || parseInt(pkgamout1) > 0) {
if (parseInt(discountamount) > parseInt(pkgamout1)) {
//alert("Discount should not be Greater than or Equal to Total Amount");
$scope.SPI.alertdiscountamount = "Discount should be Less Than or Equal to Package Amount";
}
else {
$scope.SPI.alertdiscountamount = null;
//$scope.submitted = true;
//$scope.isFormValid = false;
}
var ttotlamt = $scope.SPI.numTotalAmount;
if (ttotlamt == null || ttotlamt == undefined || ttotlamt == "" || ttotlamt==0) {
ttotlamt = "0";
}
var ttotlamt1 = ttotlamt.replace(/[^0-9\.]+/g, "");;
if (parseInt(ttotlamt1) < 0) {
//alert("Total Amount should not be Less than or Equal to Zero");
$scope.SPI.alertTotalamount = "Total Amount should not be Less than Zero";
}
else {
$scope.SPI.alertTotalamount = null;
//$scope.submitted = true;
//$scope.isFormValid = false;
}
}
$scope.Finalresult = parseInt(pkgamout1) - parseInt(discountamount);
var fnres = $scope.Finalresult;
$scope.SPI.numTotalAmount = $scope.CurrencyFormat(fnres);
}
$scope.FreeMonthvalidate = function () {
;
$scope.freemopnthss = 0;
$scope.SPI.numduration = $.grep($scope.lstDuration, function (c) {
return c.numdurationid == $scope.SPI.numdurationid;
})[0].numduration;
$scope.duration = $scope.SPI.numduration;
$scope.activationdate = $scope.SPI.dataactivationdate;
$scope.freemopnthss = parseInt($scope.SPI.Freemonth);
if ($scope.SPI.Freemonth == "") {
$scope.freemopnthss = 0;
}
if ($scope.freemopnthss > $scope.duration) {
alert("Free Month Should Not be Greater Than Duration");
$scope.SPI.Freemonth = "";
$scope.freemopnthss = 0;
}
if ($scope.activationdate != null && $scope.activationdate != "" && $scope.activationdate != undefined) {
$scope.getActivationDate();
}
}
//****************** 2.Save Button Click *******************************//
$scope.SaveSubsriberPackageDetails = function (SPI) {
;
var Grid_data = $('#grdPackageDetails').jqGrid('getRowData');
for (i = 0; i < Grid_data.length; i++) {
var Amount1 = Grid_data[i].numTotalAmount;
if (Amount1 == null || Amount1 == undefined || Amount1 == "" || Amount1 == 0) {
Amount1 = "0";
}
var Amount2 = Amount1.replace(/[^0-9\.]+/g, "");
Grid_data[i].numTotalAmount = [];
Grid_data[i].numTotalAmount = Amount2;
var Amount11 = Grid_data[i].numamount;
if (Amount11 == null || Amount11 == undefined || Amount11 == "" || Amount11 == 0) {
Amount11 = "0";
}
var Amount22 = Amount11.replace(/[^0-9\.]+/g, "");
Grid_data[i].numamount = [];
Grid_data[i].numamount = Amount22;
//var t1 = Grid_data[i].numamount;
//var t2 = t1.replace(/[^0-9\.]+/g,"");
//Grid_data[i].numamount = [];
//Grid_data[i].numamount = t2;
//var t11 = Grid_data[i].numamount;
//var t22 = t11.replace(/[^0-9\.]+/g, "");
//Grid_data[i].numamount = [];
//Grid_data[i].numamount = t22;
}
if (Grid_data.length > 0) {
var ans = null;
var ans = confirm($rootScope.msgSave);
if (ans) {
var url = baseurl + "/CableTransactions/SaveSubscriberPackageInfoDetails";
$http.post(url, { objSubscriberPackageInfoDetails: Grid_data }).success(function (data) {
alert(data.Message);
if (data.transstatus) {
$scope.subscriberpackageinfo.$setPristine();
location.reload();
$scope.submitted = false;
$scope.isFormValid = false;
}
});
}
}
}
//****************** 2.Save Button Click *******************************//
//****************** 1.Add Button Click the Grid *******************************//
$scope.AddPackageDetailstoGrid = function (SPI) {
;
var checkScope = false;
var t1 = $scope.SPI.numamount;
if (t1 == null || t1 == undefined || t1 == "" || t1 == 0) {
t1 = "0";
}
var numamt = t1.replace(/[^0-9\.]+/g, "");
var t2 = $scope.SPI.numDiscount;
if (t2 == null || t2 == undefined || t2 == "" || t2 == "undefined" || t2==0) {
t2 = "0";
}
var numdisamt = t2.replace(/[^0-9\.]+/g, "");
if (parseInt(numdisamt) > 0 || parseInt(numamt) > 0) {
if (parseInt(numdisamt) > parseInt(numamt)) {
//alert("Discount should not be Greater than or Equal to Total Amount");
$scope.SPI.alertdiscountamount = "Discount should be Less Than or Equal to Package Amount";
//$scope.isFormValid = false;
checkScope = false;
}
else {
$scope.SPI.alertdiscountamount = null;
checkScope = true;
}
var talamt = $scope.SPI.numTotalAmount;
if (talamt == null || talamt == undefined || talamt == "" || talamt==0) {
talamt = "0";
}
var totalamtt = talamt.replace(/[^0-9\.]+/g, "");
if (parseInt(totalamtt) < 0) {
//alert("Total Amount should not be Less than or Equal to Zero");
$scope.SPI.alertTotalamount = "Total Amount should not be Less than Zero";
//$scope.isFormValid = false;
checkScope = false;
}
else {
$scope.SPI.alertTotalamount = null;
checkScope = true;
}
}
$scope.CalculateData();
$scope.submitted = true;
if ($scope.isFormValid && checkScope) {
;
var newrowid = 1;
var url = baseurl + "/CableTransactions/checkExistingPackageDetails";
$http.post(url, { vchconnectionid: $scope.SPI.vchconnectionid, vchpackageid: $scope.SPI.vchpackageid, registrationid: $scope.SPI.vchregistrationid }).success(function (data) {
;
if (data.Count > 0) {
alert(data.Message);
return false;
}
else {
if (jQuery("#grdPackageDetails").jqGrid('getRowData').length > 0) {
var rids = $('#grdPackageDetails').jqGrid('getDataIDs');
var Grid_data = $('#grdPackageDetails').jqGrid('getRowData');
for (var i = 0; i < Grid_data.length; i++) {
if (($scope.SPI.vchconnectionid == Grid_data[i].vchconnectionid) && ($scope.SPI.vchpackageid == Grid_data[i].vchpackageid) && ($scope.SPI.vchconnectiontype == Grid_data[i].vchconnectiontype) && ($scope.SPI.PackageType == Grid_data[i].PackageType)) {
alert("Details Already Existed");
return false;
}
}
var result = [];
for (var i = 0, l = rids.length; i < l; i++) result.push(+rids[i]);
newrowid = Math.max.apply(Math, result) + 1;
}
if ($scope.SPI.Freemonth == null || $scope.SPI.Freemonth == undefined || $scope.SPI.Freemonth == "") {
$scope.SPI.Freemonth = 0;
}
$('#grdPackageDetails').jqGrid("addRowData", newrowid, SPI, "last");
$scope.subscriberpackageinfo.$setPristine();
// $scope.SPI = {};
$scope.SPI.numnoofchannnels = null;
$scope.SPI.vchgb = null;
$scope.SPI.vchspeed = null;
$scope.SPI.numamount = null;
$scope.SPI.numTotalAmount = null;
$scope.SPI.numdurationid = null;
$scope.SPI.vchpackageid = null;
$scope.SPI.vchconnectionid = null;
$scope.SPI.vchconnectiontype = null;
$scope.SPI.PackageType = null;
$scope.SPI.vchnarration = null;
$scope.SPI.numDiscount = null;
$scope.SPI.numTotalAmount = null;
$scope.SPI.chkDiscountType = false;
$scope.SubscribersPackagesList = null;
$scope.lstDuration = null;
$scope.SPI.dataactivationdate = null;
$scope.SPI.datExpirydate = null;
$scope.SPI.vchisptype = null;
$scope.SPI.vchstbtype = null;
$scope.submitted = false;
$scope.isFormValid = false;
$scope.SPI.activationdate = null;
$scope.SPI.chkFreeDiscountType = false;
$scope.SPI.Freemonth = null;
}
});
}
}
$scope.ClearData = function () {
$scope.SPI.numnoofchannnels = null;
$scope.SPI.vchgb = null;
$scope.SPI.vchspeed = null;
$scope.SPI.numamount = null;
$scope.SPI.numTotalAmount = null;
$scope.SPI.numdurationid = null;
$scope.SPI.vchpackageid = null;
$scope.SPI.vchconnectionid = null;
$scope.SPI.vchconnectiontype = null;
$scope.SPI.PackageType = null;
$scope.SPI.vchnarration = null;
$scope.SPI.numDiscount = null;
$scope.SPI.numTotalAmount = null;
$scope.SPI.chkDiscountType = false;
$scope.SubscribersPackagesList = null;
$scope.lstDuration = null;
$scope.DatepickerEnableStatus();
}
$scope.ResetData = function () {
;
$scope.subscriberpackageinfo.$setPristine();
$scope.SPI = {};
location.reload();
$scope.submitted = false;
$scope.isFormValid = false;
}
//Package Details Grid -- Adding Temperory Rows to Grid
var Emptydata = [];
InitGrid(Emptydata);
function InitGrid(data) {
;
for (i = 0; i < data.length; i++) {
var Amount1 = data[i].numamount;
var Amount2 = $scope.CurrencyFormat(Amount1);
data[i].numamount = [];
data[i].numamount = Amount2;
var Amount11 = data[i].numTotalAmount;
var Amount22 = $scope.CurrencyFormat(Amount11);
data[i].numTotalAmount = [];
data[i].numTotalAmount = Amount22;
}
var grid_data = data;
var grid_selector = "#grdPackageDetails";
var pager_selector = "#grid-pagerPackageDetails";
//grid data refresh
jQuery(grid_selector).jqGrid('setGridParam', { datatype: 'local', data: grid_data }).trigger("reloadGrid");
//resize to fit page size
$(window).on('resize.jqGrid', function () {
$(grid_selector).jqGrid('setGridWidth', $(".page-content").width());
})
//resize on sidebar collapse/expand
var parent_column = $(grid_selector).closest('[class*="col-"]');
$(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
//setTimeout is for webkit only to give time for DOM changes and then redraw!!!
setTimeout(function () {
$(grid_selector).jqGrid('setGridWidth', parent_column.width());
}, 0);
}
})
jQuery(grid_selector).jqGrid({
data: grid_data,
datatype: "local",
height: 200,
rownumbers: true,
colModel: [
//{
// label: 'Action', width: 35, sortable: false, key: true, formatter: function (cellvalue, options, rowObject) {
// return "<button class='btn-grid' type='button' onclick='edit2(" + options.rowId + ");' ><i class='fa fa-pencil'></i><br/></button> ";
// }
//},
{ label: 'Date', name: 'datdate', width: 75, hidden: true },
{ label: 'Registration ID', name: 'vchregistrationid', width: 75, hidden: true },
{ label: 'Connection </br></br></br>ID', name: 'vchconnectionid', width: 75 },
{ label: 'Connection </br></br></br>Type', name: 'vchconnectiontype', width: 75 },
{ label: 'Type of </br></br></br>Package', name: 'PackageType', width: 75 },
{ label: 'Package Id', name: 'vchpackageid', width: 75, hidden: true },
{ label: 'Package </br></br></br>Name', name: 'vchpackagename', width: 75 },
{ label: 'Duration Id', name: 'numdurationid', width: 75, hidden: true },
{ label: 'Duration', name: 'numduration', width: 75 },
{ label: 'No.of Channels', name: 'numnoofchannnels', width: 90 },
{ label: 'GB/Month', name: 'vchgb', width: 90 },
{ label: 'Speed(MBPS)', name: 'numSpeed', width: 80 },
{ label: 'Package </br></br></br>Amount', name: 'numamount', width: 90, align: 'right' },
{ label: 'Description', name: 'vchnarration', width: 90, hidden: true },
{ label: 'Discount', name: 'numDiscount', width: 90, hidden: true },
{ label: 'TotalAmountAfterDiscount', name: 'numTotalAmount', width: 90, hidden: true },
{ label: 'DiscountStatus', name: 'chkDiscountType', width: 90, hidden: true },
{ label: 'Free Month', name: 'Freemonth', width: 90, hidden: true },
{ label: 'Free For EveryMonth', name: 'chkFreeDiscountType', width: 90, hidden: true },
{ label: 'Activation Date', name: 'dataactivationdate', width: 90 },
{ label: 'Expiry Date', name: 'datExpirydate', width: 90 },
],
viewrecords: true,
rowNum: 8,
rowList: [8, 16, 25, 100],
pager: pager_selector,
altRows: true,
search: true,
ignoreCase: true,
loadComplete: function (id) {
var table = this;
setTimeout(function () {
styleCheckbox(table);
updateActionIcons(table);
updatePagerIcons(table);
enableTooltips(table);
}, 0);
},
caption: "ADD PACKAGE DETAILS <span class='input-icon grid-search'> <input type='text' onkeyup='Search()' id='globalSearchText' placeholder='Search ...' class='nav-search-input' autocomplete='off'> <i class='ace-icon fa fa-search nav-search-icon'></i></span> "
});
$(window).triggerHandler('resize.jqGrid');
}
//****************** GET PACKAGE TYPES *******************************//
$scope.GetPackagesDetails = function () {
var url = baseurl + "/CableTransactions/GetPackageTypes";
$http({ url: url, method: 'Get' }).success(function (data) {
if (data.length != 0) {
$scope.packagetypes = data;
}
});
}
//****************** GET PACKAGE TYPES *******************************//
$scope.Selectpackagetype = function (c) {
var SelectedPackageis = $scope.SPI.packagetype;
var url = baseurl + "/CableTransactions/GetSelectedPackageDetails";
$http.post(url, { SPI: SelectedPackageis }).success(function (data) {
if (data != 0) {
$scope.lstpackagename = data;
}
else {
$scope.lstpackagename = {};
}
}).error(function (data) {
alert("Select Type of Package");
});
}
//Load Grid
$scope.GetPageLoaddata = function () {
var url = baseurl + "/CableTransactions/getSubscriberPackageInfoGrid";
$http.get(url).success(function (data) {
;
if (data != null) {
CableSTBROUTERDetailsGridBinding(data);
}
else {
var empty = [];
CableSTBROUTERDetailsGridBinding(empty);
}
}).error(function (data) {
alert("Error found");
});
}
//save data to init grid
var mydata = [];
$scope.SaveInitdata = function (SPI) {
$scope.submitted = true;
if ($scope.isFormValid) {
var myDataPromise = myService.getData(SPI);
myDataPromise.then(function (result) {
var beforesave = result;
if ($scope.btnInitSave == "Add") {
if (beforesave == 0) {
mydata = $('#grdPackageDetails').jqGrid('getGridParam', 'data');
var check = checkdataingrid(mydata);
if (check == false) {
mydata.push(SPI);
InitGrid(mydata);
}
} else {
alert("Details Already Exist ..!");
}
}
if ($scope.btnInitSave == "Update") {
if (beforesave == 0 || $scope.btnSave == "Update") {
mydata = $('#grdPackageDetails').jqGrid('getGridParam', 'data');
var check = upadatedataingrid(mydata);
if (check == false) {
var myGrid = $("#grdPackageDetails");
var selRowId = myGrid.jqGrid('getGridParam', 'selrow');
var oldData = myGrid.jqGrid('getRowData', selRowId);
delete SPI["undefined"];
myGrid.jqGrid('setRowData', selRowId, SPI);
mydata = $('#grdPackageDetails').jqGrid('getGridParam', 'data');
}
}
$scope.editdisable = false;
}
ClearAdd();
});
}
}
//update data to init grid
function upadatedataingrid(data) {
var result = false;
if ($scope.btnSave == "Save") {
var count = 0;
var count2 = 0;
if (data.length != 0) {
for (var item in data) {
var subcatname = data[item].subcatname;
var Router = data[item].Router;
var vchpackagetype = data[item].vchpackagetype;
if (subcatname != undefined && subcatname.toString() === $scope.STBR.subcatname && vchpackagetype.toString() === $scope.STBR.vchpackagetype) {
count++;
} else if (Router != undefined && Router.toString() === $scope.STBR.Router && vchpackagetype.toString() === $scope.STBR.vchpackagetype) {
count2++;
}
}
var myGrid = $("#grdPackageDetails");
var selRowId = myGrid.jqGrid('getGridParam', 'selrow');
var oldData = myGrid.jqGrid('getRowData', selRowId);
if (count == 1 && subcatname != undefined && $scope.STBR.subcatname == oldData.subcatname && $scope.STBR.vchpackagetype == oldData.vchpackagetype) {
result = false;
} else if (count2 == 1 && Router != undefined && $scope.STBR.Router == oldData.Router && $scope.STBR.vchpackagetype == oldData.vchpackagetype) {
result = false;
} else {
alert("Details Already Exist In Grid !");
result = true;
}
}
else
result = false;
}
return result;
}
//checking duplicate data in grid
function checkdataingrid(data) {
var result = false;
if (data.length != 0) {
for (var item in data) {
var subcatname = data[item].subcatname;
var Router = data[item].Router;
if (subcatname != undefined && subcatname === $scope.STBR.subcatname) {
alert("Subcategory Details Already Exist In Grid !");
result = true;
break;
}
else if (Router != undefined && Router === $scope.STBR.Router) {
alert("Router Details Already Exist In Grid !");
result = true;
break;
}
}
}
else
result = false;
return result;
}
//for load data in init grid after edit
$scope.LoadPackageData = function (data) {
InitGrid(data);
}
//MAIN loadGrid
function CableSTBROUTERDetailsGridBinding(data) {
;
for (i = 0; i < data.length; i++) {
var Amount1 = data[i].numTotalAmount;
var Amount2 = $scope.CurrencyFormat(Amount1);
data[i].numTotalAmount = [];
data[i].numTotalAmount = Amount2;
var Amount11 = data[i].packageamount;
var Amount22 = $scope.CurrencyFormat(Amount11);
data[i].packageamount = [];
data[i].packageamount = Amount22;
var Amount111 = data[i].discountamount;
var Amount222 = $scope.CurrencyFormat(Amount111);
data[i].discountamount = [];
data[i].discountamount = Amount222;
//var t1 = data[i].discountamount;
//var t2 = $scope.CurrencyFormat(t1);
//data[i].discountamount = [];
//data[i].discountamount = t2;
//var Amount111 = data[i].discountamount;
//var Amount222 = $scope.CurrencyFormat(Amount111);
//data[i].discountamount = [];
//data[i].discountamount = Amount222;
}
var grid_data = data;
var grid_selector = "#MainGridPackageDetails";
var pager_selector = "#grid-pagerMainPackageDetails";
//grid data refresh
jQuery(grid_selector).jqGrid('setGridParam', { datatype: 'local', data: grid_data }).trigger("reloadGrid");
//resize to fit page size
$(window).on('resize.jqGrid', function () {
$(grid_selector).jqGrid('setGridWidth', $(".page-content").width());
})
//resize on sidebar collapse/expand
var parent_column = $(grid_selector).closest('[class*="col-"]');
$(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
//setTimeout is for webkit only to give time for DOM changes and then redraw!!!
setTimeout(function () {
$(grid_selector).jqGrid('setGridWidth', parent_column.width());
}, 0);
}
})
jQuery(grid_selector).jqGrid({
data: grid_data,
datatype: "local",
height: 290,
autowidth: true,
rownumbers: true,
colModel: [
{ label: 'Registration Id', name: 'vchregistrationid', width: 35 },
{ label: 'Name', name: 'vchsubscribername', width: 70 },
{ label: 'Mobile No.', name: 'vchmobilenumber', width: 50 },
{ label: 'Connection Id', name: 'vchconnectionid', width: 50 },
{ label: 'Connection Type', name: 'connectiontype', width: 50 },
{ label: 'Package Name', name: 'packagename', width: 50 },
{ label: 'Total Amount', name: 'numTotalAmount', width: 50, align: 'right' },
{ label: '', name: 'datactivationdate', width: 50, hidden: true },
{ label: '', name: 'stbtype', width: 50, hidden: true },
{ label: '', name: 'numnoofchannnels', width: 50, hidden: true },
{ label: '', name: 'vchisptype', width: 50, hidden: true },
{ label: '', name: 'vchgb', width: 50, hidden: true },
{ label: '', name: 'speed', width: 50, hidden: true },
{ label: '', name: 'gblimit', width: 50, hidden: true },
{ label: '', name: 'reducedspeed', width: 50, hidden: true },
{ label: '', name: 'numduration', width: 50, hidden: true },
{ label: '', name: 'packageamount', width: 50, hidden: true },
{ label: '', name: 'discountamount', width: 50, hidden: true },
{ label: '', name: 'discounteverymonth', width: 50, hidden: true },
{ label: '', name: 'packagetype', width: 50, hidden: true },
{ label: '', name: 'activationdatee', width: 50, hidden: true },
{ label: '', name: 'expairydatee', width: 50, hidden: true },
{ label: 'freeduration', name: 'numfremonth', width: 50, hidden: true },
{ label: 'freedurationeverymonth', name: 'vchfreeeverymonth', width: 50, hidden: true },
{
label: ' ', width: 5, sortable: false, width: 30, formatter: function (cellvalue, options, rowObject) {
return "<button class='btn-grid' type='button' id='btnEdit' onclick='ViewRow(" + options.rowId + ");' ><i class='fa fa-eye'></i><span style='color:#111; font-size:14px; font-weight:400;'>View</span><br/> ";
}
}],
viewrecords: true,
rowNum: 8,
rowList: [8, 16, 25, 100],
pager: pager_selector,
altRows: true,
search: true,
ignoreCase: true,
loadComplete: function (id) {
var table = this;
setTimeout(function () {
styleCheckbox(table);
updateActionIcons(table);
updatePagerIcons(table);
enableTooltips(table);
}, 0);
},
caption: "SUBSCRIBER PAKCAGE INFO <span class='input-icon grid-search'> <input type='text' onkeyup='SearchSTBR()' id='globalSTBRSearchText' placeholder='Search ...' class='nav-search-input' autocomplete='off'> <i class='ace-icon fa fa-search nav-search-icon'></i></span> "
});
$(window).triggerHandler('resize.jqGrid');
}
$scope.SetCurrency = function (instalamt) {
;
var amount = 0;
var amtt = instalamt;
if (amtt == null || amtt == undefined || amtt == "" || amtt == 0) {
amtt = "0";
}
amount = amtt.replace(/[^0-9\.]+/g, "");
$scope.SPI.numDiscount = $scope.CurrencyFormat(amount);
}
$scope.CurrencyFormat = function (nStr) {
;
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
var z = 0;
var len = String(x1).length;
var num = parseInt((len / 2) - 1);
while (rgx.test(x1)) {
if (z > 0) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
else {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
rgx = /(\d+)(\d{2})/;
}
z++;
num--;
if (num == 0) {
break;
}
}
return x1 + x2;
}
});