Advertisement
RcPel

checkout.php

Oct 29th, 2016
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 9.00 KB | None | 0 0
  1.  <header>
  2.    
  3.         <nav class="navbar navbar-inverse navbar-fixed-top">
  4.             <div class="container">
  5.             <!-- Brand and toggle get grouped for better mobile display -->
  6.                     <div class="navbar-header">
  7.                       <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  8.                         <span class="sr-only">Toggle navigation</span>
  9.                         <span class="icon-bar"></span>
  10.                         <span class="icon-bar"></span>
  11.                         <span class="icon-bar"></span>
  12.                       </button>
  13.                       <a class="navbar-brand" href="#">Lista</a>
  14.                     </div>
  15.            
  16.             <!-- Collect the nav links, forms, and other content for toggling -->
  17.         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  18.             <ul class="nav navbar-nav">
  19.                <li class=""><a href="index.php" onClick="history.go(0)" VALUE="Refresh">Início <span class="sr-only"></span></a></li>
  20.                 <!--<li><a href="#">Nao definido</a></li>-->
  21.                
  22.                   </ul>
  23.                 </li>
  24.               </ul>
  25.               <!--<form class="navbar-form navbar-left"  action="search.php" role="form">
  26.                <div class="form-group">
  27.                   <input type="search" name="search" class="form-control" placeholder="Procurar">
  28.                   <button name="search_submit" class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i> Pesquisar</button>
  29.                </div>
  30.                
  31.              </form>-->
  32.               <ul class="nav navbar-nav navbar-right">
  33.              
  34.               <li><a href="../painel.php"><span class="glyphicon glyphicon-briefcase"></span> Painel</a></li>
  35.                 <li><a href="../../logout.php"><span class="glyphicon glyphicon-share-alt"></span> Logout</a></li>
  36.                
  37.                
  38.                 </li>
  39.               </ul>
  40.             </div><!-- /.navbar-collapse -->
  41.             </div><!-- /.container-fluid -->
  42. </nav>
  43.    
  44.     </header>
  45. <body style="padding-top:60px;">
  46.       <form action="postOrder.php" method="POST" enctype="multipart/form-data" class="form-horizontal">
  47.  
  48.       <div class="container">
  49.         <div class="row">
  50.          
  51.           <table class="table table-striped table-hover" id="myTable">
  52.             <thead>
  53.             <h4></h4>
  54.               <tr>
  55.               <th>Image</th>
  56.               <th>Produto</th>
  57.               <th>Fabric</th>
  58.               <th>Size</th>
  59.               <th>Qntd</th>
  60.               <th>Cost</th>
  61.               <th>sub.total</th>
  62.               </tr>
  63.             </thead>
  64.             <tbody >
  65.              
  66.              
  67.           <?php cart(); ?>
  68.            
  69.          
  70.             </tbody>
  71.           </table>
  72.           <div class="form-group">
  73.                 <input name="submit_post" class="first" type="submit" >
  74.              </div>
  75.           </form>
  76.               <div class="col-sm-4 pull-right">
  77.               <h2>Total do pedido</h2>
  78.               <table class="table table-bordered">
  79.                 <tr class="">
  80.                   <th>Itens:</th>
  81.                    <th class="text-center all_p" data-id="<?php $id ?>"><span><?php echo $_SESSION['total_products'] ?></span></th>
  82.                 </tr>
  83.                 <tr >
  84.                   <th>Valor total:</th>
  85.                    <th class="text-center valor_total"><span>R$: <?php echo $_SESSION['total'] ; ?></span></th>
  86.                 </tr>
  87.                
  88.                  
  89.  
  90.               </table>
  91.                
  92.               </div>
  93.         </div>
  94.        
  95.       </div>
  96.        
  97.      
  98.  
  99.  
  100.  
  101. </body><div class="clear"></div>
  102.       <footer class="navbar navbar-default navbar-fixed-bottom" style="background-color:#2C3E50; color:white;">
  103.       <div class="container"><p class="navbar-text pull-left" style="color: white;">
  104.       <?php echo $_SESSION['userName'] ." ".$_SESSION['userLName'];?>
  105.       </p>
  106.           <input  type="hidden" href="#myModal" role="button" data-toggle="modal" name="submit_post" type="submit" class="modal_pop btn btn-success  pull-right navbar-text " style="color: white;" >
  107.           <input value="Confirmar pedido" class="btn btn-success conf pull-right navbar-text " style="color: white;"  type="submit">
  108.        </div>
  109.        
  110.     </footer>
  111.  
  112. <script src="../../js/bootstrap.min.js" type="text/javascript"></script>
  113.  <?php modal_confirm(); ?>
  114.  
  115.  
  116.  
  117. <?php
  118. if(isset($_GET['modal'])){
  119.  $modal = $_GET['modal'];
  120. }
  121. else {
  122.  $modal = NULL;
  123. }
  124.  
  125. if ($modal == 1) {
  126. echo "<script type='text/javascript'>
  127. setTimeout(function() {
  128. jQuery('.modal_pop').trigger('click');
  129. }, 300);
  130.  
  131. $('.close_modal').click(function (e) {
  132. window.location.href = 'checkout.php';
  133. });
  134.  
  135. jQuery('.sim').click(function(){
  136.    jQuery('input.first').trigger('click');
  137.   jQuery('#myTable').empty();
  138.    localStorage.clear();
  139.    return false;
  140. });
  141. jQuery('.close_modal').click(function (e) {
  142.    
  143.   window.location.href = 'checkout.php';
  144.    
  145. });
  146.  
  147. </script>";
  148. }
  149.  
  150. ?>
  151.  
  152. <script type="text/javascript">
  153. jQuery(".conf").click(function(){
  154.   window.location.href = 'checkout.php?modal=1';
  155. });
  156. </script>
  157.  
  158.  
  159.  
  160.  
  161.  
  162. <script type="text/javascript">
  163.  
  164. $(function() {
  165.  
  166.     $(".row").each(function(index){
  167.  
  168.         // Fabric selection
  169.         if (localStorage.getItem('row_'+index+'_fabric')) {
  170.             $(this).find('.fabric option').prop('selected', false).eq(localStorage.getItem('row_'+index+'_fabric')).prop('selected', true);
  171.             console.log("Row#"+index+" get-fabric: "+localStorage.getItem('row_'+index+'_fabric'));
  172.         }
  173.  
  174.         $(this).find(".fabric").on('change', function() {
  175.             localStorage.setItem('row_'+index+'_fabric', $(this).find('option:selected').index());
  176.             console.log("Row#"+index+" set-fabric: "+$(this).find('option:selected').index());
  177.         });
  178.  
  179.  
  180.         // Size selection
  181.         if (localStorage.getItem('row_'+index+'_size')) {
  182.             $(this).find('.size option').prop('selected', false).eq(localStorage.getItem('row_'+index+'_size')).prop('selected', true);
  183.             console.log("Row#"+index+" get-size: "+localStorage.getItem('row_'+index+'_size'));
  184.         }
  185.  
  186.         $(this).find(".size").on('change', function() {
  187.             localStorage.setItem('row_'+index+'_size', $(this).find('option:selected').index());
  188.             console.log("Row#"+index+" set size: "+$(this).find('option:selected').index());
  189.         });
  190.     });
  191. });
  192.  
  193.  
  194.  
  195. </script>
  196.  
  197. <script type="text/javascript">
  198.  $(document).ready(function() {
  199.  
  200.   $('.fabric, .size').on('change', sendData);
  201.  
  202.   function sendData() {
  203.    //use the data-id attribute of the selected element to match the correct elements
  204.    var id = $(this).data("id");
  205.     var action = $(this).attr('data-action');
  206.     var fabricID = $('.fabric[data-id=' + id +']').val();
  207.     var sizeID   = $('.size[data-id=' + id +']').val();
  208.    
  209.  
  210.     if ( fabricID !== "" && sizeID !== "") {
  211.      $.ajax({
  212.            type     : 'GET',
  213.            url      : 'calculates.php',
  214.            dataType : 'json',
  215.            data     : {
  216.                prod_id:id,
  217.                fabric_id: fabricID,
  218.                action:action,
  219.                size_id: sizeID
  220.            }
  221.        }).done(function(data) {
  222.          console.log(data);
  223.          
  224.            /*$('.cost[data-id=' + id + ']').html('R$:' + data);
  225.            $('.subtotal[data-id=' + id + ']').html('R$:' + data);*/
  226.           $('.cost[data-id=' + id + ']').html('R$:' + data.cost);
  227.            $('.subtotal[data-id=' + id + ']').html('R$:' + data.subtotal);
  228.           $('.total_cost[data-id=' + id + ']').text('R$:' + data.all_cost);
  229.            
  230.            
  231.            
  232.         });
  233.       }
  234.   }
  235. });
  236. </script>
  237.  
  238.  
  239. <script>  //this deletes the rows in checkout page
  240. function deleteRow(r) {
  241.     var i = r.parentNode.parentNode.rowIndex;
  242.     document.getElementById("myTable").deleteRow(i);
  243. }
  244. </script>
  245.  
  246. <script type="text/javascript">
  247.  
  248. $('.actions').click(function(e){
  249.   e.preventDefault();
  250.   var action = $(this).attr('data-action'); //identifica a ação do botão
  251.   var id = $(this).attr('product_id');
  252.   var cost_id = $(this).data("id");
  253.  
  254.   console.log("triggered action " + action + " for product " + id); //debugging
  255.   $.ajax({
  256.   url: 'cart_functions.php',
  257.   type : 'GET',
  258.   data: {action:action,prod_id:id},
  259.   dataType: 'json'
  260.   // Be consistent and use .done()
  261. }).done(function(data) {
  262.   if (data.result == "success" ) {
  263.     $(".product" + id).text(data.val);
  264.     $('.subtotal[data-id=' + id + ']').html('R$:' + data.subtotal);
  265.     $('.valor_total').text('R$:' + data.valor_total);
  266.  
  267.   }
  268.   else {
  269.     alert("error");
  270.   }
  271. }).fail(function(jqXHR, textStatus, errorThrown) { //in case of server/network error
  272.   console.log("An error occurred whilst attempting to contact the server: " + jqXHR.status + " " + textStatus + " " + errorThrown);
  273. });
  274. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement