/// <summary>
        /// Récupére les différentes informations relatives au LAB/RECUEIL sur la liste de clients/prospects
        /// </summary>
        /// <param name="pLstCustomersProspects"></param>
        /// <param name="pCurrentUser">The current user connected to define LAB/RECUEIL access</param>
        public static List<Data.Model.CustomerProspect> GetCustomerProspectInformations(Guid pSelectedUserId, bool? isCustomer, Upsilab.Data.Model.User pCurrentUser, FirmInstitution pFirmInstitutionParent, List<FirmInstitution> pLstFirmInstitutions)
        {
            //bool HasLAB = false;
            //bool HasReport = false;

            //if (pCurrentUser != null)
            //{
            //    HasLAB = Upsilab.Business.License.LicenseBL.IsValid(pCurrentUser.IdLicenseLab);
            //    HasReport = Upsilab.Business.License.LicenseBL.IsValid(pCurrentUser.IdLicenseReport);
            //}

            //Get customers with all infos for a selected user
            List<Data.Model.CustomerProspect> customerProspects = null;

            //Si la FirmInstitutionParent est "SingleUsersDB", afficher tous les clients de l'établissement auquel l'utilisateur est rattaché
            if (pFirmInstitutionParent.SingleUsersDB
                || pSelectedUserId == Guid.Empty) //Aucun user selectionné => Tous : Filtrer par établissement
            {
                customerProspects = GetCustomerProspectsByIdFirmInstitution(null, pLstFirmInstitutions, isCustomer);
            }
            else
            {
                customerProspects = GetCustomerProspectsByIdUserCreated2(pSelectedUserId, isCustomer);
            }

            //foreach (var _customer in customerProspects)
            //{
            //    _customer.HasReport = HasReport;
            //    _customer.HasLAB = HasLAB;
            //}

            return customerProspects;

        }
 public ConventionVM(FirmInstitution firmInstitutionCGP, string statutConvention, Guid idTransaction, string documentType)
 {
     FirmInstitutionCGP = firmInstitutionCGP;
     FirmInstitutionName = firmInstitutionCGP.FirmInstitutionName;
     Status = statutConvention;
     IdTransaction = idTransaction;
     DocumentType = documentType;
 }
        public static List<LABMeasure> GetLABMeasureForFirmInstitution(FirmInstitution firmInstitution)
        {
            List<LABMeasure> returnValue = new List<LABMeasure>();

            if (firmInstitution != null)
                returnValue = LABMeasureBL.GetLABMeasuresByIdFirmInstitution(firmInstitution.idFirmInstitution);

            return returnValue;
        }
        public static Boolean UploadFirmInstitutionLogo(FirmInstitution firm, HttpPostedFileBase postedFile, String fileExtension, out string newFilename)
        {
            var currentUser = SessionManager.GetUserSession();
            newFilename = string.Empty;

            if (currentUser == null)
                return false;

            if (firm == null)
                return false;

            newFilename = string.Format("{0}_logo_{1}{2}", GetCorrectFileName(firm.FirmInstitutionName), DateTime.Now.ToString("yyyyMMdd_HHmmss"), fileExtension);
            var path = BuildLogoPath(firm.idFirmInstitution);

            return FileManager.Upload(postedFile, path, newFilename, true); //Upload logo
        }
        public static List<AgregSuiviCommercialModel> GetListClientsSuiviCommercial(Guid pSelectedUserId, bool? isCustomer, Upsilab.Data.Model.User pCurrentUser, FirmInstitution pFirmInstitutionParent, List<FirmInstitution> pLstFirmInstitutions)
        {
            using (UpsilabEntities db = new UpsilabEntities())
            {
                string sIdFirms = string.Empty;

                List<string> idfirms = pLstFirmInstitutions.Select(f => f.idFirmInstitution.ToString()).ToList();
                if (idfirms != null && idfirms.Count() > 0)
                {
                    sIdFirms = string.Join(",", idfirms.ToArray());
                }

                List<AgregSuiviCommercialModel> resultat = db.ExecuteStoreQuery<AgregSuiviCommercialModel>("exec GetListClientsSuiviCommercial @idUser, @isSingleUserDB ,@isCustomer ,@lstIdFirm", new SqlParameter("@idUser", pSelectedUserId), new SqlParameter("@isSingleUserDB", pFirmInstitutionParent.SingleUsersDB), new SqlParameter("@isCustomer", isCustomer), new SqlParameter("@lstIdFirm", sIdFirms)).ToList<AgregSuiviCommercialModel>(); ;

                return resultat;
            }
        }
        public static void GenerateLicense(FirmInstitution pFirm, Subscription pSub)
        {
            LicenseType licLAB = LicenseTypeBL.GetLicenseTypeeByName(LicenseTypeBL.LabApplication);
            LicenseType licReport = LicenseTypeBL.GetLicenseTypeeByName(LicenseTypeBL.RecueilApplication);

            List<int> lstLicenseType = new List<int>();
            List<string> lstLicensePrefixe = new List<string>();
            switch (pSub.Application)
            {
                case "Lab":
                    lstLicenseType.Add(licLAB.idLicenseType);
                    lstLicensePrefixe.Add("L");
                    break;
                case "Recueil":
                    lstLicenseType.Add(licReport.idLicenseType);
                    lstLicensePrefixe.Add("R");
                    break;
                case "Recueil+Lab":
                    lstLicenseType.Add(licLAB.idLicenseType);
                    lstLicenseType.Add(licReport.idLicenseType);
                    lstLicensePrefixe.Add("L");
                    lstLicensePrefixe.Add("R");
                    break;
            }

            using (UpsilabEntities context = new UpsilabEntities())
            {
                for (int j = 0; j < lstLicenseType.Count; j++)
                {
                    for (int i = 1; i <= pSub.UserCount; i++)
                    {
                        Upsilab.Data.Model.License li = new Data.Model.License();
                        li.idLicense = Guid.NewGuid();
                        li.DateCreated = DateTime.Now;
                        li.DateExpired = pSub.DateExpired;
                        li.idLicenseType = lstLicenseType[j];
                        li.IsValid = true;
                        li.IdSubscription = pSub.IdSubscription;
                        li.LicenseKey = GenerateLicenseKey(pFirm.idFirmInstitution, lstLicensePrefixe[j], pSub.DateCreated, i);
                        context.License.AddObject(li);
                    }
                }
                context.SaveChanges();

            }
        }
        public static List<FirmInstitutionAdviser> GetAdvisers(FirmInstitution _FirmInstitution, Boolean includeDeletedOrInactive = true)
        {
            List<FirmInstitutionAdviser> retVal = new List<FirmInstitutionAdviser>();

            using (UpsilabEntities retrieveContext = new UpsilabEntities())
            {
                var query = retrieveContext.FirmInstitutionAdviser
                    .Include("User").Include("FirmInstitution").Include("FirmInstitution1")
                    .Where(a => a.idFirmInstitution.Equals(_FirmInstitution.idFirmInstitution));

                if (!includeDeletedOrInactive)
                    query = query.Where(a => a.User.IsDeleted == false)
                        .Where(a => a.User.IsActive == true);

                foreach (var _adv in query)
                {
                    retrieveContext.LoadProperty(_adv, "User");
                    retVal.Add(_adv);
                }
            }

            return retVal;
        }
Esempio n. 8
0
        public static FirmInstitution AddCGP(Guid idFirmSdg, Guid idUserCreated, string firmCGPName, string address, string city, string zipCode, string email, string phone, string oriasNumber)
        {
            using (Data.Model.UpsilabEntities context = new UpsilabEntities())
            {
                try
                {
                    //
                    //
                    //
                    var cgp = new FirmInstitution
                    {
                        idFirmInstitution = Guid.NewGuid(),
                        IdFirmInstitutionType = 1, //CGP by default
                        FirmInstitutionParent = idFirmSdg,
                        FirmInstitutionName = firmCGPName,
                        FirmStreet = address,
                        FirmPostCode = zipCode,
                        FirmCity = city,
                        FirmPhone = phone,
                        E_mail = email,
                        OriasNumber = oriasNumber,
                        DateCreated = DateTime.Now,
                    };

                    context.FirmInstitution.AddObject(cgp);
                    context.SaveChanges();

                    return cgp;
                }
                catch (Exception e)
                {
                    Log.Log.AppendException(e);
                    throw new Exception("SavingError");
                }

            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="NomPrenomConseillerPrincipal"></param>
        /// <returns>maybe  NULL</returns>
        private User GetAdviser(string NomPrenomConseillerPrincipal, FirmInstitution pFirmInstitution)
        {
            string conseiller = NomPrenomConseillerPrincipal.Trim();

            bool isEmail = Regex.IsMatch(conseiller, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.Compiled);

            User CustomerProspectCreator;

            if (isEmail)
                CustomerProspectCreator = UserBL.GetUserAdviserByEmail(conseiller, pFirmInstitution/*SessionManager.GetFirmInstitutionSession()*/);
            else
                CustomerProspectCreator = UserBL.GetUserByNameAndFirstname(conseiller, pFirmInstitution/*SessionManager.GetFirmInstitutionSession()*/);

            return CustomerProspectCreator;
        }
        public static List<AgregClientModel> GetListAgregClientByCodeisin(Guid idCgp, string codeisin, bool? isCustomer, Upsilab.Data.Model.User pCurrentUser, FirmInstitution pFirmInstitutionParent, List<FirmInstitution> pLstFirmInstitutions)
        {
            using (UpsilabEntities db = new UpsilabEntities())
            {
                string sIdFirms = string.Empty;

                List<string> idfirms = pLstFirmInstitutions.Select(f => f.idFirmInstitution.ToString()).ToList();
                if (idfirms != null && idfirms.Count() > 0)
                {
                    sIdFirms = string.Join(",", idfirms.ToArray());
                    //sIdFirms = string.Format("'{0}'",sIdFirms);
                }

                db.CommandTimeout = 180;
                List<AgregClientModel> resultat = db.ExecuteStoreQuery<AgregClientModel>("exec GetListAgregClientByCodeisin @idUser,@codeisin, @isSingleUserDB ,@isCustomer ,@lstIdFirm", new SqlParameter("@idUser", idCgp), new SqlParameter("@codeisin", codeisin), new SqlParameter("@isSingleUserDB", pFirmInstitutionParent.SingleUsersDB), new SqlParameter("@isCustomer", isCustomer), new SqlParameter("@lstIdFirm", sIdFirms)).ToList<AgregClientModel>();

                return resultat;
            }
        }
 public static Boolean DoesFirmInstitutionHaveValidReportLicense(FirmInstitution firmInstitution)
 {
     return FirmInstitutionBL.DoesFirmInstitutionHaveValidReportLicense(firmInstitution.idFirmInstitution);
 }
        private static string GetFile(FirmInstitution firm, bool isUrl, DocumentType docType)
        {
            string retFile = string.Empty;
            string fileToGet = string.Empty;

            if (docType == DocumentType.Presentation)
            {
                fileToGet = firm.PresentationFile;
            }
            else if (docType == DocumentType.StartRelation)
            {
                fileToGet = firm.LegalInformationFile;
            }

            //File name set ?
            if (!string.IsNullOrEmpty(fileToGet))
            {
                //Exist file
                string fileNamePath = string.Format(@"{0}\{1}", BuildDocumentPath(firm.idFirmInstitution), fileToGet);

                string fileNameFullPath = string.Format(@"{0}\{1}", System.Web.HttpContext.Current.Server.MapPath("~/uploads"), fileNamePath);
                string fileNameUrl = string.Format("{0}/uploads/{1}", Upsilab.Business.Utility.UrlHelper.GetHost(), fileNamePath).Replace("\\", "/");

                if (System.IO.File.Exists(fileNameFullPath))
                {
                    retFile = (isUrl) ? fileNameUrl : fileNameFullPath;
                }
            }

            return retFile;
        }
        public static bool CreateAdviserWithoutUser(FirmInstitution _firmInstitution, FirmInstitutionAdviser _adviser)
        {
            bool retVal = true;

            using (Data.Model.UpsilabEntities createContext = new UpsilabEntities())
            {
                Data.Model.FirmInstitutionAdviser adviser = new FirmInstitutionAdviser();
                adviser.idFirmInstitution = _firmInstitution.idFirmInstitution;
                adviser.idUser = _adviser.User.idUser;
                adviser.DateCreated = DateTime.Now;

                adviser.HasLAB = _adviser.HasLAB;
                adviser.HasReport = _adviser.HasReport;
                adviser.idFirmInstitutionParent = _adviser.idFirmInstitutionParent;

                createContext.FirmInstitutionAdviser.AddObject(adviser);
                createContext.SaveChanges();
            }

            return retVal;
        }
        public List<CustomerProspect> GetCustomersData(Guid userCreatorId, List<Guid> firmInstitutionIds, FirmInstitution firmInstitutionParent)
        {
            List<CustomerProspect> customerProspects = new List<CustomerProspect>();

            //Redmine #6916 : Si la FirmInstitutionParent est "SingleUsersDB", pas de dropdown User
            bool isCustomer = true;
            if (firmInstitutionParent.SingleUsersDB)
            {
                customerProspects = CustomerProspectBL.GetCustomerProspectLAB_ReportInfosByIdFirmInstitution(null, firmInstitutionIds, isCustomer);
            }
            else
            {
                customerProspects = CustomerProspectBL.GetCustomerProspectLAB_ReportInfosByIdUserCreated(userCreatorId, firmInstitutionIds, isCustomer);
            }

            return customerProspects;
        }
 public static string GetStartRelationFile(FirmInstitution firm, bool isUrl)
 {
     return GetFile(firm, isUrl, DocumentType.StartRelation);
 }
        public ActionResult Identification()
        {
            FirmInstitution objFirmInstution = SessionManager.GetFirmInstitutionSession();
            if (objFirmInstution == null)
            {
                objFirmInstution = new FirmInstitution() { idFirmInstitution = Guid.NewGuid() };
            }

            return View(objFirmInstution);
        }
 public static Boolean DoesFirmInstitutionHaveAnyValidLicense(FirmInstitution firmInstitution)
 {
     return DoesFirmInstitutionHaveAnyValidLicense(firmInstitution.idFirmInstitution);
 }
        public static byte[] ConvertHtmlSringToPDF(FirmInstitution firmInstitutionSDG, string cgpName, Data.Model.Document document, string destinationPathFileName, bool forceDownload, out int pageCount, string logoUrl = "")
        {            
            Byte[] documentBytes = null;
            pageCount = 0;
            try
            {
                var firmSDG = GetFirmSDG();
                var languageData = PageLanguageHelper.GetLanguageContent("User", "Convention");

                DocumentModel documentModel = GetDocumentModel(firmInstitutionSDG.idFirmInstitution, !string.IsNullOrEmpty(document.DocumentType) ? document.DocumentType : "");
                if(documentModel != null)
                {
                    string strHtmlMapped = null;
                    string strFooter = null;

                    var model = EntityToModel(documentModel);
                    strHtmlMapped = AppendIntoBodyHtml(model.HtmlTemplate);

                    strHtmlMapped = strHtmlMapped.Replace("[sdg_lieu_fait_a]", firmSDG.FirmCity);
                    strHtmlMapped = strHtmlMapped.Replace("[sdg_attention]", "Service administratif");

                    using (UpsilabEntities context = new UpsilabEntities())
                    {
                        var firmInstitution = context.FirmInstitution.Where(f => f.idFirmInstitution == firmInstitutionSDG.idFirmInstitution).FirstOrDefault();


                        strHtmlMapped = MapSignatoryKeys(context, document.idSignatureTransaction, strHtmlMapped); 

                        strFooter = firmInstitution.DocumentFooterContent.ToString();
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_NOM + "]",
                            firmInstitution.FirmInstitutionName);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_DIRIGEANT_NOM + "]",
                            firmInstitution.LeaderName);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_DIRIGEANT_PRENOM + "]",
                            firmInstitution.LeaderFirstName);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_DIRIGEANT_CIVILITE + "]",
                            firmInstitution.User.Civility);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_DIRIGEANT_FONCTION + "]",
                            firmInstitution.LeaderFonction);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_DIRIGEANT_DATE_NAIS + "]",
                            firmInstitution.LeaderBirthDay.ToString());
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_DIRIGEANT_LIEU_NAIS + "]",
                            firmInstitution.LeaderPlaceOfBirth);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_DIRIGEANT_FORMATION + "]",
                            firmInstitution.LeaderFormation);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_DIRIGEANT_CURSUS + "]",
                            firmInstitution.LeaderCursusProfessional);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_ADRESSE + "]",
                            firmInstitution.FirmStreet);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_CODE_POSTAL + "]",
                            firmInstitution.FirmPostCode);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_VILLE + "]",
                            firmInstitution.FirmCity);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_TEL_PROF + "]",
                            firmInstitution.FirmPhone);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_TEL_PORTABLE + "]",
                            firmInstitution.MobilePhone);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_FAX + "]", firmInstitution.Fax);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_EMAIL + "]",
                            firmInstitution.E_mail);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_WEB + "]",
                            firmInstitution.Website);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_APE + "]",
                            firmInstitution.NAF_APE);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_NAF + "]", firmInstitution.NAF);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_CAPITAL + "]",
                            firmInstitution.ShareCapital);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.DATE_FAIT_A + "]",
                            DateTime.Now.ToString("d"));
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_NUM_AGREMENT + "]",
                            firmInstitution.AgreementNumber);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_NUM_SOCIETE + "]",
                            firmInstitution.RCS);
                        strHtmlMapped = strHtmlMapped.Replace("[" + FieldsEditorBL.ETAB_NUM_ASSURANCE + "]",
                            firmInstitution.NumeroAssuranceQBE);

                        strHtmlMapped = strHtmlMapped.Replace("[logo]", logoUrl + "NextStatge.jpg");

                        if (forceDownload == true)
                        {
                            strHtmlMapped = strHtmlMapped.Replace("[readApprovedLabel]", string.Format("{0}.", languageData.GetContent("Read_approved_signature_label")));
                            strHtmlMapped = strHtmlMapped.Replace("[dateApprovedLabel]", string.Format("{0} : ", languageData.GetContent("Date_approved_signature_label")));
                        }
                        else
                        {
                            strHtmlMapped = strHtmlMapped.Replace("[readApprovedLabel]", "");
                            strHtmlMapped = strHtmlMapped.Replace("[dateApprovedLabel]", "");
                        }


                        var valDico = new Dictionary<string, string>();
                        var fieldDico = new Dictionary<string, FieldValueModel>();
                        //Get all NameKey exist
                        var nameKeys = FieldValuesBL.GetAllNameKeyForMapping(documentModel.IdDocumentModel);
                        var listNameKey = nameKeys.ToList();

                        //Replace all NameKey value to empty                        
                        foreach (var item in listNameKey)
                        {
                            valDico[item.NameKey] = string.Empty;
                            fieldDico[item.NameKey] = item;
                        }


                        //Get all NameKey which has value
                        var dico = FieldValuesBL.GetForMapping(document.idDocument);

                        foreach (var item in dico)
                        {
                            //Replace NameKey value with his right value
                            valDico[item.Key] = item.Value;
                        }
                        
                        foreach (var fv in valDico)
                        {
                            var value = fv.Value;
                            var nk = fieldDico[fv.Key] ?? new FieldValueModel() { Value = string.Empty };
                            var type = (nk != null && !string.IsNullOrEmpty(nk.Value)) ? nk.Value : "";

                            switch (type)
                            {
                                case "radio":
                                case "radiogroup":
                                //case "civilite":
                                    var rad_pattern = string.Format("ckvalue=\"{0}_{1}\"", fv.Key, value);
                                    var rad_replace = "checked";
                                    strHtmlMapped = strHtmlMapped.Replace(rad_pattern, rad_replace);
                                    break;
                                case "civilite":
                                    if(!string.IsNullOrEmpty(value)) 
                                    {
                                        var pattern = value.ToLower();
                                        value = languageData.GetContent(string.Format("civilite_{0}", value.ToLower()));
                                    }
                                    strHtmlMapped = strHtmlMapped.Replace("[" + fv.Key + "]", !string.IsNullOrEmpty(value) ? value : string.Empty);
                                    break;
                                case "checkbox":
                                    var cbx_pattern = string.Format("value=\"[{0}]\"", fv.Key);
                                    var cbx_replace = (value == "True") ? "checked" : "";
                                    strHtmlMapped = strHtmlMapped.Replace(cbx_pattern, cbx_replace);
                                    break;

                                case "numeric":
                                    if (!String.IsNullOrEmpty(value))
                                    {
                                        decimal d = 0;
                                        Decimal.TryParse(value.Replace('.', ','), out d);
                                        if (d > 0)
                                        {
                                            var f = new NumberFormatInfo { NumberGroupSeparator = " ", CurrencyDecimalDigits = 2 }; //TODO cultureInfo
                                            value = d.ToString("n", f);
                                        }
                                    }
                                    strHtmlMapped = strHtmlMapped.Replace("[" + fv.Key + "]", !string.IsNullOrEmpty(value) ? value : string.Empty);
                                    break;

                                case "ibanfield":
                                    string[] ibanwords = value.Split(' ');
                                    for (int i = 0; i < ibanwords.Length; i++)
                                    {
                                        var iban_pattern = string.Format("ibanvalue=\"{0}_{1}\"", fv.Key, i);
                                        var iban_replace = string.Format("value=\"{0}\"", ibanwords[i]);  //ibanwords[i];
                                        strHtmlMapped = strHtmlMapped.Replace(iban_pattern, iban_replace);
                                    }
                                    break;
                                case "datetime":
                                    if (!string.IsNullOrEmpty(value))
                                    {
                                        var dt = DateTime.MinValue;
                                        DateTime.TryParse(value, CultureInfo.CreateSpecificCulture("Fr"), DateTimeStyles.None, out dt);
                                        if (dt == DateTime.MinValue)
                                        {
                                            DateTime.TryParse(value, CultureInfo.CreateSpecificCulture("en-US"), DateTimeStyles.None, out dt);
                                        }
                                        if (dt != DateTime.MinValue)
                                        {
                                            value = dt.ToString("dd/MM/yyyy");
                                        }
                                    }
                                    strHtmlMapped = strHtmlMapped.Replace("[" + fv.Key + "]", !string.IsNullOrEmpty(value) ? value : string.Empty);
                                    break;
                                default:
                                    strHtmlMapped = strHtmlMapped.Replace("[" + fv.Key + "]", !string.IsNullOrEmpty(value) ? value : string.Empty);
                                    break;
                            }

                        }


                }

                    if (!forceDownload)
                    {
                        // save the PDF bytes in a file on disk
                        string outFilePath = System.IO.Path.Combine(destinationPathFileName);
                        ExpertPDFHelper expertPdfEngine = new ExpertPDFHelper();
                        ExpertPdf.HtmlToPdf.PdfDocument.Document pdfDocument = expertPdfEngine.GeneratePdfDocumentUsingComponent(strHtmlMapped, cgpName, strFooter, true);
                        pageCount = pdfDocument.Pages.Count;
                        pdfDocument.Save(outFilePath);

                    }
                    else
                    {
                         ExpertPDFHelper expertPdfEngine = new ExpertPDFHelper();
                         documentBytes = expertPdfEngine.GeneratePdfBytesUsingComponent(strHtmlMapped, cgpName, strFooter, true);  
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Erreur lors de la génération du template HTML en PDF : {0}", ex.Message));
            }

            return documentBytes;
        }
 public static void CreateFirmInstition(FirmInstitution _firmInstitution)
 {
     using (Data.Model.UpsilabEntities createContext = new UpsilabEntities())
     {
         createContext.FirmInstitution.AddObject(_firmInstitution);
         createContext.SaveChanges();
     }
 }
        public ActionResult UnLogiciel(SubscriptionModel postedSubscriptionModel)
        {
            var currentUser = SessionManager.GetUserSession();
            var isModelStateValid = ModelState.IsValid;
            var currentHost = Upsilab.Business.Utility.ConfigurationManager.ExtranetHostCode;

            if (currentUser.IsSuperAdmin())
            {
                isModelStateValid = true; //N'est pas utilisé en superadmin
            }

            if (isModelStateValid)
            {
                FirmInstitution currentFirm = new FirmInstitution();

                #region Gestion de l'etablissement
                //Prendre l'etablissement en session si c'est un admin
                #region SuperAdmin
                if (SessionManager.GetUserSession().IsSuperAdmin())
                {
                    int idSponsor = 0;
                    #region Sponsor
                    if (Request.Params["IdSponsor"] != null)
                    {
                        string sIdSponsor = Request.Params["IdSponsor"].ToString();

                        Int32.TryParse(sIdSponsor, out idSponsor);
                    }
                    #endregion

                    if (Request.Params["souscripteur"] != null)
                    {
                        if (Request.Params["souscripteur"].ToString().ToLower() == "new")
                        {
                            currentFirm.idFirmInstitution = GuidHelper.GenerateGuid();
                            //currentFirm.LeaderName = postedSubscriptionModel.FirmInstitution.LeaderName;
                            //currentFirm.LeaderFirstName = postedSubscriptionModel.FirmInstitution.LeaderFirstName;
                            currentFirm.ContactName = postedSubscriptionModel.FirmInstitution.ContactName;
                            currentFirm.ContactFirstName = postedSubscriptionModel.FirmInstitution.ContactFirstName;
                            currentFirm.E_mail = postedSubscriptionModel.FirmInstitution.E_mail;
                            currentFirm.FirmInstitutionName = postedSubscriptionModel.FirmInstitution.FirmInstitutionName;
                            currentFirm.FirmPostCode = postedSubscriptionModel.FirmInstitution.FirmPostCode;
                            currentFirm.FirmStreet = postedSubscriptionModel.FirmInstitution.FirmStreet;
                            currentFirm.FirmCity = postedSubscriptionModel.FirmInstitution.FirmCity;
                            currentFirm.FirmPhone = postedSubscriptionModel.FirmInstitution.FirmPhone;
                            currentFirm.idUserCreated = currentUser.idUser; //TODO : it's not the really admin, change it later
                            currentFirm.IdFirmInstitutionType = 1; //CGP by default
                            currentFirm.DateCreated = DateTime.Now;
                            currentFirm.HostCode = currentHost;

                            if (idSponsor != 0)
                            {
                                currentFirm.IdSponsor = idSponsor;
                            }

                            if (currentHost == PageLanguageHelper.HostCode.BE.ToString())
                            {
                                currentFirm.ContactFonction = postedSubscriptionModel.FirmInstitution.ContactFonction;
                                currentFirm.ContactMobile = postedSubscriptionModel.FirmInstitution.ContactMobile;
                                currentFirm.NumeroTVAIntracommunautaire = postedSubscriptionModel.FirmInstitution.NumeroTVAIntracommunautaire;
                            }

                            FirmInstitutionBL.CreateFirmInstition(currentFirm);

                            if (currentHost == PageLanguageHelper.HostCode.BE.ToString())
                            {
                                //save FSMAFirmInstitution
                                Option objOption = Upsilab.Business.Option.OptionBL.GetOptionById(1);
                                if (objOption != null)
                                {
                                    FirmInstitutionOptionBL.SaveFirmInstitutionOptionValue(currentFirm.idFirmInstitution, objOption, 1, postedSubscriptionModel.FirmInstitution.NumFSMA, "txtAttr");
                                }
                            }

                        }
                        else if (Request.Params["souscripteur"].ToString().ToLower() == "old" && Request.Params["IdSelectedFirmInstitution"] != null)
                        {
                            Guid idSelectedFirm;
                            Guid.TryParse(Request.Params["IdSelectedFirmInstitution"].ToString(), out idSelectedFirm);

                            if (idSelectedFirm != null)
                            {
                                currentFirm = FirmInstitutionBL.GetFirmInstitutionByIdFirmInstitution(idSelectedFirm);
                            }
                        }

                        if (idSponsor != 0)
                        {
                            FirmInstitutionBL.UpdateFirmInstitution(currentFirm.idFirmInstitution, "FirmInstitution.IdSponsor", idSponsor.ToString());
                        }

                        //Save selected firm to session
                        SessionManager.SetSelectedFirmInstitutionBySuperAdmin(currentFirm);
                    }
                }
                #endregion

                #region User Admin
                else
                {
                    currentFirm = SessionManager.GetFirmInstitutionSession(); //Extranet user
                }
                #endregion

                #endregion

                if (currentFirm != null)
                {
                    #region Cas SuperAdmin
                    if (SessionManager.GetUserSession().IsSuperAdmin())
                    {
                        #region Sponsor
                        int idSponsor = 0;
                        if (Request.Params["IdSponsor"] != null)
                        {
                            string sIdSponsor = Request.Params["IdSponsor"].ToString();

                            Int32.TryParse(sIdSponsor, out idSponsor);
                        }
                        #endregion

                        //Subscription newSouscription = null;
                        IDictionary<string, string> dicoRes = new Dictionary<string, string>();

                        dicoRes.Add("Page_title", LanguageData.GetContent("Page_title"));
                        dicoRes.Add("Title_h1", LanguageData.GetContent("Title_h1"));
                        dicoRes.Add("Title_h1_span", LanguageData.GetContent("Title_h1_span"));
                        Subscription subscription = null;

                        try
                        {
                            string isPaymentChecked = Request.Params["chkPaiement"]; ;
                            DateTime datePayment;
                            DateTime? dateUpdated = null;

                            DateTime.TryParse(Request.Params["inputPaiement"], out datePayment);

                            //Get subscription in session                            
                            SessionManager.Get<Subscription>(SouscriptionBL.SubscriptionSession, out subscription);

                            if (currentFirm != null && subscription != null)
                            {
                                subscription.IdFirmInstitution = currentFirm.idFirmInstitution;
                                subscription.DateCreated = DateTime.Now;
                                subscription.DateExpired = DateTime.Now.AddYears(postedSubscriptionModel.Subscription.Duration.Value);


                                switch (postedSubscriptionModel.Subscription.Application)
                                {
                                    case "Recueil": subscription.Product = SouscriptionBL.Product_Type_Recueil; break;
                                    case "Lab": subscription.Product = SouscriptionBL.Product_Type_lab; break;
                                    case "Recueil+Lab": subscription.Product = SouscriptionBL.Product_Type_Recueil_lab.ToString(); break;
                                }

                                //-----------
                                //SouscriptionBL.Calculate(postedSubscriptionModel.Subscription, true, currentFirm.idFirmInstitution.ToString());
                                //Ne plus calculer puisque c'est deja en session ?
                                //-----------

                                #region Paiement
                                // Si payé, on additionne avec le creditnumber déjà existant
                                if (!string.IsNullOrEmpty(isPaymentChecked) && isPaymentChecked == "on" && datePayment != null)
                                {
                                    subscription.DateUpdate = datePayment;
                                    subscription.IsPaid = true;
                                    dateUpdated = datePayment;
                                }
                                #endregion

                                SouscriptionBL.AddSubscription(subscription); //add to have primary key

                                #region Génération pdf
                                //Génération de la facture
                                string factName = "";
                                string logoPath = System.IO.Path.Combine(Server.MapPath("~/Content/images/"), "LogoUpsideoFoxit.png");

                                string invoicePath = ConfigurationManager.InvoicePath;
                                if (!System.IO.Directory.Exists(invoicePath))
                                {
                                    System.IO.Directory.CreateDirectory(invoicePath);
                                }

                                SouscriptionBL.GenerateInvoiceForSubscription(subscription, currentFirm, invoicePath, logoPath, out factName, dateUpdated);

                                subscription.InvoiceFilename = factName;
                                SouscriptionBL.UpdateSubscription(subscription);
                                #endregion

                                #region Generate Licence and update credit
                                //Génération licence
                                if (subscription.IsPaid)
                                {
                                    LicenseBL.GenerateLicense(currentFirm, subscription);

                                    var newCreditNumber = (currentFirm.CreditCount == null ? 0 : currentFirm.CreditCount) + subscription.CreditNumber;
                                    if (idSponsor != 0)
                                    {
                                        currentFirm.IdSponsor = idSponsor;
                                    }
                                    FirmInstitutionBL.UpdateFirmInstitution(currentFirm.idFirmInstitution, "FirmInstitution.CreditCount", newCreditNumber.ToString());
                                }
                                #endregion

                                dicoRes.Add("Table_Title", LanguageData.GetContent("Table_Title_ok"));
                                dicoRes.Add("Message", LanguageData.GetContent("Message_ok"));

                                if (idSponsor != 0)
                                {
                                    FirmInstitutionBL.UpdateFirmInstitution(currentFirm.idFirmInstitution, "FirmInstitution.IdSponsor", idSponsor.ToString());
                                }

                                SessionManager.Clear(SouscriptionBL.SubscriptionSession);
                            }
                            else
                            {
                                dicoRes.Add("Table_Title", LanguageData.GetContent("Table_Title_firm_non_ok"));
                                dicoRes.Add("Message", LanguageData.GetContent("Message_firm_non_ok"));
                            }
                        }
                        catch (Exception ex)
                        {
                            dicoRes.Add("Table_Title", LanguageData.GetContent("Table_Title_non_ok"));
                            dicoRes.Add("Message", LanguageData.GetContent("Message_non_ok") + ex.Message);
                        }

                        dicoRes.Add("ProductType", subscription.Product);

                        //Si new firminstitution
                        //1- envoyer email au contact facturation
                        //2- créer administrateur central
                        if (Request.Params["souscripteur"] != null && Request.Params["souscripteur"].ToString().ToLower() == "new")
                        {
                            //Config admin central
                            return RedirectToAction(string.Format("Configuration/{0}", subscription.IdSubscription)); // /Souscrire/Configuration/idSubscription
                        }
                        else
                        {
                            //Envoi l'email au contact de facturation
                            if (subscription.IsPaid)
                            {
                                //Ne plus envoyer d'email au contact facturation
                                //subscription = SouscriptionBL.GetSubscriptionsById(subscription.IdSubscription);
                                //SouscriptionBL.SendInvoiceMail(subscription, true); //Send to FirmIntitution Email

                                //subscription.DateSendEmail = DateTime.Now;
                                //SouscriptionBL.UpdateSubscription(subscription);
                            }

                            TempData["DicoRetour"] = dicoRes;
                            return RedirectToAction("Retour");
                        }
                    }
                    #endregion

                    #region Cas User admin
                    else
                    {
                        switch (postedSubscriptionModel.Subscription.Application)
                        {
                            case "Recueil": postedSubscriptionModel.Subscription.Product = SouscriptionBL.Product_Type_Recueil; break;
                            case "Lab": postedSubscriptionModel.Subscription.Product = SouscriptionBL.Product_Type_lab; break;
                            case "Recueil+Lab": postedSubscriptionModel.Subscription.Product = SouscriptionBL.Product_Type_Recueil_lab.ToString(); break;
                        }

                        SouscriptionBL.Calculate(postedSubscriptionModel.Subscription, false, currentFirm.idFirmInstitution.ToString());
                        // TVA or NOT
                        if (ConfigurationManager.ExtranetHostCode == PageLanguageHelper.HostCode.BE.ToString())
                        {
                            if (!string.IsNullOrEmpty(currentFirm.NumeroTVAIntracommunautaire) && currentFirm.NumeroTVAIntracommunautaire.StartsWith("BE-0"))
                            {
                                postedSubscriptionModel.Subscription.TotalAmount = postedSubscriptionModel.Subscription.AmountHT;
                            }
                        }
                        SessionManager.Set<Data.Model.Subscription>(SouscriptionBL.SubscriptionSession, postedSubscriptionModel.Subscription);

                        ViewBag.Title = LanguageData.GetContent("un_logiciel");
                        ViewBag.SelectedClass = "mt1"; //Un logiciel

                        return View("SouscriptionPaiement", postedSubscriptionModel.Subscription);
                    }
                    #endregion
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            else
            {
                SubscriptionModel subscriptionModel = GetSubcriptionModel(postedSubscriptionModel.IdSelectedFirmInstitution); //TODO ?

                postedSubscriptionModel.FirmInstitutionsParents = subscriptionModel.FirmInstitutionsParents;
                postedSubscriptionModel.Licences = subscriptionModel.Licences;

                return View(postedSubscriptionModel);
            }
        }
        public static int GeneratePM_EngagementLetter(Upsilab.Data.Model.MissionDocument pMissionDoc, string pathFileName, bool forceDownload, bool pIsEmptyDocument = false)
        {
            float y = 240;
            int height = 20;
            int width = 500;
            int interligne = 15;
            int paddingLeft = 50;
            float label_width = 200;
            float answer_width = 280;
            float answer_x = 200;

            FirmInstitution firmInstitution = pMissionDoc.CustomerProspect.FirmInstitution;
            string footerContent = pMissionDoc.CustomerProspect.FirmInstitution.DocumentFooterContent;
            Data.Model.User userAdviser = (pMissionDoc.User != null) ? pMissionDoc.User : pMissionDoc.CustomerProspect.User1;


            //Title and footer document
            string documentTitle = "Lettre de mission";
            string name = string.Empty;
            string date = string.Empty;
            string idDocument = string.Empty;

            if (!pIsEmptyDocument)
            {
                name = pMissionDoc.CustomerProspect.CompanyName;
                date = DateTime.Now.ToShortDateString();
                idDocument = pMissionDoc.idMissionDocument.ToString();
            }

            if (forceDownload)
                date = string.Empty;
            //FoxitPDFGenerator pdfGen = new FoxitPDFGenerator(documentTitle, footerContent);
            FoxitPDFGenerator pdfGen = new FoxitPDFGenerator(documentTitle, footerContent, name, string.Format("{0} {1}", string.IsNullOrEmpty(date) ? string.Empty : LanguageContentBL.Translate("PdfReportPP_004"), date));

            #region page 1
            //Logo
            string logoPathFileName = Upsilab.Business.Utility.FileManager.BuildLogoPath(firmInstitution.idFirmInstitution) + firmInstitution.Logo;
            pdfGen.AddBackgroungImage();
            pdfGen.AddLogoOnFirstPage(logoPathFileName, firmInstitution.LogoAlign);


            if (pIsEmptyDocument)
            {
                firmInstitution = new FirmInstitution();
                userAdviser = new Data.Model.User();
            }

            //pdfGen.AddReceuil_Title_Center_CalibriBold_Label(LanguageContentBL.Translate("PdfLM_001"), y, width, 100);
            //pdfGen.AddReceuil_SubTitle_Center_CalibriBold_Label(LanguageContentBL.Translate("PdfLM_134"), y += 50, width, height);

            //if (pIsEmptyDocument)
            //{
            //    string[] rowContents = { LanguageContentBL.Translate("PdfRapportMission_002") //Date de maj ou Date de création
            //                         , LanguageContentBL.Translate("PdfFirm_082")
            //                         , string.Empty
            //                       };
            //    pdfGen.LM_AddTableTitle(rowContents, 90, y += 50);
            //}
            //else
            //{
            //    string[] rowContents = { string.Format(LanguageContentBL.Translate("PdfRapportMission_002"), DateTime.Now.ToShortDateString()) //Date de maj ou Date de création
            //                         , string.Format("{0} LM-{1}",LanguageContentBL.Translate("PdfFirm_082"),pMissionDoc.idMissionDocument)
            //                         , string.Format("{0}", pMissionDoc.CustomerProspect.CompanyName)
            //                       };
            //    pdfGen.LM_AddTableTitle(rowContents, 90, y += 50);
            //}

            y = 380;
            pdfGen.AddWhiteTitle(LanguageContentBL.Translate("PdfLM_001"), y, 240, 60, 260, 20);

            pdfGen.AddWhiteTitle(LanguageContentBL.Translate("PdfLM_134"), y += (2 * interligne + 15), 500, 20, 0, 12);//PERSONNE MORALE

            pdfGen.AddWhiteBorder(y += interligne * 1.7f, 210, 290, 70);

            if (pIsEmptyDocument)
            {
            }
            else
            {
                if (!forceDownload)
                    pdfGen.AddWhiteTitleLeft(DateTime.Now.ToShortDateString(), y += 10, 500, 11, 220, 10);
                pdfGen.AddWhiteTitleLeft(name, y += (interligne), 500, 11, 220, 10);
                pdfGen.AddWhiteTitleLeft(string.Format("LM-{0}", pMissionDoc.idMissionDocument), y += (interligne), 500, 11, 220, 10);
            }


            //pdfGen.AddBlueBorder(y += 100, 105, 375, 30);
            //pdfGen.AddReceuil_DetailText_Justify_Calibri_Label(string.Format("{0}", pMissionDoc.CustomerProspect.CompanyName), y + 5, 300, 20, 120);
            #endregion

            #region page 2

            Data.Model.CustomerProspect cust = new Data.Model.CustomerProspect();
            cust.User = new Data.Model.User();
            List<CustomerProspectOptionValue> data = new List<CustomerProspectOptionValue>();
            if (!pIsEmptyDocument)
            {
                cust = pMissionDoc.CustomerProspect;
                data = Upsilab.Business.CustomerProspect.CustomerProspectOptionBL.GetOptionValueListWithIdCustomerProspectAndIdParentOption(cust.idCustomer,
                    Upsilab.Business.CustomerProspect.CustomerProspectBL.EngagementLetterParentQuestionId);
            }

            pdfGen.CreatePage();
            y = 0;
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_003"), y, width, height);
            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_004"), cust.CompanyName), y += interligne * 1.5f, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_004"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(cust.CompanyName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format("Prénom : {0}", "XXX"), y += interligne, width, height);
            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_006"), cust.Adress), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_006"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(cust.Adress, y, answer_width, height * 3, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_007"), cust.ZipCode), y += interligne*2.8f, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_007"), string.Empty), y += interligne * 2.8f, label_width, height);
            pdfGen.AddAnswer(cust.ZipCode, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_008"), cust.City), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_008"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(cust.City, y, answer_width, height, answer_x);


            FirmInstitution firm = new FirmInstitution();
            if (!pIsEmptyDocument)
                firm = cust.FirmInstitution;
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_009"), y += interligne * 1.5f, width, height);
            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_010"), firm.FirmInstitutionName), y += interligne * 1.5f, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_010"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.FirmInstitutionName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_011"), userAdviser.UserName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_011"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(userAdviser.UserName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_012"), userAdviser.UserFirstName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_012"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(userAdviser.UserFirstName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_013"), firm.LeaderName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_013"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.LeaderName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_014"), firm.LeaderFirstName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_014"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.LeaderFirstName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_015"), firm.FirmStreet), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_015"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.FirmStreet, y, answer_width, height * 3, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_016"), firm.FirmPostCode), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_016"), string.Empty), y += interligne * 2.8f, label_width, height);
            pdfGen.AddAnswer(firm.FirmPostCode, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_017"), firm.FirmCity), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_017"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.FirmCity, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_018"), firm.RCS), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_018"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.RCS, y, answer_width, height, answer_x);


            if (SessionManager.GetHostCodeSession() != PageLanguageHelper.HostCode.BE.ToString())
            {
                //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_019"), firm.RegisteredInRegister), y += interligne, width, height);
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_019"), string.Empty), y += interligne, label_width, height);
                pdfGen.AddAnswer(firm.RegisteredInRegister, y, answer_width, height, answer_x);

                //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_020"), firm.AgregateurNoms), y += interligne, width, height);
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_020"), string.Empty), y += interligne, label_width, height);
                pdfGen.AddAnswer(firm.AgregateurNoms, y, answer_width, height, answer_x);

            }

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_021"), y += interligne * 2, width, height, paddingLeft);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_022"), y += interligne * 1.5f, width, height);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_023"), y += interligne * 1.5f, width, height * 2);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_024"), y += interligne * 3f, width, height * 2);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_025"), y += interligne * 2.5f, width, height * 2);

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_026"), y += interligne * 2.5f, width, height);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_027"), y += interligne * 1.5f, width, height * 3);


            #endregion

            #region page 3

            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_028"), y, width, height);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(138, data), y += interligne * 1.5f, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_029"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(139, data), y += interligne + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_030"), y, width, height * 2, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(140, data), y += interligne * 1.5f, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_031"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(141, data), y += interligne + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_032"), y, width, height * 2, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(142, data), y += interligne * 1.5f, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_033"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(143, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_034"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(144, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_035"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(145, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_036"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(146, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_037"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(147, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_038"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(148, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_039"), y, width, 20, 15);
            //PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetProspectValue(149, data), y += interligne, 0, "1");
            //pdfGen.AddDefaultText("Réception / transmission d’ordres", y, width, 20, 15);
            //PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetProspectValue(150, data), y += interligne, 0, "1");
            //pdfGen.AddDefaultText("Suivi annuel de patrimoine et produits financiers externes", y, width, 20, 15);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_040"), y += interligne, width, height);
            pdfGen.AddBlueBorder(y += interligne, 0, width, 20);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(128, 96, data), y + 5, width, height, 5);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_040"), y += interligne * 1.5f, width, height);
            pdfGen.AddBlueBorder(y += interligne, 0, width, 20);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(128, 97, data), y + 5, width, height, 5);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_040"), y += interligne * 1.5f, width, height);
            pdfGen.AddBlueBorder(y += interligne, 0, width, 20);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(128, 98, data), y + 5, width, height, 5);

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_041"), y += interligne * 2, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_042"), y += interligne * 1.5f, width, height);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_031", data), y += interligne * 1.5f + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_043"), y, width, 40, 15);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_032", data), y += interligne * 1.5f, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_045"), y, width, 20, 15);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_033", data), y += interligne + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_054"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_034", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_055"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_035", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_135"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_036", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_136"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_037", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_137"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_038", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_138"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_039", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_139"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_040", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_140"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_041", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_141"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_042", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_142"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Letter_PM_043", data), y += interligne);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_143"), y, width, 20, 15);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_040"), y += interligne, width, height);
            pdfGen.AddBlueBorder(y += interligne, 0, width, 20);
            //if (!cust.IsCorporation.Value)//PP
            //    pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(151, 59, data), y + 5, width, height, 5);
            //else
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue("Client_Letter_PM_044", data), y + 5, width, height, 5);

            #endregion

            #region page 4

            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_056"), y, width, height);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(166, data), y += interligne * 1.5f, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_057"), y, width, 20 * 2, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(167, data), y += interligne * 1.5f, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_058"), y, width, 20 * 3, 15);

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_059"), y += interligne * 3, width, height);
            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_060"), y += interligne * 1.5f, width, height);
            pdfGen.AddLabelNote(LanguageContentBL.Translate("PdfLM_061"), y += interligne, width, height);
            pdfGen.AddBlueBorder(y += interligne, 0, 480, 280);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(168, 100, data), y + 5, 480, 280, 5);
            #endregion

            #region page 5
            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_062"), y, width, height);
            pdfGen.AddLabelNote(LanguageContentBL.Translate("PdfLM_061"), y += interligne, width, height);//Notes
            pdfGen.AddBlueBorder(y += interligne, 0, 480, 280);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(169, 101, data), y + 5, 480, 280, 5);

            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_063"), y += interligne * 22f, width, height);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(172, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_064"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(173, data), y += interligne + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_065"), y, width, 40, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(174, data), y += interligne * 1.5f, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_066"), y, width, 20, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(175, data), y += interligne + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_067"), y, width, 40, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(176, data), y += (interligne) + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_068"), y, width, 40, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(177, data), y += (interligne) + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_069"), y, width, 40, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(178, data), y += (interligne) + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_070"), y, width, 40, 15);

            #endregion

            #region page 6
            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_040"), y, width, height);
            pdfGen.AddBlueBorder(y += interligne, 0, width, 20);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(170, 102, data), y + 5, width, height, 5);

            pdfGen.AddLabelNote(LanguageContentBL.Translate("PdfLM_061"), y += interligne * 2f, width, height);
            pdfGen.AddBlueBorder(y += interligne, 0, width, 280);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(170, 103, data), y + 5, 480, 280, 5);
            #endregion

            #region page 7
            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_071"), y, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_061"), y += interligne, width, height);
            pdfGen.AddBlueBorder(y += interligne, 0, 480, 280);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(171, 104, data), y + 5, 480, 125, 5);

            #endregion

            #region page 8

            pdfGen.CreatePage();
            y = 0;
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_072"), y, width, height);//Le mode de facturation et de rémunération
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_073"), y += interligne, width, 20);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_074"), y += interligne, width, 20 * 3);

            pdfGen.AddBlueBorder(y += interligne * 3, 0, 30, 20);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(131, 105, data), y + 5, 50, 20, 5);
            pdfGen.AddDefaultText("X", y + 8, 20, 20, 40);
            pdfGen.AddBlueBorder(y, 60, 30, 20);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(131, 106, data), y + 5, 50, 30, 65);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_075"), y + 8, width, height, 110);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_076"), y += interligne * 3, width, height * 2);
            // pdfGen.AddDefaultText("Au titre de l’accompagnement du client, une information plus précise sera fournie ultérieurement sur simple demande une fois connus les supports choisis par le client.", y += interligne * 3, width, height * 2, 15);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_077"), y += interligne * 2, width, height * 2, 15);


            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_078"), y += interligne * 3, width, height);//Les honoraires

            //Concernant 1
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(181, data), y += (interligne * 1.5f) + 10, 0, "1");
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_079")
                , pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(181, 115, data)
                , pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(181, 116, data)
                , pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(181, 117, data))
                , y - 10, width, height * 4, 20);

            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_080"), y += interligne * 3f, width, height);

            //Concernant 2
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(182, data), y += (interligne * 1.5f) + 10, 0, "1");
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_081")
                , pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(182, 118, data)), y - 10, width, height * 3, 20);

            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_080"), y += interligne * 2.5f, width, height);

            //Concernant 3
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(183, data), y += (interligne * 1.5f) + 20, 0, "1");
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_082")
                , pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(183, 119, data)), y - 20, width, height * 5, 20);

            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_083")
                , pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(133, 120, data)), y += interligne * 4, width, height * 2);

            /*pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_084")
               , ), y += interligne * 2, width, height);*/

            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_084"), string.Empty), y += interligne * 2, label_width, height);
            pdfGen.AddAnswer(CustomerProspectOptionBL.GetAttributeValue(133, 121, data), y, answer_width, height, answer_x);

            /* pdfGen.CreatePage();
             y = 0;*/

            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_080"), y += interligne * 2.5f, width, height);

            //Autre 4
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(1239, data), y += interligne, 0, "1");
            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_084_1")), y, 480, 20, 20);
            //pdfGen.AddDefaultText(pIsEmptyDocument ? Espace : string.Format(CustomerProspectOptionBL.GetAttributeValue(1239, 765, data)), y += interligne, width, 280, 20);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_084_1"), string.Empty), y, label_width, height, 15);
            //pdfGen.AddAnswer(pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(1239, 765, data), y, answer_width, height, answer_x);
            pdfGen.AddBlueBorder(y += interligne, 20, width - 20, 100);
            pdfGen.AddDefaultText(pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(1239, 765, data), y + 5, width - 30, 100, 25);

            //#endregion

            #endregion

            #region page 9

            pdfGen.CreatePage();
            y = 0;
            //Section : La nature et les modalités de la prestation de conseil
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_085"), y, width, height);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_086"), y += interligne, width, height);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(184, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_087"), y, width, height, 15);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(185, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_088"), y, width, height, 15);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(186, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_089"), y, width, height * 2, 15);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(187, data), y += interligne + 5, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_090"), y, width, height * 2, 15);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(188, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_091"), y, width, height, 15);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(189, data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_092"), y, width, height, 15);

            //Section : La durée et le calendrier de la mission
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_093"), y += interligne * 2.5f, width, height);

            pdfGen.AddJustifyText(string.Format(LanguageContentBL.Translate("PdfLM_094")
            , CustomerProspectOptionBL.GetAttributeValue(135, 122, data)), y += interligne * 1.5f, width, height * 2);

            pdfGen.AddJustifyText(string.Format(LanguageContentBL.Translate("PdfLM_095")
            , CustomerProspectOptionBL.GetAttributeValue(135, 123, data)), y += interligne * 1.5f, width, height * 2);

            //Section : Modalité de notre intervention
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_096"), y += interligne * 2.5f, width, height);

            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_097")
            , CustomerProspectOptionBL.GetAttributeValue(136, 124, data)), y += interligne * 1.5f, width, height * 2);

            //Section : Typologie de client
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_098"), y += interligne * 3, width, height);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_099"), y += interligne * 1.5f, width, height * 4);

            //Section : Déroulement de la mission
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_100"), y += interligne * 3f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_101"), y += interligne * 1.5f, width, height * 2);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_102"), y += interligne * 2f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_103"), y += interligne * 1.5f, width, height * 2);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_104"), y += interligne * 2f, width, height * 3);//Parallelement,...
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_105"), y += interligne * 2.5f, width, height * 3); //La totalité...
            #endregion

            #region page 10

            pdfGen.CreatePage();
            y = 0;
            //Suite Section : Déroulement de la mission
            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_106"), y, width, height * 2);
            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_107"), y += interligne * 2f, width, 2 * height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_108"), y += interligne * 2f, width, height * 2);

            //Section : Suivi patrimonial envisagé
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_109"), y += interligne * 2f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_110"), y += interligne * 1.5f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_111"), y += interligne * 1.5f, width, height * 3);

            //Section : Modalités d'information
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_112"), y += interligne * 2, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_113"), y += interligne * 1.5f, width, height);

            //Section : Dénonciation de la mission
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_114"), y += interligne * 2f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_115"), y += interligne * 1.5f, width, height * 3);
            if (SessionManager.GetHostCodeSession() != PageLanguageHelper.HostCode.BE.ToString())
            {
                pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_116"), y += interligne * 3f, width, height * 4);
                pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_117"), y += interligne * 4f, width, height * 3);
            }

            //Section : Responsabilité
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_118"), y += interligne * 2f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_119"), y += interligne * 1.5f, width, height * 4);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_120"), y += interligne * 2f, width, height * 2);

            //Section : Confidentialité
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_121"), y += interligne * 2f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_122"), y += interligne * 1.5f, width, height * 2);

            #endregion

            #region page 11

            pdfGen.CreatePage();
            y = 0;
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_123"), y, width, height);//Litiges
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_124"), y += interligne * 1.5f, width, height * 2);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_125"), y += interligne * 2f, width, height * 2);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_126"), y += interligne * 2f, width, height * 3);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_127"), y += interligne * 3f, width, height * 2);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_128"), y += interligne * 2f, width, height * 2);

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_129"), y += interligne * 3, width, height);//Traitement des informations
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_130"), y += interligne * 1.5f, width, height * 5);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_131"), y += interligne * 3f, width, height * 3);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_132"), y += interligne * 3f, width, height * 4);
            pdfGen.AddJustifyText(LanguageContentBL.Translate("PdfLM_133"), y += interligne * 3f, width, height * 4);
            #endregion

            #region page 12

            pdfGen.CreatePage();
            y = 0;
            //Signature
            pdfGen.AddSubtitle(LanguageContentBL.Translate("Pdf_Signature"), 0);

            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("Pdf_Signature_Etabs"), 100, 500, 20, 80);


            pdfGen.AddBlueBorder(130, 35, 200, 170);

            //Ne pas afficher si signature electronique
            if (forceDownload)
            {
                pdfGen.AddDefaultText(LanguageContentBL.Translate("Pdf_Lu_Et_Accepte"), 135, 200, 20, 40);
                pdfGen.AddDefaultText(LanguageContentBL.Translate("Pdf_Lu_Et_Approuve"), 145, 145, 20, 40);
                pdfGen.AddDefaultText(LanguageContentBL.Translate("Pdf_Date"), 160, 145, 20, 40);
            }

            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("Pdf_Signature_Client"), 100, 500, 20, 340);
            pdfGen.AddBlueBorder(130, 280, 200, 170);

            //Ne pas afficher si signature electronique
            if (forceDownload)
            {
                pdfGen.AddDefaultText(LanguageContentBL.Translate("Pdf_Lu_Et_Accepte"), 135, 200, 20, 285);
                pdfGen.AddDefaultText(LanguageContentBL.Translate("Pdf_Lu_Et_Approuve"), 145, 145, 20, 285);
                pdfGen.AddDefaultText(LanguageContentBL.Translate("Pdf_Date"), 160, 145, 20, 285);
            }

            #endregion

            //Force download if pathFileName is not set
            if (forceDownload)
            {
                string fileName = string.Format("LettreMission_PM_{0}.pdf", pMissionDoc.idMissionDocument);
                pdfGen.GeneratePdfToWeb(fileName);
            }
            else
            {
                pdfGen.GeneratePdf(pathFileName);
            }
            return pdfGen.PageCount;
        }
        public static int Generate_MissionReport(Upsilab.Data.Model.MissionDocument pMissionDoc, string pathFileName, bool forceDownload, bool pIsEmptyDocument = false)
        {
            float y = 260;
            int height = 20;
            int width = 500;
            int interligne = 15;
            float label_width = 200;
            float answer_width = 280;
            float answer_x = 200;
            // int paddingLeft = 50;
            FirmInstitution firmInstitution = pMissionDoc.CustomerProspect.FirmInstitution;

            //Title and footer document
            string documentTitle = "Rapport de mission";
            string footerContent = firmInstitution.DocumentFooterContent;

            string name = string.Empty;
            string date = string.Empty;
            string idDocument = string.Empty;

            if (!pIsEmptyDocument)
            {
                if (pMissionDoc.CustomerProspect.IsCorporation.HasValue && pMissionDoc.CustomerProspect.IsCorporation.Value)
                    name = pMissionDoc.CustomerProspect.CompanyName;
                else
                    name = string.Format("{0} {1}", pMissionDoc.CustomerProspect.User.UserName, pMissionDoc.CustomerProspect.User.UserFirstName);

                date = DateTime.Now.ToShortDateString();
                idDocument = pMissionDoc.idMissionDocument.ToString();
            }
            if (forceDownload)
                date = string.Empty;
            FoxitPDFGenerator pdfGen = new FoxitPDFGenerator(documentTitle, footerContent, name, string.Format("{0} {1}", string.IsNullOrEmpty(date) ? string.Empty : LanguageContentBL.Translate("PdfReportPP_004"), date));

            //FoxitPDFGenerator pdfGen = new FoxitPDFGenerator(documentTitle, footerContent);

            #region page 1
            string logoPathFileName = Upsilab.Business.Utility.FileManager.BuildLogoPath(firmInstitution.idFirmInstitution) + firmInstitution.Logo;
            pdfGen.AddBackgroungImage();
            pdfGen.AddLogoOnFirstPage(logoPathFileName, firmInstitution.LogoAlign);



            y = 380;
            pdfGen.AddWhiteTitle(LanguageContentBL.Translate("PdfRapportMission_001"), y, 240, 60, 260, 20);

            pdfGen.AddWhiteTitle((pMissionDoc.CustomerProspect.IsCorporation.HasValue && pMissionDoc.CustomerProspect.IsCorporation.Value) ? LanguageContentBL.Translate("PdfLM_134") : LanguageContentBL.Translate("PdfReportPP_003"), y += (2 * interligne + 15), 500, 20, 0, 12);//PERSONNE PHYSIQUE ou PERSONNE MORALE

            pdfGen.AddWhiteBorder(y += interligne * 1.7f, 210, 290, 70);

            if (pIsEmptyDocument)
            {
            }
            else
            {
                if (!forceDownload)
                    pdfGen.AddWhiteTitleLeft(DateTime.Now.ToShortDateString(), y += 10, 500, 11, 220, 10);
                pdfGen.AddWhiteTitleLeft(name, y += (interligne), 500, 11, 220, 10);
                pdfGen.AddWhiteTitleLeft(string.Format("{0}-{1}", LanguageContentBL.Translate("PdfRapportMission_003"), idDocument), y += (interligne), 500, 11, 220, 10);
            }

            #endregion

            #region page 2

            Data.Model.CustomerProspect cust = new Data.Model.CustomerProspect();
            Data.Model.User userAdviser = new Data.Model.User();
            List<CustomerProspectOptionValue> data = new List<CustomerProspectOptionValue>();

            if (!pIsEmptyDocument)
            {
                cust = pMissionDoc.CustomerProspect;
                data = Upsilab.Business.CustomerProspect.CustomerProspectOptionBL.GetOptionValueListWithIdCustomerProspectAndIdParentOptionPlus(cust.idCustomer, Upsilab.Business.CustomerProspect.CustomerProspectBL.MissionParentQuestionId);
                userAdviser = (pMissionDoc.User != null) ? pMissionDoc.User : pMissionDoc.CustomerProspect.User1;
            }

            pdfGen.CreatePage();
            y = 0;
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfMissionClient"), y, width, height);
            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionNom"), (pIsEmptyDocument) ? string.Empty : (cust.IsCorporation.HasValue && cust.IsCorporation.Value) ? cust.CompanyName : cust.User.UserName), y += interligne * 1.5f, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionNom"), string.Empty), y += interligne * 1.5f, label_width, height);
            pdfGen.AddAnswer((pIsEmptyDocument) ? string.Empty : (cust.IsCorporation.HasValue && cust.IsCorporation.Value) ? cust.CompanyName : cust.User.UserName, y, answer_width, height, answer_x);

            // pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionPrenom"), (pIsEmptyDocument) ? string.Empty : (cust.IsCorporation.HasValue && cust.IsCorporation.Value) ? LanguageContentBL.Translate("PdfMission") : cust.User.UserFirstName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionPrenom"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer((pIsEmptyDocument) ? string.Empty : (cust.IsCorporation.HasValue && cust.IsCorporation.Value) ? string.Empty : cust.User.UserFirstName, y, answer_width, height, answer_x);

            //  pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionAdresse"), (pIsEmptyDocument) ? string.Empty : cust.Adress), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionAdresse"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer((pIsEmptyDocument) ? string.Empty : cust.Adress, y, answer_width, height * 3, answer_x);

            // pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionCP"), (pIsEmptyDocument) ? string.Empty : cust.ZipCode), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionCP"), string.Empty), y += interligne * 2.8f, label_width, height);
            pdfGen.AddAnswer((pIsEmptyDocument) ? string.Empty : cust.ZipCode, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionVille"), (pIsEmptyDocument) ? string.Empty : cust.City), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionVille"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer((pIsEmptyDocument) ? string.Empty : cust.City, y, answer_width, height, answer_x);

            FirmInstitution firm = new FirmInstitution();
            if (!pIsEmptyDocument)
            {
                firm = cust.FirmInstitution;
            }
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfMissionConseiller"), y += interligne * 1.5f, width, height);
            // pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionNomEtabs"), firm.FirmInstitutionName), y += interligne * 1.5f, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionNomEtabs"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.FirmInstitutionName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionNomCons"), userAdviser.UserName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionNomCons"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(userAdviser.UserName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionPrenomCons"), userAdviser.UserFirstName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionPrenomCons"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(userAdviser.UserFirstName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionNomDir"), firm.LeaderName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionNomDir"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.LeaderName, y, answer_width, height, answer_x);

            // pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionPrenomDir"), firm.LeaderFirstName), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionPrenomDir"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.LeaderFirstName, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionAdrssSiege"), firm.FirmStreet), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionAdrssSiege"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.FirmStreet, y, answer_width, height * 3, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionCP"), firm.FirmPostCode), y += interligne*2.8f, width, height);//CP
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionCP"), string.Empty), y += interligne * 2.8f, label_width, height);
            pdfGen.AddAnswer(firm.FirmPostCode, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionVille"), firm.FirmCity), y += interligne, width, height);//Ville
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionVille"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.FirmCity, y, answer_width, height, answer_x);

            //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionRCS"), firm.RCS), y += interligne, width, height);
            pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionRCS"), string.Empty), y += interligne, label_width, height);
            pdfGen.AddAnswer(firm.RCS, y, answer_width, height, answer_x);


            if (SessionManager.GetHostCodeSession() != PageLanguageHelper.HostCode.BE.ToString())
            {
                //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionRegistre"), firm.RegisteredInRegister), y += interligne, width, height);
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionRegistre"), string.Empty), y += interligne, label_width, height);
                pdfGen.AddAnswer(firm.RegisteredInRegister, y, answer_width, height, answer_x);

                //pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionAgregateur"), ""), y += interligne, width, height);
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfMissionAgregateur"), string.Empty), y += interligne, label_width, height);
                pdfGen.AddAnswer("", y, answer_width, height, answer_x);

            }

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfMmeMsieur"), y += interligne * 2f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_004"), y += interligne * 2f, width, height * 3);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_005"), y += interligne * 2f, width, height * 3);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_006"), y += interligne * 3f, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_007"), y += interligne * 1.5f, width, height * 2);

            #endregion

            #region page 3

            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfRapportmission_008"), y, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_009"), y += interligne * 1.5f, width, height * 2);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_010"), y += interligne * 1.5f, width, height * 2);
            pdfGen.AddBlueBorder(y += interligne, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue("Client_Mission_008", data), y + 5 * 1.5f, width, height, 5);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_011"), y += interligne * 3f, width, height);

            pdfGen.AddBlueBorder(y += interligne * 1.5f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 126, data), y + 2 * 1.5f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 127, data), y + 2 * 1.5f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 128, data), y + 2 * 2.6f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 129, data), y + 2 * 2.6f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 130, data), y + 2 * 2.6f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 131, data), y + 2 * 2.6f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 132, data), y + 2 * 2.6f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 133, data), y + 2 * 2.6f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 134, data), y + 2 * 2.6f, width, height, 5);
            pdfGen.AddBlueBorder(y += interligne * 3f, 0, width, height * 2);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(192, 135, data), y + 2 * 2.6f, width, height, 5);

            #endregion

            #region page 4

            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfRapportmission_012"), y, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_013"), y += interligne * 1.5f, width, height * 3);

            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_012", data), y += interligne * 3, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_014"), y, width, height, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_013", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_015"), y, width, height, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_014", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_016"), y, width, height, 15);

            if (SessionManager.GetHostCodeSession() != PageLanguageHelper.HostCode.BE.ToString())
            {
                PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_015", data), y += interligne, 0, "1");
                pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_017"), y, width, height, 15);
                PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_016", data), y += interligne, 0, "1");
                pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_018"), y, width, height, 15);
            }
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_017", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_019"), y, width, height, 15);

            if (SessionManager.GetHostCodeSession() != PageLanguageHelper.HostCode.BE.ToString())
            {
                PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_1241", data), y += interligne, 0, "1");
                pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_1241"), y, width, height, 15);
            }

            // PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetProspectValue("Client_Mission_018", data), y += interligne, 0, "1"); --> pas de checkbox sur le formulaire
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_020"), y += interligne, width, height);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue("Client_Mission_018", data), y, 480, height * 2, 40);




            if (SessionManager.GetHostCodeSession() != PageLanguageHelper.HostCode.BE.ToString())
            {
                pdfGen.AddLabelNote(LanguageContentBL.Translate("PdfReportPP_Notes"), y += interligne * 2, 500, 20);
                pdfGen.AddBlueBorder(y += interligne, 0, width, 280);
                pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue("Client_Mission_019", data), y + 5, 480, 280, 10);
            }

            #endregion

            #region page 5
            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfRapportmission_021"), y, width, height);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_020", data), y += interligne * 1.5f, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_022"), y, width, height, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_021", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_023"), y, width, height, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_022", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_024"), y, width, height, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_023", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_025"), y, width, height, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_024", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_026"), y, width, height, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_025", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_027"), y, width, height, 15);
            PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue("Client_Mission_026", data), y += interligne, 0, "1");
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_028"), y, width, height, 15);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(208, 138, data), y += interligne, 480, height * 2, 15);

            pdfGen.CreatePage();
            y = 0;
            pdfGen.AddLabelNote(LanguageContentBL.Translate("PdfReportPP_Notes"), y += interligne, 500, 20);
            pdfGen.AddBlueBorder(y += interligne, 0, width, 600);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(194, 139, data), y + 5, 480, 600, 10);

            #endregion

            #region page 6
            pdfGen.CreatePage();
            y = 0;

            //Analyse de la situation
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfRapportmission_029"), y, width, height);
            pdfGen.AddLabelNote(LanguageContentBL.Translate("PdfReportPP_Notes"), y += interligne * 2, 500, 20);
            pdfGen.AddBlueBorder(y += interligne, 0, width, 600);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(195, 140, data), y + 5, 480, 600, 10);
            #endregion

            #region page 7

            pdfGen.CreatePage();
            y = 0;

            //Rappel de la remuneration
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfRapportmission_029_0"), y, width, height);
            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfRapportmission_029_1"), y += interligne * 2, 500, 20);

            //From LM
            //Le mode de facturation et de rémunération
            pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_072"), y += (interligne * 2) - 5, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_073"), y += interligne * 2, width, 20);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_074"), y += interligne, width, 20 * 3);

            pdfGen.AddBlueBorder(y += interligne * 3, 0, 30, 20);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(1234, 756, data), y + 5, 50, 20, 5);
            pdfGen.AddDefaultText("X", y + 8, 20, 20, 40);
            pdfGen.AddBlueBorder(y, 60, 30, 20);
            pdfGen.AddDefaultText(CustomerProspectOptionBL.GetAttributeValue(1234, 757, data), y + 5, 50, 30, 65);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_075"), y + 8, width, height, 110);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfLM_076"), y += interligne * 3, width, height * 2);
            // pdfGen.AddDefaultText("Au titre de l’accompagnement du client, une information plus précise sera fournie ultérieurement sur simple demande une fois connus les supports choisis par le client.", y += interligne * 3, width, height * 2, 15);
            pdfGen.AddReference(LanguageContentBL.Translate("PdfLM_077"), y += interligne * 2, width, height * 2, 15);

            //Les honoraires : n'afficher que les honoraires fournis
            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfLM_078"), y += interligne * 3, width, height);

            string honoraire_1_Value = CustomerProspectOptionBL.GetOptionValue(1236, data);
            string honoraire_2_Value = CustomerProspectOptionBL.GetOptionValue(1237, data);
            string honoraire_3_Value = CustomerProspectOptionBL.GetOptionValue(1238, data);
            string honoraire_4_Value = CustomerProspectOptionBL.GetOptionValue(1240, data);

            //1-
            if (honoraire_1_Value == "1" || pIsEmptyDocument)
            {
                PlotBooleanValue(pdfGen, honoraire_1_Value, y += (interligne * 1.5f) + 10, 0, "1");
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_079")
                    , (pIsEmptyDocument) ? Espace : CustomerProspectOptionBL.GetAttributeValue(1236, 760, data)
                    , (pIsEmptyDocument) ? Espace : CustomerProspectOptionBL.GetAttributeValue(1236, 761, data)
                    , (pIsEmptyDocument) ? Espace : CustomerProspectOptionBL.GetAttributeValue(1236, 762, data))
                    , y - 10, 480, height * 4, 20);
            }

            //Ou
            if (pIsEmptyDocument)
                pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_080"), y += interligne * 3f, width, height);

            //2-
            if (honoraire_2_Value == "1" || pIsEmptyDocument)
            {
                PlotBooleanValue(pdfGen, honoraire_2_Value, y += (interligne * 1.5f) + 10, 0, "1");
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_081")
                    , (pIsEmptyDocument) ? Espace : CustomerProspectOptionBL.GetAttributeValue(1237, 763, data)), y - 10, width, height * 3, 20);
            }

            if (pIsEmptyDocument)
                pdfGen.AddReceuil_DefaultText_Justify_CalibriBold_Label(LanguageContentBL.Translate("PdfLM_080"), y += interligne * 2.5f, width, height);

            //3-
            if (honoraire_3_Value == "1" || pIsEmptyDocument)
            {
                PlotBooleanValue(pdfGen, honoraire_3_Value, y += (interligne * 1.5f) + 20, 0, "1");
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_082")
                    , (pIsEmptyDocument) ? Espace : CustomerProspectOptionBL.GetAttributeValue(1238, 764, data)), y - 20, width, height * 5, 20);
            }

            if (honoraire_4_Value == "0" || pIsEmptyDocument)
            {
                //Nous sommes convenus d'un règlement d'un montant de {0} Euros HT à l'acceptation de la lettre de mission et le solde lors du rendez-vous de synthèse de la mission.
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_083")
                    , (pIsEmptyDocument) ? Espace : CustomerProspectOptionBL.GetAttributeValue(1235, 758, data)), y += interligne * 4, width, height * 2);

                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_084")
                   , CustomerProspectOptionBL.GetAttributeValue(1235, 759, data)), y += interligne * 2, width, height);
            }

            //Ou
            if (pIsEmptyDocument)
                pdfGen.AddDefaultBoldText(LanguageContentBL.Translate("PdfLM_080"), y += interligne * 2.5f, width, height);


            //4- Autre ?
            if (honoraire_4_Value == "1" || pIsEmptyDocument)
            {
                PlotBooleanValue(pdfGen, CustomerProspectOptionBL.GetOptionValue(1240, data), y += (interligne * 1.5f) + 10, 0, "1");
                pdfGen.AddDefaultText(string.Format(LanguageContentBL.Translate("PdfLM_084_1")), y, 480, 20, 20);
                //pdfGen.AddDefaultText(string.Format(CustomerProspectOptionBL.GetAttributeValue(1240, 766, data)), y += interligne, width, 280, 20);
                pdfGen.AddBlueBorder(y += interligne, 20, width - 20, 100);
                pdfGen.AddDefaultText(pIsEmptyDocument ? Espace : CustomerProspectOptionBL.GetAttributeValue(1240, 766, data), y + 5, width - 30, 100, 25);

            }

            #endregion

            #region page 8

            pdfGen.CreatePage();
            y = 0;

            pdfGen.AddSubtitle(LanguageContentBL.Translate("PdfRapportmission_030"), y, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_031"), y += interligne * 2, width, height);
            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_032"), y += interligne, width, height);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_033"), y += interligne * 2, width, height * 2);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_034"), y += interligne * 2, width, height * 2);

            pdfGen.AddDefaultText(LanguageContentBL.Translate("PdfRapportmission_035"), y += interligne * 2, width, height * 2);

            #endregion

            #region page 9

            pdfGen.CreatePage();
            y = 0;
            //Signature
            pdfGen.AddTitle(@"Signatures", 0);

            pdfGen.AddDefaultBoldText(@"Signature de l'Etablissement", 100, 500, 20, 80);


            pdfGen.AddBlueBorder(130, 35, 200, 170);

            //Ne pas afficher si signature electronique
            if (forceDownload)
            {
                pdfGen.AddDefaultText(@"J'ai lu et j'accepte les conditions générales.", 135, 200, 20, 40);
                pdfGen.AddDefaultText(@"Lu et approuvé.", 145, 145, 20, 40);
                pdfGen.AddDefaultText(@"Date:", 160, 145, 20, 40);
            }

            pdfGen.AddDefaultBoldText(@"Signature du Client", 100, 500, 20, 340);
            pdfGen.AddBlueBorder(130, 280, 200, 170);

            //Ne pas afficher si signature electronique
            if (forceDownload)
            {
                pdfGen.AddDefaultText(@"J'ai lu et j'accepte les conditions générales.", 135, 200, 20, 285);
                pdfGen.AddDefaultText(@"Lu et approuvé.", 145, 145, 20, 285);
                pdfGen.AddDefaultText(@"Date:", 160, 145, 20, 285);
            }

            #endregion

            //Force download if pathFileName is not set
            if (forceDownload)
            {
                string fileName = string.Format("RapportDeMission_{0}.pdf", pMissionDoc.idMissionDocument);
                pdfGen.GeneratePdfToWeb(fileName);
            }
            else
            {
                pdfGen.GeneratePdf(pathFileName);
            }
            return pdfGen.PageCount;
        }
        public ActionResult Identification(FirmInstitution objFirmInstution)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Subscription sub = null;
                    SessionManager.Get<Data.Model.Subscription>(SouscriptionBL.SubscriptionSession, out sub);

                    if (sub != null)
                    {
                        // ajout de la FirmInstitution à la session
                        //SessionManager.Add<Data.Model.FirmInstitution>(objFirmInstution, FirmInstitutionBL.FirmInstitutionSession);


                        using (var context = new UpsilabEntities())
                        {
                            // S'il existe une session utilisateur, on fait une UPDATE, sinon on fait un ADD de la FirmInstitution
                            if (SessionManager.Exists(UserBL.AuthenticatedUserSessionKey))
                            {
                                // Extranet user
                                FirmInstitution objFirmInstutionSession = SessionManager.GetFirmInstitutionSession();
                                //Update data
                                objFirmInstutionSession.ContactName = objFirmInstution.ContactName;
                                objFirmInstutionSession.ContactFirstName = objFirmInstution.ContactFirstName;
                                objFirmInstutionSession.E_mail = objFirmInstution.E_mail;
                                objFirmInstutionSession.FirmInstitutionName = objFirmInstution.FirmInstitutionName;
                                objFirmInstutionSession.FirmStreet = objFirmInstution.FirmStreet;
                                objFirmInstutionSession.FirmCity = objFirmInstution.FirmCity;
                                objFirmInstutionSession.FirmPostCode = objFirmInstution.FirmPostCode;
                                objFirmInstutionSession.FirmPhone = objFirmInstution.FirmPhone;

                                // Update FirmInstitution infos                                
                                context.FirmInstitution.Attach(objFirmInstutionSession);
                                context.ObjectStateManager.ChangeObjectState(objFirmInstutionSession, System.Data.EntityState.Modified);
                            }
                            else
                            {
                                objFirmInstution.idFirmInstitution = Guid.NewGuid();
                                objFirmInstution.MaxUserCount = 0; // update after payment
                                objFirmInstution.CreditCount = 0; // update after payment
                                objFirmInstution.DateCreated = DateTime.Now;

                                context.FirmInstitution.AddObject(objFirmInstution);
                            }

                            //Save the souscription in table.
                            sub.IdFirmInstitution = objFirmInstution.idFirmInstitution;

                            sub.DateCreated = DateTime.Now;
                            sub.DateExpired = sub.DateCreated.AddYears(sub.Duration.Value);
                            context.Subscription.AddObject(sub);

                            context.SaveChanges();

                            //Si tout est ok, supprimer la session Subscription ?
                            SessionManager.Clear(SouscriptionBL.SubscriptionSession);
                        }

                        return RedirectToAction("Aller", "Paiement", new { id = sub.IdSubscription });
                    }
                    else
                    {
                        var languageData = PageLanguageHelper.GetLanguageContent("Public", "Identification");
                        ViewBag.Info = languageData.GetContent("Identification_NoSub");
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Info = "Erreur: " + ex.Message;
            }
            return View();
        }
Esempio n. 24
0
 /// <summary>
 /// Check in 2 ways Name+Firstname <=> Firstname+Name
 /// performance maybe lol
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="FirstName"></param>
 /// <returns></returns>
 public static Upsilab.Data.Model.User GetUserByNameAndFirstname(string NameAndFirstname, FirmInstitution pFirmInstitution)
 {
     List<Upsilab.Data.Model.User> users = GetUsersByIdFirmInstitution(pFirmInstitution);
     NameAndFirstname = NameAndFirstname.ToLowerInvariant().Replace(" ", string.Empty);
     using (UpsilabEntities context = new UpsilabEntities())
     {
         Upsilab.Data.Model.User pUser = context.User.Where(user =>
             ((user.UserName.ToLower() + user.UserFirstName.ToLower()).Trim().Replace(" ", string.Empty).Equals(NameAndFirstname) && user.IsActive == true && (user.idUserProfile == 6 || user.idUserProfile == 7))
                 ||
             ((user.UserFirstName.ToLower() + user.UserName.ToLower()).Trim().Replace(" ", string.Empty).Equals(NameAndFirstname) && user.IsActive == true && (user.idUserProfile == 6 || user.idUserProfile == 7))
             ).FirstOrDefault();
         if (pUser == null)
             return null;
         else
         {
             if (users != null && users.Where(x => x.idUser == pUser.idUser).FirstOrDefault() != null)
                 return pUser;
         }
     }
     return null;
 }
        private void GenerateInvoice(Subscription pSubscription, FirmInstitution pFirmInstitution)
        {
            //Génération de la facture
            string factName = "";
            string logoPath = System.IO.Path.Combine(Server.MapPath("~/Content/images/"), "LogoUpsideoFoxit.png");

            string invoicePath = ConfigurationManager.InvoicePath;
            if (!System.IO.Directory.Exists(invoicePath))
            {
                System.IO.Directory.CreateDirectory(invoicePath);
            }

            SouscriptionBL.GenerateInvoiceForSubscription(pSubscription, pFirmInstitution, invoicePath, logoPath, out factName);
            SetSubscriptionInvoiceName(pSubscription, factName, false); // Don't save yet
        }
        public static List<FirmInstitutionAdviser> GetAdvisersByIdFirmParent(FirmInstitution _FirmInstitution, Data.Model.User  _User, bool filterByUserFirm, Boolean includeDeletedOrInactive)
        {
            using (UpsilabEntities retrieveContext = new UpsilabEntities())
            {
                var query = retrieveContext.FirmInstitutionAdviser
                    .Include("User").Include("FirmInstitution").Include("FirmInstitution1")
                    .Where(a => a.idFirmInstitutionParent == _FirmInstitution.idFirmInstitution || a.idFirmInstitution == _FirmInstitution.idFirmInstitution);

                if (!includeDeletedOrInactive)
                    query = query.Where(a => a.User.IsDeleted == false)
                        .Where(a => a.User.IsActive == true);

                List<FirmInstitutionAdviser> lstAdvisers = query.ToList();

                //Filtrer by firm where user is attached
                if (filterByUserFirm)
                {
                    //List of firminstitution of the user
                    List<FirmInstitution> lstFirmInstitutions = GetFirmInstitutionsByIdUser(_User.idUser);
                    List<Guid> lstIdFirmInstitutions = new List<Guid>();
                    if (lstFirmInstitutions != null)
                    {
                        lstIdFirmInstitutions = lstFirmInstitutions.Select(f => f.idFirmInstitution).ToList();
                    }

                    lstAdvisers = lstAdvisers.Where(a => lstIdFirmInstitutions.Contains(a.FirmInstitution1.idFirmInstitution)).ToList();
                }

                return lstAdvisers;
            }
        }
Esempio n. 27
0
        public static Upsilab.Data.Model.User GetUserAdviserByEmail(String email, FirmInstitution pFirmInstitution)
        {
            List<Upsilab.Data.Model.User> users = GetUsersByIdFirmInstitution(pFirmInstitution);

            using (UpsilabEntities context = new UpsilabEntities())
            {
                Upsilab.Data.Model.User pUser = context.User.Where(user => user.UserEmail.Equals(email.Trim()) && !user.IsDeleted && user.IsActive && (user.idUserProfile == 6 || user.idUserProfile == 7)).FirstOrDefault();

                if (users != null && pUser != null && users.Where(x => x.UserEmail == pUser.UserEmail).FirstOrDefault() != null)
                    return pUser;

            }
            return null;
        }
 public static string GetPresentationFile(FirmInstitution firm, bool isUrl)
 {
     return GetFile(firm, isUrl, DocumentType.Presentation);
 }
Esempio n. 29
0
 public static List<Upsilab.Data.Model.User> GetUsersByIdFirmInstitution(FirmInstitution firmInstitution)
 {
     return UserBL.GetUsersByIdFirmInstitution(firmInstitution.idFirmInstitution);
 }
 private Dictionary<string, string> GetDefaultValues(FirmInstitution firmInstitution) 
 {
     var dico = new Dictionary<string, string>();
     dico.Add("cgp_societe", firmInstitution.FirmInstitutionName);
     dico.Add("cgp_adresse", firmInstitution.FirmStreet);
     dico.Add("cgp_codepostal", firmInstitution.FirmPostCode);
     dico.Add("cgp_ville", firmInstitution.FirmCity);
     dico.Add("cgp_telephone", firmInstitution.FirmPhone);
     dico.Add("cgp_fax", firmInstitution.Fax);
     dico.Add("cgp_email", firmInstitution.E_mail);
     return dico;
 }