Exemplo n.º 1
0
        public ActionResult Detail(ProjectDonor pdModel)
        {
            ProjectDonor pDonor = this.projectService.GetProjectDonorById(pdModel.Id);
            Currency displayCurrency = currencyService.GetCurrency((Guid)pdModel.CurrencyId);
            if (displayCurrency == null)
                displayCurrency = pDonor.Currency;

            List<Models.Category> categories = Models.BudgetExtension.PrepareBudgetModel(budSvc, exchangeRateService, currencyService, countryProg, pDonor, displayCurrency);
            Dictionary<String, String> data = new Dictionary<string, string>();

            data.Add("{START-DATE}", pDonor.StartDate.ToString("dd/MM/yyyy"));
            data.Add("{END-DATE}", pDonor.EndDate.ToString("dd/MM/yyyy"));

            data.Add("{PROJECT}", pDonor.Project.Name);
            data.Add("{DONOR}", pDonor.Donor.Name);
            data.Add("{CURRENCY}", displayCurrency.ShortName);
            data.Add("{BUDGET_NUM}", pDonor.ProjectNumber);

            data.Add("{TOTAL_BUDGET}", categories[categories.Count - 1].TotalBudget.ToString("#,##0.00"));
            data.Add("{TOTAL_COMMITTED}", ND2S(categories[categories.Count - 1].TotalCommitted));
            data.Add("{ACTUAL_POSTED}", ND2S(categories[categories.Count - 1].TotalPosted));
            data.Add("{REMAINING_FUNDS}", ND2S(categories[categories.Count - 1].RemainingBalance));

            data.Add("{GENERATED}", DateTime.Now.ToString("f"));

            String tbody = "";
            for (int k = 0; k < categories.Count - 1; k++)
            {
                tbody += "<tr style=\"background-color: #EAF1DD; font-weight:bold;\"><td class='central'><b>" + categories[k].Number + "</b></td>";
                tbody += "<td><b>" + categories[k].Name + "</b></td>";
                tbody += "<td class='east'><b>" + categories[k].TotalBudget.ToString("#,##0.00") + "</b></td>";
                tbody += "<td class='east'><b>" + ND2S(categories[k].TotalCommitted) + "</b></td>";
                tbody += "<td class='east'><b>" + ND2S(categories[k].TotalPosted) + "</b></td>";
                tbody += "<td class='east'><b>" + ND2S(categories[k].RemainingBalance) + "</b></td></tr>";

                foreach (SCMS.UI.Models.BudgetLine b in categories[k].BudgetLines)
                {
                    tbody += "<tr><td class='central'>" + b.LineNumber + "</td>";
                    tbody += "<td>" + b.Description + "</td>";
                    tbody += "<td class='east'>" + b.TotalBudget.ToString("#,##0.00") + "</td>";
                    tbody += "<td class='east'>" + ND2S(b.TotalCommitted) + "</td>";
                    tbody += "<td class='east'>" + ND2S(b.TotalPosted) + "</td>";
                    tbody += "<td class='east'>" + ND2S(b.RemainingBalance) + "</td></tr>";
                }
            }

            data.Add("{DETAIL}", tbody);

            Byte[] output = WkHtml2Pdf.CreateReport(data, "project-budget.html");//= new Byte[1];;//

            return File(output, "application/pdf", "ProjectB_" + DateTime.Now.FormatDDMMMYYYYHHmm());
        }
Exemplo n.º 2
0
        //
        // GET: /Reports/CompletionC/

        public ActionResult Index(Guid CCid)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            Models.ViewCC modelCC = CompletionCExtention.PrepareCC(CCid, ccService);
            using (var db = new SCMSEntities())
            {
                data.Add("{DATE}", modelCC.EntityCC.PreparedOn.ToString());
                data.Add("{RegNo}", modelCC.EntityCC.RefNumber);
                data.Add("{OFFICE}", modelCC.EntityCC.CountrySubOffice.Name);
                data.Add("{COUNTRY}", modelCC.EntityCC.CountrySubOffice.CountryProgramme.Country.Name);
                data.Add("{PREPAREDBY}", modelCC.PreparedBy.StaffName);
                data.Add("{TITLE}", modelCC.PreparedBy.Designation);
                if (modelCC.PreparedBy != null && modelCC.PreparedBy.SignatureImage != null)
                {
                    data.Add("{SIGNATURE}", "data:image/png;base64," + Convert.ToBase64String(modelCC.PreparedBy.SignatureImage));
                }
                data.Add("{PURPOSE}", modelCC.EntityCC.Purpose);

                data.Add("{CONTRUCTOR}", modelCC.EntityCC.PurchaseOrder.Supplier.Name);
                data.Add("{PONO}", modelCC.EntityCC.PurchaseOrder.RefNumber);
                data.Add("{PROJECTTITLE}", modelCC.EntityCC.ProjectTitle);
                data.Add("{LOCATION}", modelCC.EntityCC.Location);
                data.Add("{DRCOFFICE}", modelCC.EntityCC.CountrySubOffice1.Name);
                data.Add("{COMFIRMED}", modelCC.ComfirmedBy.StaffName);

                data.Add("{COMPLETE}", modelCC.EntityCC.WorksService == "Completed satisfactory" ? "\" checked=\"checked\"" : "");
                data.Add("{OUTSTANDING}", modelCC.EntityCC.WorksService == "Outstanding issues" ? "\" checked=\"checked\"" : "");
                data.Add("{NOTCOMPLETED}", modelCC.EntityCC.WorksService == "Not Completed" ? "\" checked=\"checked\"" : "");

                data.Add("{REMARKS}", modelCC.EntityCC.Remarks);


                data.Add("{APPROVTITLE}", (modelCC.AprovedBy != null)?modelCC.AprovedBy.Designation:"");
                data.Add("{APPROVERNAME}", (modelCC.AprovedBy != null) ? modelCC.AprovedBy.StaffName : "");
                data.Add("{APPROVERSIGNATURE}", (modelCC.AprovedBy != null && modelCC.AprovedBy.SignatureImage != null) ? "data:image/png;base64," + Convert.ToBase64String(modelCC.AprovedBy.SignatureImage) : "");
            }

            List <String> options = new List <string>();

            options.Add(" --copies 2 ");
            Byte[] output = WkHtml2Pdf.CreateReport(data, "CompletionCertificate.htm", options);

            return(File(output, "application/pdf", "CC_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Exemplo n.º 3
0
        //
        // GET: /Reports/PO/

        public ActionResult Index(Guid POid)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            using (var db = new SCMSEntities())
            {
                Model.PurchaseOrder POentity = db.PurchaseOrders.FirstOrDefault(p => p.Id == POid);
                string taNumber = "Single Quote";
                data.Add("{DATE}", POentity.PODate.ToString("dd/MM/yyyy"));
                data.Add("{PONo}", POentity.RefNumber);
                data.Add("{TANo}", taNumber);
                data.Add("{ORNo}", POentity.OrderRequest.RefNumber);

                data.Add("{PAYMENT-TERM}", POentity.PaymentTerm.Description);
                data.Add("{QUOTATION-REF}", POentity.QuotationRef);
                data.Add("{SHIPPINGTERM}", POentity.ShippingTerm.Description);
                data.Add("{PO-CURRENCY}", POentity.Currency.ShortName);

                data.Add("{TO-SUPPLIER}", POentity.Supplier.Name);
                data.Add("{DELIVER-ADDRESS}", POentity.Location.Name);
                data.Add("{DELIVERY-DATE}", POentity.LatestDeliveryDate.ToString("dd/MM/yyyy"));
                data.Add("{DRC-REMARKS}", POentity.Remarks);

                ICollection <PurchaseOrderItem> POItems = POentity.PurchaseOrderItems;

                int    count      = 1;
                String detailHtml = "";

                foreach (PurchaseOrderItem poitem in POItems)
                {
                    detailHtml += "<tr><td>" + count++ + "</td><td>";
                    detailHtml += poitem.OrderRequestItem.Item.Name;
                    detailHtml += "</td><td>";
                    detailHtml += poitem.OrderRequestItem.Item.UnitOfMeasure.Code;
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poitem.Quantity.ToString("##,##0");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poitem.UnitPrice.ToString("#,##0.00");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poitem.TotalPrice.ToString("#,##0.00");
                    detailHtml += "</td><td>";
                    detailHtml += poitem.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber;
                    detailHtml += "</td><td>";
                    detailHtml += db.ProjectBudgets.FirstOrDefault(p => p.Id == poitem.BudgetLineId).LineNumber;
                    detailHtml += "</td><td>";
                    detailHtml += poitem.Remarks;
                    detailHtml += "</td><tr>";
                }
                while (count < 18)
                {
                    detailHtml += "<tr><td>" + count++ + "</td><td>";
                    detailHtml += "</td><td>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td>";
                    detailHtml += "</td><td>";
                    detailHtml += "</td><td>";
                    detailHtml += "</td><tr>";
                }
                data.Add("{DETAILS}", detailHtml);

                data.Add("{CURRENCY}", POentity.Currency.ShortName);
                data.Add("{TOTAL-AMOUNT}", POentity.TotalAmount.Value.ToString("#,##0.00"));
                data.Add("{ADDITIONAL-REMARKS}", POentity.AdditionalRemarks);

                String      authourisation = "";
                Model.Staff s = db.Staffs.SingleOrDefault(p => p.Id == POentity.PreparedBy);
                authourisation = AuthName(db, POentity, authourisation, s);
                authourisation = AuthTitle(db, POentity, authourisation, s);
                authourisation = AuthDate(db, POentity, authourisation);
                authourisation = AuthSignature(db, POentity, authourisation, s);
                data.Add("{AUTHORISATION}", authourisation);

                data.Add("{PRO-FORMA}", string.Format("<input type=\"checkbox\" {0} />", POentity.ProformaRequired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{COMMERCIAL}", string.Format("<input type=\"checkbox\" {0} />", POentity.CommercialInvoiceRequired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{WB-AB}", string.Format("<input type=\"checkbox\" {0} />", POentity.WayBillRequired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{EPACKING}", string.Format("<input type=\"checkbox\" {0} />", POentity.PackingListRequired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{DELIVERYNN}", string.Format("<input type=\"checkbox\" {0} />", POentity.DeliveryNoteRequired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{MANUAL}", string.Format("<input type=\"checkbox\" {0} />", POentity.ManualsRequired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{CERTIFICATES}", string.Format("<input type=\"checkbox\" {0} />", POentity.CertificatesReqired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{OTHERS}", string.Format("<input type=\"checkbox\" {0} />", POentity.OtherRequired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{SPECIFY}", POentity.OtherSpecify);


                data.Add("{SHIPING-MARKS}", POentity.ShippingMarks);
                data.Add("{CONSIGNEE-ADDRESS}", POentity.ConsigneeAddress);
                data.Add("{CONSIGNEE-EMAIL}", POentity.ConsigneeEmail1);
                data.Add("{CONSIGNEE-EMANIL2}", POentity.ConsigneeEmail2);

                data.Add("{PRE-FINANCING}", string.Format("<input type=\"checkbox\" {0} />", POentity.PrefinancingGuaranteeRequired ? "value=\"\" checked=\"checked\"" : ""));
                data.Add("{PERCENTAGE-VALUE}", POentity.PFGPercentage != null ? POentity.PFGPercentage.Value.ToString("#,##0.00") + "%" : " ");
            }
            List <String> options = new List <string>();

            options.Add(" --copies 3 ");
            Byte[] output = WkHtml2Pdf.CreateReport(data, "Purchase-Order.htm", options);

            return(File(output, "application/pdf", "PO_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Exemplo n.º 4
0
        //
        public ActionResult ReleaseForm(Guid WRNid)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            using (var db = new SCMSEntities())
            {
                WarehouseRelease wrnenttiy = db.WarehouseReleases.First(p => p.Id == WRNid);

                data.Add("{DATE}", wrnenttiy.RequestDate.ToShortDateString());


                data.Add("{REF_NO}", wrnenttiy.RefNumber);
                data.Add("{OFFICE}", wrnenttiy.Staff1.CountrySubOffice.Name);

                var requestor = db.VStaffDetails.First(p => p.StaffID == wrnenttiy.PreparedBy);
                var recipient = db.VStaffDetails.First(p => p.StaffID == wrnenttiy.ReceivedBy);

                data.Add("{NAME}", requestor.StaffName);
                data.Add("{TITLE}", requestor.Designation);
                if (requestor.SignatureImage.IsNotNull())
                {
                    data.Add("{SIGNATURE}", string.Format("<img src=\"{0}\" alt=\"\" style=\"max-width: 50px;\" />", "data:image/png;base64," + Convert.ToBase64String(requestor.SignatureImage)));
                }

                data.Add("{APPROVER-NAME}", wrnenttiy.IsApproved ? wrnenttiy.Staff.Person.FirstName + " " + wrnenttiy.Staff.Person.OtherNames : "");
                data.Add("{APPROVER-TITLE}", wrnenttiy.IsApproved ? wrnenttiy.Staff.Designation.Name : "");
                data.Add("{APPROVER-OFICE}", wrnenttiy.IsApproved ? wrnenttiy.Staff.CountrySubOffice.Name : "");
                if (wrnenttiy.Staff.Person.SignatureImage.IsNotNull() && wrnenttiy.IsApproved)
                {
                    data.Add("{SIGNATURE2}", string.Format("<img src=\"{0}\" alt=\"\" style=\"max-width: 50px;\" />", "data:image/png;base64," + Convert.ToBase64String(wrnenttiy.Staff.Person.SignatureImage)));
                }

                data.Add("{RECEIVER_NAME}", recipient != null ? recipient.StaffName : "");
                data.Add("{RECEIVER_TITLE}", recipient != null ? recipient.Designation : "");
                data.Add("{RECEIVER_UNIT}", wrnenttiy.Staff2 != null ? wrnenttiy.Staff2.CountrySubOffice.Name : "");
                data.Add("{RECEIVER_DATE}", wrnenttiy.ReceiptDate.ToDDMMyyyHHmm());
                if (wrnenttiy.Staff2.Person.SignatureImage.IsNotNull())
                {
                    data.Add("{RECEIVER_SIGNATURE}", string.Format("<img src=\"{0}\" alt=\"\" style=\"max-width: 100px;\" />", "data:image/png;base64," + Convert.ToBase64String(wrnenttiy.Staff2.Person.SignatureImage)));
                }

                List <Model.WarehouseReleaseItem> writms = wrnenttiy.WarehouseReleaseItems.ToList();
                string tbody = "";
                int    r = 1; string itemName, serialNo, AssetNo;
                foreach (WarehouseReleaseItem item in writms)
                {
                    if (item.Inventory.Item.ItemCategory.CategoryCode == "C")
                    {
                        itemName = item.Inventory.Item.Name;
                        serialNo = item.Inventory.Item.SerialNumber;
                        AssetNo  = "N/A";
                    }
                    else
                    {
                        itemName = item.Asset.Name;
                        serialNo = item.Asset.SerialNumber;
                        AssetNo  = item.Asset.AssetNumber;
                    }
                    tbody += "<tr><td>" + r++ + "</td><td>";
                    tbody += itemName + "</td><td>";
                    tbody += item.Inventory.Item.UnitOfMeasure.Code + "</td><td>";
                    tbody += serialNo + "</td><td>";
                    tbody += AssetNo + "</td><td>";
                    tbody += item.Quantity + "</td><td>";
                    tbody += item.Comments + "</td></tr>";
                }
                while (r < 21)
                {
                    tbody += "<tr><td>" + r++ + "</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
                }
                data.Add("{DETAILS}", tbody);
                List <String> options = new List <string>();
                options.Add(" --copies 2 ");
                Byte[] output = WkHtml2Pdf.CreateReport(data, "warehouse-release-form.html", options);

                return(File(output, "application/pdf", "WRN_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
            }
        }
Exemplo n.º 5
0
        public ActionResult Pdf(Guid RFPid)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            using (var context = new SCMSEntities())
            {
                PaymentRequest PR = context.PaymentRequests.SingleOrDefault(p => p.Id == RFPid);

                List <R4PpaymentDetails>        pdlist      = new List <R4PpaymentDetails>();
                List <PaymentRequestBudgetLine> ARBlineList = context.PaymentRequestBudgetLines.Where(p => p.PaymentRequestId == PR.Id).ToList();
                foreach (PaymentRequestBudgetLine item in ARBlineList)
                {
                    var pb      = context.ProjectBudgets.SingleOrDefault(p => p.Id == item.BudgetLineId);
                    var pdatils = new R4PpaymentDetails()
                    {
                        BudgetLine            = pb.LineNumber,
                        BudgetLineDescription = pb.Description,
                        projectNo             = context.ProjectDonors.SingleOrDefault(p => p.Id == item.ProjectBudget.BudgetCategory.ProjectDonorId).ProjectNumber,
                        Amount = (decimal)item.Amount
                    };
                    pdlist.Add(pdatils);
                }
                Currency    c     = PR.Currency;
                PaymentType pt    = PR.PaymentType;
                Supplier    sup   = PR.Supplier;
                Staff       st    = PR.Staff1;
                Person      psn   = st.Person;
                Designation d     = st.Designation;
                PaymentTerm pterm = PR.PaymentTerm;

                data.Add("{VOUCHER_NO.}", PR.VoucherNumber);
                data.Add("{REQ_NO.}", PR.RefNumber);
                data.Add("{POSPMNO.}", PR.PurchaseOrder.RefNumber);
                data.Add("{DATE}", PR.PreparedOn.ToShortDateString());
                data.Add("{CURRENCY}", PR.Currency.ShortName);
                data.Add("{PAYMENT_TERMS}", PR.PaymentTerm.Code);
                data.Add("{PAYMENT_TYPE}", PR.PaymentType.Description);
                data.Add("{TOTAL_PAYMENT}", PR.TotalAmount.ToString("##,###.00"));

                data.Add("{SUBJECT}", PR.Subject);
                data.Add("{PAYMENT_TO}", PR.Supplier.Name);
                data.Add("{CHOICE_FP}", PR.RequestFor == "FullPayment" ? "\" checked=\"checked\"" : "");
                data.Add("{CHOICE_RI}", PR.RequestFor == "Rate_Instalment" ? "\" checked=\"checked\"" : "");
                data.Add("{CHOICE_AP}", PR.RequestFor == "Adv_Payment_percentage" ? "\" checked=\"checked\"" : "");
                data.Add("{CHOICE_AFP}", PR.RequestFor == "Adv_Final_Payment_percentage" ? "\" checked=\"checked\"" : "");

                String payHtml = "";
                int    t       = 1;
                foreach (R4PpaymentDetails pd in pdlist)
                {
                    payHtml += "<tr><td align=\"center\">" +
                               t + "</td><td>" +
                               pd.projectNo + "</td><td>" + pd.BudgetLine + " " +
                               pd.BudgetLineDescription + "</td><td align=\"right\">" +
                               pd.Amount.ToString("##,##0.00") + "</td><td align=\"center\">" +
                               PR.Currency.ShortName + "</td></tr>";
                    t++;
                }
                while (t < 11)
                {
                    payHtml += "<tr><td align=\"center\">" + t++ + "</td><td></td><td></td><td></td><td></td></tr>";
                }
                data.Add("{PAYMENT_DETAILS}", payHtml);

                data.Add("{REMARKS}", PR.Remarks);

                string masterBUdgetCurrency = "";

                if (PR.Currency1 != null)
                {
                    masterBUdgetCurrency = PR.Currency1.ShortName;
                }

                data.Add("{MB_CURRENCY}", masterBUdgetCurrency);
                string total = "";

                if (PR.MBValue != null)
                {
                    total = ((decimal)PR.MBValue).ToString("#,##0.00");
                }

                data.Add("{TOTAL}", total);


                data.Add("{PREPAROR_NAME}", PR.Staff1.Person.FirstName + " " + PR.Staff1.Person.OtherNames);
                data.Add("{PREPAROR_TITLE}", PR.Staff1.Designation.Name);
                data.Add("{PREPAROR_DATE}", PR.PreparedOn.ToString("dd/MM/yyyy"));
                data.Add("{PREPAROR_SIG}", this.signatureFilePath(PR.Staff1.Person.SignatureImage));


                String reviewerName      = "";
                String reviewerTitle     = "";
                String reviewedOn        = "";
                String reviewerSignature = "";

                if (PR.ReviewedOn.HasValue)
                {
                    reviewedOn = ((DateTime)PR.ReviewedOn).ToString("dd/MMM/yyyy");
                }

                if (PR.ReviewedBy != null)
                {
                    Staff reviewer = staffService.GetStaffById((Guid)PR.ReviewedBy);
                    reviewerName      = reviewer.Person.FirstName + " " + reviewer.Person.OtherNames;
                    reviewerTitle     = reviewer.Designation.Name;
                    reviewerSignature = this.signatureFilePath(reviewer.Person.SignatureImage);
                }

                data.Add("{REVIEWER_NAME}", reviewerName);
                data.Add("{REVIEWER_TITLE}", reviewerTitle);
                data.Add("{REVIEWER_DATE}", reviewedOn);
                data.Add("{REVIEWER_SIG}", reviewerSignature);


                String authorizerName      = "";
                String authorizerTitle     = "";
                String authorizedOn        = "";
                String authorizerSignature = "";

                if (PR.AuthorizedOn.HasValue)
                {
                    authorizedOn = ((DateTime)PR.AuthorizedOn).ToString("dd-MMM-yyyy");
                }

                if (PR.AuthorizedBy != null)
                {
                    Staff authorizer = staffService.GetStaffById((Guid)PR.AuthorizedBy);
                    authorizerName      = authorizer.Person.FirstName + " " + authorizer.Person.OtherNames;
                    authorizerTitle     = authorizer.Designation.Name;
                    authorizerSignature = this.signatureFilePath(authorizer.Person.SignatureImage);
                }

                data.Add("{AUTHORIZER_NAME}", authorizerName);
                data.Add("{AUTHORIZER_TITLE}", authorizerTitle);
                data.Add("{AUTHORIZER_DATE}", reviewedOn);
                data.Add("{AUTHORIZER_SIG}", authorizerSignature);
            }
            List <String> options = new List <string>();

            options.Add(" --copies 2 ");
            Byte[] output = WkHtml2Pdf.CreateReport(data, "request4payment.html", options);

            return(File(output, "application/pdf", "RRP_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Exemplo n.º 6
0
        //
        // GET: /Reports/GoodsReceived/

        public ActionResult Index(Guid id)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            using (var db = new SCMSEntities())
            {
                Model.GoodsReceivedNote grnentity = db.GoodsReceivedNotes.FirstOrDefault(p => p.Id == id);

                data.Add("{SUPPLIER}", grnentity.Supplier.Name);
                data.Add("{GRN}", grnentity.RefNumber);

                data.Add("{DNN}", grnentity.DnNumber);

                data.Add("{OFFICE}", grnentity.CountrySubOffice.Name);
                data.Add("{LOCATION}", grnentity.CountrySubOffice.Location.Name);

                ICollection <GoodsReceivedNoteItem> grnItems = grnentity.GoodsReceivedNoteItems;

                int    r          = 1;
                String detailHtml = "";

                foreach (GoodsReceivedNoteItem grnitem in grnItems)
                {
                    if (r == 1)
                    {
                        data.Add("{ORNO}", grnitem.PurchaseOrderItem.PurchaseOrder.OrderRequest.RefNumber);
                        data.Add("{PONO}", grnitem.PurchaseOrderItem.PurchaseOrder.RefNumber);
                        DateTime d = (DateTime)grnitem.PurchaseOrderItem.PurchaseOrder.LatestDeliveryDate;
                        data.Add("{DELIVERY_DATE}", d.ToShortDateString());
                    }
                    detailHtml += "<tr><td align=\"center\">" + r++ + "</td><td>";
                    detailHtml += grnitem.PurchaseOrderItem.OrderRequestItem.Item.Name;
                    detailHtml += "</td><td>";
                    detailHtml += grnitem.PurchaseOrderItem.OrderRequestItem.Item.UnitOfMeasure.Code;
                    detailHtml += "</td><td class='central'>";
                    detailHtml += grnitem.PurchaseOrderItem.Quantity.ToString("##,###");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += grnitem.QuantityDelivered.ToString("##,###");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += grnitem.QuantityDamaged.ToString("##,###");
                    detailHtml += "</td><td>";
                    detailHtml += grnitem.Comments;
                }
                while (r < 21)
                {
                    detailHtml += "<tr><td align=\"center\">" + r++ + "</td><td>";
                    detailHtml += "</td><td>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td>";
                }
                data.Add("{DETAILS}", detailHtml);
                data.Add("{ADDITONALRMARKS}", grnentity.Remarks);

                var recBy = db.VStaffDetails.FirstOrDefault(p => p.StaffID == grnentity.ReceivedBy);

                if (grnentity.DeliverDate.HasValue)
                {
                    if (recBy.SignatureImage.IsNotNull())
                    {
                        data.Add("{SIGNATURE2}", string.Format("<img src=\"{0}\" alt=\"\" style=\"max-width: 80px;\" />", "data:image/png;base64," + Convert.ToBase64String(recBy.SignatureImage)));
                    }
                    data.Add("{SIGNATURE_DATE}", grnentity.DeliverDate.FormatDDMMMYYYY());
                }
                else
                {
                    data.Add("{SIGNATURE_DATE}", "N/A");
                }
                data.Add("{TRANSPORTER_NAME}", grnentity.DeliveredBy);
                data.Add("{TRANSPORTER_COMPANY}", grnentity.DeliveryCompany);
                data.Add("{DRIVER_ID}", grnentity.DriverLicenseNumber);
                data.Add("{VEHICLE_PLATE}", grnentity.VehicleRegNumber);

                data.Add("{RECEIVED_BY}", recBy.StaffName);
                data.Add("{TITLE}", recBy.Designation);
            }
            List <String> options = new List <string>();

            options.Add(" --copies 2 ");
            Byte[] output = WkHtml2Pdf.CreateReport(data, "goods-received-note.html", options);

            return(File(output, "application/pdf", "GRN_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Exemplo n.º 7
0
        public ActionResult GRNTemplate(Model.GoodsReceivedNote model)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            using (var db = new SCMSEntities())
            {
                Model.GoodsReceivedNote grnentity = model;

                Model.PurchaseOrder po   = db.PurchaseOrders.FirstOrDefault(p => p.Id == model.PurchaseOrderId);
                CountrySubOffice    csof = db.CountrySubOffices.FirstOrDefault(p => p.Id == model.CountryOfficeId);

                data.Add("{SUPPLIER}", po != null ? po.Supplier.Name : "<sub>________________________________________</sub>");
                data.Add("{GRN}", "<sub>________________________________________</sub>");
                //data.Add("{GRN}", grnentity.RefNumber.IsNotNullOrEmpty() ? grnentity.RefNumber : "<sub>________________________________________</sub>");

                data.Add("{DNN}", grnentity.DnNumber ?? "<sub>________________________________________</sub>");

                data.Add("{OFFICE}", csof != null ? csof.Name : "<sub>________________________________________</sub>");
                data.Add("{LOCATION}", csof != null ? csof.Location.Name : "<sub>________________________________________</sub>");

                data.Add("{ORNO}", po != null ? po.OrderRequest.RefNumber : "<sub>________________________________________</sub>");
                data.Add("{PONO}", po != null ? po.RefNumber : "<sub>________________________________________</sub>");
                data.Add("{DELIVERY_DATE}", "<sub>________________________________________</sub>");

                int    r          = 1;
                String detailHtml = "";

                foreach (POItemsView poItem in model.POItemz)
                {
                    detailHtml += "<tr><td align=\"center\">" + r++ + "</td><td>";
                    detailHtml += poItem.ItemName;
                    detailHtml += "</td><td>";
                    detailHtml += poItem.unitOfMessure;
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poItem.QtyOrdered.ToString("##,###");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poItem.QtyDelivered.ToString("##,###");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poItem.QtyDamaged.ToString("##,###");
                    detailHtml += "</td><td>";
                    detailHtml += poItem.comments;
                }
                while (r < 21)
                {
                    detailHtml += "<tr><td align=\"center\">" + r++ + "</td><td>";
                    detailHtml += "</td><td>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td>";
                }
                data.Add("{DETAILS}", detailHtml);

                var recBy = db.VStaffDetails.FirstOrDefault(p => p.StaffID == grnentity.ReceivedBy);


                data.Add("{SIGNATURE2}", "<sub>___________________________________________</sub>");
                data.Add("{SIGNATURE_DATE}", grnentity.DeliverDate.Value.ToShortDateString());

                data.Add("{TRANSPORTER_NAME}", grnentity.DeliveredBy.IsNotNullOrWhiteSpace() ? grnentity.DeliveredBy : "<sub>_________________________________________</sub>");
                data.Add("{TRANSPORTER_COMPANY}", grnentity.DeliveryCompany.IsNotNullOrEmpty() ? grnentity.DeliveryCompany : "<sub>_____________________________________</sub>");
                data.Add("{DRIVER_ID}", grnentity.DriverLicenseNumber.IsNotNullOrEmpty() ? grnentity.DriverLicenseNumber : "<sub>________________________________________</sub>");
                data.Add("{VEHICLE_PLATE}", grnentity.VehicleRegNumber.IsNotNullOrEmpty() ? grnentity.VehicleRegNumber : "<sub>_________________________________________</sub>");

                data.Add("{RECEIVED_BY}", recBy != null ? recBy.StaffName : "<sub>_______________________________________________</sub>");
                data.Add("{TITLE}", recBy != null ? recBy.Designation : "<sub>____________________________________________________</sub>");
            }

            Byte[] output = WkHtml2Pdf.CreateReport(data, "goods-received-note.html");

            return(File(output, "application/pdf", "GRN_Template_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Exemplo n.º 8
0
        private ActionResult PreparePdf(Guid orId, int pagecount)
        {
            string original = "original", copy = "copy";
            Dictionary <String, String> data = new Dictionary <string, string>();

            Model.OrderRequest model         = orderRequestService.GetOrderRequestById(orId);
            //prepare labels
            PrepareLabels(data);
            data.Add("{REQ_NO.}", model.RefNumber);
            data.Add("{ISSUE-DATE}", model.OrderDate.HasValue ? model.OrderDate.Value.ToString(Constants.DATE_FORMAT) : string.Empty);
            data.Add("{CURRENCY}", model.Currency != null ? model.Currency.ShortName : string.Empty);

            data.Add("{PROJECT-NAME}", model.ProjectDonor.Project.Name);
            data.Add("{PROJECT-NO}", model.ProjectDonor.ProjectNumber);
            data.Add("{DONOR}", model.ProjectDonor.Donor.ShortName);

            data.Add("{DELIVERY-DATE}", model.DeliveryDate.HasValue ? model.DeliveryDate.Value.ToString(Constants.DATE_FORMAT) : string.Empty);
            data.Add("{DELIVERY-DESTINATION}", model.Location1 != null ? model.Location1.Name : string.Empty);
            data.Add("{FINAL-DESTINATION}", model.Location != null ? model.Location.Name : string.Empty);

            int    count      = 1;
            String detailHtml = "";

            foreach (var item in model.OrderRequestItems.ToList())
            {
                detailHtml += "<tr ><td align=\"center\">" + count++ + "</td><td>";
                detailHtml += item.Item.Name;
                detailHtml += "</td><td>";
                detailHtml += item.ItemDescription;
                detailHtml += "</td><td>";
                detailHtml += item.Item.UnitOfMeasure.Code;
                detailHtml += "</td><td align=\"center\">";
                detailHtml += item.Quantity.ToString(Constants.NUMBER_FORMAT_NO_DECIMAL);
                detailHtml += "</td><td align=\"right\">";
                detailHtml += item.EstimatedUnitPrice.ToString(Constants.NUMBER_FORMAT_TWO_DECIMAL);
                detailHtml += "</td><td align=\"right\">";
                detailHtml += item.EstimatedPrice.ToString(Constants.NUMBER_FORMAT_TWO_DECIMAL);
                detailHtml += "</td><td align=\"center\">";
                detailHtml += item.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber;
                detailHtml += "</td><td align=\"center\">";
                detailHtml += item.ProjectBudget.LineNumber;
                detailHtml += "</td><td>";
                detailHtml += item.Remarks;
                detailHtml += "</td></tr>";
            }
            while (count < 18)
            {
                detailHtml += "<tr ><td align=\"center\">" + count++ + "</td><td>";
                detailHtml += "</td><td>";
                detailHtml += "</td><td>";
                detailHtml += "</td><td align=\"center\">";
                detailHtml += "</td><td align=\"right\">";
                detailHtml += "</td><td align=\"right\">";
                detailHtml += "</td><td align=\"center\">";
                detailHtml += "</td><td align=\"center\">";
                detailHtml += "</td><td>";
                detailHtml += "</td></tr>";
            }
            data.Add("{DETAILS}", detailHtml);

            data.Add("{OR-CURRENCY}", model.Currency != null ? model.Currency.ShortName : string.Empty);
            data.Add("{OR-VALUE}", model.TotalAmount.HasValue ? model.TotalAmount.Value.ToString(Constants.NUMBER_FORMAT_TWO_DECIMAL) : string.Empty);

            data.Add("{MB-CURRENCY}", model.Currency1 != null ? model.Currency1.ShortName : string.Empty);
            data.Add("{MB-VALUE}", model.MBValue.HasValue ? model.MBValue.Value.ToString(Constants.NUMBER_FORMAT_TWO_DECIMAL) : string.Empty);

            data.Add("{REMARKS}", model.Remarks);

            String authourisation = "";

            authourisation = AuthName(model, authourisation);
            authourisation = AuthTitle(model, authourisation);
            authourisation = AuthDate(model, authourisation);
            authourisation = AuthSignature(model, authourisation);
            data.Add("{AUTHORISATION}", authourisation);

            //data.Add("{PAGETYPE}", pagecount == 1 ? original : copy);
            List <String> options = new List <string>();

            options.Add(" --copies 2 ");
            //options.Add(" --footer-center page 1 of 1 – original ");

            Byte[] output = WkHtml2Pdf.CreateReport(data, "Order-Request.htm", options);
            //if (pagecount == 1)
            //    return PreparePdf(orId, ++pagecount);
            //else
            return(File(output, "application/pdf", "OR_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Exemplo n.º 9
0
        //
        // GET: /Reports/WB/

        public ActionResult pdf(Guid wbId)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();
            ViewWayBill Model = WayBillExtension.prepareWB(wbId);

            data.Add("{REFNO}", Model.EntityWBill.RefNumber);
            data.Add("{ORIGIN-OFFICE}", Model.OrignSOfiice.Name);
            data.Add("{ORIGIN-WH}", Model.OrrignWH.Name);
            data.Add("{DESTINATION-NAME}", Model.destinationWH.Location.Name);
            data.Add("{DESTINATION-WH}", Model.destinationWH.Name);

            data.Add("{LOADING-DATE}", Model.EntityWBill.LoadingDate.Value.ToString("dd/MM/yyyy"));
            data.Add("{DISPATCH-DATE}", Model.EntityWBill.DispatchDate.Value.ToString("dd/MM/yyyy"));
            data.Add("{CONSIGNEE}", Model.consignee.ShortName);
            data.Add("{CONSIGNEE-CONTACT}", Model.consignee.OfficialPhone);


            data.Add("{WH-NO}", Model.EntityWBill.WarehouseRelease.RefNumber);
            data.Add("{DRC-VEHICLE-NO}", Model.EntityWBill.DRCVehicleRegNo);
            data.Add("{DRC-VEHICLE-KM}", Model.EntityWBill.DRCVehicleMileage.ToString("##,###"));
            data.Add("{VEHICLE-CONTACT}", Model.EntityWBill.DRCVehicleContactNo);

            int    count = 1;
            String itemName, serialNo, weight = "N/A", detailHtml = "";

            foreach (var item in Model.WRItems)
            {
                if (item.Inventory.Item.ItemCategory.CategoryCode == "C")
                {
                    itemName = item.Inventory.Item.Name;
                    serialNo = item.Inventory.Item.SerialNumber;
                }
                else
                {
                    itemName = item.Asset.Name;
                    serialNo = item.Asset.SerialNumber;
                }
                count++;
                detailHtml += "<tr ><td style=\"text-align: left;\">";
                detailHtml += serialNo;
                detailHtml += "</td><td style=\"text-align: left;\">";
                detailHtml += itemName;
                detailHtml += "</td><td style=\"text-align: center;\">";
                detailHtml += item.Inventory.Item.UnitOfMeasure.Code;
                detailHtml += "</td><td style=\"text-align: right;\">";
                detailHtml += item.Inventory.Item.ItemCategory.CategoryCode == "C" ? weight : item.Asset.Weight.ToString("##,###");
                detailHtml += "</td><td style=\"text-align: right;\">";
                detailHtml += item.Quantity;
                detailHtml += "</td><td style=\"text-align: right;\">";
                detailHtml += item.QuantityReceived;
                detailHtml += "</td><td style=\"text-align: right;\">";
                detailHtml += item.QuantityDamaged;
                detailHtml += "</td><td style=\"text-align: left;\">";
                detailHtml += item.Comments;
                detailHtml += "  </td></tr>";
            }
            while (count < 8)
            {
                count++;
                detailHtml += "<tr ><td style=\"text-align: left;\">&nbsp;&nbsp;";
                detailHtml += "</td><td style=\"text-align: left;\">";
                detailHtml += "</td><td style=\"text-align: center;\">";
                detailHtml += "</td><td style=\"text-align: right;\">";
                detailHtml += "</td><td style=\"text-align: right;\">";
                detailHtml += "</td><td style=\"text-align: right;\">";
                detailHtml += "</td><td style=\"text-align: right;\">";
                detailHtml += "</td><td style=\"text-align: left;\">";
                detailHtml += "  </td></tr>";
            }
            data.Add("{DETAILS}", detailHtml);
            data.Add("{LOADING-REMARKS}", Model.EntityWBill.LoadingRemarks);

            data.Add("{DRIVER-NAME}", Model.EntityWBill.DriverName);
            data.Add("{ISSUER-STAFF}", Model.issuer.StaffName);
            data.Add("{VEHICLE-REG-NO}", Model.EntityWBill.DRCVehicleRegNo);

            data.Add("{ISSUER-TITLE}", Model.issuer.Designation);
            data.Add("{TRANSPORT-COMPANY}", Model.EntityWBill.TransportCompany);
            data.Add("{DRIVER-LICENSEE}", Model.EntityWBill.DriverLicenseNo);

            if (Model.EntityWBill.Staff != null && Model.EntityWBill.Staff.Person.SignatureImage != null)
            {
                data.Add("{ISSUER-SIGNATURE}", "data:image/png;base64," + Convert.ToBase64String(Model.EntityWBill.Staff.Person.SignatureImage));
            }

            data.Add("{DESTINATION-LOC}", Model.DestnationOfiice.Location.Name);
            data.Add("{ARRIVAL-DATE}", Model.EntityWBill.ArrivalDate.HasValue ? Model.EntityWBill.ArrivalDate.Value.ToString("dd/MM/yyyy") : "");

            data.Add("{RECEIVED-BY}", Model.ReceivedBy != null ? Model.ReceivedBy.StaffName : "");
            data.Add("{RECEIVED-KM}", Model.EntityWBill.RecvDRCVehicleOdometer.ToString());

            data.Add("{RECEIVED-BY-TITLE}", Model.ReceivedBy != null ? Model.ReceivedBy.Designation : "");
            data.Add("{RECEIVED-TOTAL-DISTANCE}", Model.EntityWBill.RecvDRCVehicleTotalDistance.ToString());


            if (Model.EntityWBill.Staff1 != null && Model.EntityWBill.Staff1.Person.SignatureImage != null)
            {
                data.Add("{RECEIVEDBY-SIGNATURE}", "data:image/png;base64," + Convert.ToBase64String(Model.EntityWBill.Staff1.Person.SignatureImage));
            }

            List <String> options = new List <string>();

            options.Add(" --copies 3 ");
            Byte[] output = WkHtml2Pdf.CreateReport(data, "Way-Bill.htm", options);
            return(File(output, "application/pdf", "WB_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Exemplo n.º 10
0
        public ActionResult PrintMasterB()
        {
            if (!permissionService.Authorize(StandardPermissionProvider.MasterBudgetView))
            {
                return(AccessDeniedView());
            }

            Dictionary <String, String> data = new Dictionary <string, string>();
            string mb_currency = ""; int pjCount = 0;

            Models.MasterBudgetHeader mb = MBHeader(ref mb_currency);

            data.Add("{CURRENCY}", mb_currency);

            data.Add("{TOTAL_BUDGET}", ND2S(mb.MBCList[mb.MBCList.Count - 1].TotalBudget));
            data.Add("{TOTAL_COMMITTED}", ND2S(mb.MBCList[mb.MBCList.Count - 1].TotalCommitted));
            data.Add("{TOTAL_POSTED}", ND2S(mb.MBCList[mb.MBCList.Count - 1].TotalPosted));
            data.Add("{REMAINING_FUNDS}", ND2S(mb.MBCList[mb.MBCList.Count - 1].RemainingBalance));
            data.Add("{%_ACTUAL_SPENT}", ND2S((decimal)mb.MBCList[mb.MBCList.Count - 1].PercentageSpent));
            data.Add("{FUNDS_AVAILABLE}", ND2S(mb.MBCList[mb.MBCList.Count - 1].RemainingBalance));
            data.Add("{EXPENDITURE_PROJECTION}", ND2S(mb.MBCList[mb.MBCList.Count - 1].CostProjection));
            if (mb.MBCList[mb.MBCList.Count - 1].Surplus < 0)
            {
                data.Add("{SHORTFALL_SURPLUS}", "<font color=\"red\"><b>" + ND2S(mb.MBCList[mb.MBCList.Count - 1].Surplus) + "</b></font>");
            }
            else
            {
                data.Add("{SHORTFALL_SURPLUS}", ND2S(mb.MBCList[mb.MBCList.Count - 1].Surplus));
            }

            string DetailsHTML = ""; int x = 0;

            for (int j = 0; j < mb.MBCList.Count - 1; j++)
            {
                if (x >= 0)
                {
                    x = x + 1; pjCount = mb.MBCList[j].Projects.Count;
                }

                DetailsHTML += "<tr><td rowspan=\"" + pjCount + "\" align=\"center\" valign=\"middle\" style=\"background-color: #FCD5B4;\"><b>";
                DetailsHTML += mb.MBCList[j].EntityBudgetCategory.Description + "</b>";
                DetailsHTML += "</td><td  style=\"background-color: #FCD5B4;\">";
                DetailsHTML += mb.MBCList[j].Projects[0].EntityProjectDonor.ProjectNumber;
                DetailsHTML += "</td><td  style=\"background-color: #FCD5B4;\">";
                DetailsHTML += mb.MBCList[j].Projects[0].EntityProjectDonor.Donor.ShortName;
                DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                DetailsHTML += ND2S(mb.MBCList[j].Projects[0].TotalBudget);
                DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                DetailsHTML += ND2S(mb.MBCList[j].Projects[0].TotalCommitted);
                DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                DetailsHTML += ND2S(mb.MBCList[j].Projects[0].TotalPosted);
                DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                DetailsHTML += ND2S(mb.MBCList[j].Projects[0].RemainingBalance);
                DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                DetailsHTML += ND2S((decimal)mb.MBCList[j].Projects[0].PercentageSpent);
                DetailsHTML += "</td><td rowspan=\"" + pjCount + "\" align=\"center\" valign=\"middle\" style=\"background-color: #DCE6F1; border-bottom-style: none;\"><b>";
                DetailsHTML += ND2S(mb.MBCList[j].RemainingBalance) + "</b>";
                DetailsHTML += "</td><td rowspan=\"" + pjCount + "\" align=\"center\" valign=\"middle\" style=\"background-color: #C4D79B; border-bottom-style: none;\"><b>";
                if (mb.MBCList[j].CostProjection > 0)
                {
                    DetailsHTML += ND2S(mb.MBCList[j].CostProjection) + "</b>";
                }
                DetailsHTML += "</td><td rowspan=\"" + pjCount + "\" align=\"center\" valign=\"middle\" style=\"background-color: #C4D79B; border-bottom-style: none;\">";
                if (mb.MBCList[j].CostProjection > 0)
                {
                    if (mb.MBCList[j].Surplus < 0)
                    {
                        DetailsHTML += "<font color=\"red\"><b>" + ND2S(mb.MBCList[j].Surplus) + "</b></font>";
                    }
                    else
                    {
                        DetailsHTML += "<b>" + ND2S(mb.MBCList[j].Surplus) + "</b>";
                    }
                }
                DetailsHTML += "</td></tr>";

                for (int i = 1; i < mb.MBCList[j].Projects.Count; i++)
                {
                    DetailsHTML += "<tr><td style=\"background-color: #FCD5B4;\">";
                    DetailsHTML += mb.MBCList[j].Projects[i].EntityProjectDonor.ProjectNumber;
                    DetailsHTML += "</td><td style=\"background-color: #FCD5B4;\">";
                    DetailsHTML += mb.MBCList[j].Projects[i].EntityProjectDonor.Donor.Name;
                    DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                    DetailsHTML += ND2S(mb.MBCList[j].Projects[i].TotalBudget);
                    DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                    DetailsHTML += ND2S(mb.MBCList[j].Projects[i].TotalCommitted);
                    DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                    DetailsHTML += ND2S(mb.MBCList[j].Projects[i].TotalPosted);
                    DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                    DetailsHTML += ND2S(mb.MBCList[j].Projects[i].RemainingBalance);
                    DetailsHTML += "</td><td align=\"right\" style=\"background-color: #DCE6F1;\">";
                    DetailsHTML += ND2S((decimal)mb.MBCList[j].Projects[i].PercentageSpent);
                    DetailsHTML += "</td></tr>";
                }

                DetailsHTML += "<tr><td colspan=\"11\">&nbsp;</td></tr>";
            }

            data.Add("DETAIL", DetailsHTML);

            List <String> options = new List <string>();

            options.Add(" --orientation Landscape ");
            //options.Add(" --copies 3 ");
            Byte[] output = WkHtml2Pdf.CreateReport(data, "master-budget.html", options);
            return(File(output, "application/pdf", "Project_Budget_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Exemplo n.º 11
0
        public ActionResult Detail(Guid currencyId, Guid countryProgrammeId)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            Currency currency = currencyService.GetCurrency(currencyId);

            data.Add("{CURRENCY}", currency.Name);

            CountryProgramme cp = countryProgrammeSvc.GetCountryProgrammeById(countryProgrammeId);

            List <MBCategory> mbcList = mbService.GenerateMasterBudget(currency, cp);

            this.ComputeTotals(mbcList);

            decimal totalCommitted = 0;

            if (mbcList[mbcList.Count - 1].TotalCommitted.HasValue)
            {
                totalCommitted = (decimal)mbcList[mbcList.Count - 1].TotalCommitted;
            }

            decimal totalPosted = 0;

            if (mbcList[mbcList.Count - 1].TotalPosted.HasValue)
            {
                totalPosted = (decimal)mbcList[mbcList.Count - 1].TotalPosted;
            }

            decimal remBal = 0;

            if (mbcList[mbcList.Count - 1].RemainingBalance.HasValue)
            {
                remBal = (decimal)mbcList[mbcList.Count - 1].RemainingBalance;
            }

            float pctSpent = 0;

            if (mbcList[mbcList.Count - 1].PercentageSpent.HasValue)
            {
                pctSpent = (float)mbcList[mbcList.Count - 1].PercentageSpent;
            }

            decimal costP = 0;

            if (mbcList[mbcList.Count - 1].CostProjection.HasValue)
            {
                costP = (decimal)mbcList[mbcList.Count - 1].CostProjection;
            }


            decimal surplus = 0;
            string  style   = " style='color:red;' ";

            if (mbcList[mbcList.Count - 1].Surplus.HasValue)
            {
                surplus = (decimal)mbcList[mbcList.Count - 1].Surplus;
            }

            if (surplus > 0)
            {
                style = "";
            }

            data.Add("{TOTAL_BUDGET}", mbcList[mbcList.Count - 1].TotalBudget.ToString("###,0.00"));
            data.Add("{TOTAL_COMMITTED}", totalCommitted.ToString("###,0.00"));
            data.Add("{TOTAL_POSTED}", totalPosted.ToString("###,0.00"));
            data.Add("{REMAINING_FUNDS}", remBal.ToString("###,0.00"));
            data.Add("{%_ACTUAL_SPENT}", pctSpent.ToString("0.00"));
            data.Add("{FUNDS_AVAILABLE}", remBal.ToString("###,0.00"));
            data.Add("{EXPENDITURE_PROJECTION}", costP.ToString("###,0.00"));
            data.Add("{SHORTFALL_SURPLUS}", "<span" + style + ">" + surplus.ToString("###,0.00") + "</span>");

            string tbody = "";

            for (int i = 0; i < mbcList.Count - 1; i++)
            {
                int pCount  = mbcList[i].Projects.Count;
                int rowSpan = 1 + pCount;

                tbody += "<tr><td  style='vertical-align:middle;' rowspan='" + rowSpan + "'><h4>";
                tbody += mbcList[i].EntityBudgetCategory.Description + "</h4></td></tr>";

                for (int k = 0; k < pCount; k++)
                {
                    tbody += "<tr><td class='central'>";
                    tbody += mbcList[i].Projects[k].EntityProjectDonor.ProjectNumber + "</td><td>";
                    tbody += mbcList[i].Projects[k].EntityProjectDonor.Donor.ShortName + "</td><td class='east'>";
                    tbody += mbcList[i].Projects[k].TotalBudget.ToString("###,0.00") + "</td><td class='east'>";
                    tbody += ND2S(mbcList[i].Projects[k].TotalCommitted) + "</td><td class='east'>";
                    tbody += ND2S(mbcList[i].Projects[k].TotalPosted) + "</td><td class='east'>";
                    tbody += ND2S(mbcList[i].Projects[k].RemainingBalance) + "</td><td class='east'>";
                    tbody += FD2S(mbcList[i].Projects[k].PercentageSpent);

                    if (k == 0)
                    {
                        tbody += "</td><td class='east'  style='vertical-align:middle;'  rowspan='" + rowSpan + "'><b>";
                        tbody += WrapMinus(ND2S(mbcList[i].RemainingBalance)) + "</b></td>";
                        tbody += "<td class='east'  style='vertical-align:middle;'  rowspan='" + rowSpan + "'><b>";
                        tbody += WrapMinus(ND2S(mbcList[i].CostProjection)) + "</b></td>";
                        tbody += "<td class='east'  style='vertical-align:middle;'  rowspan='" + rowSpan + "'><b>";
                        tbody += WrapMinus(ND2S(mbcList[i].Surplus)) + "</b></td></tr>";
                    }
                    else
                    {
                        tbody += "</td></tr>";
                    }
                }

                tbody += "<tr><td colspan='3'><h4 class='central'>";
                tbody += mbcList[i].EntityBudgetCategory.Description + "</h4></td><td class='east'><b>";
                tbody += mbcList[i].TotalBudget.ToString("###,0.00") + "</b></td><td class='east'><b>";
                tbody += ND2S(mbcList[i].TotalCommitted) + "</b></td><td class='east'><b>";
                tbody += ND2S(mbcList[i].TotalPosted) + "</b></td><td class='east'><b>";
                tbody += WrapMinus(ND2S(mbcList[i].RemainingBalance)) + "</b></td><td class='east'><b>";
                tbody += FD2S(mbcList[i].PercentageSpent) + "</b></td>";
                tbody += "</tr>";

                tbody += "<tr><td colspan='11'>&nbsp;&nbsp;</td></tr>";
            }

            data.Add("{DETAIL}", tbody);
            data.Add("{GENERATED}", DateTime.Now.ToString("f"));

            List <String> options = new List <string>();

            options.Add(" --orientation Landscape ");

            Byte[] output = WkHtml2Pdf.CreateReport(data, "master-budget.html", options);

            return(File(output, "application/pdf"));
        }
Exemplo n.º 12
0
        public ActionResult Summary(Guid currencyId, Guid countryProgrammeId)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            Currency currency = currencyService.GetCurrency(currencyId);

            data.Add("{CURRENCY}", currency.Name);

            CountryProgramme cp = countryProgrammeSvc.GetCountryProgrammeById(countryProgrammeId);

            List <MBCategory> mbcList = mbService.GenerateMasterBudget(currency, cp);

            this.ComputeTotals(mbcList);

            decimal totalCommitted = 0;

            if (mbcList[mbcList.Count - 1].TotalCommitted.HasValue)
            {
                totalCommitted = (decimal)mbcList[mbcList.Count - 1].TotalCommitted;
            }

            decimal totalPosted = 0;

            if (mbcList[mbcList.Count - 1].TotalPosted.HasValue)
            {
                totalPosted = (decimal)mbcList[mbcList.Count - 1].TotalPosted;
            }

            decimal remBal = 0;

            if (mbcList[mbcList.Count - 1].RemainingBalance.HasValue)
            {
                remBal = (decimal)mbcList[mbcList.Count - 1].RemainingBalance;
            }

            float pctSpent = 0;

            if (mbcList[mbcList.Count - 1].PercentageSpent.HasValue)
            {
                pctSpent = (float)mbcList[mbcList.Count - 1].PercentageSpent;
            }

            decimal costP = 0;

            if (mbcList[mbcList.Count - 1].CostProjection.HasValue)
            {
                costP = (decimal)mbcList[mbcList.Count - 1].CostProjection;
            }


            decimal surplus = 0;
            string  style   = " style='color:red;' ";

            if (mbcList[mbcList.Count - 1].Surplus.HasValue)
            {
                surplus = (decimal)mbcList[mbcList.Count - 1].Surplus;
            }

            if (surplus > 0)
            {
                style = "";
            }

            data.Add("{TOTAL_BUDGET}", mbcList[mbcList.Count - 1].TotalBudget.ToString("###,###.00"));
            data.Add("{TOTAL_COMMITTED}", totalCommitted.ToString("###,###.00"));
            data.Add("{TOTAL_POSTED}", totalPosted.ToString("###,###.00"));
            data.Add("{REMAINING_FUNDS}", remBal.ToString("###,###.00"));
            data.Add("{%_ACTUAL_SPENT}", pctSpent.ToString("0.00"));
            data.Add("{FUNDS_AVAILABLE}", remBal.ToString("###,###.00"));
            data.Add("{EXPENDITURE_PROJECTION}", costP.ToString("###,###.00"));
            data.Add("{SHORTFALL_SURPLUS}", "<span" + style + ">" + surplus.ToString("###,###.00") + "</span>");

            string tbody = "";

            for (int i = 0; i < mbcList.Count - 1; i++)
            {
                tbody += "<tr><td>";
                tbody += mbcList[i].EntityBudgetCategory.Description + "</td><td>";
                tbody += mbcList[i].Projects[0].EntityProjectDonor.ProjectNumber + "</td><td>";
                tbody += mbcList[i].Projects[0].EntityProjectDonor.Donor.ShortName + "</td><td>";
                tbody += mbcList[i].Projects[0].TotalBudget.ToString("###,###.00") + "</td><td>";
                tbody += ND2S(mbcList[i].Projects[0].TotalCommitted) + "</td><td>";
                tbody += ND2S(mbcList[i].Projects[0].TotalPosted) + "</td><td>";
                tbody += ND2S(mbcList[i].Projects[0].RemainingBalance) + "</td><td>";
                tbody += FD2S(mbcList[i].Projects[0].PercentageSpent) + "</td><td>";
                tbody += ND2S(mbcList[i].CostProjection) + "</td><td>";
                tbody += "</tr>";
            }

            data.Add("{DETAIL}", tbody);

            List <String> options = new List <string>();

            options.Add(" --orientation Landscape ");

            Byte[] output = WkHtml2Pdf.CreateReport(data, "master-budget.html", options);

            return(File(output, "application/pdf", "Project_Bu=dget_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }