686 lines
27 KiB
C#
686 lines
27 KiB
C#
using System;
|
|
using System.Web.Mvc;
|
|
|
|
using GZTW.AyaNova.BLL;
|
|
using ri.util;
|
|
|
|
namespace ri.Controllers
|
|
{
|
|
public class WorkorderController : Controller
|
|
{
|
|
|
|
#region Create
|
|
//
|
|
// GET: /Workorder/Create
|
|
public ActionResult Create(Guid ClientId, WorkorderTypes WType)
|
|
{
|
|
Workorder w = null;
|
|
if (WType == WorkorderTypes.Service)
|
|
{
|
|
Guid gTemplate = TemplateServiceResolver.ResolveTemplate(ClientId, GZTW.AyaNova.BLL.User.CurrentThreadUserID);
|
|
if (gTemplate != Guid.Empty)
|
|
w = Workorder.NewItem(gTemplate, ClientId);
|
|
}
|
|
|
|
if(w==null)
|
|
w = Workorder.NewItem(WType);
|
|
|
|
w.ClientID = ClientId;
|
|
|
|
w.Save();
|
|
return RedirectToAction("Edit", new { id = w.ID });
|
|
}
|
|
|
|
public ActionResult CreateForUnit(Guid UnitId, WorkorderTypes WType)
|
|
{
|
|
Guid ClientId=Unit.GetOwnerIDForUnit(UnitId);
|
|
Workorder w = null;
|
|
if (WType == WorkorderTypes.Service)
|
|
{
|
|
Guid gTemplate = TemplateServiceResolver.ResolveTemplate(ClientId, GZTW.AyaNova.BLL.User.CurrentThreadUserID);
|
|
if (gTemplate != Guid.Empty)
|
|
w = Workorder.NewItem(gTemplate, ClientId);
|
|
}
|
|
|
|
if (w == null)
|
|
w = Workorder.NewItem(WType);
|
|
|
|
w.ClientID = ClientId;
|
|
w.WorkorderItems[0].UnitID = UnitId;
|
|
w.Save();
|
|
return RedirectToAction("Edit", new { id = w.ID });
|
|
}
|
|
#endregion create
|
|
|
|
#region Edit
|
|
//
|
|
// GET: /Workorder/Edit/5
|
|
public ActionResult Edit(Guid id)
|
|
{
|
|
if (id == AyaBizUtils.NewObjectGuid)
|
|
throw new System.NotSupportedException("Workorder can't be created from NewObjectGuid");
|
|
Workorder c = getWOFromRequest(id);
|
|
|
|
//serve up a 404 if not found
|
|
if (c == null)
|
|
return HttpNotFound();
|
|
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
|
|
#endregion edit
|
|
|
|
#region Update
|
|
//
|
|
// POST: /Workorder/Edit/5
|
|
[HttpPost]
|
|
[ValidateInput(false)]
|
|
public ActionResult Edit(Guid id, FormCollection f)
|
|
{
|
|
bool justClosed = false;
|
|
bool justServiceCompleted = false;
|
|
bool initiallyServiceCompleted=false;
|
|
bool initiallyClosed=false;
|
|
Workorder c = null;
|
|
try
|
|
{
|
|
c = getWOFromRequest(id);
|
|
if (c == null) return HttpNotFound();
|
|
|
|
//get pre-update closed and service completed status
|
|
if(c.WorkorderType== WorkorderTypes.Service)
|
|
{
|
|
initiallyServiceCompleted=c.ServiceCompleted;
|
|
initiallyClosed=c.Closed;
|
|
}
|
|
|
|
//check if this is a subtle update only to some fields that are allowed above and
|
|
//beyond the general workorder rights (closed, service completed etc) or the whole thing
|
|
if (c.uiResolvedRights == SecurityLevelTypes.ReadOnly)
|
|
{
|
|
if (c.WorkorderType == WorkorderTypes.Service)
|
|
{
|
|
//it's likely a "subtle" update but let's be sure
|
|
if (c.IsServiceCompletedEditable)
|
|
{
|
|
c.ServiceCompleted = ay.parseBool("ServiceCompleted", f);
|
|
|
|
if (initiallyServiceCompleted == false && c.ServiceCompleted == true)
|
|
justServiceCompleted = true;
|
|
}
|
|
|
|
if (c.IsCloseAllowed || c.IsReopenAllowed)
|
|
{
|
|
c.Closed = ay.parseBool("Closed", f);
|
|
|
|
if (initiallyClosed == false && c.Closed == true)
|
|
justClosed = true;
|
|
}
|
|
|
|
if (c.IsCloseByDateAllowed)
|
|
c.WorkorderService.CloseByDate = ay.ParseDateToDbValue("CloseByDate", f);
|
|
|
|
if (c.IsInvoiceNumberEditable)//only if service completed
|
|
c.WorkorderService.InvoiceNumber = f["InvoiceNumber"];
|
|
if(c.IsWorkorderStatusEditable)
|
|
c.WorkorderService.WorkorderStatusID = ay.parseGuid("WorkorderStatusID", f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//update all the fields from collection
|
|
//Since the workorder is split amongst different controllers
|
|
//here we only need to update top level fields
|
|
|
|
//first common fields to all workorder types
|
|
c.Summary = f["Summary"];
|
|
c.ProjectID = ay.parseGuid("ProjectID", f);
|
|
c.WorkorderCategoryID = ay.parseGuid("WorkorderCategoryID", f);
|
|
c.CustomerContactName = f["CustomerContactName"];
|
|
c.CustomerReferenceNumber = f["CustomerReferenceNumber"];
|
|
c.InternalReferenceNumber = f["InternalReferenceNumber"];
|
|
c.Onsite = ay.parseBool("Onsite", f);
|
|
|
|
//now specific to workorder type fields
|
|
switch (c.WorkorderType)
|
|
{
|
|
case WorkorderTypes.Service:
|
|
{
|
|
WorkorderService ws = c.WorkorderService;
|
|
c.ServiceCompleted = ay.parseBool("ServiceCompleted", f);
|
|
c.Closed = ay.parseBool("Closed", f);
|
|
ws.WorkorderStatusID = ay.parseGuid("WorkorderStatusID", f);
|
|
if (c.IsCloseByDateAllowed)
|
|
ws.CloseByDate = ay.ParseDateToDbValue("CloseByDate", f);
|
|
ws.ServiceDate = ay.ParseDateToDbValue("ServiceDate", f);
|
|
|
|
if(c.IsInvoiceNumberEditable)//only if service completed
|
|
ws.InvoiceNumber = f["InvoiceNumber"];
|
|
|
|
if (initiallyServiceCompleted == false && c.ServiceCompleted == true)
|
|
justServiceCompleted = true;
|
|
|
|
if (initiallyClosed == false && c.Closed == true)
|
|
justClosed = true;
|
|
|
|
}
|
|
break;
|
|
case WorkorderTypes.Quote:
|
|
{
|
|
WorkorderQuote wq = c.WorkorderQuote;
|
|
wq.QuoteStatus = (WorkorderQuoteStatusTypes)(ay.ParseInt("QuoteStatus", f));
|
|
wq.DateApproved = ay.ParseDateToDbValue("DateApproved", f);
|
|
wq.DateSubmitted = ay.ParseDateToDbValue("DateSubmitted", f);
|
|
wq.QuoteRequestDate = ay.ParseDateToDbValue("QuoteRequestDate", f);
|
|
wq.ValidUntilDate = ay.ParseDateToDbValue("ValidUntilDate", f);
|
|
wq.PreparedByID = ay.parseGuid("PreparedByID", f);
|
|
wq.Introduction = ay.ParseMultiLineText("Introduction", f);
|
|
}
|
|
break;
|
|
case WorkorderTypes.PreventiveMaintenance:
|
|
{
|
|
WorkorderPreventiveMaintenance wp = c.WorkorderPreventiveMaintenance;
|
|
wp.Active = ay.parseBool("Active", f);
|
|
wp.DayOfTheWeek = (AyaDayOfWeek)(ay.ParseInt("DayOfTheWeek", f));
|
|
wp.WorkorderStatusID = ay.parseGuid("WorkorderStatusID", f);
|
|
wp.NextServiceDate = ay.ParseDateToDbValue("NextServiceDate", f);
|
|
wp.StopGeneratingDate = ay.ParseDateToDbValue("StopGeneratingDate", f);
|
|
wp.GenerateSpan = ay.ParseInt("GenerateSpan", f);
|
|
wp.GenerateSpanUnit = (AyaUnitsOfTime)(ay.ParseInt("GenerateSpanUnit", f));
|
|
wp.ThresholdSpan = ay.ParseInt("ThresholdSpan", f);
|
|
wp.ThresholdSpanUnit = (AyaUnitsOfTime)(ay.ParseInt("ThresholdSpanUnit", f));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//check if service completed is a valid operation
|
|
if (justServiceCompleted)
|
|
{
|
|
bool hasError = false;
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
|
|
if (c.HasPartRequestsOnOrder)
|
|
{
|
|
hasError = true;
|
|
sb.AppendLine(ay.lt("Workorder.Label.Error.PartRequestsOnOrder"));
|
|
}
|
|
|
|
if (c.HasPartRequestsUnOrdered)
|
|
{
|
|
if (hasError)
|
|
sb.AppendLine("---------------------------");
|
|
hasError = true;
|
|
sb.AppendLine(ay.lt("Workorder.Label.Error.PartRequestsUnOrdered"));
|
|
}
|
|
|
|
if (c.HasOutstandingLoanItems)
|
|
{
|
|
if (hasError)
|
|
sb.AppendLine("---------------------------");
|
|
hasError = true;
|
|
sb.AppendLine(ay.lt("Workorder.Label.Error.LoanItemsNotReturned"));
|
|
}
|
|
|
|
if(hasError)
|
|
{
|
|
ay.setGeneralError(TempData, sb.ToString());
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//Handle change if service completed or close status has just changed
|
|
if (justServiceCompleted || justClosed)
|
|
{
|
|
if (!c.AllPartsUsed)
|
|
{
|
|
c.SetAllPartsUsed();
|
|
}
|
|
}
|
|
|
|
//handle update
|
|
if (c.IsDirty)
|
|
{
|
|
if (c.IsSavable)
|
|
{
|
|
//all ok
|
|
c.Save();
|
|
}
|
|
else
|
|
{
|
|
//Broken rules
|
|
ayBrokenRules rulesError = new ayBrokenRules(c);
|
|
ViewBag.err = rulesError;
|
|
}
|
|
}
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ay.setGeneralError(TempData, ex);
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
}
|
|
#endregion update
|
|
|
|
#region Delete
|
|
//
|
|
// GET: /Workorder/Delete/5
|
|
public ActionResult Delete(Guid id, string ayf)
|
|
{
|
|
try
|
|
{
|
|
Workorder w = Workorder.GetItemNoMRU(id);
|
|
if (w == null) return HttpNotFound();
|
|
w.Delete();
|
|
w.Save();
|
|
return Redirect(ayf);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ay.setGeneralError(TempData, util.ay.GetSQLError(ex));
|
|
return RedirectToAction("Index");
|
|
}
|
|
}
|
|
|
|
#endregion delete
|
|
|
|
#region Generate from quote / pm
|
|
//
|
|
// GET: /Workorder/Generate
|
|
public ActionResult Generate(Guid id, WorkorderTypes WType)
|
|
{
|
|
Workorder w=null;
|
|
if (WType == WorkorderTypes.Quote)
|
|
{
|
|
w = Workorder.NewServiceWorkorderFromQuote(id);
|
|
}
|
|
else if (WType == WorkorderTypes.PreventiveMaintenance)
|
|
{
|
|
w = Workorder.NewServiceWorkorderFromPM(id);
|
|
}
|
|
else
|
|
{
|
|
throw new System.NotSupportedException("WorkorderController->Generate: type " + WType.ToString() + " is not supported");
|
|
}
|
|
|
|
w.Save();
|
|
return RedirectToAction("Edit", new { id = w.ID });
|
|
}
|
|
|
|
|
|
#endregion create
|
|
|
|
#region Signature
|
|
//
|
|
// GET: /Workorder/Sign/5
|
|
public ActionResult Sign(Guid id)
|
|
{
|
|
if (id == AyaBizUtils.NewObjectGuid)
|
|
throw new System.NotSupportedException("Workorder can't be created from NewObjectGuid");
|
|
Workorder c = getWOFromRequest(id);
|
|
|
|
//serve up a 404 if not found
|
|
if (c == null || c.WorkorderType != WorkorderTypes.Service)
|
|
return HttpNotFound();
|
|
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
|
|
//
|
|
// POST: /Workorder/Sign/5
|
|
[HttpPost]
|
|
[ValidateInput(false)]
|
|
public ActionResult Sign(Guid id, FormCollection f)
|
|
{
|
|
Workorder c = null;
|
|
try
|
|
{
|
|
c = getWOFromRequest(id);
|
|
//serve up a 404 if not found
|
|
if (c == null || c.WorkorderType != WorkorderTypes.Service)
|
|
return HttpNotFound();
|
|
|
|
//save signature
|
|
string sigData = f["sigpad-data"];
|
|
if (!string.IsNullOrWhiteSpace(sigData))
|
|
{
|
|
c.WorkorderService.SetSignature = sigData;
|
|
}
|
|
if (f["btnDelete"] != null)
|
|
{
|
|
c.WorkorderService.ClearSignature = true;
|
|
}
|
|
|
|
//handle update
|
|
if (c.IsDirty)
|
|
{
|
|
if (c.IsSavable)
|
|
{
|
|
//all ok
|
|
c.Save();
|
|
}
|
|
else
|
|
{
|
|
//Broken rules
|
|
ayBrokenRules rulesError = new ayBrokenRules(c);
|
|
ViewBag.err = rulesError;
|
|
}
|
|
}
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ay.setGeneralError(TempData, ex);
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
}
|
|
#endregion sign
|
|
|
|
#region Report
|
|
//
|
|
// GET: /Workorder/Report/5
|
|
public ActionResult Report(Guid id)
|
|
{
|
|
Workorder c = getWOFromRequest(id);
|
|
//serve up a 404 if not found
|
|
if (c == null)
|
|
return HttpNotFound();
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ValidateInput(false)]
|
|
public ActionResult Report(Guid id, FormCollection f)
|
|
{
|
|
|
|
Workorder c = getWOFromRequest(id);
|
|
//serve up a 404 if not found
|
|
if (c == null)
|
|
return HttpNotFound();
|
|
|
|
string[] s = f["btnRpt"].Split(',');
|
|
bool summary = (s[0] != "PRINTDETAILED");
|
|
Guid reportId = new Guid(s[1]);
|
|
string sReportUrl = string.Empty;
|
|
string baseurl = ay.genBaseSiteUrl(Url);
|
|
//============
|
|
|
|
switch (c.WorkorderType)
|
|
{
|
|
case WorkorderTypes.Service:
|
|
|
|
if (summary)
|
|
sReportUrl = util.ay.cacheReport( s[1], WorkorderServiceList.ReportKey,
|
|
WorkorderServiceList.GetListForSingleItem(c.ID), Url);
|
|
else
|
|
sReportUrl = util.ay.cacheReport( s[1], WorkorderServiceDetailedReportData.ReportKey,
|
|
WorkorderServiceDetailedReportData.GetItem(c.ID), Url);
|
|
break;
|
|
|
|
case WorkorderTypes.PreventiveMaintenance:
|
|
if (summary)
|
|
sReportUrl = util.ay.cacheReport( s[1], WorkorderPMList.ReportKey,
|
|
WorkorderPMList.GetListForSingleItem(c.ID), Url);
|
|
|
|
else
|
|
sReportUrl = util.ay.cacheReport( s[1], WorkorderPMDetailedReportData.ReportKey,
|
|
WorkorderPMDetailedReportData.GetItem(c.ID), Url);
|
|
break;
|
|
|
|
case WorkorderTypes.Quote:
|
|
if (summary)
|
|
sReportUrl = util.ay.cacheReport( s[1], WorkorderQuoteList.ReportKey,
|
|
WorkorderQuoteList.GetListForSingleItem(c.ID), Url);
|
|
|
|
else
|
|
sReportUrl = util.ay.cacheReport( s[1], WorkorderQuoteDetailedReportData.ReportKey,
|
|
WorkorderQuoteDetailedReportData.GetItem(c.ID), Url);
|
|
break;
|
|
}
|
|
|
|
//============
|
|
|
|
|
|
return Redirect(sReportUrl);
|
|
|
|
//formInit(c);
|
|
//return View(c);
|
|
}
|
|
|
|
|
|
#endregion report
|
|
|
|
#region Shared code
|
|
private Workorder getWOFromRequest(Guid id)
|
|
{
|
|
Workorder c = null;
|
|
//if no rel (related object) query string then it's a straight open up by id
|
|
if (Request.QueryString["rel"] == null)
|
|
return Workorder.GetItem(id);
|
|
|
|
//It might have a child id either for navigation purposes
|
|
//or simply because there is no parent workorder id in the url
|
|
if (Request.QueryString["rel"] != null)
|
|
{
|
|
//rel = relative record type which is the first initial of each word of the workorder descendant root object types
|
|
string rel = Request.QueryString["rel"].ToString();
|
|
RootObjectTypes relType = RootObjectTypes.Nothing;
|
|
//These are the types supported in the workorder get by relative code
|
|
|
|
switch (rel)
|
|
{
|
|
case "wi":
|
|
relType = RootObjectTypes.WorkorderItem;
|
|
break;
|
|
case "wil":
|
|
relType = RootObjectTypes.WorkorderItemLabor;
|
|
break;
|
|
case "wit":
|
|
relType = RootObjectTypes.WorkorderItemTravel;
|
|
break;
|
|
case "wisu":
|
|
relType = RootObjectTypes.WorkorderItemScheduledUser;
|
|
break;
|
|
case "wios":
|
|
relType = RootObjectTypes.WorkorderItemOutsideService;
|
|
break;
|
|
case "wipr":
|
|
relType = RootObjectTypes.WorkorderItemPartRequest;
|
|
break;
|
|
case "wip":
|
|
relType = RootObjectTypes.WorkorderItemPart;
|
|
break;
|
|
case "wilo":
|
|
relType = RootObjectTypes.WorkorderItemLoan;
|
|
break;
|
|
case "wime":
|
|
relType = RootObjectTypes.WorkorderItemMiscExpense;
|
|
break;
|
|
case "wpm":
|
|
relType = RootObjectTypes.WorkorderPreventiveMaintenance;
|
|
break;
|
|
case "wq":
|
|
relType = RootObjectTypes.WorkorderQuote;
|
|
break;
|
|
default:
|
|
throw new System.NotSupportedException("WorkorderController->getWOFromRequest(" + rel + ") not supported");
|
|
}
|
|
|
|
//where to go in the view specifically:
|
|
ViewBag.goToObject = relType;
|
|
ViewBag.goToObjectId = id;
|
|
//If no workorder yet then fetch via relative
|
|
if (c == null)
|
|
return Workorder.GetWorkorderByRelative(relType, id);
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
#endregion shared code
|
|
|
|
#region Menu and rights
|
|
|
|
private void formInit(Workorder c)
|
|
{
|
|
|
|
ViewBag.client = c.uiClient;
|
|
string sWOType = string.Empty;
|
|
string sWOTypeIcon = string.Empty;
|
|
bool isQuote = false;
|
|
bool isPM = false;
|
|
string sType = ((int)c.FollowTypeAndID.RootObjectType).ToString();
|
|
|
|
switch(c.WorkorderType)
|
|
{
|
|
case WorkorderTypes.Service:
|
|
sWOType = ay.lt("O.WorkorderService");
|
|
sWOTypeIcon = "icon-Workorder";
|
|
break;
|
|
case WorkorderTypes.Quote:
|
|
sWOType = ay.lt("O.WorkorderQuote");
|
|
sWOTypeIcon = "icon-WorkorderQuote";
|
|
isQuote = true;
|
|
break;
|
|
case WorkorderTypes.PreventiveMaintenance:
|
|
sWOType = ay.lt("O.PreventiveMaintenance");
|
|
sWOTypeIcon = "icon-WorkorderPreventiveMaintenance";
|
|
isPM = true;
|
|
break;
|
|
default:
|
|
throw new System.NotSupportedException("WorkorderController->formInit: workorder type " + c.WorkorderType.ToString() + " is not a supported type");
|
|
|
|
}
|
|
ViewBag.workorderTypeName = sWOType;
|
|
|
|
|
|
//set rights using method in workorder itself
|
|
util.ay.setViewBagRights(ViewBag, c.uiResolvedRights);
|
|
|
|
//EXCEPTIONS TO RIGHTS
|
|
if (ViewBag.ayReadOnly)
|
|
{
|
|
//is read only, let's check for exceptions though...
|
|
System.Collections.Generic.List<string> allowedFields = new System.Collections.Generic.List<string>();
|
|
if (c.IsServiceCompletedEditable)
|
|
allowedFields.Add("ServiceCompleted");
|
|
if (c.IsCloseAllowed || c.IsReopenAllowed)
|
|
allowedFields.Add("Closed");
|
|
|
|
if (c.IsCloseByDateAllowed)
|
|
allowedFields.Add("CloseByDate");
|
|
|
|
if (c.IsInvoiceNumberEditable)
|
|
{
|
|
allowedFields.Add("InvoiceNumber");
|
|
allowedFields.Add("WorkorderStatusID");
|
|
}
|
|
|
|
|
|
|
|
//this is from WBI for reference:
|
|
//Check for special exception to enable service completed checkbox
|
|
//ckServiceCompleted.Enabled = c.IsServiceCompletedEditable;
|
|
//cbWorkorderStatusID.Enabled = ckServiceCompleted.Enabled;
|
|
//edInvoiceNumber.Enabled = c.IsInvoiceNumberEditable;
|
|
//ckClosed.Enabled = c.IsCloseAllowed;
|
|
|
|
if (allowedFields.Count > 0)
|
|
ViewBag.allowedFields = allowedFields;
|
|
}
|
|
else
|
|
{
|
|
//is not read only, let's check for exceptions to that though...
|
|
System.Collections.Generic.List<string> restrictedFields = new System.Collections.Generic.List<string>();
|
|
if (!c.IsCloseByDateAllowed)
|
|
restrictedFields.Add("CloseByDate");
|
|
|
|
if(!c.IsInvoiceNumberEditable)
|
|
restrictedFields.Add("InvoiceNumber");
|
|
|
|
//case 3575
|
|
if (!c.IsCloseAllowed)
|
|
restrictedFields.Add("Closed");
|
|
|
|
if (restrictedFields.Count > 0)
|
|
ViewBag.restrictedFields = restrictedFields;
|
|
}
|
|
#region Generate menu
|
|
ayMenu m = new ayMenu();
|
|
m.title = sWOType;
|
|
m.icon = sWOTypeIcon;
|
|
string cId = c.ID.ToString();
|
|
string baseurl = ay.genBaseSiteUrl(Url);
|
|
|
|
|
|
if (c.uiCanSign)
|
|
m.menuItems.Add(new ayMenuItem("navitem", "Workorder.Label.Sign", ay.genBaseSiteUrl(Url) + "Workorder/Sign?id=" + c.ID.ToString(), "glyphicon glyphicon-pencil"));
|
|
|
|
if (AyaBizUtils.Right("Object.ScheduleMarker") > (int)SecurityLevelTypes.NoAccess)
|
|
m.menuItems.Add(new ayMenuItem("navitem", "ScheduleMarker.Label.FollowUp", baseurl + "FollowUp?followId=" + cId + "&followType=" + sType, "icon-FollowUp"));
|
|
|
|
|
|
if (c.CanWiki)
|
|
{// util.ay.OpenWikiPage(mWorkorder.RootObjectType, mWorkorder.ID, false);//case 1584 was RootObjectTypes.Workorder
|
|
|
|
m.menuItems.Add(new ayMenuItem("navitem", "O.WikiPage", ay.WikiUrl(c.RootObjectType, c.ID, Url), "icon-WikiPage"));
|
|
m.menuItems.Add(new ayMenuItem("navitem", "O.AyaFile", ay.WikiFileUrl(c.RootObjectType, c.ID, Url), "icon-WikiFile"));
|
|
}
|
|
|
|
//GENERATE WO FROM QUOTE
|
|
if (isQuote)
|
|
{
|
|
m.menuItems.Add(new ayMenuItem("navitem", "WorkorderQuote.Label.GenerateServiceWorkorder",
|
|
baseurl + "Workorder/Generate?id=" + cId + "&WType=" + WorkorderTypes.Quote, "icon-Workorder"));
|
|
}
|
|
|
|
//GENERATE WO FROM PM
|
|
if (isPM)
|
|
{
|
|
m.menuItems.Add(new ayMenuItem("navitem", "WorkorderPreventiveMaintenance.Label.GenerateServiceWorkorder",
|
|
baseurl + "Workorder/Generate?id=" + cId + "&WType=" + WorkorderTypes.PreventiveMaintenance, "icon-Workorder"));
|
|
}
|
|
|
|
//REPORT
|
|
if (AyaBizUtils.Right("Object.Report") > (int)SecurityLevelTypes.NoAccess)
|
|
m.menuItems.Add(new ayMenuItem("navitem", "UI.Toolbar.Print", ay.genBaseSiteUrl(Url) + "Workorder/Report?id=" + c.ID.ToString(), "icon-Report"));
|
|
|
|
|
|
//---COMMAND ITEMS---
|
|
m.menuItems.Add(new ayMenuItem("divider", "", "", ""));
|
|
|
|
m.menuItems.Add(new ayMenuItem("scriptitem", "UI.Command.RecordHistory", "alert('" +
|
|
ay.RecordHistoryText(c.Creator, c.Modifier, c.Created, c.Modified) +
|
|
"')", "icon-RecordHistory"));
|
|
|
|
|
|
//DELETE
|
|
if (c.IsDeleteable)
|
|
{
|
|
m.menuItems.Add(new ayMenuItem("navitem", "UI.Command.Delete", baseurl + "Workorder/Delete?id=" + cId, "icon-Delete", ay.PromptForDelete(), "ay-set-ret-url"));
|
|
}
|
|
|
|
|
|
//c.WorkorderService.Signature.HasSignature
|
|
ViewBag.ayMenu = m;
|
|
#endregion generate menu
|
|
}
|
|
#endregion
|
|
|
|
//eoc
|
|
}
|
|
}
|