add site
This commit is contained in:
		
							
								
								
									
										370
									
								
								Site/Security/AddCurfew.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										370
									
								
								Site/Security/AddCurfew.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,370 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/Security/Security.master" AutoEventWireup="true" CodeFile="AddCurfew.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: unset; | ||||
|                 height: unset; | ||||
|                 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: 100px; | ||||
|                 resize: none; | ||||
|                 /*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: 26px; | ||||
|             margin-right: 8px; | ||||
|         } | ||||
|     </style> | ||||
|  | ||||
|     <script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script> | ||||
|     <script type="text/javascript">         | ||||
|         var IsDealer = <%=IsDealer ?"true":"false"%>; | ||||
|         var contractorid; | ||||
|  | ||||
|         curfewquery = function (method, param, callback, error, nolog) { | ||||
|             _network.request("Security/AddCurfew.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 showAlert('Failed to load data: ' + e.statusText, GetTextByKey("P_CM_SCHEDULEASSETS", 'Schedule Assets')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function setDays(days) { | ||||
|             $("#tdDays input").prop("checked", false); | ||||
|             if (days.indexOf(daysArray[0]) >= 0) | ||||
|                 $("#chkSu").prop("checked", true); | ||||
|             if (days.indexOf(daysArray[1]) >= 0) | ||||
|                 $("#chkMo").prop("checked", true); | ||||
|             if (days.indexOf(daysArray[2]) >= 0) | ||||
|                 $("#chkTu").prop("checked", true); | ||||
|             if (days.indexOf(daysArray[3]) >= 0) | ||||
|                 $("#chkWe").prop("checked", true); | ||||
|             if (days.indexOf(daysArray[4]) >= 0) | ||||
|                 $("#chkTh").prop("checked", true); | ||||
|             if (days.indexOf(daysArray[5]) >= 0) | ||||
|                 $("#chkFr").prop("checked", true); | ||||
|             if (days.indexOf(daysArray[6]) >= 0) | ||||
|                 $("#chkSa").prop("checked", true); | ||||
|         } | ||||
|  | ||||
|         var daysArray = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; | ||||
|         function getDays() { | ||||
|             var days = ""; | ||||
|             if ($("#chkSu").prop("checked")) | ||||
|                 days += daysArray[0] + ","; | ||||
|             if ($("#chkMo").prop("checked")) | ||||
|                 days += daysArray[1] + ","; | ||||
|             if ($("#chkTu").prop("checked")) | ||||
|                 days += daysArray[2] + ","; | ||||
|             if ($("#chkWe").prop("checked")) | ||||
|                 days += daysArray[3] + ","; | ||||
|             if ($("#chkTh").prop("checked")) | ||||
|                 days += daysArray[4] + ","; | ||||
|             if ($("#chkFr").prop("checked")) | ||||
|                 days += daysArray[5] + ","; | ||||
|             if ($("#chkSa").prop("checked")) | ||||
|                 days += daysArray[6] + ","; | ||||
|  | ||||
|             if (days.length > 0) | ||||
|                 days = days.substr(0, days.length - 1); | ||||
|             return days; | ||||
|         } | ||||
|  | ||||
|         function initControl(index) { | ||||
|             var c = $('#starttimehour_' + index); | ||||
|             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 = $('#starttimeminute_' + index); | ||||
|             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 = $('#endtimehour_' + index); | ||||
|             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 = $('#endtimeminute_' + index); | ||||
|             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)) | ||||
|             } | ||||
|  | ||||
|         } | ||||
|         var timeindex = 0; | ||||
|         function AddTimePeriod(type, time) { | ||||
|             timeindex++; | ||||
|             var tr_add = $('#tr_addtimepreiod'); | ||||
|             var tr = $('<tr id="trtime_' + timeindex + '" class="trtimeperiod"></tr>'); | ||||
|             var td1 = $('<td class="label">' + GetTextByKey("P_CM_STARTTIME_COLON", "Start Time:") + '</td>"'); | ||||
|             var td2 = $('<td></td>'); | ||||
|             var s_sel = $('<select id="starttimehour_' + timeindex + '" style="width: 48px;"></select><span style="font-weight: bold;">  :  </span><select id="starttimeminute_' + timeindex + '" style="width: 48px;"></select>') | ||||
|             var e_sel = $('<span class="timespan">' + GetTextByKey("P_CM_ENDTIME_COLON", "End Time:") + '</span><select id="endtimehour_' + timeindex + '" style="width: 48px;"></select><span style="font-weight: bold;">  :  </span><select  id="endtimeminute_' + timeindex + '" style="width: 48px;"></select>'); | ||||
|             var s_del = $('<span class="sbutton icondelete" onclick="DeleteTimePeriod(' + timeindex + ');"></span>'); | ||||
|             td2.append(s_sel).append(e_sel).append(s_del); | ||||
|             tr.append(td1).append(td2); | ||||
|             tr_add.before(tr); | ||||
|             initControl(timeindex); | ||||
|             if (type == 1) { | ||||
|                 $('#starttimehour_' + timeindex).val(time.BeginHours); | ||||
|                 $('#starttimeminute_' + timeindex).val(time.BeginMinutes); | ||||
|                 $('#endtimehour_' + timeindex).val(time.EndHours); | ||||
|                 $('#endtimeminute_' + timeindex).val(time.EndMinutes); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function DeleteTimePeriod(index) { | ||||
|             var trs = $('.trtimeperiod'); | ||||
|             if (trs && trs.length == 1) { | ||||
|                 showAlert(GetTextByKey("P_CM_PERIODCANNOTBEEMPTY", "Period cannot be empty."), GetTextByKey("P_CM_DELETEPERIOD", 'Delete Period')); | ||||
|                 return; | ||||
|             } | ||||
|             $('#trtime_' + index).remove(); | ||||
|         } | ||||
|  | ||||
|         function OnAdd() { | ||||
|             $('#dialog_title').val(''); | ||||
|             $("#tdDays input").prop("checked", false); | ||||
|             $('#dialog_starttimehour').val('00'); | ||||
|             $('#dialog_starttimeminute').val('00'); | ||||
|             $('#dialog_endtimehour').val('00'); | ||||
|             $('#dialog_endtimeminute').val('00'); | ||||
|             $('#dialog_urlkey').focus(); | ||||
|             $('.trtimeperiod').remove(); | ||||
|             AddTimePeriod(2); | ||||
|         } | ||||
|  | ||||
|         var curfewid; | ||||
|         function getCurfewInfo() { | ||||
|             curfewquery("GetCurfewInfo", contractorid + String.fromCharCode(170) + curfewid, function (data) { | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_CM_ERROR", 'Error')); | ||||
|                     return; | ||||
|                 } | ||||
|                 var curfew = data; | ||||
|                 $('#dialog_title').val(curfew.Title); | ||||
|                 setDays(curfew.Day); | ||||
|  | ||||
|                 var times = curfew.TimePeriods; | ||||
|                 if (times) { | ||||
|                     $('.trtimeperiod').remove(); | ||||
|                     for (var i = 0; i < times.length; i++) { | ||||
|                         AddTimePeriod(1, times[i]); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|             }, function (err) { | ||||
|                 console.log(err); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function OnEdit() { | ||||
|             getCurfewInfo(); | ||||
|         } | ||||
|  | ||||
|         function OnSave(exit) { | ||||
|             var item = { | ||||
|                 'Title': $('#dialog_title').val().trim(), | ||||
|                 'Day': getDays() | ||||
|             }; | ||||
|  | ||||
|             var alerttitle; | ||||
|             if (curfewid) { | ||||
|                 item.Id = curfewid; | ||||
|                 alerttitle = GetTextByKey("P_CM_EDITCURFEWCONFIGURATION", "Edit Curfew Configuration"); | ||||
|             } else { | ||||
|                 item.Id = ""; | ||||
|                 alerttitle = GetTextByKey("P_CM_ADDCURFEWCONFIGURATION", "Add Curfew Configuration"); | ||||
|             } | ||||
|             if (!item.Title || item.Title.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_CM_TITLECANNOTBEEMPTY", 'Title cannot be empty.'), alerttitle); | ||||
|                 return; | ||||
|             } | ||||
|             if (!item.Day || item.Day.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_CM_PLEASESELECTATLEASTONEDAY", 'Please select at least one day.'), alerttitle); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             var times = []; | ||||
|             var trs = $('.trtimeperiod'); | ||||
|             if (trs.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_CM_PERIODCANNOTBEEMPTY", "Period cannot be empty."), alerttitle); | ||||
|                 return; | ||||
|             } | ||||
|             for (var i = 0; i < trs.length; i++) { | ||||
|                 var sels = $(trs[i]).find('select'); | ||||
|                 var time = { | ||||
|                     'BeginHours': $(sels[0]).val(), | ||||
|                     'BeginMinutes': $(sels[1]).val(), | ||||
|                     'EndHours': $(sels[2]).val(), | ||||
|                     'EndMinutes': $(sels[3]).val() | ||||
|                 }; | ||||
|                 times.push(time); | ||||
|             } | ||||
|  | ||||
|             item.TimePeriods = times; | ||||
|  | ||||
|             showloading(true); | ||||
|             var param = JSON.stringify(item); | ||||
|             param = htmlencode(param); | ||||
|             curfewquery("SaveCurfew", contractorid + String.fromCharCode(170) + param, function (data) { | ||||
|                 showloading(false); | ||||
|                 if (typeof (data) === "string") { | ||||
|                     var msg = data; | ||||
|                     if (data === "The curfew title must be unique.") | ||||
|                         msg = GetTextByKey("P_CM_THECURFEWTITLEMUSTBEUNIQUE", 'The curfew title must be unique.'); | ||||
|                     else if (data === "Period cannot be empty.") | ||||
|                         msg = GetTextByKey("P_CM_PERIODCANNOTBEEMPTY", 'Period cannot be empty.'); | ||||
|                     else if (data === "End Time must be later than Start Time.") | ||||
|                         msg = GetTextByKey("P_CM_ENDTIMEMUSTBELATERTHANSTARTTIME", 'End Time must be later than Start Time.'); | ||||
|  | ||||
|                     showAlert(msg, GetTextByKey("P_CM_SAVECURFEWCONFIGURATION", 'Save Curfew Configuration')); | ||||
|                 } else { | ||||
|                     curfewid = data[0]; | ||||
|                     if (exit == 0) | ||||
|                         showAlert(GetTextByKey("P_CM_SAVSUCCESSFULLY", "Saved successfully."), GetTextByKey("P_CM_SAVECURFEWCONFIGURATION", 'Save Curfew Configuration')); | ||||
|                     if (exit == 1) | ||||
|                         OnExit(exit); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|                 showAlert(GetTextByKey("P_CM_FAILEDTOSAVECURFEWCONFIGURATION", 'Failed to save curfew configuration.'), GetTextByKey("P_CM_SAVECURFEWCONFIGURATION", 'Save Curfew Configuration')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnExit(type) { | ||||
|             window.parent.CloseDialog(type); | ||||
|         } | ||||
|  | ||||
|         function init(cid, id) { | ||||
|             curfewid = id; | ||||
|             contractorid = cid; | ||||
|             OnAdd(); | ||||
|  | ||||
|             if (curfewid !== undefined && curfewid !== '') { | ||||
|                 OnEdit(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             init(); | ||||
|  | ||||
|             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_CM_SAVE">Save</span> | ||||
|             <span class="sbutton iconsave" onclick="OnSave(1);" data-lgid="P_CM_SAVE1">Save and Exit</span> | ||||
|             <span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_CM_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_CM_CURFEWINFORMATION">Curfew Information</span> | ||||
|                     <hr /> | ||||
|                 </div> | ||||
|                 <table style="line-height: 40px;"> | ||||
|                     <tr> | ||||
|                         <td class="label" data-lgid="P_CM_TITLE_COLON">Title:</td> | ||||
|                         <td> | ||||
|                             <input id="dialog_title" tabindex="2" maxlength="200" style="width: 280px;" /></td> | ||||
|                     </tr> | ||||
|                     <tr> | ||||
|                         <td class="label" data-lgid="P_CM_DAYS_COLON">Day(s):</td> | ||||
|                         <td id="tdDays"> | ||||
|                             <input type="checkbox" id="chkSu" tabindex="3" style="width: auto; margin-left: 0px; margin-right: 2px;" class="middlechk" /><label for="chkSu" data-lgid="P_CM_SUNDAY">Sunday</label> | ||||
|                             <input type="checkbox" id="chkMo" tabindex="4" style="width: auto; margin-left: 26px; margin-right: 2px;" class="middlechk" /><label for="chkMo" data-lgid="P_CM_MONDAY">Monday</label> | ||||
|                             <input type="checkbox" id="chkTu" tabindex="5" style="width: auto; margin-left: 26px; margin-right: 2px;" class="middlechk" /><label for="chkTu" data-lgid="P_CM_TUESDAY">Tuesday</label> | ||||
|                             <input type="checkbox" id="chkWe" tabindex="6" style="width: auto; margin-left: 26px; margin-right: 2px;" class="middlechk" /><label for="chkWe" data-lgid="P_CM_WEDNESDAY">Wednesday</label> | ||||
|                             <input type="checkbox" id="chkTh" tabindex="7" style="width: auto; margin-left: 26px; margin-right: 2px;" class="middlechk" /><label for="chkTh" data-lgid="P_CM_THURSDAY">Thursday</label> | ||||
|                             <input type="checkbox" id="chkFr" tabindex="8" style="width: auto; margin-left: 26px; margin-right: 2px;" class="middlechk" /><label for="chkFr" data-lgid="P_CM_FRIDAY">Friday</label> | ||||
|                             <input type="checkbox" id="chkSa" tabindex="9" style="width: auto; margin-left: 26px; margin-right: 2px;" class="middlechk" /><label for="chkSa" data-lgid="P_CM_SATURDAY">Saturday</label> | ||||
|                         </td> | ||||
|                     </tr> | ||||
|                     <tr id="tr_addtimepreiod"> | ||||
|                         <td class="label"></td> | ||||
|                         <td><span class="sbutton iconadd" onclick="AddTimePeriod();" style="background-color: #f0f0f0;" data-lgid="P_CM_ADDPERIOD">Add Period</span></td> | ||||
|                     </tr> | ||||
|                 </table> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
		Reference in New Issue
	
	Block a user