<?php	
	include('../../includes/db.php'); 
	include('_config.php');
	$id=mysql_real_escape_string($_GET[id]);
	$row= mysql_fetch_array(mysql_query("SELECT * FROM `$moduleTable` WHERE id = $id"));
?>
<div id="right_column">
<? adminBreadcrumbs($moduleHttp.'/'.$moduleFolder.'.list.php',$moduleTable,$moduleTitle,'edit',$row['title']); ?>

<div class="right_bg">
    <h3>Edytuj <? echo lcfirst($moduleItem); ?></h3>
    <div class="table">         

	<?php
    if($_POST[save]){ 	
        
        if(validateForm($formSettings, $_POST)){
        // validacja wymaganych pół	
            if(generateSql($moduleTable, $_POST, 'update', "WHERE id = $id",$id)){
                echo showNote("$moduleItem zaktualizowano poprawnie.",'success');
                unset($_POST);
            } else {
                echo showNote("Wystąpił błąd podczas zapisu do bazy.",'error');
            }		
            
        } else {
            echo showNote(validateForm($formSettings, $_POST, true),'error');
            // wyswietlanie bledow validacji
        }
    
    }
    ?>
    <form name="formAdd" enctype="multipart/form-data" action="" method="post">
    <input type="hidden" name="save" value="1" />
      <table width="100%" border="0">
        <? 
		$row= mysql_fetch_array(mysql_query("SELECT * FROM `$moduleTable` WHERE id = $id"));
		echo generateForm($formSettings, $row);
		?>
        <tr>
            <td></td>
            <td><p><input name="save" type="image" src="<? echo $basehttp; ?>/admin/gfx/buttons/button_submit.gif" style="border:none;" /></p></td>
        </tr>  
        </table>
    </form>

</div>
</div>
<div class="right_bottom"></div>
</div>
<? include($basepath.'/admin/templates/footer.php'); ?>