File: D:/HostingSpaces/SBogers10/vangogh.komma-mediadesign.nl/wwwroot/kms/foto_overzicht.php
<?php
if (isset($_GET['auto_id']))
{
$auto_id = $_GET['auto_id'];
}
if (isset($_POST['auto_id']))
{
$auto_id = $_POST['auto_id'];
}
/* on form submission */
if(isset($_POST['do_submit'])) {
/* split the value of the sortation */
$ids = explode(',',$_POST['sort_order']);
/* run the update query for each id */
foreach($ids as $index=>$id) {
$id = (int) $id;
if($id != '') {
$query = 'UPDATE kms_images SET sort_order = '.($index + 1).' WHERE kms_images.foto_id = '.$id;
$result = mysql_query($query) or die(mysql_error().': '.$query);
echo($query);
}
}
/* now what? */
if($_POST['byajax']) { die(); } else { $message = 'Sortation has been saved.'; }
}
$q_auto_naam = sprintf("SELECT kms_autos.naam, kms_autos.image_dir, kms_brands.brand_name FROM kms_autos, kms_brands WHERE kms_autos.brand_id = kms_brands.brand_id AND kms_autos.auto_id='%s' LIMIT 0,1", $auto_id);
$r_auto_naam = mysql_query($q_auto_naam);
$rec_auto_naam = mysql_fetch_array($r_auto_naam);
$auto_naam = html_entity_decode($rec_auto_naam['naam']);
$merk = html_entity_decode($rec_auto_naam['brand_name']);
$image_dir = $rec_auto_naam['image_dir'];
?>
<h1><?php echo($merk." ".$auto_naam);?> foto's ordenen of toevoegen</h1>
<?php
$query = sprintf("SELECT kms_images.foto_id, kms_images.icon_dir, kms_images.sort_order FROM kms_images WHERE kms_images.auto_id ='%s' ORDER BY kms_images.sort_order ASC", $auto_id );
$result = mysql_query($query);
if(mysql_num_rows($result)) {
?>
<p>Sleep de onderstaande fotos in de volgorde dat u ze op de auto pagina wilt hebben of <a href="index.php?p=foto_toevoegen&auto_id=<?php echo($auto_id); ?>">klik hier om een foto toe te voegen ></a></p>
<div id="message-box"><?php echo $message; ?> Pagina wacht op herordening...</div>
<form id="dd-form" action="/kms/index.php?p=foto_overzicht" method="post">
<p class="autoSubmit">
<input type="checkbox" value="1" name="autoSubmit" id="autoSubmit" <?php if($_POST['autoSubmit']) { echo 'checked="checked"'; } ?> />
<label for="autoSubmit">Wijzigen meteen toevoegen na het slepen</label>
</p>
<ul id="sortable-list">
<?php
$order = array();
while($item = mysql_fetch_assoc($result)) {
echo '<li style="float:left;" title="',$item['foto_id'],'"><img style="float:left;" src="/auto_images/',$image_dir,'/tegel_',$item['icon_dir'],'.jpg"/>
<div style="float:right; margin-top: 55px; width: 225px;"><a href="index.php?p=foto_wijzigen&foto_id=',$item['foto_id'],'&auto_id=',$auto_id,'">Foto wijzigen</a><br /><br />
<a href="index.php?p=foto_verwijderen&foto_id=',$item['foto_id'],'&auto_id=',$auto_id,'">Foto verwijderen</a></div></li>';
$order[] = $item['foto_id'];
}
?>
</ul>
<br /><br /><br />
<input type="hidden" name="sort_order" id="sort_order" value="<?php echo implode(',',$order); ?>" />
<input type="hidden" name="auto_id" id="auto_id" value="<?php echo($auto_id); ?>" />
<input style="clear:both; margin-top:15px;" type="submit" name="do_submit" value="Wijzigingen opslaan" class="button submit" />
</form>
<div class="clear_both"></div><br /><br /><br />
<p style="float:left;"><a href="index.php?p=auto_overzicht">Klik hier om terug te gaan naar het auto overzicht ></a></p>
<?php } else { ?>
<p>Sorry! Er zijn geen foto's bij deze auto. <br /><br /><a href="index.php?p=foto_toevoegen&auto_id=<?php echo($auto_id); ?>">Klik hier om een foto toe te voegen ></a></p>
<?php } ?>