invoices_paged = null;
+ if (proposal == true)
+ {
+ invoices = invoices.Where(i => i.InvoiceNumber == 0); //we can not use Where(i => i.IsProposal) from within the LINQ db context
+ }
+ else
+ {
+ invoices = invoices.Where(i => i.InvoiceNumber > 0); //we can not use Where(i => i.IsProposal) from within the LINQ db context
+ }
+
+ invoices_paged = invoices.OrderByDescending(i => i.TimeStamp).ToPagedList(currentPageIndex, (pagesize.HasValue) ? pagesize.Value : defaultPageSize);
+
+ FillIndexViewBags(invoices_paged);
+
+ return View(invoices_paged);
+ }
+
+ //
+ // GET: /Invoice/Print/5
+
+ public ViewResult Print(int id, bool? proposal = false, bool? reminder = false)
+ {
+ try
+ {
+ if (Request["lan"] != null)
+ {
+ //valid culture name?
+ CultureInfo[] cultures = System.Globalization.CultureInfo.GetCultures
+ (CultureTypes.SpecificCultures);
+
+ var selectCulture = from p in cultures
+ where p.Name == Request["lan"]
+ select p;
+
+ if (selectCulture.Count() == 1)
+ System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request["lan"]);
+ }
+ }
+ catch
+ {
+ }
+
+
+ ViewBag.Print = true;
+ ViewBag.MyCompany = System.Configuration.ConfigurationManager.AppSettings["MyCompanyName"];
+ ViewBag.MyCompanyID = System.Configuration.ConfigurationManager.AppSettings["MyCompanyID"];
+ ViewBag.MyVATID = System.Configuration.ConfigurationManager.AppSettings["MyVATID"];
+ ViewBag.MyCompanyAddress = System.Configuration.ConfigurationManager.AppSettings["MyCompanyAddress"];
+ ViewBag.MyCompanyPhone = System.Configuration.ConfigurationManager.AppSettings["MyCompanyPhone"];
+ ViewBag.MyEmail = System.Configuration.ConfigurationManager.AppSettings["MyEmail"];
+ ViewBag.MyBankAccount = System.Configuration.ConfigurationManager.AppSettings["MyBankAccount"];
+
+ Invoice invoice = db.Invoices.Find(id);
+ if (proposal == true)
+ return View("PrintProposal", invoice);
+ else if (reminder == true)
+ return View("PrintReminder", invoice);
+ else
+ return View(invoice);
+ }
+
+ //
+ // GET: /Invoice/Pdf/5
+
+ public ActionResult Pdf(int id, bool? proposal = false, bool? reminder = false)
+ {
+ return new ActionAsPdf(
+ "Print",
+ new { id = id, proposal = proposal, reminder = reminder }) { FileName = "Invoice.pdf" };
+ }
+
+ //
+ // GET: /Invoice/Create
+
+ public ActionResult Create(bool? proposal=false)
+ {
+ Invoice i = new Invoice();
+ i.TimeStamp = DateTime.Now;
+ //i.DueDate = DateTime.Now.AddDays(30); //30 days after today
+ i.DueDate = DateTime.Now.AddDays(14); //14 days after today
+ i.AdvancePaymentTax = Convert.ToDecimal(System.Configuration.ConfigurationManager.AppSettings["DefaultAdvancePaymentTax"]);
+
+ if (!proposal == true)
+ {
+ //generate next invoice number
+ var next_invoice = (from inv in db.Invoices
+ orderby inv.InvoiceNumber descending
+ select inv).FirstOrDefault();
+ if (next_invoice != null)
+ i.InvoiceNumber = next_invoice.InvoiceNumber + 1;
+ }
+ ViewBag.IsProposal = proposal;
+ ViewBag.CustomerID = new SelectList(db.Customers.OrderBy(c=>c.Name), "CustomerID", "Name");
+ return View(i);
+ }
+
+ //
+ // POST: /Invoice/Create
+
+ [HttpPost]
+ [ValidateInput(false)]
+ public ActionResult Create(Invoice invoice, bool? proposal = false, bool? reminder = false)
+ {
+ ViewBag.CustomerID = new SelectList(db.Customers.OrderBy(c => c.Name), "CustomerID", "Name", invoice.CustomerID);
+ ViewBag.IsProposal = proposal;
+ ViewBag.IsReminder = reminder;
+
+ if (ModelState.IsValid)
+ {
+ //make sure invoice number doesn't exist
+ if (proposal == false)
+ {
+ var invoice_exists = (from inv in db.Invoices where inv.InvoiceNumber == invoice.InvoiceNumber select inv).FirstOrDefault();
+ if (invoice_exists != null)
+ {
+ ModelState.AddModelError("InvoiceNumber", "Invoice with that number already exists");
+ return View(invoice);
+ }
+ }
+ db.Invoices.Add(invoice);
+ db.SaveChanges();
+ return RedirectToAction("Edit", "Invoice", new { id = invoice.InvoiceID, proposal = proposal });
+ }
+ return View(invoice);
+ }
+
+ //
+ // GET: /Invoice/Edit/5
+
+ public ActionResult Edit(int id, bool? proposal = false, bool? makeinvoice = false, bool? makeproposal = false, bool? reminder = false)
+ {
+ Invoice invoice = db.Invoices.Find(id);
+ ViewBag.CustomerID = new SelectList(db.Customers.OrderBy(c => c.Name), "CustomerID", "Name", invoice.CustomerID);
+
+ if (makeinvoice == true)
+ {
+ //we want to make invoice from this proposal
+ //generate next invoice number
+ var next_invoice = (from inv in db.Invoices
+ orderby inv.InvoiceNumber descending
+ select inv).FirstOrDefault();
+
+ if (next_invoice != null)
+ invoice.InvoiceNumber = next_invoice.InvoiceNumber + 1; //assign next available invoice number
+
+ invoice.TimeStamp = DateTime.Now;
+ invoice.DueDate = DateTime.Now.AddDays(30);
+
+ ViewBag.Warning = "The current item is going to be converted on Invoice. A new InvoiceNumber has been pre-assigned. The dates will be modified accordingly. Click on 'Save' to continue.";
+ ViewBag.ShowMakeInvoice = ViewBag.ShowMakeProposal = false;
+ }
+ else if (makeproposal == true)
+ {
+ invoice.InvoiceNumber = 0; //reset invoice number
+ ViewBag.Warning = "The current item is going to be converted on Proposal. You will lose InvoiceNumber. If that's what you want click on 'Save'";
+ ViewBag.ShowMakeInvoice = ViewBag.ShowMakeProposal = false;
+ }
+ else
+ {
+ if (!invoice.IsProposal && proposal == true)
+ {
+ //item is invoice, redirect to proper route (hack)
+ return RedirectToAction("Edit", new { id = id, proposal = false, makeinvoice = false });
+ }
+
+ ViewBag.ShowMakeInvoice = invoice.IsProposal;
+ ViewBag.ShowMakeProposal = !invoice.IsProposal;
+ }
+
+ ViewBag.IsProposal = invoice.IsProposal;
+
+ return View(invoice);
+ }
+
+ //
+ // POST: /Invoice/Edit/5
+
+ [HttpPost]
+ [ValidateInput(false)]
+ public ActionResult Edit(Invoice invoice, bool? proposal = false, bool? reminder = false)
+ {
+ ViewBag.CustomerID = new SelectList(db.Customers.OrderBy(c => c.Name), "CustomerID", "Name", invoice.CustomerID);
+ ViewBag.IsProposal = proposal;
+ ViewBag.IsPrReminder = reminder;
+ if (ModelState.IsValid)
+ {
+ if (proposal == false)
+ {
+ //make sure invoice number doesn't exist
+ var invoice_exists = (from inv in db.Invoices
+ where inv.InvoiceNumber == invoice.InvoiceNumber
+ && inv.InvoiceID != invoice.InvoiceID
+ select inv).Count();
+
+ if (invoice_exists > 0)
+ {
+ ModelState.AddModelError("InvoiceNumber", "Invoice with that number already exists");
+ return View(invoice);
+ }
+ }
+
+ db.Entry(invoice).State = EntityState.Modified;
+ db.SaveChanges();
+ return RedirectToAction("Index", new { proposal = proposal });
+ }
+ return View(invoice);
+ }
+
+ //
+ // GET: /Invoice/Delete/5
+
+ public ActionResult Delete(int id, bool? proposal = false, bool? reminder = false)
+ {
+ ViewBag.IsProposal = proposal;
+ ViewBag.IsReminder = reminder;
+ Invoice invoice = db.Invoices.Find(id);
+ return View(invoice);
+ }
+
+ //
+ // POST: /Invoice/Delete/5
+
+ [HttpPost, ActionName("Delete")]
+ public ActionResult DeleteConfirmed(int id, bool? proposal = false, bool? reminder = false)
+ {
+ ViewBag.IsProposal = proposal;
+ ViewBag.IsReminder = reminder;
+ Invoice invoice = db.Invoices.Find(id);
+ db.Invoices.Remove(invoice);
+ db.SaveChanges();
+ return RedirectToAction("Index", new { proposal = proposal });
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ db.Dispose();
+ base.Dispose(disposing);
+ }
+ }
}
\ No newline at end of file
diff --git a/iloire Facturacion/Global.asax.cs b/iloire Facturacion/Global.asax.cs
index ec11833..9900fd5 100644
--- a/iloire Facturacion/Global.asax.cs
+++ b/iloire Facturacion/Global.asax.cs
@@ -24,13 +24,19 @@ public static void RegisterRoutes(RouteCollection routes)
routes.MapRoute(
"Invoice", // Nombre de ruta
"Invoice/{action}/{id}", // URL con parámetros
- new { controller = "Invoice", action = "Index", id = UrlParameter.Optional, proposal = false } // Valores predeterminados de parámetro
+ new { controller = "Invoice", action = "Index", id = UrlParameter.Optional, proposal = false, reminder = false } // Valores predeterminados de parámetro
+ );
+
+ routes.MapRoute(
+ "Proposal", // Nombre de ruta
+ "Proposal/{action}/{id}", // URL con parámetros
+ new { controller = "Invoice", action = "Index", id = UrlParameter.Optional, proposal = true, reminder = false } // Valores predeterminados de parámetro
);
routes.MapRoute(
- "Proposal", // Nombre de ruta
- "Proposal/{action}/{id}", // URL con parámetros
- new { controller = "Invoice", action = "Index", id = UrlParameter.Optional, proposal=true } // Valores predeterminados de parámetro
+ "Reminder", // Nombre de ruta
+ "Reminder/{action}/{id}", // URL con parámetros
+ new { controller = "Invoice", action = "Index", id = UrlParameter.Optional, proposal=false, reminder = true } // Valores predeterminados de parámetro
);
diff --git a/iloire Facturacion/Rotativa/README.txt b/iloire Facturacion/Rotativa/README.txt
new file mode 100644
index 0000000..cecb844
--- /dev/null
+++ b/iloire Facturacion/Rotativa/README.txt
@@ -0,0 +1,11 @@
+This folder contains file necessary to Rotativa to generate Pdf files
+
+Please don't move or rename them or the folder itself
+
+If you need to you should add a key in web.config with the path to this files:
+
+
+
+
+
+
\ No newline at end of file
diff --git a/iloire Facturacion/Rotativa/libeay32.dll b/iloire Facturacion/Rotativa/libeay32.dll
new file mode 100644
index 0000000..8d31f86
Binary files /dev/null and b/iloire Facturacion/Rotativa/libeay32.dll differ
diff --git a/iloire Facturacion/Rotativa/libgcc_s_dw2-1.dll b/iloire Facturacion/Rotativa/libgcc_s_dw2-1.dll
new file mode 100644
index 0000000..9e32dc2
Binary files /dev/null and b/iloire Facturacion/Rotativa/libgcc_s_dw2-1.dll differ
diff --git a/iloire Facturacion/Rotativa/mingwm10.dll b/iloire Facturacion/Rotativa/mingwm10.dll
new file mode 100644
index 0000000..cf2113a
Binary files /dev/null and b/iloire Facturacion/Rotativa/mingwm10.dll differ
diff --git a/iloire Facturacion/Rotativa/ssleay32.dll b/iloire Facturacion/Rotativa/ssleay32.dll
new file mode 100644
index 0000000..a30ff0e
Binary files /dev/null and b/iloire Facturacion/Rotativa/ssleay32.dll differ
diff --git a/iloire Facturacion/Rotativa/wkhtmltopdf.exe b/iloire Facturacion/Rotativa/wkhtmltopdf.exe
new file mode 100644
index 0000000..1e6c742
Binary files /dev/null and b/iloire Facturacion/Rotativa/wkhtmltopdf.exe differ
diff --git a/iloire Facturacion/Views/Account/LogOn.cshtml b/iloire Facturacion/Views/Account/LogOn.cshtml
index fedb31e..975f515 100644
--- a/iloire Facturacion/Views/Account/LogOn.cshtml
+++ b/iloire Facturacion/Views/Account/LogOn.cshtml
@@ -6,7 +6,7 @@
-

+
Log in
@@ -52,21 +52,4 @@
}
-
-
-
Demo
-
- In order to try the application, use this credentials:
-
-
-
- - login: user
- - password: pass
-
-
-
Remember you can fork the project on github: Fork project on Github
-
-
-
-
\ No newline at end of file
diff --git a/iloire Facturacion/Views/Home/Index.cshtml b/iloire Facturacion/Views/Home/Index.cshtml
index 9e31bc6..9dd854b 100644
--- a/iloire Facturacion/Views/Home/Index.cshtml
+++ b/iloire Facturacion/Views/Home/Index.cshtml
@@ -1,5 +1,5 @@
-@{
- ViewBag.Title = "Página principal";
+@{
+ ViewBag.Title = "homepage";
}
diff --git a/iloire Facturacion/Views/Invoice/EditOrCreateInvoicePartial.cshtml b/iloire Facturacion/Views/Invoice/EditOrCreateInvoicePartial.cshtml
index 7775ed8..6129617 100644
--- a/iloire Facturacion/Views/Invoice/EditOrCreateInvoicePartial.cshtml
+++ b/iloire Facturacion/Views/Invoice/EditOrCreateInvoicePartial.cshtml
@@ -126,17 +126,36 @@
}
@Html.ActionLink("Print", "Print", "Invoice", new { id = Model.InvoiceID, proposal = ViewBag.IsProposal }, new { target = "_blank", @class = "btn" })
+
+ @Html.ActionLink("PDF", "Pdf", "Invoice", new { id = Model.InvoiceID, proposal = ViewBag.IsProposal }, new { target = "_blank", @class = "btn" })
@if (!Model.IsProposal)
{ //even if this is an invoice, we let be printed with proposal format
- @Html.ActionLink("Print as proposal", "Print", "Invoice", new { id = Model.InvoiceID, proposal = true }, new { target = "_blank", @class = "btn" })
+ @Html.ActionLink("Print as proposal", "Print", "Invoice", new { id = Model.InvoiceID, proposal = true }, new { target = "_blank", @class = "btn" })
+ }
+
+ @if (!Model.IsProposal)
+ { //even if this is an invoice, we let be printed with proposal format
+ @Html.ActionLink("PDF proposal", "Pdf", "Invoice", new { id = Model.InvoiceID, proposal = true }, new { target = "_blank", @class = "btn" })
+ }
+
+ @if (!Model.IsProposal)
+ { //even if this is an invoice, we let be printed with proposal format
+ @Html.ActionLink("Print as reminder", "Print", "Invoice", new { id = Model.InvoiceID, reminder = true }, new { target = "_blank", @class = "btn" })
+ }
+
+ @if (!Model.IsProposal)
+ { //even if this is an invoice, we let be printed with proposal format
+ @Html.ActionLink("PDF reminder", "Pdf", "Invoice", new { id = Model.InvoiceID, reminder = true }, new { target = "_blank", @class = "btn" })
}
- @if (ViewBag.ShowMakeInvoice == true) {
- @Html.ActionLink("Make invoice", "Edit", "Invoice", new { id = Model.InvoiceID, makeinvoice = true }, new { @class = "btn" })
+ @if (ViewBag.ShowMakeInvoice == true)
+ {
+ @Html.ActionLink("Make invoice", "Edit", "Invoice", new { id = Model.InvoiceID, makeinvoice = true }, new { @class = "btn" })
}
- @if (ViewBag.ShowMakeProposal == true) {
+ @if (ViewBag.ShowMakeProposal == true)
+ {
@Html.ActionLink("Make proposal", "Edit", "Invoice", new { id = Model.InvoiceID, makeproposal = true }, new { @class = "btn" })
}
diff --git a/iloire Facturacion/Views/Invoice/Index.cshtml b/iloire Facturacion/Views/Invoice/Index.cshtml
index 8a199b4..da9582b 100644
--- a/iloire Facturacion/Views/Invoice/Index.cshtml
+++ b/iloire Facturacion/Views/Invoice/Index.cshtml
@@ -119,6 +119,7 @@
@Html.ActionLink("Edit", "Edit", new { id = item.InvoiceID, proposal = ViewBag.IsProposal }, new { @class = "btn primary" })
@Html.ActionLink("Print", "Print", new { id = item.InvoiceID, proposal = ViewBag.IsProposal }, new { target = "_blank", @class = "btn" })
+ @Html.ActionLink("PDF", "Pdf", new { id = item.InvoiceID, proposal = ViewBag.IsProposal }, new { target = "_blank", @class = "btn" })
@Html.ActionLink("Delete", "Delete", new { id = item.InvoiceID, proposal = ViewBag.IsProposal }, new { @class = "btn" })
@if (ViewBag.IsProposal) {
diff --git a/iloire Facturacion/Views/Invoice/Print.cshtml b/iloire Facturacion/Views/Invoice/Print.cshtml
index 1b57752..2a5d1fc 100644
--- a/iloire Facturacion/Views/Invoice/Print.cshtml
+++ b/iloire Facturacion/Views/Invoice/Print.cshtml
@@ -7,18 +7,20 @@
@model Invoice
-@{
- ViewBag.Title = DateTime.Now.Year + "#" + Model.InvoiceNumber + " " + Model.Name + " " + Model.Customer.Name;
+@{
+ ViewBag.Title = "FAC" + Model.TimeStamp.ToString("yyyy") + "-" + Model.InvoiceNumber + " " + Model.Name + " " + Model.Customer.Name;
+ ViewBag.Invoicename = "FAC" + Model.TimeStamp.ToString("yyyy") + "-" + Model.InvoiceNumber;
Layout = "~/Views/Shared/_LayoutPrint.cshtml";
+
}
|