More subscription license work
This commit is contained in:
@@ -13,18 +13,19 @@
|
||||
/*global $, app */
|
||||
|
||||
app.ravLicense = (function () {
|
||||
"use strict";
|
||||
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
|
||||
var stateMap = {},
|
||||
configModule,
|
||||
initModule,
|
||||
onGenerate,
|
||||
onRevoke;
|
||||
//----------------- END MODULE SCOPE VARIABLES ---------------
|
||||
"use strict";
|
||||
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
|
||||
var stateMap = {},
|
||||
configModule,
|
||||
initModule,
|
||||
onGenerate,
|
||||
onRevoke,
|
||||
onPerpetualChanged;
|
||||
//----------------- END MODULE SCOPE VARIABLES ---------------
|
||||
|
||||
//------------------- BEGIN UTILITY METHODS ------------------
|
||||
//-------------------- END UTILITY METHODS -------------------
|
||||
/*
|
||||
//------------------- BEGIN UTILITY METHODS ------------------
|
||||
//-------------------- END UTILITY METHODS -------------------
|
||||
/*
|
||||
public class dtoRavLicense
|
||||
{
|
||||
[Required]
|
||||
@@ -55,165 +56,195 @@ app.ravLicense = (function () {
|
||||
|
||||
*/
|
||||
|
||||
//------------------- BEGIN EVENT HANDLERS -------------------
|
||||
onGenerate = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish("app-clear-error");
|
||||
//get form data
|
||||
var formData = $("form").serializeArray({
|
||||
checkboxesAsBools: true
|
||||
});
|
||||
//------------------- BEGIN EVENT HANDLERS -------------------
|
||||
onGenerate = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish("app-clear-error");
|
||||
//get form data
|
||||
var formData = $("form").serializeArray({
|
||||
checkboxesAsBools: true
|
||||
});
|
||||
|
||||
var submitData = app.utilB.objectifyFormDataArray(formData);
|
||||
//do features separately, above can't deal with multi select and we need to add schedtechs anyway
|
||||
let features = [];
|
||||
features.push({
|
||||
Feature: "ServiceTechs",
|
||||
Count: Number($("#techcount").val())
|
||||
});
|
||||
let options = $("#options").val();
|
||||
var submitData = app.utilB.objectifyFormDataArray(formData);
|
||||
//do features separately, above can't deal with multi select and we need to add schedtechs anyway
|
||||
let features = [];
|
||||
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
features.push({ Feature: options[i], Count: 0 });
|
||||
}
|
||||
if ($("#perpetual").prop("checked")) {
|
||||
features.push({
|
||||
Feature: "ServiceTechs",
|
||||
Count: Number($("#techcount").val())
|
||||
});
|
||||
} else {
|
||||
features.push({
|
||||
Feature: "ActiveInternalUsers",
|
||||
Count: Number($("#subusercount").val())
|
||||
});
|
||||
|
||||
submitData["features"] = features;
|
||||
//submit
|
||||
// alert("STUB submit");
|
||||
app.api.createRavLicense(submitData, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
page(
|
||||
"#!/ravLicenses/" +
|
||||
stateMap.id +
|
||||
"/" +
|
||||
stateMap.context.params.cust_id
|
||||
features.push({
|
||||
Feature: "ActiveCustomerUsers",
|
||||
Count: Number($("#subcustcount").val())
|
||||
});
|
||||
}
|
||||
|
||||
let options = $("#options").val();
|
||||
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
features.push({ Feature: options[i], Count: 0 });
|
||||
}
|
||||
|
||||
submitData["features"] = features;
|
||||
//submit
|
||||
// alert("STUB submit");
|
||||
app.api.createRavLicense(submitData, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
page(
|
||||
"#!/ravLicenses/" +
|
||||
stateMap.id +
|
||||
"/" +
|
||||
stateMap.context.params.cust_id
|
||||
);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return false; //prevent default
|
||||
};
|
||||
|
||||
onRevoke = function (event) {
|
||||
event.preventDefault();
|
||||
$("#registeredTo").val("REVOKED");
|
||||
$("#licenseExpires").prop("checked", true);
|
||||
var yesterday = moment().add(-1, "days").toISOString().substring(0, 10);
|
||||
$('input[type="date"]').val(yesterday);
|
||||
|
||||
return false; //prevent default
|
||||
};
|
||||
|
||||
onPerpetualChanged = function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
$("#perpettechcountblock").toggleClass("d-none");
|
||||
$("#subusercountblock").toggleClass("d-none");
|
||||
$("#subcustcountblock").toggleClass("d-none");
|
||||
return false; //prevent default
|
||||
};
|
||||
|
||||
// onSelectAllAddOns = function (event) {
|
||||
// event.preventDefault();
|
||||
// $('#wbi').prop('checked', true);
|
||||
// $('#mbi').prop('checked', true);
|
||||
// $('#ri').prop('checked', true);
|
||||
// $('#qbi').prop('checked', true);
|
||||
// $('#qboi').prop('checked', true);
|
||||
// $('#pti').prop('checked', true);
|
||||
// $('#quickNotification').prop('checked', true);
|
||||
// $('#exportToXls').prop('checked', true);
|
||||
// $('#outlookSchedule').prop('checked', true);
|
||||
// $('#oli').prop('checked', true);
|
||||
// $('#importExportCSVDuplicate').prop('checked', true);
|
||||
|
||||
// return false; //prevent default
|
||||
// };
|
||||
|
||||
// onTemplates = function(event) {
|
||||
// event.preventDefault();
|
||||
// alert("STUB: templates");
|
||||
|
||||
// return false; //prevent default
|
||||
// };
|
||||
|
||||
//-------------------- END EVENT HANDLERS --------------------
|
||||
|
||||
//------------------- BEGIN PUBLIC METHODS -------------------
|
||||
//CONFIGMODULE
|
||||
//
|
||||
configModule = function (context) {
|
||||
stateMap.context = context.context;
|
||||
if (stateMap.context.params.id) {
|
||||
stateMap.id = stateMap.context.params.id;
|
||||
}
|
||||
};
|
||||
|
||||
//INITMODULE
|
||||
//
|
||||
initModule = function ($container) {
|
||||
if (typeof $container === "undefined") {
|
||||
$container = $("#app-shell-main-content");
|
||||
}
|
||||
$container.html(Handlebars.templates["app.ravLicense"]({}));
|
||||
|
||||
///ravLicense/:id
|
||||
//id is always site id and this form is only to make a new license, not to view one
|
||||
|
||||
//case 3233 customer list
|
||||
//Fill customer list combo
|
||||
// var customerList = {};
|
||||
|
||||
//get company name to pre-fill regto
|
||||
//api/site/77/name
|
||||
|
||||
app.api.get("site/" + stateMap.id + "/newlicenseinfo", function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
$("#registeredTo").val(res.name);
|
||||
$("#dbId").val(res.dbid);
|
||||
}
|
||||
});
|
||||
|
||||
//Context menu
|
||||
app.nav.contextClear();
|
||||
|
||||
////app.nav.setContextTitle("License");
|
||||
|
||||
//make context menu
|
||||
|
||||
//Context menu
|
||||
app.nav.contextClear();
|
||||
app.nav.contextAddButton(
|
||||
"btn-generate",
|
||||
"Generate and Send",
|
||||
"key",
|
||||
onGenerate
|
||||
);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return false; //prevent default
|
||||
};
|
||||
// app.nav.contextAddButton('btn-select-all-addons', 'All', 'check-all', onSelectAllAddOns);
|
||||
// app.nav.contextAddLink("licenseRequests/", "Requests", "voice");
|
||||
// app.nav.contextAddLink("licenseTemplates/", "", "layers");
|
||||
//case 3233
|
||||
|
||||
onRevoke = function (event) {
|
||||
event.preventDefault();
|
||||
$("#registeredTo").val("REVOKED");
|
||||
$("#licenseExpires").prop("checked", true);
|
||||
var yesterday = moment().add(-1, "days").toISOString().substring(0, 10);
|
||||
$('input[type="date"]').val(yesterday);
|
||||
app.nav.contextAddLink(
|
||||
"ravLicenses/" +
|
||||
stateMap.id +
|
||||
"/" +
|
||||
stateMap.context.params.cust_id,
|
||||
"Licenses",
|
||||
"ticket"
|
||||
); //from here to new license
|
||||
|
||||
return false; //prevent default
|
||||
};
|
||||
app.nav.contextAddButton("btn-revoke", "Revoke", "nuke", onRevoke);
|
||||
|
||||
// onSelectAllAddOns = function (event) {
|
||||
// event.preventDefault();
|
||||
// $('#wbi').prop('checked', true);
|
||||
// $('#mbi').prop('checked', true);
|
||||
// $('#ri').prop('checked', true);
|
||||
// $('#qbi').prop('checked', true);
|
||||
// $('#qboi').prop('checked', true);
|
||||
// $('#pti').prop('checked', true);
|
||||
// $('#quickNotification').prop('checked', true);
|
||||
// $('#exportToXls').prop('checked', true);
|
||||
// $('#outlookSchedule').prop('checked', true);
|
||||
// $('#oli').prop('checked', true);
|
||||
// $('#importExportCSVDuplicate').prop('checked', true);
|
||||
//set all date inputs to today plus one year
|
||||
var oneYearFromNow = moment()
|
||||
.add(1, "years")
|
||||
.toISOString()
|
||||
.substring(0, 10);
|
||||
$('input[type="date"]').val(oneYearFromNow);
|
||||
$("#siteId").val(stateMap.id);
|
||||
|
||||
// return false; //prevent default
|
||||
// };
|
||||
//var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10);
|
||||
//$('#lockoutDate').val(oneMonthFromNow);
|
||||
// bind actions
|
||||
$("#btn-revoke").bind("click", onRevoke);
|
||||
$("#perpetual").bind("change", onPerpetualChanged);
|
||||
};
|
||||
|
||||
// onTemplates = function(event) {
|
||||
// event.preventDefault();
|
||||
// alert("STUB: templates");
|
||||
|
||||
// return false; //prevent default
|
||||
// };
|
||||
|
||||
//-------------------- END EVENT HANDLERS --------------------
|
||||
|
||||
//------------------- BEGIN PUBLIC METHODS -------------------
|
||||
//CONFIGMODULE
|
||||
//
|
||||
configModule = function (context) {
|
||||
stateMap.context = context.context;
|
||||
if (stateMap.context.params.id) {
|
||||
stateMap.id = stateMap.context.params.id;
|
||||
}
|
||||
};
|
||||
|
||||
//INITMODULE
|
||||
//
|
||||
initModule = function ($container) {
|
||||
if (typeof $container === "undefined") {
|
||||
$container = $("#app-shell-main-content");
|
||||
}
|
||||
$container.html(Handlebars.templates["app.ravLicense"]({}));
|
||||
|
||||
///ravLicense/:id
|
||||
//id is always site id and this form is only to make a new license, not to view one
|
||||
|
||||
//case 3233 customer list
|
||||
//Fill customer list combo
|
||||
// var customerList = {};
|
||||
|
||||
//get company name to pre-fill regto
|
||||
//api/site/77/name
|
||||
|
||||
app.api.get("site/" + stateMap.id + "/newlicenseinfo", function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
$("#registeredTo").val(res.name);
|
||||
$("#dbId").val(res.dbid);
|
||||
}
|
||||
});
|
||||
|
||||
//Context menu
|
||||
app.nav.contextClear();
|
||||
|
||||
////app.nav.setContextTitle("License");
|
||||
|
||||
//make context menu
|
||||
|
||||
//Context menu
|
||||
app.nav.contextClear();
|
||||
app.nav.contextAddButton(
|
||||
"btn-generate",
|
||||
"Generate and Send",
|
||||
"key",
|
||||
onGenerate
|
||||
);
|
||||
// app.nav.contextAddButton('btn-select-all-addons', 'All', 'check-all', onSelectAllAddOns);
|
||||
// app.nav.contextAddLink("licenseRequests/", "Requests", "voice");
|
||||
// app.nav.contextAddLink("licenseTemplates/", "", "layers");
|
||||
//case 3233
|
||||
|
||||
app.nav.contextAddLink(
|
||||
"ravLicenses/" + stateMap.id + "/" + stateMap.context.params.cust_id,
|
||||
"Licenses",
|
||||
"ticket"
|
||||
); //from here to new license
|
||||
|
||||
//set all date inputs to today plus one year
|
||||
var oneYearFromNow = moment()
|
||||
.add(1, "years")
|
||||
.toISOString()
|
||||
.substring(0, 10);
|
||||
$('input[type="date"]').val(oneYearFromNow);
|
||||
$("#siteId").val(stateMap.id);
|
||||
|
||||
//var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10);
|
||||
//$('#lockoutDate').val(oneMonthFromNow);
|
||||
// bind actions
|
||||
$("#btn-revoke").bind("click", onRevoke);
|
||||
};
|
||||
|
||||
// return public methods
|
||||
return {
|
||||
configModule: configModule,
|
||||
initModule: initModule
|
||||
};
|
||||
//------------------- END PUBLIC METHODS ---------------------
|
||||
// return public methods
|
||||
return {
|
||||
configModule: configModule,
|
||||
initModule: initModule
|
||||
};
|
||||
//------------------- END PUBLIC METHODS ---------------------
|
||||
})();
|
||||
|
||||
@@ -2,82 +2,141 @@
|
||||
<form id="frm" method="post" action="index.html">
|
||||
<div class="row">
|
||||
|
||||
<input id="siteId" name="siteId" type="hidden" value="">
|
||||
<input id="siteId" name="siteId" type="hidden" value="" />
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="registeredTo">Registered to</label>
|
||||
<input class="form-control" type="text" id="registeredTo" name="registeredTo" value="">
|
||||
<input
|
||||
class="form-control"
|
||||
type="text"
|
||||
id="registeredTo"
|
||||
name="registeredTo"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="dbId">dbId</label>
|
||||
<input class="form-control" type="text" id="dbId" name="dbId" value="">
|
||||
<input
|
||||
class="form-control"
|
||||
type="text"
|
||||
id="dbId"
|
||||
name="dbId"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="maintenanceExpirationDate">Support expires</label>
|
||||
<input class="form-control" type="date" id="maintenanceExpirationDate"
|
||||
name="maintenanceExpirationDate" value="">
|
||||
<input
|
||||
class="form-control"
|
||||
type="date"
|
||||
id="maintenanceExpirationDate"
|
||||
name="maintenanceExpirationDate"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label" for="licenseExpires">
|
||||
<input class="form-check-input" type="checkbox" name="licenseExpires" id="licenseExpires">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
name="licenseExpires"
|
||||
id="licenseExpires"
|
||||
/>
|
||||
Temporary key / expires
|
||||
</label>
|
||||
<input class="form-control" type="date" id="licenseExpirationDate" name="licenseExpirationDate"
|
||||
value="">
|
||||
<input
|
||||
class="form-control"
|
||||
type="date"
|
||||
id="licenseExpirationDate"
|
||||
name="licenseExpirationDate"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="techcount">Scheduleable users</label>
|
||||
<input class="form-control" type="number" id="techcount" name="techcount" value="1">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label" for="perpetual">
|
||||
<input class="form-check-input" type="checkbox" name="perpetual" id="perpetual">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
name="perpetual"
|
||||
id="perpetual"
|
||||
/>
|
||||
Perpetual license
|
||||
</label>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div id="perpettechcountblock" class="col-sm-6 d-none">
|
||||
<div class="form-group">
|
||||
<label for="registeredTo">Subscription: 100 block Customer contacts</label>
|
||||
<input class="form-control" type="number" id="subcustcount" name="subcustcount" value="1">
|
||||
<label for="techcount">Scheduleable users</label>
|
||||
<input
|
||||
class="form-control"
|
||||
type="number"
|
||||
id="techcount"
|
||||
name="techcount"
|
||||
value="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="subusercountblock" class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="subusercount">Internal users</label>
|
||||
<input
|
||||
class="form-control"
|
||||
type="number"
|
||||
id="subusercount"
|
||||
name="subusercount"
|
||||
value="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="subcustcountblock" class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="registeredTo">Customer users</label>
|
||||
<input
|
||||
class="form-control"
|
||||
type="number"
|
||||
id="subcustcount"
|
||||
name="subcustcount"
|
||||
value="100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="options">Additional features</label>
|
||||
<select class="form-control" name="options" id="options" multiple>
|
||||
<select
|
||||
class="form-control"
|
||||
name="options"
|
||||
id="options"
|
||||
multiple
|
||||
>
|
||||
<option value="TrialMode">TrialMode</option>
|
||||
<option value="XXXXX">XXXXX</option>
|
||||
<option value="XXXXXX">XXXXXX</option>
|
||||
<option value="future1">future1</option>
|
||||
<option value="future2">future2</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="app-frm-buttons">
|
||||
{{!-- <div class="app-frm-buttons">
|
||||
<button id="btn-revoke" class="btn btn-warning">Revoke</button>
|
||||
</div>
|
||||
</div> --}}
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user