function GetRoadMachines() { jobsitequery("GetRoadMachines", "", function (data) { if (data && data.length > 0) { allroadassets = data; $('#dialog_assignasset').dropdownDisabled(false); $('#dialog_assignasset').dropdownSource(data); } }, function (err) { }); } function openAssignDispatch(seltype,) { assignAsset = null; _seltype = seltype; if (_sendType == 1) { _selectdispatchids = []; var tempsource = grid_dt.source; for (var i = 0; i < tempsource.length; i++) { var ct = tempsource[i]; if (ct.Selected) { _selectdispatchids.push(ct.DispatchId); } } if (_selectdispatchids.length == 0) { var title = ""; if (seltype == 1) title = GetTextByKey('P_JS_EMAIL', 'Email'); else title = GetTextByKey('P_MR_PRINT', 'Print'); showAlert(GetTextByKey('P_JS_PLEASESELECTDISPATCH', 'Please select Dispatch.'), title); return; } } if (!allroadassets) GetRoadMachines(); $('#dialog_assignasset').dropdownVal(''); showmaskbg(true); $('#dialog_assignment .dialog-title span.title').text(GetTextByKey('P_JS_DISPATCHASSIGNMENT', 'Dispatch Assignment')); $('#dialog_assignment') .attr('act', 'edit') .css({ 'width': 400, 'top': (document.documentElement.clientHeight - $('#dialog_assignment').height()) / 4, 'left': (document.documentElement.clientWidth - $('#dialog_assignment').width()) / 2 }) .showDialogfixed(); } var assignAsset = null; function onAssignContinue() { assignAsset = $('#dialog_assignasset').dropdownItem(); if (assignAsset == null) { onAssignSkip(); } else { onAssignSkip(assignAsset.DisplayName); } } function assignDispatch(asset) { var item = { 'Type': _sendType, 'AssetID': asset.Id, 'ObjectIDs': _sendType == 0 ? _createrequireids : _selectdispatchids }; var param = JSON.stringify(item); param = htmlencode(param); jobsitequery("AssignDispatch", param, function (data) { if (typeof OnRefresh == "function") OnRefresh(); }, function (err) { }); } function onAssignSkip(assignto) { $("#dialog_assignment").hide(); if (_seltype == 0) { showmaskbg(false); if (_sendType == 0) { onPrint(_createrequireids, assignto); OnExit(); } else if (_sendType == 1) { OnPrint(assignto); } else if (_sendType == 2) { OnPrint(assignto); } if (assignAsset != null) assignDispatch(assignAsset); } else if (_seltype == 1) { if (_sendType == 0) { openSendEmails(assignto, _assetids, function () { if (assignAsset != null) assignDispatch(assignAsset); }); } else if (_sendType == 1) { openSendEmails(assignto, null, function () { if (assignAsset != null) assignDispatch(assignAsset); }); } else if (_sendType == 2) { openSendEmails(assignto, null, function () { if (assignAsset != null) assignDispatch(assignAsset); }); } } }