Friends, I have a problem with a code, I hope you can help me.
What it does is take the available cars from the database, then place an image of each one so that they can be rented. Once rented, you must mark the percentage of time elapsed according to the time they rented it.
The problem is that I can not make it mark the elapsed time of each of the rented cars, I only get one of the cars.
<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>