Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <header>
- <nav class="navbar navbar-inverse navbar-fixed-top">
- <div class="container">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="#">Lista</a>
- </div>
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
- <ul class="nav navbar-nav">
- <li class=""><a href="index.php" onClick="history.go(0)" VALUE="Refresh">Início <span class="sr-only"></span></a></li>
- <!--<li><a href="#">Nao definido</a></li>-->
- </ul>
- </li>
- </ul>
- <!--<form class="navbar-form navbar-left" action="search.php" role="form">
- <div class="form-group">
- <input type="search" name="search" class="form-control" placeholder="Procurar">
- <button name="search_submit" class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i> Pesquisar</button>
- </div>
- </form>-->
- <ul class="nav navbar-nav navbar-right">
- <li><a href="../painel.php"><span class="glyphicon glyphicon-briefcase"></span> Painel</a></li>
- <li><a href="../../logout.php"><span class="glyphicon glyphicon-share-alt"></span> Logout</a></li>
- </li>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div><!-- /.container-fluid -->
- </nav>
- </header>
- <body style="padding-top:60px;">
- <form action="postOrder.php" method="POST" enctype="multipart/form-data" class="form-horizontal">
- <div class="container">
- <div class="row">
- <table class="table table-striped table-hover" id="myTable">
- <thead>
- <h4></h4>
- <tr>
- <th>Image</th>
- <th>Produto</th>
- <th>Fabric</th>
- <th>Size</th>
- <th>Qntd</th>
- <th>Cost</th>
- <th>sub.total</th>
- </tr>
- </thead>
- <tbody >
- <?php cart(); ?>
- </tbody>
- </table>
- <div class="form-group">
- <input name="submit_post" class="first" type="submit" >
- </div>
- </form>
- <div class="col-sm-4 pull-right">
- <h2>Total do pedido</h2>
- <table class="table table-bordered">
- <tr class="">
- <th>Itens:</th>
- <th class="text-center all_p" data-id="<?php $id ?>"><span><?php echo $_SESSION['total_products'] ?></span></th>
- </tr>
- <tr >
- <th>Valor total:</th>
- <th class="text-center valor_total"><span>R$: <?php echo $_SESSION['total'] ; ?></span></th>
- </tr>
- </table>
- </div>
- </div>
- </div>
- </body><div class="clear"></div>
- <footer class="navbar navbar-default navbar-fixed-bottom" style="background-color:#2C3E50; color:white;">
- <div class="container"><p class="navbar-text pull-left" style="color: white;">
- <?php echo $_SESSION['userName'] ." ".$_SESSION['userLName'];?>
- </p>
- <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;" >
- <input value="Confirmar pedido" class="btn btn-success conf pull-right navbar-text " style="color: white;" type="submit">
- </div>
- </footer>
- <script src="../../js/bootstrap.min.js" type="text/javascript"></script>
- <?php modal_confirm(); ?>
- <?php
- if(isset($_GET['modal'])){
- $modal = $_GET['modal'];
- }
- else {
- $modal = NULL;
- }
- if ($modal == 1) {
- echo "<script type='text/javascript'>
- setTimeout(function() {
- jQuery('.modal_pop').trigger('click');
- }, 300);
- $('.close_modal').click(function (e) {
- window.location.href = 'checkout.php';
- });
- jQuery('.sim').click(function(){
- jQuery('input.first').trigger('click');
- jQuery('#myTable').empty();
- localStorage.clear();
- return false;
- });
- jQuery('.close_modal').click(function (e) {
- window.location.href = 'checkout.php';
- });
- </script>";
- }
- ?>
- <script type="text/javascript">
- jQuery(".conf").click(function(){
- window.location.href = 'checkout.php?modal=1';
- });
- </script>
- <script type="text/javascript">
- $(function() {
- $(".row").each(function(index){
- // Fabric selection
- if (localStorage.getItem('row_'+index+'_fabric')) {
- $(this).find('.fabric option').prop('selected', false).eq(localStorage.getItem('row_'+index+'_fabric')).prop('selected', true);
- console.log("Row#"+index+" get-fabric: "+localStorage.getItem('row_'+index+'_fabric'));
- }
- $(this).find(".fabric").on('change', function() {
- localStorage.setItem('row_'+index+'_fabric', $(this).find('option:selected').index());
- console.log("Row#"+index+" set-fabric: "+$(this).find('option:selected').index());
- });
- // Size selection
- if (localStorage.getItem('row_'+index+'_size')) {
- $(this).find('.size option').prop('selected', false).eq(localStorage.getItem('row_'+index+'_size')).prop('selected', true);
- console.log("Row#"+index+" get-size: "+localStorage.getItem('row_'+index+'_size'));
- }
- $(this).find(".size").on('change', function() {
- localStorage.setItem('row_'+index+'_size', $(this).find('option:selected').index());
- console.log("Row#"+index+" set size: "+$(this).find('option:selected').index());
- });
- });
- });
- </script>
- <script type="text/javascript">
- $(document).ready(function() {
- $('.fabric, .size').on('change', sendData);
- function sendData() {
- //use the data-id attribute of the selected element to match the correct elements
- var id = $(this).data("id");
- var action = $(this).attr('data-action');
- var fabricID = $('.fabric[data-id=' + id +']').val();
- var sizeID = $('.size[data-id=' + id +']').val();
- if ( fabricID !== "" && sizeID !== "") {
- $.ajax({
- type : 'GET',
- url : 'calculates.php',
- dataType : 'json',
- data : {
- prod_id:id,
- fabric_id: fabricID,
- action:action,
- size_id: sizeID
- }
- }).done(function(data) {
- console.log(data);
- /*$('.cost[data-id=' + id + ']').html('R$:' + data);
- $('.subtotal[data-id=' + id + ']').html('R$:' + data);*/
- $('.cost[data-id=' + id + ']').html('R$:' + data.cost);
- $('.subtotal[data-id=' + id + ']').html('R$:' + data.subtotal);
- $('.total_cost[data-id=' + id + ']').text('R$:' + data.all_cost);
- });
- }
- }
- });
- </script>
- <script> //this deletes the rows in checkout page
- function deleteRow(r) {
- var i = r.parentNode.parentNode.rowIndex;
- document.getElementById("myTable").deleteRow(i);
- }
- </script>
- <script type="text/javascript">
- $('.actions').click(function(e){
- e.preventDefault();
- var action = $(this).attr('data-action'); //identifica a ação do botão
- var id = $(this).attr('product_id');
- var cost_id = $(this).data("id");
- console.log("triggered action " + action + " for product " + id); //debugging
- $.ajax({
- url: 'cart_functions.php',
- type : 'GET',
- data: {action:action,prod_id:id},
- dataType: 'json'
- // Be consistent and use .done()
- }).done(function(data) {
- if (data.result == "success" ) {
- $(".product" + id).text(data.val);
- $('.subtotal[data-id=' + id + ']').html('R$:' + data.subtotal);
- $('.valor_total').text('R$:' + data.valor_total);
- }
- else {
- alert("error");
- }
- }).fail(function(jqXHR, textStatus, errorThrown) { //in case of server/network error
- console.log("An error occurred whilst attempting to contact the server: " + jqXHR.status + " " + textStatus + " " + errorThrown);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement