393 lines
16 KiB
Plaintext
393 lines
16 KiB
Plaintext
<%@ Page Title="" Language="C#" MasterPageFile="~/Security/Security.master" AutoEventWireup="true" CodeFile="AddJobsiteLimit.aspx.cs" Inherits="AddCurfew" %>
|
|
|
|
|
|
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
|
|
<style type="text/css">
|
|
::-ms-clear, ::-ms-reveal {
|
|
display: none;
|
|
}
|
|
|
|
.edit-content table {
|
|
border-collapse: collapse;
|
|
width: 100%;
|
|
}
|
|
|
|
.edit-content table td.label {
|
|
width: 200px;
|
|
text-align: right;
|
|
padding-right: 10px;
|
|
line-height: 24px;
|
|
height: 24px;
|
|
vertical-align: top;
|
|
}
|
|
|
|
.edit-content table td input,
|
|
.edit-content table td textarea {
|
|
border: 1px solid #a9a9a9;
|
|
width: 320px;
|
|
height: 18px;
|
|
padding: 1px;
|
|
}
|
|
|
|
.edit-content table td input[type="checkbox"] {
|
|
border: none;
|
|
height: 13px;
|
|
}
|
|
|
|
.edit-content table td textarea {
|
|
height: 150px;
|
|
resize: none;
|
|
width: 600px;
|
|
/*max-width: 200px;*/
|
|
}
|
|
|
|
.a {
|
|
text-decoration: none;
|
|
color: #2140fb;
|
|
}
|
|
|
|
.subtitle {
|
|
margin: 20px 40px 5px 0px;
|
|
font-size: 16px;
|
|
color: gray;
|
|
}
|
|
|
|
.subtitle span {
|
|
margin-left: 10px;
|
|
}
|
|
|
|
.subtitle hr {
|
|
background-color: #d8d8d8;
|
|
border: none;
|
|
height: 1px;
|
|
}
|
|
|
|
|
|
.machinetd {
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.timespan {
|
|
margin-left: 16px;
|
|
margin-right: 8px;
|
|
}
|
|
|
|
.div_filter .dropdown {
|
|
width: 322px;
|
|
margin: 2px 0 0 0px;
|
|
}
|
|
|
|
.div_panel {
|
|
min-width: 322px;
|
|
}
|
|
</style>
|
|
|
|
<script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script>
|
|
<script type="text/javascript">
|
|
var IsDealer = <%=IsDealer ?"true":"false"%>;
|
|
var contractorid;
|
|
var machinetypes;
|
|
var editmultiselect_type;
|
|
var assettypeparam;
|
|
|
|
jobsitelimitquery = function (method, param, callback, error, nolog) {
|
|
_network.request("JobSite/AddJobsiteLimit.aspx", -1, method, param, callback, error || function (e) {
|
|
showAlert(GetTextByKey("P_M3_FAILEDTOLOADDATA", 'Failed to load data: {0}').replace('{0}', e.statusText), GetTextByKey("P_M3_SCHEDULEASSETS", 'Schedule Assets'));
|
|
});
|
|
}
|
|
|
|
function devicerequest(method, param, callback, error) {
|
|
_network.request("MachineDeviceManagement/ManageMachines.aspx", -1, method, param, callback, error || function (e) {
|
|
console.log(e);
|
|
showmaskbg(false, true);
|
|
showAlert(GetTextByKey('P_M3_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_M3_QUERY', 'Query'));
|
|
});
|
|
}
|
|
|
|
function trim_str(s) {
|
|
if (s == null)
|
|
return "";
|
|
else
|
|
return s.replace(/(^\s*)|(\s*$)/g, "");
|
|
}
|
|
|
|
function OnAdd() {
|
|
jlid = undefined;
|
|
$('#dialog_jobsite').val('');
|
|
$('#dialog_active').prop('checked', true);
|
|
$('#dialog_starttimehour').val('00');
|
|
$('#dialog_starttimeminute').val('00');
|
|
$('#dialog_endtimehour').val('00');
|
|
$('#dialog_endtimeminute').val('00');
|
|
$('#dialog_mintrucks').val('');
|
|
$('#dialog_maxtrucks').val('');
|
|
if (editmultiselect_type)
|
|
editmultiselect_type.setValues([]);
|
|
$('#dialog_notes').val('');
|
|
}
|
|
|
|
function OnEdit() {
|
|
$('#dialog_jobsite').val(jobsitelimit.JobSiteID);
|
|
$('#dialog_active').prop('checked', jobsitelimit.Active.Value);
|
|
var st = jobsitelimit.StartTime.split(':');
|
|
$('#dialog_starttimehour').val(st[0]);
|
|
$('#dialog_starttimeminute').val(st[1]);
|
|
var et = jobsitelimit.EndTime.split(':');
|
|
$('#dialog_endtimehour').val(et[0]);
|
|
$('#dialog_endtimeminute').val(et[1]);
|
|
$('#dialog_mintrucks').val(jobsitelimit.MinTrucks);
|
|
$('#dialog_maxtrucks').val(jobsitelimit.MaxTrucks);
|
|
var types = [];
|
|
types = jobsitelimit.AssetTypes.split(',');
|
|
if (assettypeparam)
|
|
editmultiselect_type.setValues(types);
|
|
$('#dialog_notes').val(jobsitelimit.Notes);
|
|
}
|
|
|
|
var IsPositiveInteger = /^[0-9]\d*$/;
|
|
function OnSave(exit) {
|
|
var start_hour = $('#dialog_starttimehour').val();
|
|
var start_minute = $('#dialog_starttimeminute').val();
|
|
var end_hour = $('#dialog_endtimehour').val();
|
|
var end_minute = $('#dialog_endtimeminute').val();
|
|
var typeary = [];
|
|
if (assettypeparam)
|
|
typeary = assettypeparam.selectedvalue;
|
|
var assettypes = typeary.join(',');
|
|
var item = {
|
|
'JobSiteID': $('#dialog_jobsite').val(),
|
|
'Active': $('#dialog_active').prop('checked'),
|
|
'StartTime': start_hour + ":" + start_minute,
|
|
'EndTime': end_hour + ":" + end_minute,
|
|
'MinTrucks': $.trim($('#dialog_mintrucks').val()),
|
|
'MaxTrucks': $.trim($('#dialog_maxtrucks').val()),
|
|
'AssetTypes': assettypes,
|
|
'Notes': $('#dialog_notes').val()
|
|
};
|
|
|
|
var alerttitle;
|
|
if (jlid) {
|
|
item.ID = jlid;
|
|
alerttitle = GetTextByKey("P_M3_EDITJOBSITELIMITCONFIGURATION", "Edit Jobsite Limit Configuration");
|
|
} else {
|
|
item.ID = -1;
|
|
alerttitle = GetTextByKey("P_M3_ADDJOBSITELIMITCONFIGURATION", "Add Jobsite Limit Configuration");
|
|
}
|
|
|
|
if ((start_hour + start_minute) >= (end_hour + end_minute)) {
|
|
showAlert(GetTextByKey("P_M3_ENDTIMEMUSTBELATERTHANSTARTTIME", "End Time must be later than Start Time."), alerttitle);
|
|
return;
|
|
}
|
|
if (item.MinTrucks !== "" && !IsPositiveInteger.test(item.MinTrucks)) {
|
|
showAlert(GetTextByKey("P_M3_ACCEPTABLEMINIMUMTRUCKSFORMATERROR", 'Acceptable minimum trucks format error.'), alerttitle);
|
|
return;
|
|
}
|
|
if (item.MaxTrucks !== "" && !IsPositiveInteger.test(item.MaxTrucks)) {
|
|
showAlert(GetTextByKey("P_M3_ACCEPTABLEMAXIMUMTRUCKSFORMATERROR", 'Acceptable maximum trucks format error.'), alerttitle);
|
|
return;
|
|
}
|
|
|
|
if (item.MinTrucks === "")
|
|
item.MinTrucks = 0;
|
|
if (item.MaxTrucks === "")
|
|
item.MaxTrucks = 0;
|
|
|
|
if (parseInt(item.MinTrucks) > parseInt(item.MaxTrucks)) {
|
|
showAlert(GetTextByKey("P_M3_ACCEPTABLEMAXIMUMTRUCKSCANNOTBELESSTHANACCEPTABLEMINIMUMTRUCKS", 'Acceptable Maximum Trucks cannot be less than Acceptable Minimum Trucks.'), alerttitle);
|
|
return;
|
|
}
|
|
|
|
if (assettypes === "") {
|
|
showAlert(GetTextByKey("P_M3_ACCEPTABLEASSETTYPESCANNOTBEEMPTY", 'Acceptable Asset Types cannot be empty.'), alerttitle);
|
|
return;
|
|
}
|
|
|
|
showloading(false);
|
|
var param = JSON.stringify(item);
|
|
param = htmlencode(param);
|
|
jobsitelimitquery("SaveJobsiteLimit", contractorid + String.fromCharCode(170) + param, function (data) {
|
|
showloading(false);
|
|
if (typeof (data) === "string") {
|
|
showAlert(data, alerttitle);
|
|
} else {
|
|
jlid = data[0];
|
|
if (exit == 0)
|
|
showAlert(GetTextByKey("P_M3_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
|
|
if (exit == 1)
|
|
OnExit(exit);
|
|
}
|
|
}, function (err) {
|
|
showloading(false);
|
|
showAlert(GetTextByKey("P_M3_FAILEDTOSAVEJOBSITELIMITCONFIGURATION", 'Failed to save jobsite limit configuration.'), alerttitle);
|
|
});
|
|
}
|
|
|
|
function OnExit(type) {
|
|
window.parent.CloseDialog(type);
|
|
}
|
|
|
|
var jobsitelimit;
|
|
var jlid;
|
|
function init(cid, jl) {
|
|
contractorid = cid;
|
|
if (jl) {
|
|
jlid = jl.ID;
|
|
jobsitelimit = jl;
|
|
OnEdit();
|
|
}
|
|
else
|
|
OnAdd();
|
|
}
|
|
|
|
function GetMachineTypes() {
|
|
devicerequest("GetMachineTypes", contractorid, function (data) {
|
|
if (typeof (data) === "string") {
|
|
showAlert(data, GetTextByKey("P_M3_ERROR", 'Error'));
|
|
return;
|
|
}
|
|
assettypeparam = {
|
|
items: data,
|
|
selectedvalue: [],
|
|
allowall: false
|
|
};
|
|
editmultiselect_type = editmultiselect(assettypeparam);
|
|
$('#dialog_assettype').append(editmultiselect_type);
|
|
}, function (err) {
|
|
});
|
|
}
|
|
|
|
var activejobsitedata;
|
|
function GetActiveJobsites(contractorid) {
|
|
devicerequest('GetActiveJobsites', contractorid, function (data) {
|
|
if (typeof (data) === "string") {
|
|
showAlert(data, GetTextByKey("P_M3_ERROR", 'Error'));
|
|
return;
|
|
}
|
|
if (data && data.length > 0) {
|
|
activejobsitedata = data;
|
|
$("#dialog_jobsite").empty();
|
|
for (var i = 0; i < data.length; i++) {
|
|
var kv = data[i];
|
|
var op = $("<option></option>").val(kv.ID).text(kv.Name);
|
|
$("#dialog_jobsite").append(op);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function initTime() {
|
|
var c = $('#dialog_starttimehour');
|
|
for (var i = 0; i < 24; i++) {
|
|
if (i < 10)
|
|
c.append($("<option></option>").val("0" + i).text("0" + i))
|
|
else
|
|
c.append($("<option></option>").val(i).text(i))
|
|
}
|
|
c = $('#dialog_starttimeminute');
|
|
for (var i = 0; i < 60; i++) {
|
|
if (i < 10)
|
|
c.append($("<option></option>").val("0" + i).text("0" + i))
|
|
else
|
|
c.append($("<option></option>").val(i).text(i))
|
|
}
|
|
c = $('#dialog_endtimehour');
|
|
for (var i = 0; i < 24; i++) {
|
|
if (i < 10)
|
|
c.append($("<option></option>").val("0" + i).text("0" + i))
|
|
else
|
|
c.append($("<option></option>").val(i).text(i))
|
|
}
|
|
c = $('#dialog_endtimeminute');
|
|
for (var i = 0; i < 60; i++) {
|
|
if (i < 10)
|
|
c.append($("<option></option>").val("0" + i).text("0" + i))
|
|
else
|
|
c.append($("<option></option>").val(i).text(i))
|
|
}
|
|
}
|
|
|
|
$(function () {
|
|
GetMachineTypes();
|
|
GetActiveJobsites();
|
|
init();
|
|
initTime();
|
|
function resizeContent() {
|
|
$('#divcontent').css('height', $(window).height() - $('#divcontent').offset().top - 4);
|
|
}
|
|
|
|
window.onresize = resizeContent;
|
|
resizeContent();
|
|
});
|
|
|
|
</script>
|
|
</asp:Content>
|
|
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
|
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
|
|
<div>
|
|
<div class="function_title">
|
|
<span class="sbutton iconsave" onclick="OnSave(0);" data-lgid="P_M3_SAVE">Save</span>
|
|
<span class="sbutton iconsave" onclick="OnSave(1);" data-lgid="P_M3_SAVE1">Save and Exit</span>
|
|
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_M3_SAVE2">Exit Without Saving</span>
|
|
</div>
|
|
<div class="clear"></div>
|
|
<div class="content_main" id="divcontent" style="overflow: auto;">
|
|
<div class="edit-content">
|
|
<div class="subtitle">
|
|
<span data-lgid="P_M3_JOBSITELIMITINFORMATION">Jobsite Limit Information</span>
|
|
<hr />
|
|
</div>
|
|
<table style="line-height: 30px;">
|
|
<tr>
|
|
<td class="label" data-lgid="P_M3_JOBSITE_COLON">JobSite:</td>
|
|
<td>
|
|
<select id="dialog_jobsite" tabindex="1" style="width: 322px;"></select></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label"></td>
|
|
<td>
|
|
<input type="checkbox" id="dialog_active" tabindex="2" style="width: auto; height: 13px; margin-left: 0; margin-top: -2px; margin-bottom: 1px; vertical-align: middle;" />
|
|
<label data-lgid="P_M3_ACTIVE">Active</label></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label" data-lgid="P_M3_STARTTIME_COLON">Start Time:</td>
|
|
<td>
|
|
<select id="dialog_starttimehour" style="width: 48px;" tabindex="3"></select><span style="font-weight: bold;"> : </span>
|
|
<select id="dialog_starttimeminute" style="width: 48px;" tabindex="4"></select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label" data-lgid="P_M3_ENDTIME_COLON">End Time:</td>
|
|
<td>
|
|
<select id="dialog_endtimehour" style="width: 48px;" tabindex="5"></select><span style="font-weight: bold;"> : </span>
|
|
<select id="dialog_endtimeminute" style="width: 48px;" tabindex="6"></select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label" data-lgid="P_M3_ACCEPTABLEMINIMUMTRUCKS_COLON">Acceptable Minimum Trucks:</td>
|
|
<td>
|
|
<input id="dialog_mintrucks" tabindex="7" maxlength="8" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label" data-lgid="P_M3_ACCEPTABLEMAXIMUMTRUCKS_COLON">Acceptable Maximum Trucks:</td>
|
|
<td>
|
|
<input id="dialog_maxtrucks" tabindex="8" maxlength="8" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label" data-lgid="P_M3_ACCEPTABLEASSETTYPES_COLON">Acceptable Asset Types:</td>
|
|
<td>
|
|
<div id="dialog_assettype" tabindex="9"></div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label" data-lgid="P_M3_NOTES_COLON">Notes:</td>
|
|
<td>
|
|
<textarea id="dialog_notes" maxlength="1000" tabindex="10" style="margin-top: 10px;"></textarea></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</asp:Content>
|