コード例 #1
0
        private static void AddHeader(Document pdfDoc, Employee employee, Duty duty)
        {
            pdfDoc.Add(new Paragraph());
            Chunk chunk = new Chunk("SLUŽBA:	Služba transporta\n", FontFactory.GetFont("TIMES_ROMAN", 10, Font.NORMAL, BaseColor.BLACK));

            pdfDoc.Add(chunk);
            chunk = new Chunk("Oddelek: PSO\n", FontFactory.GetFont("TIMES_ROMAN", 10, Font.NORMAL, BaseColor.BLACK));
            pdfDoc.Add(chunk);
            chunk = new Chunk("Delavec: " + employee.Name + " " + employee.Surname + "\n", FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK));
            pdfDoc.Add(chunk);
            pdfDoc.Add(Chunk.NEWLINE);
            pdfDoc.Add(Chunk.NEWLINE);
            PdfPTable pt = new PdfPTable(1);

            AddCellCenterBold(pt, "OBRAČUN PRIPRAVLJENOSTI IN INTERVENCIJ", 12);
            AddCellCenterBold(pt, ("od " + PlinovodiDezurstvaUtils.SubStringMonthInDate(duty.From.ToString("d.MMMM.yy")) + " do " +
                                   PlinovodiDezurstvaUtils.SubStringMonthInDate(duty.To.ToString("d.MMMM.yy"))), 12);
            pdfDoc.Add(pt);
        }
コード例 #2
0
        private static void GenerateHourOverwiev(Document pdfDoc, Employee employee, Duty duty, int[] takenHoursInOneDay,
                                                 IEnumerable <Intervention> interventionListSeperated)
        {
            double realHoursAllSum = 0;
            int    hoursSum        = 0;
            double realHoursSum    = 0;

            //process header
            PlinovodiDezurstvaUtils.AddHeader(pdfDoc, employee, duty);

            //process workdays
            PdfPTable table = PlinovodiDezurstvaUtils.GetTable(5);

            PlinovodiDezurstvaUtils.AddTableLine(table, new List <string>()
            {
                "Datum", "Dan", "", "Število ur", "Število rednih  ur (10%)"
            });

            for (int indexDays = 0; indexDays < 8; indexDays++)
            {
                if (indexDays == 5 || indexDays == 6)
                {
                    continue;
                }

                int hours = PlinovodiDezurstvaUtils.GetSteviloUr(indexDays, takenHoursInOneDay);
                PlinovodiDezurstvaUtils.AddTableLine(table, new List <string>()
                {
                    PlinovodiDezurstvaUtils.SubStringMonthInDate(duty.From.AddDays(indexDays).ToString("d.MMMM.yy")),
                    PlinovodiDezurstvaUtils.GetDayName(indexDays),
                    "", hours.ToString(), (hours * 0.1).ToString()
                });
                hoursSum += hours; realHoursSum += hours * 0.1;
            }

            PlinovodiDezurstvaUtils.AddTableLine(table, new List <string>()
            {
                "", "", "Skupaj", hoursSum.ToString(), realHoursSum.ToString()
            });
            pdfDoc.Add(table);
            realHoursAllSum += realHoursSum;
            /////////////////////////////////////////////////

            //process weekends
            hoursSum     = 0;
            realHoursSum = 0;
            table        = PlinovodiDezurstvaUtils.GetTable(5);
            PlinovodiDezurstvaUtils.AddTableLine(table, new List <string>()
            {
                "Datum", "Dan", "", "Število ur", "Število rednih  ur (20%)"
            });

            for (int indexDays = 0; indexDays < 8; indexDays++)
            {
                if (indexDays != 5 && indexDays != 6)
                {
                    continue;
                }

                int hours = PlinovodiDezurstvaUtils.GetSteviloUr(indexDays, takenHoursInOneDay);
                PlinovodiDezurstvaUtils.AddTableLine(table, new List <string>()
                {
                    PlinovodiDezurstvaUtils.SubStringMonthInDate(duty.From.AddDays(indexDays).ToString("d.MMMM.yy")),
                    PlinovodiDezurstvaUtils.GetDayName(indexDays),
                    "", hours.ToString(), (hours * 0.2).ToString()
                });

                hoursSum += hours; realHoursSum += hours * 0.2;
            }

            PlinovodiDezurstvaUtils.AddTableLine(table, new List <string>()
            {
                "", "", "Skupaj", hoursSum.ToString(), realHoursSum.ToString()
            });
            pdfDoc.Add(table);
            realHoursAllSum += realHoursSum;
            /////////////////////////////////////

            //process interventions
            table = PlinovodiDezurstvaUtils.GetTable(5);
            PlinovodiDezurstvaUtils.AddTableLine(table, new List <string>()
            {
                "Datum", "Objekt", "Od ure", "Do ure", "Opis del"
            });
            bool weHaveInterventions = false;

            foreach (Intervention intervention in interventionListSeperated)
            {
                int endHour = intervention.From.Day != intervention.To.Day ? 24 : intervention.To.Hour;
                PlinovodiDezurstvaUtils.AddTableLine(table, new List <string>()
                {
                    PlinovodiDezurstvaUtils.SubStringMonthInDate(intervention.From.ToString("d.MMMM.yy")), "",
                    intervention.From.ToString("HH:mm"), endHour + ":00", intervention.ShortDescription
                });

                weHaveInterventions = true;
            }
            if (weHaveInterventions)
            {
                PdfPTable pt = new PdfPTable(1);
                PlinovodiDezurstvaUtils.AddCellCenterBold(pt, "INTERVENCIJA", 12);
                pdfDoc.Add(pt);

                pdfDoc.Add(table);
            }
            //////////////
            ///

            //add Footer
            PlinovodiDezurstvaUtils.AddFooter(pdfDoc, employee, duty, realHoursAllSum, takenHoursInOneDay);
        }