PHP - Control de tiempo

 
Vista:
Imágen de perfil de novo34

Control de tiempo

Publicado por novo34 (9 intervenciones) el 27/01/2017 12:35:31
Amigos, tengo un problema con un codigo, espero me puedan ayudar.

Lo que hace es sacar de la base de datos los coches disponibles, luego coloca una imagen de cada uno para poder alquilarlos, una vez alquilado debe marcar el porcentaje del tiempo transcurrido segun el tiempo que lo alquilaron.

El problema es que no logro hacer que marque el tiempo transcurrido de cada uno, solo me sale de uno de los coches.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<div class="row">
    <div class="col-xs-12">
     <div>
        <ul class="ace-thumbnails clearfix">
          <?php
            $coches = ProductData::getAll(1);
          ?>
 
            <?php if (count($coches)>0): ?>
                <?php foreach($coches as $coche):?>
                  <?php $sell = SellData::getByCar($coche->id); ?>
                  <?php if ($coche->name == $coche->name): ?>
                    <li style="border: solid white;" !important>
                      <div>
                        <img width="200" height="200" alt="200x200" src="storage/products/<?php echo $coche->image;?>" />
                        <div class="text">
                          <div class="inner">
                            <span><?php echo $coche->name;?></span>
 
                            <br />
                            <!-- <a href="#table-Coche-Time?coche=<?php $coche->id; ?>" class="blue" data-toggle="modal"></a> -->
                            <a href="javascript:void(0);" data-toggle="modal" data-target="#Coche-Time" onclick="DataForm(<?php echo $coche->id ?>);">
                            <!-- <a data-target="#table-Coche-Time" href="#" class="sepV_a"> -->
                              <i class="ace-icon fa fa-users"></i>
                            </a>
                          </div>
                        </div>
                      </div>
                      <?php if (isset($sell)): ?>
                        <!-- datos del alquiler del coche -->
                        <?php
                            $fechaAlquiler = $sell->created_at;
                            // $tiempoAlquiler = ($sell->tAlquilado);
                            $tiempoAlquilermili = ($sell->tAlquilado)*60000;
                            // echo $fechaAlquiler;
                            // echo " - ".$tiempoAlquiler." - ".$tiempoAlquilermili;
                            $client = PersonData::getById($sell->person_id);
                         ?>
                        <div>
                          <div id="pbar_outerdiv" style="width: 200px; height: 20px; border: 1px solid grey; z-index: 1; position: relative; border-radius: 5px; -moz-border-radius: 5px;">
                            <div id="pbar_innerdiv" style="background-color: lightblue; z-index: 2; height: 100%; width: 0%;"></div>
                            <div id="pbar_innertext" style="z-index: 3; position: absolute; top: 0; left: 0; width: 100%; height: 100%; color: black; font-weight: bold; text-align: center;">0%</div>
                          </div>
                          <div id="NameClient"><span style="width=200px; height=auto;" !important><?php echo $client->name." ".$client->lastname; ?></span></div>
                          <div id="MinRent"><span style="width=200px; height=auto;" !important><?php echo $sell->tAlquiler." Minutos"; ?></span></div>
                          <div id="MinNow"><span style="width=200px; height=auto;" !important><?php echo "0 Minutos pasados"; ?></span></div>
                        </div>
                        <!-- Script para calcular el tiempo -->
                        <script type="text/javascript">
                            // var fechaAlquiler= '<?php echo strtotime($fechaAlquiler)*1000; ?>';
                            var start = new Date(<?php echo strtotime($fechaAlquiler)*1000;?>);
                            var maxTime = '<?php echo $tiempoAlquilermili; ?>';
                            var timeoutVal = Math.floor(maxTime/100);
                            animateUpdate();
 
                            function updateProgress(percentage) {
                                $('#pbar_innerdiv').css("width", percentage + "%");
                                $('#pbar_innertext').text(percentage + "%");
                            }
 
                            function animateUpdate() {
                                var now = new Date();
                                var timeDiff = now.getTime() - start.getTime();
                                var perc = Math.round((timeDiff/maxTime)*100);
                                console.log(perc);
                                  if (perc <= 100) {
                                   updateProgress(perc);
                                   setTimeout(animateUpdate, timeoutVal);
                                  }
                            }
                        </script>
 
                      <?php endif ?>
                    </li>
                  <?php endif ?>
                <?php endforeach; ?>
            <?php endif ?>
 
        </ul>
      </div>
    </div>
  </div>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder