Advertisement
Guest User

PreviewExportPDF

a guest
Sep 30th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.45 KB | None | 0 0
  1. @model WebApplication1.Models.Cotizacion
  2.  
  3. @{
  4. ViewBag.Title = "PreviewExportPDF";
  5. }
  6.  
  7. @{
  8. Layout = "~/Views/Shared/_Layout3.cshtml";
  9.  
  10.  
  11. string tipomoneda = (string)ViewBag.TipoMoneda;
  12.  
  13. System.Globalization.CultureInfo cultura = new System.Globalization.CultureInfo("is-IS");
  14. if (tipomoneda == "US" || tipomoneda == "€")
  15. {
  16. cultura = new System.Globalization.CultureInfo("en-US");
  17. }
  18. int numDecimales = 0;
  19. if (tipomoneda == "US" || tipomoneda == "€" || tipomoneda == "UF")
  20. {
  21. numDecimales = 2;
  22. }
  23.  
  24. bool rubroVehicular = false;
  25.  
  26. if (Model.EmpresaId != null)
  27. {
  28. rubroVehicular = Model.Empresa.RubroVehículos;
  29. }
  30.  
  31. string codigostring = Model.ClienteId + "|" + Model.Id + "|" + Model.Codigo;
  32.  
  33.  
  34. List<string> titulos = new List<string>();
  35. foreach (WebApplication1.Clases.CondicionCotizacion cond in ViewBag.CondicionesCotizacion)
  36. {
  37. if (titulos.Contains(cond.NombreItem.ToUpper()) == false)
  38. {
  39. titulos.Add(cond.NombreItem.ToUpper());
  40. }
  41. }
  42. }
  43.  
  44. <div class="container-fluid">
  45. <div class="row-fluid">
  46. <div class="span20">
  47. <div class="widget-box">
  48. <div class="widget-content">
  49. <div class="divTable">
  50. <div class="divTableBody">
  51. <div class="divTableRow">
  52.  
  53. @*<div class="divTableCell" style="text-align:center"><img src="~/img/LogosEmpresas/avangrasustentable.png" /></div>
  54. <div class="divTableCell" style="text-align:right"><img src="~/img/LogosEmpresas/aynsust.png" /></div>
  55. <div class="divTableCell" style="text-align:right"><img height="200" width="300" src="~/img/pauchard_logo_large.jpg" /></div>*@
  56. @{
  57. if (Model.LogoId != null)
  58. {
  59. <div class="divTableCell" style="text-align:right"><img src="@Url.Content("~/img/LogosEmpresas/" + Model.Empresa.Id + "/" + System.IO.Path.GetFileName(Model.LogoRemitente.DireccionLogo))" /></div>
  60. }
  61. }
  62. </div>
  63. </div>
  64. </div>
  65. <div class="divTable">
  66. <div class="divTableBody">
  67. <div class="divTableRow">
  68. <div class="divTableCell taskOptions"></div>
  69. <div class="divTableCell" style="text-align:center; width:100%"><h4><strong>COTIZACIÓN</strong></h4></div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="divTable">
  74.  
  75. <div class="divTableBody">
  76. <div class="divTableRow">
  77. <div class="divTableCell" style="width:12%"><strong>Referencia:</strong></div>
  78. <div class="divTableCell" style="width:49%">@Html.DisplayFor(model => model.Emision)</div>
  79. <div class="divTableCell" style="text-align:right"><h5>Código: @Html.DisplayFor(model => model.Codigo)</h5></div>
  80. </div>
  81. </div>
  82.  
  83. </div>
  84. <div class="divTable">
  85.  
  86. <div class="divTableBody">
  87. <div class="divTableRow" style="background-color:#808080; color:#ffffff">
  88. <div class="divTableCell"><strong>DATOS DEL CLIENTE</strong></div>
  89. </div>
  90. </div>
  91.  
  92. </div>
  93. <div class="divTable">
  94. <div class="divTableBody">
  95. @if (Model.Cliente.TipoDeCliente == WebApplication1.Models.Cliente.TipoCliente.Empresa)
  96. {
  97. <div class="divTableRow">
  98. <div class="divTableCell" style="width:12%">Nombre Fantasía:</div>
  99. <div class="divTableCell" style="width:17%">@Html.DisplayFor(model => model.Cliente.NombreFantasia)</div>
  100. <div class="divTableCell" style="width:12%">Giro:</div>
  101. <div class="divTableCell" style="width:17%">@Html.DisplayFor(model => model.Cliente.Giro)</div>
  102. </div>
  103. }
  104. else if (Model.Cliente.TipoDeCliente == WebApplication1.Models.Cliente.TipoCliente.Particular)
  105. {
  106. <div class="divTableRow">
  107. <div class="divTableCell" style="width:12%">Nombre:</div>
  108. <div class="divTableCell" style="width:17%">@Html.DisplayFor(model => model.Cliente.Nombre)</div>
  109. <div class="divTableCell" style="width:12%">Apellido:</div>
  110. <div class="divTableCell" style="width:20%">@Html.DisplayFor(model => model.Cliente.ApellidoPaterno)</div>
  111. </div>
  112. }
  113.  
  114. <div class="divTableRow">
  115. <div class="divTableCell">Email:</div>
  116. <div class="divTableCell">@Html.DisplayFor(model => model.Cliente.Email)</div>
  117. <div class="divTableCell">Razón Social:</div>
  118. <div class="divTableCell">@Html.DisplayFor(model => model.Cliente.RazonSocial)</div>
  119. </div>
  120. <div class="divTableRow">
  121. <div class="divTableCell">Rut:</div>
  122. <div class="divTableCell">@Html.DisplayFor(model => model.Cliente.Rut)</div>
  123.  
  124. @if (Model.Cliente.TipoDeCliente == WebApplication1.Models.Cliente.TipoCliente.Particular)
  125. {
  126. <div class="divTableCell">Giro:</div>
  127. <div class="divTableCell">@Html.DisplayFor(model => model.Cliente.Giro)</div>
  128. }
  129. else if (Model.Cliente.TipoDeCliente == WebApplication1.Models.Cliente.TipoCliente.Empresa)
  130. {
  131. <div class="divTableCell">Atención:</div>
  132. string nombreAtendio = "";
  133. if (Model.UsuarioId != null)
  134. {
  135. nombreAtendio = Model.UsuarioQueAtendio.Nombre + " " + Model.UsuarioQueAtendio.Apellido;
  136. }
  137. <div class="divTableCell">
  138. @nombreAtendio
  139. </div>
  140. }
  141.  
  142. </div>
  143. <div class="divTableRow">
  144. <div class="divTableCell">Dirección:</div>
  145. <div class="divTableCell">@Html.DisplayFor(model => model.Cliente.Domicilio)</div>
  146. <div class="divTableCell">Fecha Emisión:</div>
  147. <div class="divTableCell">@Model.Fecha.ToString("dd/MM/yyyy")</div>
  148.  
  149. </div>
  150. <div class="divTableRow">
  151. <div class="divTableCell">Teléfono:</div>
  152. <div class="divTableCell">@Html.DisplayFor(model => model.Cliente.Telefono)</div>
  153. @if (Model.Cliente.TipoDeCliente == WebApplication1.Models.Cliente.TipoCliente.Particular)
  154. {
  155. string nombre = "";
  156. <div class="divTableCell">Atención:</div>
  157. {
  158.  
  159. if (Model.UsuarioId != null)
  160. {
  161. nombre = Model.UsuarioQueAtendio.Nombre + " " + Model.UsuarioQueAtendio.Apellido;
  162. }
  163. }
  164. <div class="divTableCell">
  165. @nombre
  166. </div>
  167. }
  168. </div>
  169. </div>
  170. </div>
  171.  
  172. @{if (rubroVehicular == true && Model.VehiculoId != null)
  173. {
  174. <div class="divTable">
  175.  
  176. <div class="divTableBody">
  177. <div class="divTableRow" style="background-color:#808080; color:#ffffff">
  178. <div class="divTableCell"><strong>DATOS DEL VEHÍCULO</strong></div>
  179. </div>
  180. </div>
  181.  
  182. </div>
  183. <div class="divTable">
  184. <div class="divTableBody">
  185. <div class="divTableRow">
  186. <div class="divTableCell" style="width:12%">Patente:</div>
  187. <div class="divTableCell" style="width:17%">@Model.Vehiculo.Patente</div>
  188. <div class="divTableCell" style="width:12%">Modelo:</div>
  189. <div class="divTableCell" style="width:17%">@Model.Vehiculo.Modelo</div>
  190. </div>
  191. <div class="divTableRow">
  192. <div class="divTableCell" style="width:12%">Marca:</div>
  193. <div class="divTableCell" style="width:17%">@Model.Vehiculo.Marca</div>
  194. <div class="divTableCell" style="width:12%">Año:</div>
  195. <div class="divTableCell" style="width:20%">@Model.Vehiculo.Year</div>
  196. </div>
  197. <div class="divTableRow">
  198. <div class="divTableCell" style="width:12%">Color:</div>
  199. <div class="divTableCell" style="width:17%">@Model.Vehiculo.Color</div>
  200. <div class="divTableCell" style="width:12%">Kilometraje:</div>
  201. <div class="divTableCell" style="width:20%">@Model.Vehiculo.Kilometraje</div>
  202. </div>
  203. </div>
  204.  
  205. </div>
  206.  
  207. }
  208. }
  209. </div>
  210. <div class="widget-content">
  211. @{
  212. bool dividirPorCategoria = Model.DividirPorCategoria;
  213.  
  214. //puedes fijarte en el email de don felipe con los excel para ver
  215. //si ese bool es false, todo aparece como hasta ahora
  216. //si es true la categoría aparece de título
  217. //y se van acomodando cada producto de esa categoria
  218. //imagino que el campo "Categoria" no exisitira en la tabla aqui, porque ya estaria en el titulo
  219. //al final de cada grupo se pone un Total con la suma de los valores
  220.  
  221. //el resto de resultados (subtotal, total neto, etc) quedan tal como estan
  222. List<WebApplication1.Models.ProductoCotizado> productosOrdenadosPorCategoria = new List<WebApplication1.Models.ProductoCotizado>();
  223. productosOrdenadosPorCategoria = Model.ProductosCotizados;
  224. if (dividirPorCategoria == true)
  225. {
  226. productosOrdenadosPorCategoria = Model.ProductosCotizados.OrderBy(x => x.Producto.Categoria.Categoria).ToList();
  227. }
  228.  
  229. }
  230.  
  231. <table class="table table-bordered table-striped" style="width:100%; font-size:11px" id="TablaProductos">
  232. <thead>
  233. <tr>
  234. <th>N°</th>
  235. <th>Código</th>
  236. <th>Nombre Producto</th>
  237. @{ if (dividirPorCategoria == false)
  238. {
  239. <th>Categoria</th>}}
  240. <th>Valor</th>
  241. <th>Cantidad</th>
  242. <th>Valor Total</th>
  243. </tr>
  244. </thead>
  245. @{
  246. float subValorTotal = 0;
  247. int cont = 0;
  248. int contCatIn = 1;
  249. int conCat = 0;
  250. String categoria = "";}
  251. @foreach (var item in productosOrdenadosPorCategoria)
  252. {
  253. cont++;
  254. string valorString = (item.Valor).ToString("N" + numDecimales, cultura);
  255. string totalString = (item.ValorTotal).ToString("N" + numDecimales, cultura);
  256.  
  257. if (dividirPorCategoria == true)
  258. {
  259.  
  260. if (categoria != item.Producto.Categoria.Categoria)
  261. {
  262. categoria = item.Producto.Categoria.Categoria;
  263. <tr><td colspan="6" style="background-color:#808080; color:#fff">@categoria</td></tr>
  264. contCatIn = 1;
  265. subValorTotal = 0;
  266. }
  267. else
  268. {
  269. contCatIn++;
  270. }
  271.  
  272. }
  273. <tr class="odd gradeX">
  274. <td style="text-align:center; font-weight:bold">@cont</td>
  275. <td style="text-align:center;">@item.Producto.Codigo</td>
  276. <td>
  277. @Html.DisplayFor(modelItem => item.Producto.NombreProducto)
  278. @if (item.Comentario != null && item.Comentario != "")
  279. {
  280. <br />
  281. @item.Comentario
  282. }
  283. </td>
  284. @{ if (dividirPorCategoria == false)
  285. {
  286. <td>@Html.DisplayFor(modelItem => item.Producto.Categoria.Categoria)</td>}}
  287. <td style="text-align:right">@tipomoneda @valorString</td>
  288. <td style="text-align:center">@Html.DisplayFor(modelItem => item.Cantidad)</td>
  289. <td style="text-align:right">@tipomoneda @totalString</td>
  290. </tr>
  291. if (dividirPorCategoria == true)
  292. {
  293. subValorTotal += item.ValorTotal;
  294. foreach (var p in productosOrdenadosPorCategoria)
  295. {
  296. if (categoria == p.Producto.Categoria.Categoria)
  297. {
  298. conCat++;
  299. }
  300. }
  301.  
  302. if (conCat == contCatIn)
  303. {
  304. string vString = (subValorTotal).ToString("N" + numDecimales, cultura);
  305. <tr class="trClass"><td colspan="7" style="text-align:right"><strong>@tipomoneda @vString</strong></td></tr>
  306. }
  307. conCat = 0;
  308. }
  309. }
  310. </table>
  311. <div class="divTable">
  312. <div class="divTableBody">
  313. <div class="divTableRow">
  314. <div class="divTableCell" style="width:60%; min-width:120px">
  315. @{
  316. Boolean FormaPago = false;
  317. int contItems = 0;
  318. foreach (WebApplication1.Clases.CondicionCotizacion item in ViewBag.CondicionesCotizacion)
  319. {
  320. if (item.NombreItem.ToUpper() == "FORMA DE PAGO")
  321. {
  322. contItems++;
  323. FormaPago = true;
  324. }
  325. }
  326. if (FormaPago == true && contItems <= 4)
  327. {
  328. titulos.Remove("FORMA DE PAGO");
  329. contItems = 0;
  330. <div class="divTable">
  331. <div class="divTableBody">
  332. <div class="divTableRow" style="background-color:#808080; color:#ffffff">
  333. <div class="divTableCell"><strong>FORMA DE PAGO</strong></div>
  334. </div>
  335. </div>
  336. </div>
  337. <div class="divTable">
  338. <div class="divTableBody">
  339. @foreach (WebApplication1.Clases.CondicionCotizacion item in ViewBag.CondicionesCotizacion)
  340. {
  341. if (item.NombreItem.ToUpper() == "FORMA DE PAGO")
  342. {
  343. contItems++;
  344. <div class="divTableRow">
  345. <div class="divTableCell taskOptions" style="width:15px"><strong>@contItems:</strong></div>
  346. <div class="divTableCell">@item.Descripcion</div>
  347. </div>
  348. }
  349. }
  350. </div>
  351. </div>
  352. contItems = 0;
  353. }
  354.  
  355. }
  356. <div class="divTable">
  357. <div class="divTableBody">
  358. <div class="divTableRow" style="background-color:#808080; color:#ffffff">
  359. <div class="divTableCell"><strong>OBSERVACIONES</strong></div>
  360. </div>
  361. </div>
  362. </div>
  363. @Html.DisplayFor(model => model.NotasVendedor)
  364. </div>
  365. <div class="divTableCell" style="width:40%; min-width:170px">
  366. <table class="table table-bordered table-striped" style="width:100%; line-height: 3px; font-size:11px; margin: 0">
  367. @{
  368.  
  369. string subTotalNeto = (Model.SubTotalNeto).ToString("N" + numDecimales, cultura);
  370. string descuento = (Model.Descuento).ToString("N" + numDecimales, cultura);
  371. string recargo = (Model.Recargo).ToString("N" + numDecimales, cultura);
  372. string totalNeto = (Model.TotalNeto).ToString("N" + numDecimales, cultura);
  373. string iva = (Model.IVA).ToString("N" + numDecimales, cultura);
  374. string totalPagar = (Model.TotalAPagar).ToString("N" + numDecimales, cultura);
  375. }
  376. <tr>
  377. <td>Sub Total Neto:</td>
  378. <td style="text-align:right; height:10px;">@tipomoneda @subTotalNeto </td>
  379. </tr>
  380. <tr>
  381. <td>Descuento:</td>
  382. <td style="text-align:right">@tipomoneda @descuento </td>
  383. </tr>
  384. <tr>
  385. <td>Recargo:</td>
  386. <td style="text-align:right">@tipomoneda @recargo </td>
  387. </tr>
  388. <tr>
  389. <td>Total Neto:</td>
  390. <td style="text-align:right">@tipomoneda @totalNeto </td>
  391. </tr>
  392. <tr>
  393. <td>IVA (19%):</td>
  394. <td style="text-align:right">@tipomoneda @iva </td>
  395. </tr>
  396. <tr>
  397. <td>Total a pagar (iva incl.):</td>
  398. <td style="text-align:right">@tipomoneda @totalPagar </td>
  399. </tr>
  400. </table>
  401. </div>
  402. </div>
  403. </div>
  404. </div>
  405. </div>
  406.  
  407. <div class="widget-content">
  408.  
  409. @{
  410.  
  411.  
  412. foreach (string titulo in titulos)
  413. {
  414. <div class="divTable">
  415. <div class="divTableBody">
  416. <div class="divTableRow" style="background-color:#808080; color:#ffffff">
  417. <div class="divTableCell"><strong>@titulo</strong></div>
  418. </div>
  419. </div>
  420. </div>
  421. contItems = 0;
  422. <div class="divTable">
  423. <div class="divTableBody">
  424. @foreach (WebApplication1.Clases.CondicionCotizacion item in ViewBag.CondicionesCotizacion)
  425. {
  426. if (item.NombreItem.ToUpper() == titulo)
  427. {
  428. contItems++;
  429. <div class="divTableRow">
  430. <div class="divTableCell taskOptions" style="width:15px"><strong>@contItems:</strong></div>
  431. <div class="divTableCell">@item.Descripcion</div>
  432. </div>
  433. }
  434. }
  435. </div>
  436. </div>
  437.  
  438. }
  439. }
  440.  
  441. </div>
  442.  
  443. </div>
  444. </div>
  445. </div>
  446. </div>
  447.  
  448. <div style="width:100%; text-align:center; font-size:18px; color:black">
  449. Si quiere confirmar esta cotización, puede hacer uso del siguiente link para informar a la empresa.<br />
  450. <a style="color:#174ccb" target="_blank" href="@Url.Action("ConfirmarCotizacionDX", "Cotizacion", new { id = Model.Id, codigo = Model.codigoEncriptado })">Confirmar aquí</a>
  451. </div>
  452.  
  453. <br />
  454.  
  455. <style>
  456. .tabC {
  457. table-layout: fixed;
  458. }
  459.  
  460. .tabD {
  461. word-wrap: break-word;
  462. }
  463.  
  464.  
  465. .divTable {
  466. display: table;
  467. width: 100%;
  468. }
  469.  
  470. .divTableRow {
  471. display: table-row;
  472. }
  473.  
  474. .divTableHeading {
  475. background-color: #EEE;
  476. display: table-header-group;
  477. }
  478.  
  479. .divTableCell, .divTableHead {
  480. border: 0em solid #d8d8d8;
  481. display: table-cell;
  482. padding: 1px 4px;
  483. }
  484.  
  485. .divTableHeading {
  486. background-color: #EEE;
  487. display: table-header-group;
  488. font-weight: bold;
  489. }
  490.  
  491. .divTableFoot {
  492. background-color: #EEE;
  493. display: table-footer-group;
  494. font-weight: bold;
  495. }
  496.  
  497. .divTableBody {
  498. display: table-row-group;
  499. }
  500. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement