Ejemplo n.º 1
0
        /// <summary>
        /// Metoda koja generira Pdf dokument. Stvara se tablica svih stanja s njezinim atributima
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> PDFReport()
        {
            string naslov = "Popis stanja";
            var    stanja = await ctx.Stanje
                            .AsNoTracking()
                            .ToListAsync();

            PdfReport report = Constants.CreateBasicReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(stanja));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName <Stanje>(o => o.SifraStanja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(4);
                    column.HeaderCell("Šifra stanja", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Stanje>(o => o.NazivStanja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(4);
                    column.HeaderCell("Naziv stanja", horizontalAlignment: HorizontalAlignment.Left);
                });
            });


            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=stanja.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Metoda koja generira Pdf tablice zaraženih osoba
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> PDFReport()
        {
            string naslov        = "Popis zaraženih osoba";
            var    zarazeneOsobe = await ctx.ZarazenaOsoba
                                   .Include(o => o.IdentifikacijskiBrojNavigation)
                                   .Include(o => o.SifraStanjaNavigation)
                                   .AsNoTracking()
                                   .ToListAsync();

            PdfReport report = Constants.CreateBasicReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(zarazeneOsobe));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName <ZarazenaOsoba>(o => o.IdentifikacijskiBroj);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(4);
                    column.HeaderCell("Identifikacijski broj", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <ZarazenaOsoba>(o => o.IdentifikacijskiBrojNavigation.Ime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(4);
                    column.HeaderCell("Ime", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <ZarazenaOsoba>(o => o.IdentifikacijskiBrojNavigation.Prezime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(2);
                    column.HeaderCell("Prezime", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <ZarazenaOsoba>(o => o.SifraStanjaNavigation.NazivStanja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Stanje osobe", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <ZarazenaOsoba>(o => o.DatZaraze);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(2);
                    column.HeaderCell("Datum zaraze", horizontalAlignment: HorizontalAlignment.Center);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj =>
                        {
                            if (obj == null || string.IsNullOrEmpty(obj.ToString()))
                            {
                                return(string.Empty);
                            }
                            else
                            {
                                DateTime date = (DateTime)obj;
                                return(date.ToString("dd.MM.yyyy"));
                            }
                        });
                    });
                });
            });


            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=zarazeneosobe.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Dokumenti()
        {
            string naslov    = "Popis dokumenata";
            var    dokumenti = await ctx.Dokuments
                               .AsNoTracking()
                               .OrderBy(p => p.Naslov)
                               .ToListAsync();

            PdfReport report = CreateReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true);
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });

            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(dokumenti));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(Dokument.DokumentId));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Dokument id");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Dokument>(x => x.Naslov);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Naziv Dokumenta", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Dokument>(x => x.Vrsta);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("Vrsta dokumenta", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Dokument>(x => x.Blob);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(3);
                    column.HeaderCell("Link dokumenta", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Dokument>(x => x.DatumPredaje);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(3);
                    column.HeaderCell("Datum predaje dokumenta", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Dokument>(x => x.PonudaId);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(6);
                    column.Width(3);
                    column.HeaderCell("Id ponude", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=dokumenti.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Metoda koja generira pdf izvješće za detalje neke osobe.
        /// </summary>
        /// <param name="id">Identifikacijski broj osobe</param>
        /// <returns></returns>
        public async Task <IActionResult> PDFReportOsoba(string id)
        {
            string naslov = "Detalji osobe";
            var    osobe  = await ctx.Osoba
                            .Include(o => o.KontaktIdKontaktNavigation)
                            .Include(o => o.ZarazenaOsoba)
                            .Where(o => o.IdentifikacijskiBroj == id)
                            .Select(o => new OsobaDetailsViewModel
            {
                IdentifikacijskiBroj = o.IdentifikacijskiBroj,
                Ime            = o.Ime,
                Prezime        = o.Prezime,
                Adresa         = o.Adresa,
                DatRod         = o.DatRod,
                Zanimanje      = o.Zanimanje,
                Zarazena       = o.ZarazenaOsoba.IdentifikacijskiBroj.Equals(id) ? true : false,
                Zarazenastring = o.ZarazenaOsoba.IdentifikacijskiBroj.Equals(id) ? "Da" : "Ne",
                DatZaraze      = o.ZarazenaOsoba.DatZaraze,
                NazivStanja    = o.ZarazenaOsoba.SifraStanjaNavigation.NazivStanja
            })
                            .ToListAsync();

            PdfReport report = Constants.CreateBasicReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(osobe));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName <OsobaDetailsViewModel>(o => o.IdentifikacijskiBroj);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(4);
                    column.HeaderCell("Identifikacijski broj", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <OsobaDetailsViewModel>(o => o.Ime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Ime", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <OsobaDetailsViewModel>(o => o.Prezime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(2);
                    column.HeaderCell("Prezime", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <OsobaDetailsViewModel>(o => o.Adresa);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Adresa", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <OsobaDetailsViewModel>(o => o.DatRod);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(2);
                    column.HeaderCell("Datum rođenja", horizontalAlignment: HorizontalAlignment.Center);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj =>
                        {
                            if (obj == null || string.IsNullOrEmpty(obj.ToString()))
                            {
                                return(string.Empty);
                            }
                            else
                            {
                                DateTime date = (DateTime)obj;
                                return(date.ToString("dd.MM.yyyy"));
                            }
                        });
                    });
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <OsobaDetailsViewModel>(o => o.Zanimanje);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(2);
                    column.HeaderCell("Zanimanje", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <OsobaDetailsViewModel>(o => o.Zarazenastring);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(2);
                    column.HeaderCell("Zaražena?", horizontalAlignment: HorizontalAlignment.Left);
                });
            });


            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=osobadetalji.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Uredaji()
        {
            string naslov  = "Popis uredaja";
            var    list    = new List <UredajDenorm>();
            var    uredaji = _context.Uredaj
                             .Include(u => u.IdNadredeneKomponenteNavigation)
                             .Include(u => u.IdStatusaNavigation)
                             .Include(u => u.IdZidaNavigation)
                             .ToList();

            if (uredaji.Count <= 0)
            {
                return(NotFound());
            }

            foreach (var u in uredaji)
            {
                var ur = LoadDetails(u);
                list.Add(ur.GetInfo());
            }

            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(list));


            report.MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Ukupno");
            });

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <UredajDenorm>(x => x.Naziv);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Naziv ureðaja");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <UredajDenorm>(x => x.DatumNabavke);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(2);
                    column.HeaderCell("Datum Nabavke", horizontalAlignment: HorizontalAlignment.Center);
                });

                /*columns.AddColumn(column =>
                 * {
                 *  column.PropertyName<UredajDenorm>(x => x.NabavnaCijena);
                 *  column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                 *  column.IsVisible(true);
                 *  column.Order(3);
                 *  column.Width(1);
                 *  column.HeaderCell("Nabavna Cijena", horizontalAlignment: HorizontalAlignment.Center);
                 * });
                 */
                /*columns.AddColumn(column =>
                 * {
                 *  column.PropertyName<UredajDenorm>(x => x.AktualnaCijena);
                 *  column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                 *  column.IsVisible(true);
                 *  column.Order(4);
                 *  column.Width(1);
                 *  column.HeaderCell("Aktualna Cijena", horizontalAlignment: HorizontalAlignment.Center);
                 * });
                 *
                 * columns.AddColumn(column =>
                 * {
                 *  column.PropertyName<UredajDenorm>(x => x.Zida);
                 *  column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                 *  column.IsVisible(true);
                 *  column.Order(5);
                 *  column.Width(1);
                 *  column.HeaderCell("Videozid", horizontalAlignment: HorizontalAlignment.Center);
                 * });
                 *
                 * columns.AddColumn(column =>
                 * {
                 *  column.PropertyName<UredajDenorm>(x => x.Status);
                 *  column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                 *  column.IsVisible(true);
                 *  column.Order(6);
                 *  column.Width(1);
                 *  column.HeaderCell("Status", horizontalAlignment: HorizontalAlignment.Center);
                 * });
                 */
                columns.AddColumn(column =>
                {
                    column.PropertyName <UredajDenorm>(x => x.Zamjena);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("Zamjenski ureðaji", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <UredajDenorm>(x => x.ZamjenaZa);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(3);
                    column.HeaderCell("Zamjena Za", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <UredajDenorm>(x => x.Servisi);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(3);
                    column.HeaderCell("Servisi", horizontalAlignment: HorizontalAlignment.Center);
                });


                columns.AddColumn(column =>
                {
                    column.PropertyName("Nabavna Cijena");
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(6);
                    column.Width(2);
                    column.HeaderCell("Nabavna Cijena", horizontalAlignment: HorizontalAlignment.Center);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : string.Format("{0:C2}", obj));
                    });
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        aggregateFunction.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : string.Format("{0:C2}", obj));
                    });
                    column.CalculatedField(
                        l =>
                    {
                        if (l == null)
                        {
                            return(string.Empty);
                        }
                        var iznos = l.GetValueOf(nameof(UredajDenorm.NabavnaCijena));
                        return(iznos);
                    });
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=drzave.pdf");
                return(File(pdf, "application/pdf"));
                //return File(pdf, "application/pdf", "drzave.pdf"); //Otvara save as dialog
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Kreiranje PDF izvjestaja
        /// </summary>
        /// <returns>izvjestaj u PDF formatu</returns>
        public async Task <IActionResult> PDFReport()
        {
            string naslov   = "Popis sastanaka";
            var    sastanci = await ctx.Sastanak
                              .Include(o => o.SifraStozeraNavigation)
                              .ToListAsync();

            PdfReport report = Constants.CreateBasicReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(sastanci));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName <Sastanak>(o => o.SifraSastanka);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(4);
                    column.HeaderCell("Sifra sastanka", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Sastanak>(o => o.Datum);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(4);
                    column.HeaderCell("Datum sastanka", horizontalAlignment: HorizontalAlignment.Left);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj =>
                        {
                            if (obj == null || string.IsNullOrEmpty(obj.ToString()))
                            {
                                return(string.Empty);
                            }
                            else
                            {
                                DateTime date = (DateTime)obj;
                                return(date.ToString("dd.MM.yyyy"));
                            }
                        });
                    });
                    columns.AddColumn(column =>
                    {
                        column.PropertyName <Sastanak>(o => o.SifraStozeraNavigation.Naziv);
                        column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                        column.IsVisible(true);
                        column.Order(2);
                        column.Width(2);
                        column.HeaderCell("Naziv stozera", horizontalAlignment: HorizontalAlignment.Center);
                    });
                });
            });

            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=stozeri.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 7
0
        public IPdfReportData CreatePdfReport()
        {
            var report = new PdfReport();

            report.DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.LeftToRight);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A4);
                doc.DocumentMetadata(new DocumentMetadata {
                    Author = "Vios", Application = "PdfRpt", Keywords = "IList Rpt.", Subject = "Test Rpt", Title = "Test"
                });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression     = true,
                    EnableFullCompression = true
                });
                doc.PrintingPreferences(new PrintingPreferences
                {
                    ShowPrintDialogAutomatically = true
                });
            }
                                       );

            report.DefaultFonts(fonts =>
            {
                fonts.Path(System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\arial.ttf"),
                           System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\verdana.ttf"));
                fonts.Size(9);
                fonts.Color(System.Drawing.Color.Black);
            });

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("MM/dd/yyyy"));
            });

            report.PagesHeader(header =>
            {
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.ImagePath(System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\01.png"));
                    defaultHeader.Message("Our new rpt.");
                });
            });



            report.MainTableTemplate(template =>
            {
                template.BasicTemplate(BasicTemplate.ClassicTemplate);
            });

            report.MainTablePreferences(table =>
            {
                table.ColumnsWidthsType(TableColumnWidthType.Relative);
                table.NumberOfDataRowsPerPage(15);
            });

            report.MainTableDataSource(dataSource =>
            {
                var listOfRows = new List <User>();
                for (int i = 0; i < 200; i++)
                {
                    listOfRows.Add(new User {
                        Id = i, LastName = "LastName " + i, Name = "Name " + i, Balance = i + 1000
                    });
                }
                dataSource.StronglyTypedList(listOfRows);
            });

            report.MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Summary");
                summarySettings.PreviousPageSummarySettings("Previous Page Summary");
                summarySettings.PageSummarySettings("Page Summary");
            });

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName("rowNo");
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#");
                });


                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.Id);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Id");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.Name);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Name", horizontalAlignment: HorizontalAlignment.Left);
                    column.Font(font =>
                    {
                        font.Size(10);
                        font.Color(System.Drawing.Color.Brown);
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.LastName);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("Last Name");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.Balance);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(2);
                    column.HeaderCell("Balance");
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                    });
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        aggregateFunction.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                    });
                });
            });

            report.MainTableEvents(events =>
            {
                events.DataSourceIsEmpty(message: "There is no data available to display.");
            });

            report.Export(export =>
            {
                export.ToExcel();
                export.ToCsv();
                export.ToXml();
            });

            var reportHlp = report.Generate(data => data.AsPdfFile(string.Format("{0}\\Pdf\\RptTDSample-{1}.pdf", AppPath.ApplicationPath, Guid.NewGuid().ToString("N"))));

            //return report as IPdfReportData;
            return(reportHlp);
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Naručitelji()
        {
            string naslov      = "Popis naručitelja";
            var    naručitelji = await ctx.Naručiteljs
                                 .AsNoTracking()
                                 .OrderBy(p => p.NazivNaručitelja)
                                 .ToListAsync();

            PdfReport report = CreateReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true);
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });

            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(naručitelji));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(Naručitelj.OibNaručitelja));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Oib naručitelja");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Naručitelj>(x => x.NazivNaručitelja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Naziv naručitelja", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Naručitelj>(x => x.AdresaNaručitelja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("Adresa naručitelja", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Naručitelj>(x => x.PoštanskiBrojNaručitelja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(3);
                    column.HeaderCell("Poštanski broj naručitelja", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=naručitelji.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Posao()
        {
            string naslov = "Popis Poslova";
            var    servis = await ctx.Vw_Posao

                            .AsNoTracking()


                            .ToListAsync();

            PdfReport report = CreateReport(naslov);

            // byte[] content;

            #region Podnožje i zaglavlje

            report.PagesFooter(footer => { footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy.")); })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true);     // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });

            #endregion

            #region Postavljanje izvora podataka i stupaca

            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(servis));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName("PosaoId");
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(1);
                    column.HeaderCell("ID");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.Opis);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(1);
                    column.HeaderCell("Opis", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.Cijena);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(1);
                    column.HeaderCell("Cijena", horizontalAlignment: HorizontalAlignment.Center);
                });


                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.DodatniTrosak);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell(" Dodatni trosak", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.VrijemeOd);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("Vrijeme od", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.VrijemeDo);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("Vrijeme do", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.NazivZanimanja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("Naziv zanimanja", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.NazivOpreme);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("Naziv opreme", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.KategorijaId);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("Kategorija ID", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <PosaoViewModel>(x => x.NazivUsluge);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("Naziv usluge", horizontalAlignment: HorizontalAlignment.Center);
                });
            });



            #endregion

            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=posao.pdf");
                return(File(pdf, "application/pdf"));
                //return File(pdf, "application/pdf", "biljke.pdf"); //Otvara save as dialog
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Metoda koja služi za generiranje pdf izvješća. Stvara se tablica sa svim kontaktima koji su u bazi podataka
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> PDFReport()
        {
            string naslov  = "Popis osoba u kontaktu";
            var    kontkat = await ctx.Kontakt
                             .Include(o => o.IdKontaktNavigation)
                             .Include(o => o.IdOsobaNavigation)
                             .AsNoTracking()
                             .ToListAsync();

            PdfReport report = Constants.CreateBasicReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(kontkat));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName <Kontakt>(o => o.IdOsoba);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(4);
                    column.HeaderCell("Identifikacijski broj osobe", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Kontakt>(o => o.IdOsobaNavigation.Ime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Ime", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Kontakt>(o => o.IdOsobaNavigation.Prezime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(2);
                    column.HeaderCell("Prezime", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Kontakt>(o => o.IdKontakt);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Identifikacijski broj kontakta", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Kontakt>(o => o.IdKontaktNavigation.Ime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(2);
                    column.HeaderCell("Ime", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Kontakt>(o => o.IdKontaktNavigation.Prezime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(2);
                    column.HeaderCell("Prezime", horizontalAlignment: HorizontalAlignment.Left);
                });
            });


            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=kontakti.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> VrsteStavki()
        {
            string naslov      = "Popis vrsti stavki";
            var    vrsteStavki = await ctx.VrstaStavkes
                                 .AsNoTracking()
                                 .OrderBy(p => p.NazivVrste)
                                 .ToListAsync();

            PdfReport report = CreateReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true);
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });

            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(vrsteStavki));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(VrstaStavke.IdVrste));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Id vrste stavke");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VrstaStavke>(x => x.NazivVrste);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Naziv vrste stavke", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=vrsteStavki.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Poslovi()
        {
            string naslov  = "Popis nadolazećih poslova";
            var    poslovi = await ctx.Poslovi
                             .AsNoTracking()
                             .Where(a => a.VrijemeTrajanja >= DateTime.Now)
                             .OrderBy(a => a.VrijemeTrajanja)
                             .Select(a => new
            {
                a.IdPoslovi,
                a.Naziv,
                a.Mjesto,
                a.VrijemeTrajanja
            })
                             .Take(10)
                             .ToListAsync();

            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(poslovi));


            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Poslovi>(x => x.IdPoslovi);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(1);
                    column.HeaderCell("Šifra", horizontalAlignment: HorizontalAlignment.Center);
                });


                columns.AddColumn(column =>
                {
                    column.PropertyName <Poslovi>(x => x.Naziv);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Naziv posla", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Poslovi>(x => x.Mjesto);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Mjesto održavanja", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Poslovi>(x => x.VrijemeTrajanja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Vrijeme održavanja", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            #endregion

            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=poslovi.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Oprema()
        {
            string naslov = $"Popis dostupne opreme";
            var    oprema = await ctx.Oprema
                            .AsNoTracking()
                            .Where(a => a.Dostupnost == true)
                            .OrderBy(s => s.IdOprema)
                            .ThenBy(s => s.Naziv)
                            .ToListAsync();

            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance. !!!!!!!!!!!!
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(oprema));

            report.MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Ukupno");
            });

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        aggregateFunction.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                ? string.Empty : string.Format("{0:C2}", obj));
                    });
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Oprema>(x => x.IdOprema);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Width(4);
                    column.HeaderCell("Šifra", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Oprema>(x => x.Naziv);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Width(1);
                    column.HeaderCell("Naziv", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Oprema>(x => x.Status);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Width(1);
                    column.HeaderCell("Opis", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=artikli.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Korisnici()
        {
            string naslov = "Popis korisnika";

            var korisnici = ctx.Korisnik.ToList().OrderBy(k => k.Prezime);


            List <KorisnikDenorm> korisniciDenorm = new List <KorisnikDenorm>();
            var broj = 1;

            foreach (var k in korisnici)
            {
                var fer      = ctx.FerWebAcc.Where(f => f.Id == k.FerId).FirstOrDefault();
                var dhmz     = ctx.DhmzAcc.Where(d => d.Id == k.DhmzId).FirstOrDefault();
                var autori   = ctx.Sadrzaj.Where(s => s.IdAutora == k.Id).ToList().OrderBy(s => s.Ime);
                var autor    = autori.Select(s => s.Ime).ToList();
                var odobrioo = ctx.Sadrzaj.Where(s => s.IdOdobrenOd == k.Id).ToList().OrderBy(s => s.Ime);
                var odobrio  = odobrioo.Select(s => s.Ime).ToList();


                korisniciDenorm.Add(Denormalize(k, fer, dhmz, autor, odobrio, broj));
                broj++;
            }

            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(korisniciDenorm));
            report.MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Sum");
            });
            var admin = ctx.Administrator.Select(a => a.IdKorisnika).ToList();
            report.MainTableColumns(columns =>

            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width((float)0.5);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(KorisnikDenorm.Id));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width((float)0.5);
                    column.HeaderCell("ID", horizontalAlignment: HorizontalAlignment.Center);
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <KorisnikDenorm>(k => k.PrezimeIme);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width((float)1.75);
                    column.HeaderCell("Ime i prezime ", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <KorisnikDenorm>(k => k.Email);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("Email", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <KorisnikDenorm>(k => k.KorisnickoIme);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width((float)1.5);
                    column.HeaderCell("Korisničko ime", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <KorisnikDenorm>(k => k.Fer);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(1);
                    column.HeaderCell("FerWeb račun", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <KorisnikDenorm>(k => k.DHMZ);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(6);
                    column.Width(1);
                    column.HeaderCell("DHMZ račun", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(KorisnikDenorm.Autor));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(7);
                    column.Width((float)1.5);
                    column.HeaderCell("Autor sadržaja", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(KorisnikDenorm.Odobrio));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(8);
                    column.Width((float)1.5);
                    column.HeaderCell("Odobrio sadržaje", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=korisnici.pdf");
                return(File(pdf, "application/pdf"));
                //return File(pdf, "application/pdf", "drzave.pdf"); //Otvara save as dialog
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Izrada izvjestaja u PDF formatu
        /// </summary>
        /// <returns>PDF dokument</returns>
        public async Task <IActionResult> PDFReport()
        {
            string naslov = "Popis mjera";
            var    mjere  = await ctx.Mjera
                            .ToListAsync();

            PdfReport report = Constants.CreateBasicReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(mjere));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName <Mjera>(o => o.SifraMjere);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(4);
                    column.HeaderCell("Sifra mjere", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Mjera>(o => o.SifraPrethodneMjere);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(4);
                    column.HeaderCell("Sifra prethodne mjere", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Mjera>(o => o.SifraSastanka);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(2);
                    column.HeaderCell("Sifra sastanka", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Mjera>(o => o.Opis);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Opis", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Mjera>(o => o.Datum);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Datum", horizontalAlignment: HorizontalAlignment.Left);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Mjera>(o => o.VrijediDo);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Vrijedi do", horizontalAlignment: HorizontalAlignment.Left);
                });
            });


            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=mjere.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Oprema()
        {
            string naslov = "Popis opreme";
            var    biljke = await ctx.Oprema
                            .AsNoTracking()
                            .Include(c => c.Status)
                            .Include(d => d.ReferentniTipOpreme)
                            .Include(e => e.LokacijaOpreme)

                            .ToListAsync();

            PdfReport report = CreateReport(naslov);

            // byte[] content;
            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(biljke));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName("OpremaId");
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("ID-Opreme");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Oprema>(x => x.NabavnaCijena);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Nabavna cijena", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <Oprema>(x => x.Naziv);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Naziv", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Oprema>(x => x.LokacijaOpreme.NazivLokacije);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(1);
                    column.HeaderCell("Lokacija", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=posao.pdf");
                return(File(pdf, "application/pdf"));
                //return File(pdf, "application/pdf", "biljke.pdf"); //Otvara save as dialog
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Zahtjevi()
        {
            string naslov   = "Popis zahtjeva";
            var    zahtjevi = await ctx.Zahtjev
                              .AsNoTracking()
                              .OrderBy(d => d.IdZahtjeva)
                              .Select(d => new ZahtjevViewModel
            {
                IdZahtjeva  = d.IdZahtjeva,
                ImePrezime  = d.IdKlijentaNavigation.FirstName + " " + d.IdKlijentaNavigation.LastName,
                NazivUsluge = d.IdUslugeNavigation.NazivUsluge,
                DatumOd     = d.DatumOd,
                DatumDo     = d.DatumDo,
                BrojVozila  = d.BrojVozila
            })
                              .ToListAsync();

            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(zahtjevi));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(Zahtjev.IdZahtjeva));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Id zahtjeva");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ZahtjevViewModel>(x => x.ImePrezime);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Klijent", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ZahtjevViewModel>(x => x.NazivUsluge);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(1);
                    column.HeaderCell("Naziv usluge", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ZahtjevViewModel>(x => x.DatumOd);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(1);
                    column.HeaderCell("Datum od", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <ZahtjevViewModel>(x => x.DatumDo);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(1);
                    column.HeaderCell("Datum do", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=zahtjevi.pdf");
                return(File(pdf, "application/pdf"));
                //return File(pdf, "application/pdf", "drzave.pdf"); //Otvara save as dialog
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> Servisi()
        {
            string naslov = "Popis servisa";

            var servisi = ctx.Servis.ToList();

            PdfReport report = CreateReport(naslov);

            List <ServisDenorm> servisiDenorm = new List <ServisDenorm>();

            foreach (var s in servisi)
            {
                var tipServis     = ctx.TipServisa.Where(tip => tip.IdServis == s.Id).FirstOrDefault();
                var serviseri     = ctx.Serviser.Where(serviser => serviser.IdServis == s.Id).ToList();
                var uredajIdNaziv = (from ur in ctx.Uredaj
                                     join servisira in ctx.Servisira on ur.Id equals servisira.IdUredaj
                                     where (servisira.IdServis == s.Id)
                                     select ur.Naziv).ToList();

                servisiDenorm.Add(Denormalize(s, tipServis, serviseri, uredajIdNaziv));
            }

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion

            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(servisiDenorm));
            report.MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Suma");
            });

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(2);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(ServisDenorm.Id));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(1);
                    column.HeaderCell("Id ");
                    //column.ColumnItemsTemplate(template =>
                    //{
                    //    template.TextBlock();
                    //    template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                    //                                        ? string.Empty : string.Format("{0:2}", obj));
                    //});
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        //aggregateFunction.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                        //                                    ? string.Empty : string.Format("{0:C2}", obj));
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(ServisDenorm.ImeServisa));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Ime servisa");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(ServisDenorm.OpisServisa));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Opis servisa", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(ServisDenorm.Tip));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("Tip servisa", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(ServisDenorm.Serviseri));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(5);
                    column.HeaderCell("Serviseri", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(ServisDenorm.Uredaji));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(6);
                    column.HeaderCell("Uređaji", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=servisi.pdf");
                return(File(pdf, "application/pdf"));
                //return File(pdf, "application/pdf", "drzave.pdf"); //Otvara save as dialog
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Artikli()
        {
            string naslov  = "Deset najskupljih artikala koji imaju sliku";
            var    artikli = await ctx.Artikl
                             .AsNoTracking()
                             .Where(a => a.SlikaArtikla != null)
                             .OrderByDescending(a => a.CijArtikla)
                             .Select(a => new
            {
                a.SifArtikla,
                a.NazArtikla,
                a.CijArtikla,
                a.SlikaArtikla
            })
                             .Take(10)
                             .ToListAsync();

            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(artikli));

            report.MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Ukupno");
            });

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(Artikl.SlikaArtikla));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(1);
                    column.HeaderCell(" ");
                    column.ColumnItemsTemplate(t => t.ByteArrayImage(string.Empty, fitImages: true));
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(Artikl.SifArtikla));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(1);
                    column.HeaderCell("Šifra");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Artikl>(x => x.NazArtikla);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(4);
                    column.HeaderCell("Naziv artikla", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Artikl>(x => x.CijArtikla);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(1);
                    column.HeaderCell("Cijena", horizontalAlignment: HorizontalAlignment.Center);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                ? string.Empty : string.Format("{0:C2}", obj));
                    });
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        aggregateFunction.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                ? string.Empty : string.Format("{0:C2}", obj));
                    });
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=artikli.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> Dokumenti()
        {
            int    n      = 10;
            var    param  = new SqlParameter("N", n);
            string naslov = $"{n} najvećih kupnji";
            var    stavke = await ctx.StavkaDenorm
                            .AsNoTracking()
                            .FromSql("SELECT * FROM fn_NajveceKupnje(@N)", param)
                            .OrderBy(s => s.IdDokumenta)
                            .ThenBy(s => s.NazArtikla)
                            .ToListAsync();

            stavke.ForEach(s => s.UrlDokumenta = Url.Action("Edit", "Dokument", new { id = s.IdDokumenta }));
            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.CustomHeader(new MasterDetailsHeaders(naslov)
                {
                    PdfRptFont = header.PdfFont
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(stavke));

            report.MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Ukupno");
            });

            report.MainTableColumns(columns =>
            {
                #region Stupci po kojima se grupira
                columns.AddColumn(column =>
                {
                    column.PropertyName <StavkaDenorm>(s => s.IdDokumenta);
                    column.Group(
                        (val1, val2) =>
                    {
                        return((int)val1 == (int)val2);
                    });
                });
                #endregion
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <StavkaDenorm>(x => x.NazArtikla);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Width(4);
                    column.HeaderCell("Naziv artikla", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <StavkaDenorm>(x => x.KolArtikla);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Width(1);
                    column.HeaderCell("Količina", horizontalAlignment: HorizontalAlignment.Center);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                ? string.Empty : string.Format("{0:.00}", obj));
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <StavkaDenorm>(x => x.JedCijArtikla);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Width(1);
                    column.HeaderCell("Jedinična cijena", horizontalAlignment: HorizontalAlignment.Center);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                ? string.Empty : string.Format("{0:C2}", obj));
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <StavkaDenorm>(x => x.PostoRabat);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Width(1);
                    column.HeaderCell("Rabat", horizontalAlignment: HorizontalAlignment.Center);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                ? string.Empty : string.Format("{0:P2}", obj));
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName("Ukupno");
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Width(1);
                    column.HeaderCell("Ukupno", horizontalAlignment: HorizontalAlignment.Center);
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                ? string.Empty : string.Format("{0:C2}", obj));
                    });
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        aggregateFunction.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                ? string.Empty : string.Format("{0:C2}", obj));
                    });
                    column.CalculatedField(
                        list =>
                    {
                        if (list == null)
                        {
                            return(string.Empty);
                        }
                        decimal kolArtikla    = (decimal)list.GetValueOf(nameof(StavkaDenorm.KolArtikla));
                        decimal postoRabat    = (decimal)list.GetValueOf(nameof(StavkaDenorm.PostoRabat));
                        decimal jedCijArtikla = (decimal)list.GetValueOf(nameof(StavkaDenorm.JedCijArtikla));
                        var iznos             = jedCijArtikla * kolArtikla * (1 - postoRabat);
                        return(iznos);
                    });
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=artikli.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> Drzave()
        {
            string naslov = "Popis država";
            var    drzave = await ctx.Drzava
                            .AsNoTracking()
                            .OrderBy(d => d.NazDrzave)
                            .ToListAsync();

            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion
            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(drzave));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(Drzava.OznDrzave));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Oznaka države");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Drzava>(x => x.NazDrzave);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Naziv države", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Drzava>(x => x.Iso3drzave);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(1);
                    column.HeaderCell("ISO3", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Drzava>(x => x.SifDrzave);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(1);
                    column.HeaderCell("Šifra države", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=drzave.pdf");
                return(File(pdf, "application/pdf"));
                //return File(pdf, "application/pdf", "drzave.pdf"); //Otvara save as dialog
            }
            else
            {
                return(NotFound());
            }
        }
        public async Task <IActionResult> Kompetencije()
        {
            string naslov       = "Popis kompetencija";
            var    kompetencije = await ctx.VrstaKompetencijes
                                  .AsNoTracking()
                                  .OrderBy(p => p.NazivKompetencije)
                                  .ToListAsync();

            PdfReport report = CreateReport(naslov);

            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true);
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });

            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(kompetencije));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName(nameof(VrstaKompetencije.IdKompetencije));
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Id kompetencije");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VrstaKompetencije>(x => x.NazivKompetencije);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Naziv kompetencije", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VrstaKompetencije>(x => x.SjedišteObrazovneUstanove);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("Sjedište", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VrstaKompetencije>(x => x.PočetakObrazovanja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(3);
                    column.HeaderCell("Početak obrazovanja", horizontalAlignment: HorizontalAlignment.Center);
                });
                columns.AddColumn(column =>
                {
                    column.PropertyName <VrstaKompetencije>(x => x.KrajObrazovanja);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(3);
                    column.HeaderCell("Kraj obrazovanja", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=kompetencije.pdf");
                return(File(pdf, "application/pdf"));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> Videozidovi()
        {
            string naslov = "Popis videozidova";
            var    list   = new List <VideozidDenorm>();
            var    zidovi = _context.Videozid
                            .ToList();

            if (zidovi.Count <= 0)
            {
                return(NotFound());
            }

            foreach (var v in zidovi)
            {
                var ekrani = _context.EkranZida.Where(u => u.IdZida == v.Id).Include(u => u.IdUredajaNavigation).ToList();
                var vi     = new VideozidDetailsViewModel(v, ekrani).GetInfo();
                list.Add(vi);
            }

            PdfReport report = CreateReport(naslov);

            #region Podnožje i zaglavlje
            report.PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("dd.MM.yyyy."));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message(naslov);
                });
            });
            #endregion

            #region Postavljanje izvora podataka i stupaca
            report.MainTableDataSource(dataSource => dataSource.StronglyTypedList(list));

            report.MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Right);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Right);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VideozidDenorm>(x => x.Naziv);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("Naziv Videozida");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VideozidDenorm>(x => x.Lokacija);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(2);
                    column.HeaderCell("Lokacija", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VideozidDenorm>(x => x.Sirina);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(1);
                    column.HeaderCell("Sirina", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VideozidDenorm>(x => x.Visina);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(1);
                    column.HeaderCell("Visina", horizontalAlignment: HorizontalAlignment.Center);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <VideozidDenorm>(x => x.Ekrani);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(5);
                    column.HeaderCell("Ekrani zida", horizontalAlignment: HorizontalAlignment.Center);
                });
            });

            #endregion
            byte[] pdf = report.GenerateAsByteArray();

            if (pdf != null)
            {
                Response.Headers.Add("content-disposition", "inline; filename=drzave.pdf");
                return(File(pdf, "application/pdf"));
                //return File(pdf, "application/pdf", "drzave.pdf"); //Otvara save as dialog
            }
            else
            {
                return(NotFound());
            }
        }