* Estimates as Tex or Pdf
* Estimate edition [mix Mvc&Ajax] * Billable&Bankable properties on profiles
This commit is contained in:
parent
2ac2338939
commit
b39a444cf0
31 changed files with 1101 additions and 218 deletions
|
|
@ -14,12 +14,20 @@ using System.Net;
|
|||
using WorkFlowProvider;
|
||||
using System.Web.Security;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
using Yavsc.Controllers;
|
||||
using Yavsc.Formatters;
|
||||
using System.Text;
|
||||
using System.Web.Profile;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
|
||||
public class FrontOfficeController : ApiController
|
||||
{
|
||||
|
||||
[AcceptVerbs("GET")]
|
||||
public Catalog Catalog ()
|
||||
{
|
||||
|
|
@ -77,6 +85,52 @@ namespace Yavsc.ApiControllers
|
|||
return est;
|
||||
}
|
||||
|
||||
[AcceptVerbs("GET")]
|
||||
public HttpResponseMessage GetTexEstim(long estimid)
|
||||
{
|
||||
return new HttpResponseMessage () {
|
||||
Content = new ObjectContent (typeof(string),
|
||||
getTexEstim (estimid),
|
||||
new TexFormatter ())
|
||||
};
|
||||
}
|
||||
|
||||
private string getTexEstim(long estimid)
|
||||
{
|
||||
Yavsc.templates.Estim tmpe = new Yavsc.templates.Estim();
|
||||
Estimate e = WorkFlowManager.GetEstimate (estimid);
|
||||
tmpe.Session = new Dictionary<string,object>();
|
||||
tmpe.Session.Add ("estim", e);
|
||||
Profile pr = AccountController.GetProfile (e.Responsible);
|
||||
tmpe.Session.Add ("from", pr);
|
||||
tmpe.Session.Add ("to", pr);
|
||||
tmpe.Init ();
|
||||
return tmpe.TransformText ();
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the estimate in pdf format from tex generation.
|
||||
/// </summary>
|
||||
/// <returns>The estim pdf.</returns>
|
||||
/// <param name="estimid">Estimid.</param>
|
||||
public HttpResponseMessage GetEstimPdf(long estimid)
|
||||
{
|
||||
Estimate estim = WorkFlowManager.GetEstimate (estimid);
|
||||
|
||||
Profile prpro = new Profile(ProfileBase.Create(estim.Responsible));
|
||||
if (!prpro.IsBankable)
|
||||
throw new Exception ("NotBankable:"+estim.Responsible);
|
||||
|
||||
Profile prcli = new Profile(ProfileBase.Create(estim.Client));
|
||||
if (!prcli.IsBillable)
|
||||
throw new Exception ("NotBillable:"+estim.Client);
|
||||
|
||||
return new HttpResponseMessage () {
|
||||
Content = new ObjectContent (
|
||||
typeof(Estimate),
|
||||
estim,
|
||||
new EstimToPdfFormatter ())
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue