131 lines
3.2 KiB
PHP
131 lines
3.2 KiB
PHP
|
<?php
|
|||
|
/**
|
|||
|
* @file
|
|||
|
* Liste des pays
|
|||
|
*
|
|||
|
*/
|
|||
|
setDbConn('graydon');
|
|||
|
$q = Doctrine_Query::create()
|
|||
|
->select('*')
|
|||
|
->from('Country');
|
|||
|
|
|||
|
$results = $q->execute();
|
|||
|
$results = $results->toArray();
|
|||
|
|
|||
|
$view = arg(2,$_REQUEST['q']);
|
|||
|
switch ($view) {
|
|||
|
case "add" :
|
|||
|
if (sizeof($_POST) > 0) {
|
|||
|
$frm = $_POST;
|
|||
|
insere_pays($frm);
|
|||
|
header("Location:".$_SERVER['HTTP_REFERER']);
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************
|
|||
|
* FONCTIONS
|
|||
|
*****************************************************************************/
|
|||
|
function insere_pays($frm) {
|
|||
|
|
|||
|
/*
|
|||
|
* Ajoute un nouveau Pays.
|
|||
|
* Les champs sont dans la variable $frm
|
|||
|
*
|
|||
|
*/
|
|||
|
|
|||
|
$lib = htmlspecialchars($frm['lib'], ENT_QUOTES);
|
|||
|
$code = htmlspecialchars($frm['code'], ENT_QUOTES);
|
|||
|
|
|||
|
require_once realpath(dirname(__FILE__)).'/mysql_inc.php';
|
|||
|
|
|||
|
$sql = "INSERT INTO country(
|
|||
|
code
|
|||
|
,graydon_country
|
|||
|
,lib
|
|||
|
,status
|
|||
|
)
|
|||
|
VALUES (
|
|||
|
'$code'
|
|||
|
, '".$frm['graydon_country']."'
|
|||
|
, '$lib'
|
|||
|
, '".$frm['status']."'
|
|||
|
)
|
|||
|
";
|
|||
|
|
|||
|
mysql_query($sql) or die("Une erreur de connexion <20> la base s'est produite " . __LINE__ . ".<p></p>" . mysql_error());
|
|||
|
mysql_close($connexion);
|
|||
|
}
|
|||
|
|
|||
|
?>
|
|||
|
<script>
|
|||
|
$(document).ready(function() {
|
|||
|
$('.status').editable('./modules/graydon/payssave.php', {
|
|||
|
data : "{'actif':'actif','inactif':'incatif'}",
|
|||
|
type : 'select',
|
|||
|
event : 'dblclick',
|
|||
|
indicator : 'Sauvegarde...',
|
|||
|
tooltip : 'Double-Clique pour <20>diter...',
|
|||
|
submitdata : {col: 'status'}
|
|||
|
});
|
|||
|
$('.lib').editable('./modules/graydon/payssave.php', {
|
|||
|
event : 'dblclick',
|
|||
|
indicator : 'Sauvegarde...',
|
|||
|
tooltip : 'Double-Clique pour <20>diter...',
|
|||
|
submitdata : {col: 'lib'}
|
|||
|
});
|
|||
|
$('.code').editable('./modules/graydon/payssave.php', {
|
|||
|
event : 'dblclick',
|
|||
|
indicator : 'Sauvegarde...',
|
|||
|
tooltip : 'Double-Clique pour <20>diter...',
|
|||
|
submitdata : {col: 'code'}
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
</script>
|
|||
|
<table border="1px solid">
|
|||
|
<tr>
|
|||
|
<th>Lib<EFBFBD>l<EFBFBD></th>
|
|||
|
<th>Pays</th>
|
|||
|
<th>Code</th>
|
|||
|
<th>Status</th>
|
|||
|
</tr>
|
|||
|
<?php
|
|||
|
foreach($results as $pays){
|
|||
|
?>
|
|||
|
<tr>
|
|||
|
<td align="center"><div id="<?php print $pays['id']; ?>" class="lib"><?php print $pays['lib'];?></div></td>
|
|||
|
<td align="center"><div id="<?php print $pays['id']; ?>" class="graydon_country"><?php print $pays['graydon_country'];?></div></td>
|
|||
|
<td align="center"><div id="<?php print $pays['id']; ?>" class="code"><?php print $pays['code'];?></div></td>
|
|||
|
<td align="center"><div id="<?php print $pays['id']; ?>" class="status"><?php print $pays['status'];?></div></td>
|
|||
|
</tr>
|
|||
|
<?php
|
|||
|
}
|
|||
|
?>
|
|||
|
</table>
|
|||
|
|
|||
|
<form method="post" action="./?q=graydon/pays/add">
|
|||
|
<table>
|
|||
|
<tr><td colspan="4">Ajouter un pays : </td></tr>
|
|||
|
<td align="center"><input type="text" name="lib"/></td>
|
|||
|
<td align="center">
|
|||
|
<select name="graydon_country">
|
|||
|
<?php
|
|||
|
require_once 'graydon/pays.php';
|
|||
|
|
|||
|
foreach($tabPays as $kPays => $vPays ){
|
|||
|
print '<option value="'.$kPays.'">'.$vPays['display'].'</option>';
|
|||
|
}
|
|||
|
?>
|
|||
|
</select>
|
|||
|
</td>
|
|||
|
<td align="center"><input type="text" name="code" size="2"/></td>
|
|||
|
<td align="center">
|
|||
|
<select name="status">
|
|||
|
<option value="actif">actif</option>
|
|||
|
<option value="inactif">inactif</option>
|
|||
|
</select>
|
|||
|
</td>
|
|||
|
<td colspan="4"><input type="submit" name="submit"/></td>
|
|||
|
</table>
|
|||
|
</form>
|