9tailsfox Posted July 24, 2018 Posted July 24, 2018 (edited) Hi, First of all I would like to say i'm sorry as I don't know how to highlight the texts but hope you can understand as I'm a beginner. Lately I need to create an Automation for the below webpage. I need to login about more than hundred of accounts user to manifest their shipping @.@. My eyes started pain. Please refer the code below and the snapshot. I need create a script to select the something called DOJO and DIJIT but i'm not good on coding. Please help be base on all the source code I already copied here. Thank you HINT: The Red color highlighted is the row that I wish to input text or select. thanks expandcollapse popup<html> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-35413041-1']); _gaq.push(['_trackPageview']); _gaq.push(['_trackPageLoadTime']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>New Zealand Post - Customs Manifests</title> <link rel="stylesheet" type="text/css" href="/js/djui/1.7.2/dijit/themes/tundra/tundra.css"> <style type="text/css"> @import "/js/djui/1.7.2/dojox/grid/resources/Grid.css"; @import "/js/djui/1.7.2/dojox/grid/resources/tundraGrid.css"; label { font-size: 13px; color: #666666; margin-right: 5px; } .clickImg { border-style: none; vertical-align: middle; cursor: pointer; cursor: hand; } .errorMessage { color: red; }</style> <link rel="stylesheet" type="text/css" href="/css/velocity.css?t=20180228195504"> </head> <BODY class='tundra' marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" BGCOLOR="#FFFFFF" link="#000066" vlink="#000066" alink="#000066"> <!--Header Start--> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#ffffff"><img src="/shared/images/newzea/logo.gif" width="750" height="100" border="0" alt=""></td> </tr> </table> <!--Header End--> <table width="740" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="6" class="txt" align="right" valign="bottom" height="17"> <a href="/mba/37753x0/home/" class="linktxt">Home</a> | <a href="#" onclick="return openwin('/userprofile/userprofile.php3','ndcluserprofile', 640, 480);" class="linktxt">My Profile</a> | <a href="/mba/37753x0/login/?logout" class="linktxt">Logout</a> </td> </tr> <tr> <td colspan="6" class="txt" height="4"><img src="/images/transparent.gif" height="4" width="1" alt="" border="0"></td> </tr> <tr> <td width="10"><img src="/images/transparent.gif" height="2" width="10" alt="" border="0"></td> <td width="160" align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="txt"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="menutitle">Customs Manifests</td></tr> <tr><td height="2"><img src="/images/transparent.gif" height="2" width="1" alt="" border="0"></td></tr> <tr><td height="2" bgcolor="#000066"><img src="/images/transparent.gif" height="2" width="1" alt="" border="0"></td></tr> <tr><td height="7"><img src="/images/transparent.gif" height="7" width="1" alt="" border="0"></td></tr> <tr> <td class="soft">This page allows you to generate a new Customs Manifest or to retrieve a previously generated Customs Manifest. Only labelled items not previously manifested, and with a collection date and time between the dates and times selected, will be included when a new manifest is generated. Cancelled jobs will be excluded.<p>Manifests can only be produced for items entered within the last 90 days. Manifests can only be re-printed for a maximum of 90 days.</p> <p>Please ensure that you have cancelled any consignments with labels that will not be used, before you request a manifest</p><br><br> <a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank"><img src="/shared/images/template_APC/getAdobeReader.gif" width="88" height="31" alt="Get Adobe Acrobat Reader" border="0"></a> <br><br> </td> </tr> </table> </td> </tr> <tr><td width="160"><img src="/images/transparent.gif" width="160" height="1" alt="" border="0"></td></tr> </table> </td> <td width="10"><img src="/images/transparent.gif" height="250" width="10" alt="" border="0"></td> <td width="1" bgcolor="#CCCCCC"><img src="/images/transparent.gif" height="1" width="1" alt="" border="0"></td> <td width="10"><img src="/images/transparent.gif" height="1" width="10" alt="" border="0"></td> <td valign="top" class="txt"><div id="accessError" class="txt" style="display:none; width: 100%">No Customs Manifests available.</div> <div id="loader" class="txt">Please Wait - checking manifests</div> <div id="main" class="tundra" style="display:none; width: 100%"> <table cellpadding="0" cellspacing="0"> <thead> <tr><td colspan="2" class="ttxt" style="font-weight: bold; padding-bottom:5px;">Generate New Manifest</td></tr> </thead> <tr> <td><div id="generateStatus"></div> <div id="messages" style="display: none"></div> </td> </tr> <tr><td colspan="2" class="txt"><div style="padding: 15px 0 0 0;"></div>Select the Collection Date, Time range and the Type of Manifest you wish to generate.</td></tr> <tr> <td valign="top"> <table cellpadding="0" cellspacing="5"> <tr id="rowManifest"> <td class="txt" width="90"><label for="manifest">Manifest</label></td> <td class="txt"> <div id="manifest"></div> </td> </tr> <tr id="rowManifestType"> <td class="txt"><label for="manifestType">Manifest Type</label></td> <td class="txt"> <div id="manifestType"></div> </td> </tr> <tr> <td class="txt"><label for="manifestStartDate">Start Date</label></td> <td> <table cellpadding="0" cellspacing="0"><tr> <td class="txt"><div id="manifestStartDate"></div></td> <td class="txt"> </td> <td class="txt"><label for="manifestStartTime">Time</label></td> <td class="txt"><div id="manifestStartTime"></div></td> </tr></table> <div class="errorMessage" id="errorStartDate"></div> </td> </tr> <tr> <td class="txt"><label for="manifestEndDate">End Date</label></td> <td> <table cellpadding="0" cellspacing="0"><tr> <td class="txt"><div id="manifestEndDate"></div></td> <td class="txt"> </td> <td class="txt"><label for="manifestEndTime">Time</label></td> <td class="txt"><div id="manifestEndTime"></div></td> </tr></table> <div class="errorMessage" id="errorEndDate"></div> </td> </tr> <tr id="rowManifestPort"> <td class="txt"><label for="manifestPort">Port</label></td> <td class="txt"> <div id="manifestPort"></div> </td> </tr> <tr id="rowSelectionInfo"> <td colspan="2"> <div id="selectionInfo" style="border: 1px solid #999; padding: 2px; background-color: #efefef;"> <span id="minLodgementVolume"></span> <span id="numberOfJobs"></span> </div> </td> </tr> <tr> <td colspan="2"> <img src="/shared/images/template_APC/generate_grey.gif" alt="generate" id="generateManifestButton"/> </td> </tr> </table> </td> </tr> </table> <div style="padding: 20px 0 0 0;"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr><td class="ttxt" style="font-weight: bold;">Retrieve Manifest</td></tr> </thead> <tr> <td valign="top"> <table cellpadding="0" cellspacing="5"> <tr> <td><label for="selectedManifestDate">Manifest Date</label></td> <td> <table cellpadding="0" cellspacing="0"><tr> <td class="txt"><div id="selectedManifestDate"></div></td> </tr></table> <div class="errorMessage" id="errorManifestDate"></div> </td> </tr> </table> </td> </tr> </table> <div style="padding: 0 0 10px 0;"> This is a list of previously generated manifests for the selected Manifest Date.<br/> Click the <button type='button' class='newBtn noCursorBtn'><span>pdf</span></button> or <button type='button' class='newBtn noCursorBtn'><span>csv</span></button> icon to retrieve the manifest you require. </div> <div id="manifestList"></div> <div id="confirmGenerate" dojoType="dijit.Dialog" title="Warning"> <script type="dojo/method" event="onHide" args="evt"> cancelGenerateManifest(); </script> <table width="250" cellspacing="10" cellpadding="0"> <tr> <td class="txt" colspan="2">Are you sure that you have cancelled any consignments with labels that will not be used?</td> </tr> <tr> <td class="txt"><label for="lodgementRef">Lodgement Reference</label></td> <td class="txt"> <div id="lodgementRef"></div> <div class="errorMessage" id="errorLodgmentRef">date error</div> </td> </tr> <tr> <td class="txt" align="right"> <button dojoType="dijit.form.Button" type="button">Continue <script type="dojo/method" event="onClick" args="evt"> validateExtras(); </script> </button> </td> <td class="txt" align="left"> <button dojoType="dijit.form.Button" type="button">Cancel <script type="dojo/method" event="onClick" args="evt"> dijit.byId("confirmGenerate").hide(); </script> </button> </td> </tr> </table> </div> </div> </td> </tr> </table> <img src="/images/transparent.gif" width="5" height="1" alt=""><img src="/images/power/ndpowered.gif" width="102" height="28" alt="Powered by NetDespatch"> </body> <script src="/js/velocityUI.js" type="text/javascript"></script> <script src="/js/dojoHelper.js?t=20180228195504" type="text/javascript"></script> <script src="/js/djui/1.7.2/dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: true, async: true"></script> <script type="text/javascript"> var now = new Date(); var jsonServices; var serverTime = "2018-07-25 03:27:11"; var manifestTypeObj = ""; var activeManifestGroupsStore; var activeManifestsStore; var manifestPortStore; var availableManifestsGrid; var manifestPort; var manifestMlid; var maxDateRange = ""; var portMandatory = false; var checkMinimumVol = false; var checkLodgementRef = false; var pdfDownload = false; var minLodgementVol; var numberOfJobs; var requestedManifestTypeId; var generatingManifest = false; var generateButtonHandle = null; var selectedManifestDateInput = null; var selectedManifestDateInputHandle = null; var manifestNamesObj = null; require(["dojo", "dojox/grid/DataGrid", "dojox/data/JsonRestStore", "dojo/data/ItemFileReadStore", "dojox/rpc/Service", "dojo/date/locale", "dojo/DeferredList", "dijit/form/Button", "dijit/form/DateTextBox", "dijit/form/FilteringSelect", "dijit/Dialog", "dojox/html/entities", "dojo/dom", "dojo/domReady!"], function(dojo, dom){ hideAllFields(); jsonServices = new dojox.rpc.Service("/wssmd/manifest/manifestServices.smd", {timeout: 1}); now = dojo.date.locale.parse(serverTime, {datePattern: "yyyy-MM-dd HH:mmm:ss", selector: "date"}); createDefaultManifestStore(); getManifestNames(); activeManifestGroupsStore = getActiveManifestGroups(); var manifestStartDateInput = createDateInputWithoutIcon("manifestStartDate", now, "dd MMM yyyy"); dojo.style(manifestStartDateInput.domNode, "width", "10em"); dojo.connect(manifestStartDateInput, "onChange", inputChange); var manifestStartTimeInput = createManifestStartTimeInput(); dojo.connect(manifestStartTimeInput, "onChange", inputChange); var manifestEndDateInput = createDateInputWithoutIcon("manifestEndDate", now, "dd MMM yyyy"); dojo.style(manifestEndDateInput.domNode, "width", "10em"); dojo.connect(manifestEndDateInput, "onChange", inputChange); var manifestEndTimeInput = createManifestEndTimeInput(); dojo.connect(manifestEndTimeInput, "onChange", inputChange); getNumberOfJobs(); dojo.style(dojo.byId("loader"), "display", "none"); dojo.style(dojo.byId("main"), "display", ""); selectedManifestDateInput = createDateInputWithoutIcon("selectedManifestDate", now, "dd MMM yyyy"); dojo.style(selectedManifestDateInput.domNode, "width", "10em"); dojo.connect(selectedManifestDateInput, "onChange", function(e){ if (validManifestDateTimeFormat()) { refreshList(); } }); }); function inputChange(){ hideMessages(); resetAllErrors(); if(validateDate()){ getNumberOfJobs(); } else { disconnectGenerateManifestButton(); } } function resetAfterGenerateManifest(){ resetAllErrors(); if(validateDate()){ getNumberOfJobs(); } else { disconnectGenerateManifestButton(); } } function createAvailableManifestsGrid(store) { var gridLayout = [ { name: 'Manifest ID', field: 'manifestNumber', width: '100px'}, { name: 'Type', field: 'groupCode', width: '200px', formatter: formatTypeName}, { name: 'Shipments', field: 'jobCount', width: '85px'}, { name: 'Created Date/Time', field: 'creationDateTime', width: '130px', formatter: formatDate}, { name: ' ', fields:['id', 'manifestTypeId', 'pdfAllowed', 'csvAllowed'], width: '70px', formatter: createPrintLinkTable} ]; var grid = new dojox.grid.DataGrid({ store: store, structure: gridLayout, selectionMode: 'none', autoHeight: 5, autoWidth: true, canSort: gridSortNotAllowed, noDataMessage: "There are no Customs Manifests for the selected date" }, "manifestList"); grid.setQuery("manifestDate=" + formatToServerFormatDateTime(dijit.byId("selectedManifestDate").attr('value'))); return grid; } function formatTypeName(value) { var i; var typeName = ""; if (value == null) { return typeName; } if (typeof manifestNamesObj === 'undefined') { return ""; } else { for(i = 0; i < manifestNamesObj.length; i++){ if(value == manifestNamesObj.groupCode){ typeName = manifestNamesObj.groupName; } } return typeName; } } function formatToServerFormatDateTime(value) { return dojo.date.locale.format(value, {datePattern: "yyyy-MM-dd", selector: "date"}); } function formatDate(value) { return dojo.date.locale.format( dojo.date.locale.parse(value, {datePattern: "yyyy-MM-dd", timePattern: "HH:mm:ss"}), {datePattern: "dd MMM yyyy", timePattern: "HH:mm"}); } function connectSelectedManifestDateInput() { if (selectedManifestDateInputHandle == null) { selectedManifestDateInputHandle = dojo.connect(selectedManifestDateInput, "onChange", function(e) { hideMessages(); }); } } function disconnectSelectedManifestDateInput() { dojo.disconnect(selectedManifestDateInputHandle); selectedManifestDateInputHandle = null; } function refreshList() { refreshListNoConnect(); connectSelectedManifestDateInput(); } function refreshListNoConnect() { availableManifestsGrid.removeSelectedRows(); availableManifestsGrid.store.close(); availableManifestsGrid.setQuery("manifestDate=" + formatToServerFormatDateTime(dijit.byId("selectedManifestDate").attr('value'))); availableManifestsGrid.sort(); } function hideAllFields(){ dojo.style(dojo.byId("rowManifestType"), "display", "none"); dojo.style(dojo.byId("rowManifestPort"), "display", "none"); hideMessages(); resetAllErrors(); } function getManifestNames() { jsonServices.manifestNames({}).then( function(result) { var result = dojox.html.entities.decode(result); manifestNamesObj = dojo.fromJson(result); //this code was moved here to be able to load the manifest type names correctly //before, it was not getting the names correctly because they were not available availableManifestsGrid = createAvailableManifestsGrid(getManifestList()); availableManifestsGrid.startup(); } ); } function getActiveManifestGroups() { jsonServices.getActiveManifestGroups({}).then( function(result) { var result = dojox.html.entities.decode(result); var manifestGroupObj = dojo.fromJson(result); var items = manifestGroupObj.items; if(items.length == 0){ noActiveManifests(); } else { activeManifestGroupsStore = createStoreFromData(manifestGroupObj); activeManifestGroupsStore.fetch({onComplete: populateManifestGroupsNames}); } }, function(err){ alert("ok"); } ); } function noActiveManifests(){ dojo.style(dojo.byId("loader"), "display", "none"); dojo.style(dojo.byId("main"), "display", "none"); dojo.style(dojo.byId("accessError"), "display", ""); } function populateManifestGroupsNames(items, request) { createActiveManifestGroupInput(items); } function connectGenerateManifestButton() { //change image source generateManifestButton.setAttribute("src","/shared/images/template_APC/generate.gif"); //add class dojo.addClass("generateManifestButton", "clickImg"); if (generateButtonHandle == null) { generateButtonHandle = dojo.connect(dojo.byId("generateManifestButton"), "onclick", function(e) { hideMessages(); if(checkValidations()){ if(checkLodgementRef){ showConfirmGenerate(); } else { generatingManifest = true; generateManifest(); } } //dojo.disconnect(generateButtonHandle); }); } } function disconnectGenerateManifestButton() { //change image to original source generateManifestButton.setAttribute("src","/shared/images/template_APC/generate_grey.gif"); //remove class dojo.removeClass("generateManifestButton", "clickImg"); // var handle = dojo.connect(dojo.byId("generateManifestButton"), "onclick", function(e) { // }); dojo.disconnect(generateButtonHandle); generateButtonHandle = null; //alert("disconnect"); } function checkValidations(){ var errorFlag = true; if(!validateManifestType()){ showErrorMessage("Please correct the errors on the page"); errorFlag = false; } if (!validateManifestPort()) { showErrorMessage("Please correct the errors on the page"); errorFlag = false; } if (!validateDate()) { showErrorMessage("Please correct the errors on the page"); errorFlag = false; } return errorFlag; } function validateManifestType(){ if((dijit.byId("manifestType") == null) || (dijit.byId("manifestType").attr('value') == "")){ return false; } else { return true; } } function validateMaxDateRange(startDate, endDate){ var endDateTime = endDate; endDateTime.setHours("23"); endDateTime.setMinutes("59"); endDateTime.setSeconds("59"); var startDateTime = startDate; startDateTime.setHours("00"); startDateTime.setMinutes("00"); startDateTime.setSeconds("00"); var diffDays = Math.abs(dojo.date.difference(endDateTime, startDateTime, "day")); if(diffDays <= maxDateRange){ return true; } else{ dojo.byId("errorEndDate").innerHTML = "The date range requested cannot exceed "+maxDateRange+" days inclusive"; dojo.style(dojo.byId("errorEndDate"), "display", ""); return false; } } function validateStartDateRange(startDate, nowDate){ var minusDay = parseInt(-maxDateRange) + 1;// add 1 day as wee include the current day as whole day var value = dojo.date.add(nowDate, "day", minusDay); var earliestDate = dojo.date.locale.format(value, {datePattern: "dd-MMM-yyyy", selector: "date"}); var nowDateTime = nowDate; nowDateTime.setHours("23"); nowDateTime.setMinutes("59"); nowDateTime.setSeconds("59"); var startDateTime = startDate; startDateTime.setHours("00"); startDateTime.setMinutes("00"); startDateTime.setSeconds("00"); var diffDays = Math.abs(dojo.date.difference(nowDateTime, startDateTime, "day")); if(diffDays <= maxDateRange){ return true; } else{ dojo.byId("errorStartDate").innerHTML = "The start date requested cannot be earlier than "+earliestDate; dojo.style(dojo.byId("errorStartDate"), "display", ""); return false; } } function validateStartDate(startDate, endDate){ var compare = dojo.date.compare(endDate, startDate, "hour"); return (compare >= 0); } function validManifestDateTimeFormat(){ var invalidMessage = "The value entered is not valid"; if(dijit.byId("selectedManifestDate").isValid()){ dojo.style(dojo.byId("errorManifestDate"), "display", "none"); return true; } else { dojo.byId("errorManifestDate").innerHTML = invalidMessage; dojo.style(dojo.byId("errorManifestDate"), "display", ""); return false; } } function validDateTimeFormat(){ var validStartDateFormat = false; var validStartTimeFormat = false; var validEndDateFormat = false; var validEndTimeFormat = false; var invalidMessage = "The value entered is not valid"; if(dijit.byId("manifestStartDate").isValid()){ validStartDateFormat = true; } else { dojo.byId("errorStartDate").innerHTML = invalidMessage; dojo.style(dojo.byId("errorStartDate"), "display", ""); } if(dijit.byId("manifestStartTime").isValid()){ validStartTimeFormat = true; } else { dojo.byId("errorStartDate").innerHTML = invalidMessage; dojo.style(dojo.byId("errorStartDate"), "display", ""); } if(dijit.byId("manifestEndDate").isValid()){ validEndDateFormat = true; } else { dojo.byId("errorEndDate").innerHTML = invalidMessage; dojo.style(dojo.byId("errorEndDate"), "display", ""); } if(dijit.byId("manifestEndTime").isValid()){ validEndTimeFormat = true; } else { dojo.byId("errorEndDate").innerHTML = invalidMessage; dojo.style(dojo.byId("errorEndDate"), "display", ""); } return (validStartDateFormat && validStartTimeFormat && validEndDateFormat && validEndTimeFormat); } function validateDate(){ //2012-02-23 11:00:00 if(validDateTimeFormat()){ var validDateRange = true; var validStartDateRange = true; var start = formatToServerFormatDate(dijit.byId("manifestStartDate").attr('value')) + " " + dijit.byId("manifestStartTime").attr('value'); var end = formatToServerFormatDate(dijit.byId("manifestEndDate").attr('value')) + " " + dijit.byId("manifestEndTime").attr('value'); var startDate = dojo.date.locale.parse(start, {datePattern: "yyyy-MM-dd HH:mmm:ss", selector: "date"}); var endDate = dojo.date.locale.parse(end, {datePattern: "yyyy-MM-dd HH:mmm:ss", selector: "date"}); if(maxDateRange != ""){ validStartDateRange = validateStartDateRange(startDate, now); validDateRange = validateMaxDateRange(startDate, endDate); } var validStartDate = validateStartDate(startDate, endDate); if(!validStartDate){ showErrorMessage("Please correct the errors on the page"); dojo.byId("errorEndDate").innerHTML = "End Date/Time cannot be before Start Date/Time"; dojo.style(dojo.byId("errorEndDate"), "display", ""); } if(validDateRange && validStartDateRange && validStartDate){ return true; } else { showErrorMessage("Please correct the errors on the page"); return false; } } else { showErrorMessage("Please correct the errors on the page"); return false; } } function validateManifestPort(){ if(( (dijit.byId("manifestPort") == null) || (dijit.byId("manifestPort").attr('value') == "") ) && (portMandatory)){ return false; } else { return true; } } function validateExtras(){ if(validateLodgmentReference()){ generatingManifest = true; dijit.byId("confirmGenerate").hide(); generateManifest(); } else { showErrorMessage("Please correct the errors on the page"); } } function validateLodgmentReference(){ if(dijit.byId("lodgementRef").isValid()){ return true; } else { dojo.byId("errorLodgmentRef").innerHTML = "Please enter a Lodgement Reference"; dojo.style(dojo.byId("errorLodgmentRef"), "display", ""); return false; } } function showConfirmGenerate() { dijit.byId("lodgementRef").setValue(""); dijit.byId("confirmGenerate").show(); } function generateManifest() { generatingManifest = true; hideMessages(); toggleGenerateStatus(); validateLodgmentReference(); var manifestStartDate = formatToServerFormatDate(dijit.byId("manifestStartDate").attr('value')); var manifestStartTime = dijit.byId("manifestStartTime").attr('value'); var manifestEndDate = formatToServerFormatDate(dijit.byId("manifestEndDate").attr('value')); var manifestEndTime = dijit.byId("manifestEndTime").attr('value'); var manifestType = dijit.byId("manifestType").attr('value'); //var manifestPort = dijit.byId("manifestPort").attr('value'); //var manifestMlid = dijit.byId("manifestMlid").attr('value'); var lodgementRef = dijit.byId("lodgementRef").attr('value'); requestedManifestTypeId = manifestType; jsonServices.generateManifest({manifestStartDate:manifestStartDate, manifestStartTime:manifestStartTime, manifestEndDate:manifestEndDate, manifestEndTime:manifestEndTime,manifestType:manifestType, manifestPort:manifestPort, manifestMlid:manifestMlid, lodgementRef:lodgementRef}).addCallback( function(result) { toggleGenerateStatus(); var resultObj = dojo.fromJson(result); if (resultObj[0]) { showInfoMessage("The manifest was generated successfully"); } else { showErrorMessage(resultObj[1]); } //getNumberOfJobs(); resetAfterGenerateManifest(); refreshListNoConnect(); }); generatingManifest = false; } function toggleGenerateStatus() { dojo.toggleClass("generateStatus", "spinner-busy"); } function openReportWindow(reportPath) { openwin(reportPath, "_blank", 640, 480); } function cancelGenerateManifest() { if (!generatingManifest) { hideMessages(); connectGenerateManifestButton(); } } function createLodgementRefInput(mandatory) { var lodgementRefTextBox; try { lodgementRefTextBox = dijit.byId("lodgementRef"); lodgementRefTextBox.setAttribute('required',mandatory); } catch (err) { lodgementRefTextBox = new dijit.form.ValidationTextBox({ name: "lodgementRef", value: "", required: mandatory, maxLength: 30 }, "lodgementRef"); } return lodgementRefTextBox; } function createPrintLink(manifestId) { return "<a href='#' onclick='printManifest("+manifestId+")'><img class='clickImg' src='/shared/images/template_APC/print.gif' alt='print'/></a>"; } function createPrintLinkTable(values) { var type="pdf"; var buttonInputs = ""; if(values[2] == 1) { //pdf type="pdf"; //return "<a href='#' onclick='printManifestTable("+values[0]+","+values[1]+",\""+type+"\""+")'><img class='clickImg' src='/shared/images/template_APC/print.gif' alt='printPDF'/></a>"; buttonInputs= "<button type='button' class='newBtn pdfBtn' onclick='printManifestTable("+values[0]+","+values[1]+",\""+type+"\""+")'><span>pdf</span></button> "; } if(values[3] == 1) { //csv type="csv"; //return "<a href='#' onclick='printManifestTable("+values[0]+","+values[1]+",\""+type+"\""+")'><img class='clickImg' src='/shared/images/template_APC/print.gif' alt='printCSV'/></a>"; buttonInputs = buttonInputs + "<button type='button' class='newBtn pdfBtn' onclick='printManifestTable("+values[0]+","+values[1]+",\""+type+"\""+")'><span>csv</span></button>"; } return buttonInputs; } function printManifest(manifestId) { var printManifestTypeId = requestedManifestTypeId; jsonServices.printManifest({id:manifestId, manifestTypeId:printManifestTypeId, reportType:"pdf"}).addCallback( function(result) { hideMessages(); var resultObj = dojo.fromJson(result); if (resultObj[0]) { openReportWindow(resultObj[1]); } else { alert("The Customs Manifest is not available at the moment, please try again later."); } }); } function printManifestTable(manifestId, manifestTypeId, type) { jsonServices.printManifest({id:manifestId, manifestTypeId:manifestTypeId, reportType:type}).addCallback( function(result) { hideMessages(); var resultObj = dojo.fromJson(result); if (resultObj[0]) { openReportWindow(resultObj[1]); } else { alert("The Customs Manifest is not available at the moment, please try again later."); } }); } function getManifestList() { return new dojox.data.JsonRestStore({ transport: "GET", envelope: "URL", target: "/ws/manifest_manifestService/listAvailable", idAttribute: "id", parameters: [ { name: "manifestDate", type: "STRING", optional: false } ] }); } function createStoreFromData(data){ return new dojo.data.ItemFileReadStore({ data: data }); } function createManifestGroupInput(store) { var manifestGroupInput = new dijit.form.FilteringSelect({ store: store, value: "--Please select--", labelAttr: "manifestGroupName", searchAttr: "manifestGroupName" }, "manifest"); return manifestGroupInput; } function createManifestTypeInput(store) { var manifestTypeInput = new dijit.form.FilteringSelect({ store: store, value: "--Please select--", searchAttr: "includeGroup" }, "manifestType"); dojo.style(manifestTypeInput.domNode, "width", "21.3em"); return manifestTypeInput; } function createPortInput(store) { var manifestPortInput = new dijit.form.FilteringSelect({ store: store, value: "--Please select--", searchAttr: "portName" }, "manifestPort"); //manifestPortInput.set("displayedValue", "--Please select--"); return manifestPortInput; } function getActiveManifests(manifestGroup) { jsonServices.getManifestTypes({manifestGroup:manifestGroup}).addCallback( function(result) { manifestTypeObj = dojo.fromJson(result); var items = manifestTypeObj.items; for(i = 0; i < items.length; i++){ var item = items; var includeGroup = item.includeGroup; var j; for(j = 0; j < manifestNamesObj.length; j++){ if(includeGroup == manifestNamesObj[j].groupCode){ item.includeGroup = manifestNamesObj[j].groupName; } } } activeManifestsStore = createStoreFromData(manifestTypeObj); var w = dijit.byId("manifestType"); if(w) { //w.set("value", "--Please select--"); w.set("store", activeManifestsStore); w.startup(); } else { var manifestTypeInput = createManifestTypeInput(activeManifestsStore); manifestTypeInput.startup(); dojo.connect(manifestTypeInput, "onChange", function(e) { var type = dijit.byId("manifestType").attr('value'); activeManifestsStore.fetch({ query: { manifestTypeId: type }, onComplete: getActiveManifestInfo }); }); } if(items.length != 2){ w = dijit.byId("manifestType"); w.setDisplayedValue("--Please select--"); if (items.length == 1) { dojo.style(dojo.byId("rowManifestType"), "display", "none"); } else { dojo.style(dojo.byId("rowManifestType"), "display", ""); } } else { var defaultVal = items[1].manifestTypeId; dijit.byId("manifestType").setValue(defaultVal); dojo.style(dojo.byId("rowManifestType"), "display", "none"); if(items[1].checkLodgementRef == 0){ checkLodgementRef = false; } else { checkLodgementRef = true; } createLodgementRefInput(checkLodgementRef); } inputChange(); } ); } function getActiveManifestInfo(items, request){ var item = items[0]; if(item){ var itemId = activeManifestsStore.getValue(item, "manifestTypeId"); var id = dijit.byId("manifestType").attr('value'); maxDateRange = activeManifestsStore.getValue(item, "maxDateRange"); manifestPort = ""; if(activeManifestsStore.getValue(item, "portMandatory") == 0){ portMandatory = false; dojo.style(dojo.byId("rowManifestPort"), "display", "none"); var w = dijit.byId("manifestPortInput"); if(w){ manifestPortInput.reset(); } } else { portMandatory = true; getActivePorts(); dojo.style(dojo.byId("rowManifestPort"), "display", ""); } disconnectGenerateManifestButton(); if(activeManifestsStore.getValue(item, "checkMinimumVol") == 0){ checkMinimumVol = false; } else { checkMinimumVol = true; } if(activeManifestsStore.getValue(item, "checkLodgementRef") == 0){ checkLodgementRef = false; } else { checkLodgementRef = true; } createLodgementRefInput(checkLodgementRef); //getNumberOfJobs(); inputChange(); } } // Create manifest group dropdown function createActiveManifestGroupInput(items) { var manifestGroupInput = dijit.byId("manifest"); if(manifestGroupInput){ manifestGroupInput.set("store", activeManifestGroupsStore); }else{ manifestGroupInput = createManifestGroupInput(activeManifestGroupsStore); dojo.connect(manifestGroupInput, "onChange", function(e) { manifestPort = ""; var w = dijit.byId("manifestPort"); if(w){ w.setDisplayedValue("--Please select--"); } w = dijit.byId("manifestType"); if(w){ w.setDisplayedValue("--Please select--"); } var val = dijit.byId("manifest").attr('value'); getActiveManifests(val); }); } manifestGroupInput.startup(); if(items.length == 2){ var manifestGroup = items[1].manifestGroup; var manifestGroupName = items[1].manifestGroupName; dijit.byId("manifest").setValue(manifestGroup); dijit.byId("manifest").setDisplayedValue(manifestGroupName); } else { dijit.byId("manifest").setDisplayedValue("--Please select--"); } } function getActivePorts() { jsonServices.getConfiguredPorts({}).addCallback( function(result) { var manifestPortObj = dojo.fromJson(result); manifestPortStore = createStoreFromData(manifestPortObj); var portInput = dijit.byId("manifestPort"); if(portInput){ portInput.reset(); } else { portInput = createPortInput(manifestPortStore); dojo.connect(portInput, "onChange", function(e) { //var port = dijit.byId("manifestPort").attr('value'); manifestPortStore.fetch({onComplete: getPortInfo}); }); portInput.startup(); } manifestPortStore.fetch({onComplete: setDefaultPortInfo}); } ); } function setDefaultPortInfo(items, request) { if(items.length == 2){ var item = items[1]; var defaultVal = manifestPortStore.getValue(item, "portCode"); dijit.byId("manifestPort").setValue(defaultVal); //dojo.style(dojo.byId("rowManifestPort"), "display", "none"); } else { dijit.byId("manifestPort").setDisplayedValue("--Please select--"); dojo.style(dojo.byId("rowManifestPort"), "display", ""); } } function getPortInfo(items, request){ var i; for(i = 0; i < items.length; i++){ var item = items; var itemId = manifestPortStore.getValue(item, "portCode"); var id = dijit.byId("manifestPort").attr('value'); if(id == itemId){ manifestPort = manifestPortStore.getValue(item, "portCode"); manifestMlid = manifestPortStore.getValue(item, "mlid"); minLodgementVol = manifestPortStore.getValue(item, "minLodgementVolume"); } } //getNumberOfJobs(); inputChange(); } function createManifestStartTimeInput() { var timeStoreData = createTimeStoreData(); var timeStore = new dojo.data.ItemFileReadStore({ data: timeStoreData }); var nowRounded = new Date(); nowRounded.setHours(nowRounded.getMinutes() < 30 ? nowRounded.getHours() : nowRounded.getHours()+1); nowRounded.setHours(0); nowRounded.setMinutes(0); nowRounded.setSeconds(0); nowRounded.setMilliseconds(0); var manifestStartTimeInput = new dijit.form.FilteringSelect({ value: dojo.date.locale.format(nowRounded, {timePattern: "HH:mm:ss", selector: "time"}), store: timeStore, searchAttr: "dispTime" }, "manifestStartTime"); dojo.style(manifestStartTimeInput.domNode, "width", "5em"); return manifestStartTimeInput; } function createManifestEndTimeInput() { var timeStoreData = createEndDateTimeStoreData(); var timeStore = new dojo.data.ItemFileReadStore({ data: timeStoreData }); var nowRounded = new Date(); nowRounded.setHours(nowRounded.getMinutes() < 30 ? nowRounded.getHours() : nowRounded.getHours()+1); nowRounded.setHours(23); nowRounded.setMinutes(59); nowRounded.setSeconds(59); nowRounded.setMilliseconds(0); var manifestEndTimeInput = new dijit.form.FilteringSelect({ value: dojo.date.locale.format(nowRounded, {timePattern: "HH:mm:ss", selector: "time"}), store: timeStore, searchAttr: "dispTime" }, "manifestEndTime"); dojo.style(manifestEndTimeInput.domNode, "width", "5em"); return manifestEndTimeInput; } function createTimeStoreData() { return { identifier: 'time', label: 'dispTime', items: [ { time:'00:00:00', dispTime:'00:00'}, { time:'01:00:00', dispTime:'01:00'}, { time:'02:00:00', dispTime:'02:00'}, { time:'03:00:00', dispTime:'03:00'}, { time:'04:00:00', dispTime:'04:00'}, { time:'05:00:00', dispTime:'05:00'}, { time:'06:00:00', dispTime:'06:00'}, { time:'07:00:00', dispTime:'07:00'}, { time:'08:00:00', dispTime:'08:00'}, { time:'09:00:00', dispTime:'09:00'}, { time:'10:00:00', dispTime:'10:00'}, { time:'11:00:00', dispTime:'11:00'}, { time:'12:00:00', dispTime:'12:00'}, { time:'13:00:00', dispTime:'13:00'}, { time:'14:00:00', dispTime:'14:00'}, { time:'15:00:00', dispTime:'15:00'}, { time:'16:00:00', dispTime:'16:00'}, { time:'17:00:00', dispTime:'17:00'}, { time:'18:00:00', dispTime:'18:00'}, { time:'19:00:00', dispTime:'19:00'}, { time:'20:00:00', dispTime:'20:00'}, { time:'21:00:00', dispTime:'21:00'}, { time:'22:00:00', dispTime:'22:00'}, { time:'23:00:00', dispTime:'23:00'} ] }; } function createEndDateTimeStoreData() { return { identifier: 'time', label: 'dispTime', items: [ { time:'00:59:59', dispTime:'00:59'}, { time:'01:59:59', dispTime:'01:59'}, { time:'02:59:59', dispTime:'02:59'}, { time:'03:59:59', dispTime:'03:59'}, { time:'04:59:59', dispTime:'04:59'}, { time:'05:59:59', dispTime:'05:59'}, { time:'06:59:59', dispTime:'06:59'}, { time:'07:59:59', dispTime:'07:59'}, { time:'08:59:59', dispTime:'08:59'}, { time:'09:59:59', dispTime:'09:59'}, { time:'10:59:59', dispTime:'10:59'}, { time:'11:59:59', dispTime:'11:59'}, { time:'12:59:59', dispTime:'12:59'}, { time:'13:59:59', dispTime:'13:59'}, { time:'14:59:59', dispTime:'14:59'}, { time:'15:59:59', dispTime:'15:59'}, { time:'16:59:59', dispTime:'16:59'}, { time:'17:59:59', dispTime:'17:59'}, { time:'18:59:59', dispTime:'18:59'}, { time:'19:59:59', dispTime:'19:59'}, { time:'20:59:59', dispTime:'20:59'}, { time:'21:59:59', dispTime:'21:59'}, { time:'22:59:59', dispTime:'22:59'}, { time:'23:59:59', dispTime:'23:59'} ] }; } function formatToServerFormatDate(value) { return dojo.date.locale.format(value, {datePattern: "yyyy-MM-dd", selector: "date"}); } function getNumberOfJobs() { var manifestStartDate = ""; var manifestStartTime = ""; var manifestEndDate = ""; var manifestEndTime = ""; var manifestType = ""; if(dijit.byId("manifestStartDate")){ manifestStartDate = formatToServerFormatDate(dijit.byId("manifestStartDate").attr('value')); } if(dijit.byId("manifestStartTime")){ manifestStartTime = dijit.byId("manifestStartTime").attr('value'); } if(dijit.byId("manifestEndDate")){ manifestEndDate = formatToServerFormatDate(dijit.byId("manifestEndDate").attr('value')); } if(dijit.byId("manifestEndTime")){ manifestEndTime = dijit.byId("manifestEndTime").attr('value'); } if(dijit.byId("manifestType")){ manifestType = dijit.byId("manifestType").attr('value'); } jsonServices.getNumberOfJobs({manifestStartDate:manifestStartDate, manifestStartTime:manifestStartTime, manifestEndDate:manifestEndDate, manifestEndTime:manifestEndTime,manifestType:manifestType, manifestPort:manifestPort,portMandatory:portMandatory}).addCallback( function(result) { var resultObj = dojo.fromJson(result); numberOfJobs = resultObj.numberOfJobs; createSelectionInfo(); if(numberOfJobs > 0 && !checkMinimumVol){ connectGenerateManifestButton(); } else if (numberOfJobs > 0 && checkMinimumVol && minLodgementVol > 0) { checkMinimunVolume(); } else { disconnectGenerateManifestButton(); } return ""; }); } function checkMinimunVolume() { if(parseInt(numberOfJobs) < parseInt(minLodgementVol)){ disconnectGenerateManifestButton(); } else { connectGenerateManifestButton(); } } function createSelectionInfo() { if((portMandatory) && (minLodgementVol > 0)){ var minVolumeString = "Minimum Lodgement Volume : <b>" + minLodgementVol + "</b> for MLID <b>" + manifestMlid + "</b><br/>"; dojo.byId("minLodgementVolume").innerHTML = minVolumeString; } else { dojo.byId("minLodgementVolume").innerHTML = ""; } var numberOfJobsString = ""; if (numberOfJobs > 0) { numberOfJobsString = "Number of Shipments selected : <b>" + numberOfJobs +"</b>"; if((parseInt(numberOfJobs) < parseInt(minLodgementVol)) && (checkMinimumVol)){ numberOfJobsString += "<br><b>Number of Shipments does not meet Minimum Lodgement Volume</b>"; } } else { numberOfJobsString = "No Shipments selected"; } dojo.byId("numberOfJobs").innerHTML = numberOfJobsString; } function resetAllErrors(){ dojo.query(".errorMessage").style("display", "none"); } function createDefaultManifestStore(){ var result = '{"identifier":"manifestGroup","label":"manifestGroupName","items":[{"manifestGroup":"","manifestGroupName":"--Please select--"}]}'; manifestGroupObj = dojo.fromJson(result); activeManifestGroupsStore = createStoreFromData(manifestGroupObj); activeManifestGroupsStore.fetch({onComplete: populateManifestGroupsNames}); } </script> </html> Â Â Edited July 25, 2018 by 9tailsfox Added code tags
9tailsfox Posted July 25, 2018 Author Posted July 25, 2018 Perhaps any expert here can show me how to send IE click on the DOJO textbox? thanksÂ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now