Ejemplo n.º 1
0
        private static IEnumerable <string> CreatePdfInvoiceHtml(Translate translate, Invoice invoice, InvoiceDataApi invoiceData, string organizationLogo, string organizationName, string organizationAddress)
        {
            foreach (var style in GenericCssStyles.GetDefaultInlineStyles())
            {
                yield return(style);
            }

            yield return("<html class='html'>");

            yield return("<body class='body'>");

            yield return("<div class='vertical-logo'>");

            yield return(translate.Get("INVOICE.POWERED_BY") + " <span class='logo-sorting'>Sorting</span><span class='logo-time'>time</span>");

            yield return("</div>");

            yield return("<div class='container'>");

            yield return("<div class='body-content'>");

            yield return("<div class='row'>");

            yield return("    <div class='col-md-3'>");

            yield return("        <div>");

            yield return("            <div class='invoice-logo'>" + organizationLogo != null ? "<img src='" + organizationLogo + "' />" : "" + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("    <div class='col-md-6'>");

            yield return("        <div>");

            yield return("            <div class='invoice-title'>" + invoiceData.InvoiceTitle + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("    <div class='col-md-3'>");

            yield return("        <div>");

            yield return("            <div class='organisation-name'>" + organizationName + "</div>");

            yield return("        </div>");

            yield return("        <div class='default-margin'>");

            yield return("            <div class='organisation-address'>" + organizationAddress?.ToHtml() + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("</div>");


            yield return("<div class='row'>");

            yield return("    <div class='col-md-3'>");

            yield return("        <div class='large-margin'>");

            yield return("            <div class='invoice-customer'>" + invoiceData.InvoiceCustomer?.ToHtml() + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("    <div class='col-md-offset-5-col-md-4'>");

            if (invoiceData.Vat && !string.IsNullOrWhiteSpace(invoiceData.VatNumber))
            {
                yield return("      <div class='inner-row'>");

                yield return("          <div class='col-md-5'>");

                yield return("              <div>");

                yield return("                  <div class='control-label'>" + translate.Get("INVOICE.VAT_NUMBER") + ":</div>");

                yield return("              </div>");

                yield return("          </div>");

                yield return("          <div class='col-md-7'>");

                yield return("              <div>");

                yield return("                  <div class='vat-number'>" + invoiceData.VatNumber + "</div>");

                yield return("              </div>");

                yield return("          </div>");

                yield return("      </div>");
            }

            if (!string.IsNullOrWhiteSpace(invoiceData.PaymentDetails))
            {
                yield return("        <div class='large-margin'>");

                yield return("            <div class='payment-details'>" + invoiceData.PaymentDetails?.ToHtml() + "</div>");

                yield return("        </div>");
            }

            yield return("    </div>");

            yield return("</div>");

            yield return("<div class='row'>");

            yield return("    <div class='col-md-12'>");

            yield return("        <hr class='hr' />");

            yield return("    </div>");

            yield return("</div>");


            yield return("<div class='row'>");

            yield return("    <div class='col-md-5'>");

            yield return("      <div class='inner-row'>");

            yield return("          <div class='col-md-5'>");

            yield return("              <div>");

            yield return("                  <div class='control-label'>" + (!invoice.CreditNote ? translate.Get("INVOICE.INVOICE_NUMBER") : translate.Get("INVOICE.CREDIT_NUMBER")) + ":</div>");

            yield return("              </div>");

            yield return("          </div>");

            yield return("          <div class='col-md-7'>");

            yield return("              <div>");

            yield return("                  <div class='invoice-number'>" + invoice.Number + "</div>");

            yield return("              </div>");

            yield return("          </div>");

            yield return("      </div>");

            yield return("      <div class='inner-row'>");

            yield return("          <div class='col-md-5'>");

            yield return("              <div>");

            yield return("                  <div class='control-label'>" + (!invoice.CreditNote ? translate.Get("INVOICE.INVOICE_DATE") : translate.Get("INVOICE.CREDIT_DATE")) + ":</div>");

            yield return("              </div>");

            yield return("          </div>");

            yield return("          <div class='col-md-7'>");

            yield return("              <div>");

            yield return("                  <div class='invoice-date'>" + invoice.InvoiceDate.ToShortDateString() + "</div>");

            yield return("              </div>");

            yield return("          </div>");

            yield return("      </div>");

            if (!string.IsNullOrWhiteSpace(invoiceData.InvoiceReference))
            {
                yield return("      <div class='inner-row'>");

                yield return("          <div class='col-md-5'>");

                yield return("              <div>");

                yield return("                  <div class='control-label'>" + translate.Get("INVOICE.REFERENCE") + ":</div>");

                yield return("              </div>");

                yield return("          </div>");

                yield return("          <div class='col-md-7'>");

                yield return("              <div>");

                yield return("                  <div class='invoice-reference'>" + invoiceData.InvoiceReference + "</div>");

                yield return("              </div>");

                yield return("          </div>");

                yield return("      </div>");
            }
            yield return("    </div>");

            if (!string.IsNullOrWhiteSpace(invoiceData.InvoicePaymentTerms))
            {
                yield return("    <div class='col-md-offset-1-col-md-6'>");

                yield return("        <div class='large-margin'>");

                yield return("            <div class='payment-terms'>" + invoiceData.InvoicePaymentTerms?.ToHtml() + "</div>");

                yield return("        </div>");

                yield return("    </div>");
            }
            yield return("</div>");

            if (!string.IsNullOrWhiteSpace(invoiceData.InvoiceText))
            {
                yield return("<div class='row'>");

                yield return("    <div class='col-md-12'>");

                yield return("        <div class='large-margin'>");

                yield return("            <div class='invoice-text'>" + invoiceData.InvoiceText?.ToHtml() + "</div>");

                yield return("        </div>");

                yield return("    </div>");

                yield return("</div>");
            }
            yield return("<div class='row'>");

            yield return("<div class='col-md-12'>");

            yield return("    <table class='table'>");

            yield return("    <colgroup>");

            yield return("        <col style='width: 20px' />");

            if (invoiceData.ShowGroupColl)
            {
                yield return("        <col style='width: 25%' />");
            }
            yield return("        <col style='width: auto' />");

            yield return("        <col style='width: 15%' />");

            yield return("        <col style='width: 15%' />");

            yield return("        <col style='width: 18%' />");

            yield return("    </colgroup>");

            yield return("        <tbody>");

            yield return("            <tr>");

            if (invoiceData.ShowGroupColl)
            {
                yield return("            <th class='table-head' colspan='2'>" + translate.Get("INVOICE.GROUP") + "</th>");
            }
            yield return("                <th class='table-head' colspan='" + (invoiceData.ShowGroupColl ? "1" : "2") + "'>" + translate.Get("INVOICE.TASK") + "</th>");

            yield return("                <th class='table-head-right'>" + translate.Get("INVOICE.TIME") + "</th>");

            yield return("                <th class='table-head-right'>" + translate.Get("INVOICE.HOURPRICE") + "</th>");

            yield return("                <th class='table-head-right'>" + translate.Get("INVOICE.PRICE") + "</th>");

            yield return("            </tr>");

            foreach (var groupTask in invoiceData.Invoice.GroupTasks)
            {
                yield return("            <tr>");

                if (invoiceData.ShowGroupColl)
                {
                    yield return("            <td class='table-data' colspan='2'>" + groupTask.Group + "</td>");
                }
                yield return("                <td class='table-data' colspan='" + (invoiceData.ShowGroupColl ? "1" : "2") + "'>" + groupTask.Task + "</td>");

                yield return("                <td class='table-data'></td>");

                yield return("                <td class='table-data'></td>");

                yield return("                <td class='table-data'></td>");

                yield return("            </tr>");

                yield return("            <tr class='sub-table'>");

                yield return("                <th class='sub-table-head-first'></th>");

                yield return("                <th class='sub-table-head-names1' colspan='" + (invoiceData.ShowGroupColl ? "2" : "1") + "'>" + translate.Get("INVOICE.PERSON") + "</th>");

                yield return("                <th class='sub-table-head-names2'></th>");

                yield return("                <th class='sub-table-head-names2'></th>");

                yield return("                <th class='sub-table-head-names2'></th>");

                yield return("            </tr>");

                foreach (var user in groupTask.Users)
                {
                    yield return("            <tr class='sub-table'>");

                    yield return("                <td class='table-user-first'></td>");

                    yield return("                <td class='table-user-names1' colspan='" + (invoiceData.ShowGroupColl ? "2" : "1") + "'>" + user.FullName + "</td>");

                    yield return("                <td class='table-user-data-right'>" + user.Time.ToTimeFormat() + "</td>");

                    yield return("                <td class='table-user-data-right'>" + user.HourPrice?.ToString("C").HtmlSpace() + "</td>");

                    yield return("                <td class='table-user-data-right'>" + user.Price?.ToString("C").HtmlSpace() + "</td>");

                    yield return("            </tr>");
                }

                yield return("            <tr>");

                yield return("                <td class='table-space' colspan='" + (invoiceData.ShowGroupColl ? "6" : "5") + "'></td>");

                yield return("            </tr>");
            }

            yield return("            <tr>");

            yield return("                <td class='table-space-small' colspan='" + (invoiceData.ShowGroupColl ? "6" : "5") + "'></td>");

            yield return("            </tr>");

            yield return("            <tr>");

            yield return("                <td class='table-space' colspan='" + (invoiceData.ShowGroupColl ? "3" : "2") + "'></td>");

            yield return("                <td colspan='2' class='table-data'>" + translate.Get("INVOICE.SUBTOTAL") + "</td>");

            yield return("                <td class='table-data-right'>" + invoice.SubTotalPrice.ToString("C").HtmlSpace() + "</td>");

            yield return("            </tr>");

            if (invoiceData.Tax)
            {
                yield return("            <tr>");

                yield return("                <td class='table-space' colspan='" + (invoiceData.ShowGroupColl ? "3" : "2") + "'></td>");

                yield return("                <td colspan='2' class='table-data'>" + translate.Get("INVOICE.TAX") + " (" + (invoiceData.TaxPercentage.HasValue ? invoiceData.TaxPercentage.Value : 0) + "%)</td>");

                yield return("                <td class='table-data-right'>" + invoiceData.TaxPrice?.ToString("C").HtmlSpace() + "</td>");

                yield return("            </tr>");
            }
            if (invoiceData.Vat)
            {
                yield return("            <tr>");

                yield return("                <td class='table-space' colspan='" + (invoiceData.ShowGroupColl ? "3" : "2") + "'></td>");

                yield return("                <td colspan='2' class='table-data'>" + translate.Get("INVOICE.VAT") + " (" + (invoiceData.VatPercentage.HasValue ? invoiceData.VatPercentage.Value : 0) + "%)</td>");

                yield return("                <td class='table-data-right'>" + invoiceData.VatPrice?.ToString("C").HtmlSpace() + "</td>");

                yield return("            </tr>");
            }

            yield return("            <tr>");

            yield return("                <td class='table-space' colspan='" + (invoiceData.ShowGroupColl ? "3" : "2") + "'></td>");

            yield return("                <td colspan='2' class='table-data-total'>" + translate.Get("INVOICE.TOTAL") + "</td>");

            yield return("                <td class='table-data-total-right'>" + invoiceData.TotalPrice.ToString("C").HtmlSpace() + "</td>");

            yield return("            </tr>");


            yield return("        </tbody>");

            yield return("    </table>");

            yield return("</div>");

            yield return("</div>");

            yield return("</div>");

            yield return("</div>");

            yield return("</body></html>");
        }
Ejemplo n.º 2
0
        private static IEnumerable <string> CreatePdfReportHtml(Translate translate, bool showGroupColl, string organizationLogo, string organizationName, string organizationAddress, string reportTitle, string reportSubTitle, string reportText, ReportApi report)
        {
            foreach (var style in GenericCssStyles.GetDefaultInlineStyles())
            {
                yield return(style);
            }

            yield return("<html class='html'>");

            yield return("<body class='body'>");

            yield return("<div class='vertical-logo'>");

            yield return(translate.Get("REPORT.POWERED_BY") + " <span class='logo-sorting'>Sorting</span><span class='logo-time'>time</span>");

            yield return("</div>");

            yield return("<div class='container'>");

            yield return("<div class='body-content'>");

            yield return("<div class='row'>");

            yield return("    <div class='col-md-3'>");

            yield return("        <div>");

            yield return("            <div class='report-logo'>" + organizationLogo != null ? "<img src='" + organizationLogo + "' />" : "" + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("    <div class='col-md-6'>");

            yield return("        <div>");

            yield return("            <div class='report-title'>" + reportTitle + "</div>");

            yield return("        </div>");

            yield return("        <div class='default-margin'>");

            yield return("            <div class='report-sub-title'>" + reportSubTitle + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("    <div class='col-md-3'>");

            yield return("        <div>");

            yield return("            <div class='organisation-name'>" + organizationName + "</div>");

            yield return("        </div>");

            yield return("        <div class='default-margin'>");

            yield return("            <div class='organisation-address'>" + organizationAddress?.ToHtml() + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("</div>");

            yield return("<div class='row'>");

            yield return("    <div class='col-md-12'>");

            yield return("        <div class='large-margin'>");

            yield return("            <div class='report-text'>" + reportText?.ToHtml() + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("</div>");

            yield return("<div class='row'>");

            yield return("<div class='col-md-12'>");

            yield return("    <table class='table'>");

            yield return("        <tbody>");

            yield return("            <tr>");

            if (showGroupColl)
            {
                yield return("            <th class='table-head'>" + translate.Get("REPORT.GROUP") + "</th>");
            }
            yield return("                <th class='table-head'>" + translate.Get("REPORT.TASK") + "</th>");

            yield return("                <th class='table-head-right'>" + translate.Get("REPORT.TIME") + (report.GroupTaskTotals.Count() > 1 ? " <small class='small'>(" + report.MonthTotal.ToTimeFormat() + ")</small>": "") + "</th>");

            yield return("            </tr>");

            foreach (var groupTaskTotal in report.GroupTaskTotals)
            {
                yield return("            <tr>");

                if (showGroupColl)
                {
                    yield return("            <td class='table-data'>" + groupTaskTotal.Group + "</td>");
                }
                yield return("                <td class='table-data'>" + groupTaskTotal.Task + "</td>");

                yield return("                <td class='table-data-right'>" + groupTaskTotal.MonthTotal.ToTimeFormat() + "</td>");

                yield return("            </tr>");
            }

            yield return("        </tbody>");

            yield return("    </table>");

            yield return("</div>");

            yield return("</div>");

            yield return("<div class='row'>");

            yield return("<div class='col-md-12'>");

            yield return("    <table class='table'>");

            yield return("        <tbody>");

            yield return("            <tr>");

            yield return("                <th class='table-head' colspan='" + (report.DaysInMonth + (showGroupColl ? 3 : 2)) + "'>" + translate.Get("REPORT.PERSON_TIME") + "</th>");

            yield return("            </tr>");

            foreach (var user in report.Users)
            {
                yield return("            <tr>");

                yield return("                <td class='table-data' colspan='" + (report.DaysInMonth + (showGroupColl ? 3 : 2)) + "'>" + user.FullName + (user.GroupTasks.Count() > 1 ? " <small class='small'>(" + user.MonthTotal.ToTimeFormat() + ")</small>" : "") + "</td>");

                yield return("            </tr>");

                yield return("            <tr class='sub-table'>");

                yield return("                <th class='sub-table-head-first' ></th>");

                if (showGroupColl)
                {
                    yield return("            <th class='sub-table-head-names1'>" + translate.Get("REPORT.GROUP") + "</th>");
                }
                yield return("                <th class='" + (showGroupColl ? "sub-table-head-names2" : "sub-table-head-names1") + "'>" + translate.Get("REPORT.TASK") + "</th>");

                for (int day = 1; day <= report.DaysInMonth; day++)
                {
                    yield return("            <th class='sub-table-head-numbers'>" + day + "</th>");
                }
                yield return("            </tr>");

                foreach (var groupTask in user.GroupTasks)
                {
                    yield return("            <tr class='sub-table'>");

                    yield return("                <td class='table-group-task-first'></td>");

                    if (showGroupColl)
                    {
                        yield return("            <td class='table-group-task-names1'>" + groupTask.Group + "</td>");
                    }
                    yield return("                <td class='" + (showGroupColl ? "table-group-task-names2" : "table-group-task-names1") + "'>" + groupTask.Task + " <small class='small'>(" + groupTask.MonthTotal.ToTimeFormat() + ")</small></td>");

                    for (int day = 1; day <= report.DaysInMonth; day++)
                    {
                        var currentWork = groupTask.Works.Where(w => w.Day == day).Select(w => w.Time).SingleOrDefault();
                        yield return("            <td class='table-group-task-time'>" + currentWork?.ToTimeFormat() + "</td>");
                    }
                    yield return("            </tr>");
                }
                yield return("            <tr>");

                yield return("                <td class='table-space-first'></td>");

                yield return("                <td class='table-space' colspan='" + (report.DaysInMonth + (showGroupColl ? 2 : 1)) + "'></td>");

                yield return("            </tr>");
            }

            yield return("        </tbody>");

            yield return("    </table>");

            yield return("</div>");

            yield return("</div>");

            yield return("</div>");

            yield return("</div>");

            yield return("</body></html>");
        }