176 lines
6.1 KiB
C#
176 lines
6.1 KiB
C#
using System;
|
|
using System.Web.Mvc;
|
|
using GZTW.AyaNova.BLL;
|
|
using ri.util;
|
|
|
|
namespace ri.Controllers
|
|
{
|
|
public class ClientServiceRequestController : Controller
|
|
{
|
|
#region View / accept / reject
|
|
//
|
|
// GET: /ClientServiceRequest/View/5
|
|
public ActionResult View(Guid id)
|
|
{
|
|
ClientServiceRequest c = ClientServiceRequest.GetItem(id);
|
|
|
|
ViewBag.titleName = NameFetcher.GetItem(RootObjectTypes.Client, c.ClientID, true).RecordName;
|
|
ViewBag.statusName = EnumDescConverter.GetEnumDescription(c.Status);
|
|
|
|
string sPriorityColor = "color:orange";
|
|
switch (c.Priority)
|
|
{
|
|
case ClientServiceRequestPriority.ASAP:
|
|
sPriorityColor = "color:DarkOrange";
|
|
break;
|
|
case ClientServiceRequestPriority.Emergency:
|
|
sPriorityColor = "color:Red";
|
|
break;
|
|
case ClientServiceRequestPriority.NotUrgent:
|
|
sPriorityColor = "color:DarkGreen";
|
|
break;
|
|
}
|
|
ViewBag.priorityColor = sPriorityColor;
|
|
ViewBag.priorityName = EnumDescConverter.GetEnumDescription(c.Priority);
|
|
|
|
|
|
//serve up a 404 if not found
|
|
//Needs a custom 404 page, maybe return a custom view or something
|
|
if (c == null) return HttpNotFound();
|
|
formInit(c);
|
|
return View(c);
|
|
}
|
|
|
|
//
|
|
// GET: /ClientServiceRequest/AcceptToNew/5
|
|
public ActionResult AcceptToNew(Guid id)
|
|
{
|
|
ClientServiceRequest c = null;
|
|
try
|
|
{
|
|
c = ClientServiceRequest.GetItem(id);
|
|
if (c == null) return HttpNotFound();
|
|
Workorder w = c.AcceptToNewWorkorder();
|
|
return RedirectToAction("Edit", "Workorder", new { id = w.ID });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ay.setGeneralError(TempData, ex);
|
|
return RedirectToAction("Edit", "ClientServiceRequest", new { id = c.ID });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// GET: /ClientServiceRequest/Reject/5
|
|
public ActionResult Reject(Guid id, string ayf)
|
|
{
|
|
try
|
|
{
|
|
ClientServiceRequest c = ClientServiceRequest.GetItem(id);
|
|
c.Reject();
|
|
return Redirect(ayf);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ay.setGeneralError(TempData, util.ay.GetSQLError(ex));
|
|
return RedirectToAction("Edit", "ClientServiceRequest", new { id = id });
|
|
}
|
|
}
|
|
|
|
#endregion view accept reject
|
|
|
|
#region WO Selector
|
|
//
|
|
// GET: /ClientServiceRequest/SelectWO/5
|
|
public ActionResult SelectWO(Guid id)
|
|
{
|
|
ClientServiceRequest c = ClientServiceRequest.GetItem(id);
|
|
//serve up a 404 if not found
|
|
//Needs a custom 404 page, maybe return a custom view or something
|
|
if (c == null) return HttpNotFound();
|
|
|
|
//Force rights to readonly
|
|
util.ay.setViewBagRights(ViewBag, SecurityLevelTypes.ReadWrite);
|
|
|
|
ViewBag.ayCSRID = id;
|
|
ViewBag.ayClientId = c.ClientID;
|
|
|
|
return View();
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
public ActionResult SelectWO(Guid id, FormCollection f)
|
|
{
|
|
ClientServiceRequest c = null;
|
|
try
|
|
{
|
|
//retrieve the Client in question
|
|
c = ClientServiceRequest.GetItem(id);
|
|
if (c == null) return HttpNotFound();
|
|
Workorder w = c.AcceptToWorkorder(ay.parseGuid("ayWOID", f));
|
|
return RedirectToAction("Edit", "Workorder", new { id = w.ID });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ay.setGeneralError(TempData, ex);
|
|
return RedirectToAction("Edit", "ClientServiceRequest", new { id = id });
|
|
}
|
|
}
|
|
|
|
#endregion wo selector
|
|
|
|
#region Menu and rights
|
|
|
|
private void formInit(ClientServiceRequest c)
|
|
{
|
|
|
|
//slightly different here as normal edit stuff doesn't apply to a csr
|
|
bool canEdit = c.IsEditable;
|
|
|
|
//Force rights to readonly
|
|
util.ay.setViewBagRights(ViewBag, SecurityLevelTypes.ReadOnly);
|
|
|
|
string baseurl = ay.genBaseSiteUrl(Url);
|
|
string sId = c.ID.ToString();
|
|
//string sType = ((int)RootObjectTypes.Client).ToString();
|
|
|
|
#region Generate menu
|
|
ayMenu m = new ayMenu();
|
|
m.title = "O.ClientServiceRequest";
|
|
m.icon = "icon-ClientServiceRequest";
|
|
|
|
|
|
|
|
//---COMMAND ITEMS---
|
|
|
|
//RECORD HISTORY
|
|
m.menuItems.Add(new ayMenuItem("scriptitem", "UI.Command.RecordHistory", "alert('" +
|
|
ay.RecordHistoryText(c.Creator, c.Modifier, c.Created, c.Modified) +
|
|
"')", "icon-RecordHistory"));
|
|
|
|
if (canEdit)
|
|
{
|
|
//ACCEPT TO NEW
|
|
m.menuItems.Add(new ayMenuItem("navitem", "ClientServiceRequest.Label.AcceptToNew", baseurl + "ClientServiceRequest/AcceptToNew?id=" + sId, "icon-ClientServiceRequestAcceptToNew"));
|
|
|
|
//ACCEPT TO EXISTING
|
|
m.menuItems.Add(new ayMenuItem("navitem", "ClientServiceRequest.Label.AcceptToExisting", baseurl + "ClientServiceRequest/SelectWO?id=" + sId, "icon-ClientServiceRequestAcceptToExisting"));
|
|
|
|
//REJECT
|
|
//case 1936
|
|
if(c.Status != ClientServiceRequestStatus.Declined)
|
|
m.menuItems.Add(new ayMenuItem("navitem", "ClientServiceRequest.Label.Reject", baseurl + "ClientServiceRequest/Reject?id=" + sId, "icon-ClientServiceRequestReject", "", "ay-set-ret-url"));
|
|
|
|
}
|
|
|
|
ViewBag.ayMenu = m;
|
|
#endregion generate menu
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|