Advertisement
ganryu

realizar_pedido

Nov 5th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.79 KB | None | 0 0
  1. <div class="container-fluid">
  2.     <div class="row">
  3.         <div class="col-md-8">
  4.             <div class="panel panel-default">
  5.                 <div class="panel-heading">
  6.                     <h3 class="panel-title">Catálogo</h3>
  7.                 </div>
  8.                 <div class="panel-body">
  9.                     <div class="row">
  10.                         <?php
  11.                         $productos = new Producto();
  12.                         $inventario = new Inventario();
  13.                         $sucursal = new Sucursal();
  14.                        
  15.                         $productos->get();
  16.                         $i = 0;
  17.                         foreach ( $productos as $row ) {
  18.                             $i++;
  19.                             echo form_open("index.php/Fachada_pedido/hacer_pedido", array (
  20.                                     'id' => 'formAgregarProducto',
  21.                                     'enctype' => 'multipart/form-data'
  22.                             ));
  23.                             echo '
  24.                             <div class="col-md-4">
  25.                                 <div class="thumbnail">
  26.                                     <img src="' . base_url() . 'assets/imagenes/' . $row->path_img . '" style="width:300px; height:300px" />
  27.                                     <h3>' . $row->nombre_producto . '</h3>
  28.                                     <p>
  29.                                     <label for="cant1">Cantidad:</label>
  30.                                     <input class="form-control" type="number" name="cantidad" min="1" value="1">
  31.                                     </p>
  32.                                     <button class="btn btn-primary" id="agregar">
  33.                                         <span class="glyphicon glyphicon-plus-sign"></span>
  34.                                         Agregar
  35.                                     </button>
  36.                                 </div>
  37.                             </div>';
  38.                             echo form_close();
  39.                         }
  40.                         ?>
  41.                     </div>
  42.                     <div class="row">
  43.                         <div class="text-center">
  44.                             <ul class="pagination">
  45.                                 <li><a href="#">&laquo;</a></li>
  46.                                 <li><a href="#">1</a></li>
  47.                                 <li><a href="#">2</a></li>
  48.                                 <li><a href="#">3</a></li>
  49.                                 <li><a href="#">4</a></li>
  50.                                 <li><a href="#">5</a></li>
  51.                                 <li><a href="#">&raquo;</a></li>
  52.                             </ul>
  53.                         </div>
  54.                     </div>
  55.                 </div>
  56.                 <!-- Panel Body -->
  57.             </div>
  58.             <!-- panel panel-default -->
  59.         </div>
  60.         <!-- col-md-8 -->
  61.         <div class="col-md-4">
  62.             <div class="panel panel-default">
  63.                 <div class="panel-heading">
  64.                     <h3 class="panel-title-center text-center ">Carrito de Compra</h3>
  65.                 </div>
  66.                 <div class="panel-body">
  67.                     <div class="table-responsive">
  68.                         <table
  69.                             class="table
  70.                                               table-striped table-hover table-condensed">
  71.                             <thead>
  72.                                 <tr>
  73.                                     <th width="25%" class="text-center"><strong>Producto</strong></th>
  74.                                     <th width="25%" class="text-center"><strong>Cantidad</strong></th>
  75.                                     <th width="25%" class="text-center"><strong>Importe</strong></th>
  76.                                     <th width="25%" class="text-right"><strong></strong></th>
  77.                                 </tr>
  78.                             </thead>
  79.                             <tbody id="myID">
  80.                             </tbody>
  81.                         </table>
  82.                     </div>
  83.                     <div class="panel panel-default">
  84.                         <div class="panel-body">
  85.                             <button type="button" class="btn btn-default">Comprar</button>
  86.                         </div>
  87.                     </div>
  88.                     <div class="panel panel-default">
  89.                         <div class="panel-body">
  90.                             <button type="button" class="btn btn-success btn-block">¡Crea tu
  91.                                 propio Arreglo!</button>
  92.                         </div>
  93.                     </div>
  94.                 </div>
  95.             </div>
  96.         </div>
  97.     </div>
  98. </div>
  99. <script type="text/javascript">
  100.     $(document).ready(function() {
  101.         $(".thumbnail > .btn").click(function(event) {
  102.             event.preventDefault();
  103.             var padre = $(this).parent();
  104.             var input_cantidad = padre.children().children('input[name=cantidad]');
  105.             var cantidad = input_cantidad.val();
  106.             var producto = padre.children("h3").text();
  107.             if (cantidad) {
  108.                 $.post("<?php echo base_url() ?>Fachada_pedido/agregar_producto_carrito/",
  109.                         {producto: producto, cantidad: cantidad},
  110.                         function(result) {
  111.                             var result = $("#myID").html() + result;
  112.                             $("#myID").html(result);
  113.                         });
  114.             }
  115.         });
  116.     });
  117.    
  118.     function eliminar_producto(){
  119.         $('#myID').on('click', '.btn-danger', function(event) {
  120.             event.preventDefault();
  121.             var linea = $(this).parent().parent();
  122.             linea.remove();
  123.         });
  124.     };
  125. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement