PageRenderTime 43ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/crm/symfony/src/MDR/CobranzaBundle/Resources/public/js/PedidosList.js

https://gitlab.com/Alberto.SS/crm_verquet
JavaScript | 93 lines | 79 code | 13 blank | 1 comment | 0 complexity | ba66ce8f8b401919753df4180af3bc36 MD5 | raw file
  1. var PedidoTarjeta = Backbone.Model.extend({
  2. initialize: function(){
  3. },
  4. defaults: {
  5. posFechar: 0,
  6. fechaCobro: ''
  7. }
  8. });
  9. var Productos = Backbone.Model.extend({
  10. initialize: function(){
  11. },
  12. defaults: {
  13. Descripcion: 0
  14. }
  15. });
  16. var ProductoPedido = Backbone.Model.extend({
  17. initialize: function(){
  18. },
  19. defaults: {
  20. cantidad: 0,
  21. precio: 0,
  22. item: new Productos
  23. }
  24. });
  25. var ProductoPedidoCollection = Backbone.Collection.extend({
  26. model: ProductoPedido,
  27. });
  28. var PedidoCobro = Backbone.Model.extend({
  29. initialize: function(){
  30. },
  31. defaults: {
  32. idPedido: 0,
  33. fechaPedido: '',
  34. gastosEnvio:0,
  35. subTotal:0,
  36. totalPago: 0,
  37. item: new PedidoTarjeta,
  38. productos: new ProductoPedidoCollection
  39. }
  40. });
  41. var PedidosCobroCollection = Backbone.Collection.extend({
  42. model: PedidoCobro,
  43. });
  44. var PedidoView = Backbone.View.extend({
  45. tagName: "tr",
  46. template: _.template($('#pedidoTemplate').html()),
  47. initialize: function(){
  48. this.render();
  49. },
  50. render: function(){
  51. this.$el.html(this.template(this.model.toJSON()));
  52. return this;
  53. },
  54. events: {
  55. }
  56. })
  57. var pedidos = new PedidosCobroCollection(pedidosJSON);
  58. var PedidosView = Backbone.View.extend({
  59. el: $("#pedidos_cobro"),
  60. events: {
  61. },
  62. initialize: function() {
  63. this.render();
  64. //this.listenTo(pedidosCobro, 'change', this.totalCompra);
  65. },
  66. render: function() {
  67. this.addAllPedidos(pedidos);
  68. },
  69. addPedidos: function(item)
  70. {
  71. var view = new PedidoView({model: item});
  72. this.$el.append(view.render().$el);
  73. },
  74. addAllPedidos: function(items)
  75. {
  76. this.$el.html(" ");
  77. items.each(this.addPedidos, this);
  78. }
  79. });
  80. var pedidosView = new PedidosView;