using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SurveyManagement : WorkOrderBasePage
{
    protected string IID;
    public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
    public string BeginDate = "";
    public string EndDate = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckLoginSession())
        {
            // TODO: sub page
            //RedirectToLoginPage();
        }
        else
        {
            string methodName = Request.Form["MethodName"];
            string requesttype = Request.Params["rt"];
            if (!string.IsNullOrEmpty(methodName))
            {
                ProcessRequest(methodName);
            }
            else if (!string.IsNullOrEmpty(requesttype) && requesttype.ToLower() == "f")
            {
                ProcessFileRequest();
            }
            else if (!IsPostBack)
            {
                // todo nothing
                IID = GetCurrentLoginSession().User.UID;
                this.Title = PageTitle;
                bool license = SystemParams.HasLicense("CustomerRecord");
                if (!license)
                    RedirectToLoginPage();

                bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
                bool permission1 = CheckRight(SystemParams.CompanyID, Feature.WORKORDERSURVEYS);
                if (!permission || !permission1)
                    RedirectToLoginPage();


                DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
                BeginDate = userlocaldate.AddMonths(-1).ToShortDateString();
                EndDate = userlocaldate.ToShortDateString();
            }
        }
    }
    public bool IsAdmin
    {
        get
        {
            var user = GetCurrentUser();
            if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
                return true;
            else
                return false;
        }
    }
}