118 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			118 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 
 | |
| function GetRoadMachines() {
 | |
|     jobsitequery("GetRoadMachines", "", function (data) {
 | |
|         if (data && data.length > 0) {
 | |
|             allroadassets = data;
 | |
|             editableSelectAssignAsset.setEnable(true);
 | |
| 
 | |
|             editableSelectAssignAsset.datasource = data;
 | |
|             editableSelectAssignAsset.valuepath = "Id"
 | |
|             editableSelectAssignAsset.displaypath = "DisplayName";
 | |
|         }
 | |
| 
 | |
|     }, function (err) {
 | |
|     });
 | |
| }
 | |
| 
 | |
| function openAssignDispatch(seltype,) {
 | |
|     assignAsset = null;
 | |
|     _seltype = seltype;
 | |
|     if (_sendType == 1) {
 | |
|         _selectdispatchids = [];
 | |
|         for (var i = 0; i < grid_dt.source.length; i++) {
 | |
|             var ct = grid_dt.source[i].Values;
 | |
|             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();
 | |
|     editableSelectAssignAsset.val('');
 | |
|     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 = editableSelectAssignAsset.selecteditem();
 | |
|     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);
 | |
|             });
 | |
|         }
 | |
|     }
 | |
| } |