2009-05-04 14:26:54 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file
|
2009-08-19 12:10:34 +00:00
|
|
|
* Liste des pays
|
2009-05-04 14:26:54 +00:00
|
|
|
*
|
|
|
|
*/
|
2009-05-14 09:49:31 +00:00
|
|
|
setDbConn('graydon');
|
2009-05-12 13:40:22 +00:00
|
|
|
$q = Doctrine_Query::create()
|
|
|
|
->select('*')
|
|
|
|
->from('Country');
|
|
|
|
|
|
|
|
$results = $q->execute();
|
|
|
|
$results = $results->toArray();
|
|
|
|
|
2009-08-10 16:14:38 +00:00
|
|
|
$view = arg(2,$_REQUEST['q']);
|
|
|
|
switch ($view) {
|
|
|
|
case "add" :
|
|
|
|
if (sizeof($_POST) > 0) {
|
2009-08-19 12:10:34 +00:00
|
|
|
$frm = $_POST;
|
2009-08-10 16:14:38 +00:00
|
|
|
insere_pays($frm);
|
2009-08-19 12:10:34 +00:00
|
|
|
header("Location:".$_SERVER['HTTP_REFERER']);
|
2009-08-10 16:14:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* FONCTIONS
|
|
|
|
*****************************************************************************/
|
2009-08-19 12:10:34 +00:00
|
|
|
function insere_pays($frm) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ajoute un nouveau Pays.
|
|
|
|
* Les champs sont dans la variable $frm
|
|
|
|
*
|
2009-08-10 16:14:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
$lib = htmlspecialchars($frm['lib'], ENT_QUOTES);
|
|
|
|
$code = htmlspecialchars($frm['code'], ENT_QUOTES);
|
|
|
|
|
2009-08-19 12:10:34 +00:00
|
|
|
require_once realpath(dirname(__FILE__)).'/mysql_inc.php';
|
2009-08-10 16:14:38 +00:00
|
|
|
|
2009-08-19 12:10:34 +00:00
|
|
|
$sql = "INSERT INTO country(
|
|
|
|
code
|
|
|
|
,graydon_country
|
|
|
|
,lib
|
|
|
|
,status
|
|
|
|
)
|
|
|
|
VALUES (
|
|
|
|
'$code'
|
|
|
|
, '".$frm['graydon_country']."'
|
|
|
|
, '$lib'
|
|
|
|
, '".$frm['status']."'
|
|
|
|
)
|
|
|
|
";
|
2009-08-10 16:14:38 +00:00
|
|
|
|
2010-02-10 17:27:03 +00:00
|
|
|
mysql_query($sql) or die("Une erreur de connexion à la base s'est produite " . __LINE__ . ".<p></p>" . mysql_error());
|
2009-08-19 12:10:34 +00:00
|
|
|
mysql_close($connexion);
|
2009-08-10 16:14:38 +00:00
|
|
|
}
|
|
|
|
|
2009-05-04 14:26:54 +00:00
|
|
|
?>
|
2009-05-12 10:00:40 +00:00
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
$('.status').editable('./modules/graydon/payssave.php', {
|
|
|
|
data : "{'actif':'actif','inactif':'incatif'}",
|
|
|
|
type : 'select',
|
|
|
|
event : 'dblclick',
|
|
|
|
indicator : 'Sauvegarde...',
|
2010-02-10 17:27:03 +00:00
|
|
|
tooltip : 'Double-Clique pour éditer...',
|
2009-05-12 10:00:40 +00:00
|
|
|
submitdata : {col: 'status'}
|
|
|
|
});
|
|
|
|
$('.lib').editable('./modules/graydon/payssave.php', {
|
|
|
|
event : 'dblclick',
|
|
|
|
indicator : 'Sauvegarde...',
|
2010-02-10 17:27:03 +00:00
|
|
|
tooltip : 'Double-Clique pour éditer...',
|
2009-05-12 10:00:40 +00:00
|
|
|
submitdata : {col: 'lib'}
|
|
|
|
});
|
|
|
|
$('.code').editable('./modules/graydon/payssave.php', {
|
|
|
|
event : 'dblclick',
|
|
|
|
indicator : 'Sauvegarde...',
|
2010-02-10 17:27:03 +00:00
|
|
|
tooltip : 'Double-Clique pour éditer...',
|
2009-05-12 10:00:40 +00:00
|
|
|
submitdata : {col: 'code'}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
2009-06-04 10:35:53 +00:00
|
|
|
<table border="1px solid">
|
2009-05-04 14:26:54 +00:00
|
|
|
<tr>
|
2010-02-10 17:27:03 +00:00
|
|
|
<th>Libélé</th>
|
2009-05-04 14:26:54 +00:00
|
|
|
<th>Pays</th>
|
|
|
|
<th>Code</th>
|
|
|
|
<th>Status</th>
|
|
|
|
</tr>
|
2009-08-19 12:10:34 +00:00
|
|
|
<?php
|
2009-05-04 14:26:54 +00:00
|
|
|
foreach($results as $pays){
|
|
|
|
?>
|
|
|
|
<tr>
|
2009-05-12 10:00:40 +00:00
|
|
|
<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>
|
2009-05-04 14:26:54 +00:00
|
|
|
</tr>
|
2009-08-19 12:10:34 +00:00
|
|
|
<?php
|
2009-05-04 14:26:54 +00:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</table>
|
2009-05-12 10:00:40 +00:00
|
|
|
|
2009-08-10 16:14:38 +00:00
|
|
|
<form method="post" action="./?q=graydon/pays/add">
|
2009-05-12 10:00:40 +00:00
|
|
|
<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">
|
2009-08-19 12:10:34 +00:00
|
|
|
<?php
|
2009-05-12 10:00:40 +00:00
|
|
|
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>
|
2009-08-19 12:10:34 +00:00
|
|
|
</form>
|