fleet-contractor/Site/JobSite/SchedulerManagement.aspx
2023-04-28 12:22:26 +08:00

582 lines
21 KiB
Plaintext

<%@ Page Title="" Language="C#" MasterPageFile="~/JobSite/JobSiteMasterPage.master" AutoEventWireup="true" CodeFile="SchedulerManagement.aspx.cs" Inherits="SchedulerManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<style type="text/css">
.itemselcted {
background-color: #ccc;
}
.itemhidden {
display: none;
}
.itemsuggested {
background-color: #ffff99;
}
#tbMachineTypes tbody tr:hover {
cursor: default;
background: #ddd;
}
#tbodyAssigned tr:hover {
cursor: default;
background: #ddd;
}
#tbodyUnassigned tr:hover {
cursor: default;
background: #ddd;
}
#tbodySelected tr:hover {
cursor: default;
background: #ddd;
}
#contentctrl {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.float_left {
float: left;
}
.function_bar {
float: right;
}
.user_main {
padding: 0 4px;
}
.edit-content table {
border-collapse: collapse;
width: 100%;
}
.edit-content table td.label {
width: 130px;
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;
}
.edit-content table td textarea {
height: 100px;
resize: none;
/*max-width: 200px;*/
}
.icon {
font-family: CalciteWebCoreIcons;
cursor: default;
}
.ybutton {
width: 80px;
line-height: normal;
margin-left: 6px;
border: none;
background: rgb(249, 189, 117);
padding: 5px 14px;
cursor: pointer;
}
.ybutton:hover {
background: #d7690E;
}
.td_controller {
vertical-align: middle;
padding: 40px 8px;
/*border-left: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;*/
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
.subdialog {
width: -moz-calc(100% - 24px);
width: -webkit-calc(100% - 24px);
width: calc(100% - 24px);
}
.machine_maskbg {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
background: #000;
opacity: 0.2;
}
#machine-name {
margin: 10px 10px 6px;
/*color: gray;*/
font-weight: lighter;
font-size: 18px;
width: 770px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.div_filter .dropdown {
width: 100px;
}
.span-caption {
position: absolute;
}
.span-bar {
position: absolute;
height: 100%;
margin: 0;
vertical-align: bottom;
}
.assetlabel {
width: 200px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
font-weight: 500;
}
</style>
<script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>" type="text/javascript"></script>
<script>Vue.config.productionTip = false; Vue.config.silent = true;</script>
<script src="<%=GetFileUrlWithVersion("../js/components/datagrid.js")%>" type="text/javascript"></script>
<link href="<%=GetFileUrlWithVersion("../fic/css/datepicker.min.css")%>" rel="stylesheet" />
<script src="<%=GetFileUrlWithVersion("../fic/js/datepicker.min.js")%>"></script>
<link href="<%=GetFileUrlWithVersion("../css/spectrum.css")%>" rel="stylesheet" type="text/css" />
<script src="../js/spectrum.js?v=1" type="text/javascript"></script>
<script src="../js/jquery.datetimepicker.full.js"></script>
<script src="../Maintenance/js/inputdatactr.js"></script>
<script src="<%=GetFileUrlWithVersion("../js/editmultiselect.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("js/scheduler.js")%>" type="text/javascript"></script>
<script>
jobsitequery = function (method, param, callback, error, nolog) {
_network.request("JobSite/SchedulerManagement.aspx?tp=ashx", -1, method, param, callback, error, nolog);
}
var IsReadOnly = <%=IsReadOnly ?"true":"false"%>;
var currentdate = "<%=CurrentDate %>";
/***************************Jobsites***************************/
function showConfirmIndialog(msg, title, fok, fcancel, shownote) {
$("#dialogmask").show();
_dialog.showConfirm(msg, title, function (e, notes) {
$("#dialogmask").hide();
if (typeof fok === 'function') {
fok(e, notes);
}
}, fcancel || function () {
$("#dialogmask").hide();
}, null, null, shownote);
}
function CloseDialog() {
$('#dialog_scheduler').hideDialog();
OnRefresh();
}
function ShowDialog(type) {
showmaskbg(true);
$('#dialog_scheduler')
.attr('act', type)
.showDialogRight();
}
function OnAdd() {
execIframeFunc("init", [alljobsites], "iframescheduler");
ShowDialog("add");
}
var assetsObj;
function OnRefresh() {
var alerttitle = GetTextByKey('P_JS_SCHEDULER', 'Scheduler');
var begindate = $.trim($('#txtbegindate').val());
var enddate = $.trim($('#txtenddate').val());
if (begindate && !checkDate(begindate)) {
showAlert(GetTextByKey("P_JS_BEGINDATEFORMATERROR", "Begin Date format error."), alerttitle);
return;
}
if (enddate && !checkDate(enddate)) {
showAlert(GetTextByKey("P_JS_ENDDATEFORMATERROR", "End Date format error."), alerttitle);
return;
}
if (begindate && enddate) {
var sdate = begindate;
var stdt = new Date(sdate.replace("-", "/"));
var edate = enddate;
var etdt = new Date(edate.replace("-", "/"));
if (stdt > etdt) {
showAlert(GetTextByKey("P_JS_ENDDATEMUSTBELATERTHANBEGINDATE", "End Date must be later than Begin Date."), alerttitle);
return;
}
}
showloading(true);
var jobsites = [];
if (jobsiteparam)
jobsites = jobsiteparam.selectedvalue;
var regions = [];
if (regionparam)
regions = regionparam.selectedvalue;
var agroups = [];
if (assetgroupparam)
agroups = assetgroupparam.selectedvalue;
var atypes = [];
if (assettypeparam)
atypes = assettypeparam.selectedvalue;
var unscheduled = $('#chk_unscheduled').prop('checked') ? "1" : "0";
var p = [
JSON.stringify(jobsites),
JSON.stringify(regions),
JSON.stringify(agroups),
JSON.stringify(atypes),
$.trim($('#searchinputtxt').val()),
begindate,
enddate,
unscheduled
];
jobsitequery("GetAssetSchedulers", htmlencode(JSON.stringify(p)), function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
showSchedulerData(data);
}, function (err) {
showloading(false);
});
}
function searchEnter(e) {
if (e.keyCode == 13) {
OnRefresh();
}
}
var alljobsites;
var jobsiteparam;
var regionparam;
var jobsite_editmultiselect;
function getJobsitesAndRegions() {
jobsitequery('GetJobsitesAndRegions', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
alljobsites = data.Jobsites;
jobsiteparam = {
allitems: data.Jobsites,
items: JSON.parse(JSON.stringify(data.Jobsites)),
selectedvalue: [],
width: 240
};
jobsite_editmultiselect = editmultiselect(jobsiteparam);
$('#div_jobsites').append(jobsite_editmultiselect);
setJobsites();
regionparam = {
items: data.Regions,
selectedvalue: [],
width: 240,
oncompleted: onregioncompleted
};
var ipt = editmultiselect(regionparam);
$('#div_region').append(ipt);
});
}
function onregioncompleted() {
if (!jobsiteparam || !jobsiteparam.allitems) return;
jobsiteparam.items.length = 0;
for (var i in jobsiteparam.allitems) {
var item = jobsiteparam.allitems[i];
if (!regionparam.selectedvalue
|| regionparam.selectedvalue.length == 0
|| regionparam.selectedvalue.indexOf(item.Tag3) >= 0)
jobsiteparam.items.push(item);
}
jobsite_editmultiselect.reset();
}
function setJobsites() {
$('#dialog_addjobsite').empty();
if (alljobsites && alljobsites.length > 0) {
var ops = [];
for (var i = 0; i < alljobsites.length; i++) {
var op = $('<option></option>').prop('selected', i == 0).val(alljobsites[i].Key).text(alljobsites[i].Value).data('js', alljobsites[i]);
ops.push(op);
}
$('#dialog_addjobsite').append(ops);
}
}
var assettypes;
var assettypeparam;
function getAssetTypes() {
if (assettypes)
return;
$('#div_assettypes').empty();
jobsitequery('GetAssetTypes', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
assettypes = data;
assettypeparam = {
items: data,
selectedvalue: [],
allowall: false,
width: 280
};
var ipt = editmultiselect(assettypeparam);
$('#div_assettypes').append(ipt);
});
}
var assetgroups;
var assetgroupparam;
function getAssetGroups() {
jobsitequery('GetAssetGroups', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
assetgroups = data;
assetgroupparam = {
items: data,
selectedvalue: [],
width: 240
};
var ipt = editmultiselect(assetgroupparam);
$('#div_assetgroup').append(ipt);
});
}
$(function () {
setPageTitle(GetTextByKey("P_JS_SCHEDULER", "Scheduler"), true);
InitGridData();
jobsiteschedulerCtrl = new $jobsiteschedulerCtrl();
jobsiteschedulerCtrl.Init($("#schedulerlist1"), false);
getJobsitesAndRegions();
getAssetGroups();
getAssetTypes();
$(window).resize(function () {
$("#schedulerlist").css("height", $(window).height() - $("#schedulerlist").offset().top - 14);
grid_dt && grid_dt.resize();
}).resize();
OnRefresh();
$('#searchinputtxt').keydown(searchEnter);
$('#dialog_managescheduler').dialog(function () {
$('#dialogmask').hide();
OnRefresh();
})
$('#dialog_addscheduler').dialog(function () {
$('#dialogmask').hide();
$('#dialogmask1').hide();
})
$("#txtbegindate").datetimepicker({
timepicker: false,
format: 'm/d/Y'
});
$("#txtenddate").datetimepicker({
timepicker: false,
format: 'm/d/Y'
}); $('#dialog_addbegindate').datetimepicker({
timepicker: false,
format: 'm/d/Y',
enterLikeTab: false,
onSelectDate: function (v, inp) {
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
inp.parent().data('val', [date]);
}
})
$('#dialog_addenddate').datetimepicker({
timepicker: false,
format: 'm/d/Y',
enterLikeTab: false,
onSelectDate: function (v, inp) {
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
inp.parent().data('val', [date]);
}
})
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="contentctrl">
<div class="page_title" data-lgid="P_JS_SCHEDULER">Scheduler</div>
<div class="search_bar" style="min-width: 1300px;">
<input type="password" autocomplete="new-password" style="display: none" />
<span data-lgid="P_AM_BEGINDATE_COLON">Begin Date:</span>
<div>
<input type="text" style="margin-left: 5px; width: 75px;" id="txtbegindate" value="<%=BeginDate %>" autocomplete="off" />
</div>
<span data-lgid="P_AM_ENDDATE_COLON">End Date:</span>
<div>
<input type="text" style="margin-left: 5px; width: 75px;" id="txtenddate" autocomplete="off" />
</div>
<span data-lgid="P_JS_REGION_COLON">Region:</span>
<div id="div_region" style="margin-top: 1px;"></div>
<span data-lgid="P_JS_JOBSITES_COLON">Jobsites:</span>
<div id="div_jobsites" style="margin-top: 1px;"></div>
<span data-lgid="P_AM_ASSETGROUP_COLON">Asset Group:</span>
<div id="div_assetgroup" style="margin-top: 1px;"></div>
<span data-lgid="P_JS_ASSETTYPE_COLON" style="margin-left: 10px;">Asset Type:</span>
<div id="div_assettypes" style="margin-top: 1px;"></div>
<input type="text" id="searchinputtxt" autocomplete="off" style="margin-left: 5px; width: 100px;" />
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_CM_SEARCH" style="margin-left: 5px;" />
<input id="chk_unscheduled" type="checkbox" onclick="OnRefresh();" />
<label data-lgid="P_JS_UNSCHEDULED" for="chk_unscheduled">Unscheduled</label>
</div>
<div class="function_title">
<%if (!IsReadOnly)
{ %>
<span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_JS_ADD"></span>
<%} %>
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_JS_REFRESH"></span>
</div>
<div id="schedulerlist"></div>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
<div class="dialog subdialog" id="dialog_scheduler" style="display: none; border-bottom: 0; border-top: 0;">
<%--<div class="dialog-title"><span class="title">Add Work Order</span></div>--%>
<iframe id="iframescheduler" src="AddScheduler.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
<div class="dialog" id="dialog_managescheduler" style="display: none;">
<div class="dialog-title"><span class="title" data-lgid="P_MA_SELECTASSET"></span><em class="dialog-close"></em></div>
<div class="machine_filter">
<table style="width: 500px;">
<tr>
<td class="assetlabel" data-lgid="P_MA_ASSETNAME_COLON">Asset Name:</td>
<td id="dialog_assetname" style="width: 180px;"></td>
<td class="assetlabel" style="width: 100px;" data-lgid="P_IPT_ASSETTYPE_COLON">Asset Type:</td>
<td id="dialog_assettype" style="width: 180px;"></td>
</tr>
<tr>
<td class="assetlabel" data-lgid="P_IPT_MAKE_COLON">Make:</td>
<td id="dialog_make" style="width: 180px;"></td>
<td class="assetlabel" style="width: 100px;" data-lgid="P_IPT_MODEL_COLON">Model:</td>
<td id="dialog_model" style="width: 180px;"></td>
</tr>
</table>
</div>
<div class="function_title" style="line-height: 24px;">
<span class="sbutton iconadd" onclick="openAddScheduler()" data-lgid="P_JS_ADD">Add</span>
<span class="sbutton icondelete" onclick="onDeleteScheduler()" data-lgid="P_JS_DELETE">Delete</span>
</div>
<div id="schedulerlist1" style="height: 300px; width: 600px;"></div>
<div class="dialog-func">
<input type="button" value="Close" data-lgid="P_JS_CANCEL" class="dialog-close" tabindex="28" />
<input type="button" onclick="onUpdateScheduler();" data-lgid="P_JS_OK" value="OK" tabindex="27" />
<div class="clear"></div>
</div>
<div id="dialogmask" class="maskbg" style="display: none;">
<div class="loading_icon icon c-spin"></div>
</div>
</div>
<div class="dialog" id="dialog_addscheduler" style="display: none; width: 500px;">
<div class="dialog-title"><span class="title" data-lgid="P_JS_ADDSCHEDULER"></span><em class="dialog-close"></em></div>
<div class="edit-content">
<table style="line-height: 30px;">
<tr>
<td class="label" data-lgid="P_JS_JOBSITE_COLON"></td>
<td>
<select id="dialog_addjobsite" tabindex="1" style="height: 22px; width: 300px;"></select></td>
</tr>
<tr>
<td class="label" data-lgid="P_JS_BEGINDATE_COLON"><span>*</span></td>
<td>
<input type="text" id="dialog_addbegindate" maxlength="200" tabindex="1" style="width: 200px;" autocomplete="off" />
</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 5px;" data-lgid="P_JS_ENDDATE_COLON"></td>
<td>
<input type="text" id="dialog_addenddate" maxlength="200" tabindex="1" style="width: 200px;" autocomplete="off" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_JS_POINTOFCONTACT_COLON">Point of Contact:</td>
<td>
<input type="text" id="dialog_pointofcontact" maxlength="100" autocomplete="off" style="width: 100px;" />
</td>
</tr>
<tr>
<td class="label" data-lgid="P_FR_NOTES_COLON">Notes:</td>
<td>
<textarea id="dialog_addnotes" maxlength="1000" tabindex="1" style="width: 300px; height: 120px; margin-top: 5px;"></textarea>
</td>
</tr>
</table>
</div>
<div class="dialog-func">
<input type="button" value="Close" data-lgid="P_JS_CANCEL" class="dialog-close" tabindex="28" />
<input type="button" onclick="onAddScheduler();" data-lgid="P_JS_OK" value="OK" tabindex="27" />
<div class="clear"></div>
</div>
<div id="dialogmask1" class="maskbg" style="display: none;">
<div class="loading_icon icon c-spin"></div>
</div>
</div>
</asp:Content>