1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
| <?php
include("includes/utf8.php");
define('_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__));
define( 'DS','/' );
require_once ( JPATH_BASE.DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE.DS.'includes'.DS.'framework.php' );
require(JPATH_BASE.DS.'libraries/joomla/factory.php');
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
// Ce script est appelé à chaque sélection d'un élément d'une liste
// suivi du critère
$where = array();
$data = array();
// données sélectionnées => filtres
$nom = NULL;
/**
* CE SCRIPT ANALYSE LES SELECTIONS ET RENVOIE DES DONNEES AU FORMAT XML
* La structure correspond à ce que jQuery attend pour mettre à jour la page
* <?xml version="1.0" encoding="utf-8"?>
* <xml>
* </xml>
*
* @var SimpleXMLElement
*/
$xml = simplexml_load_string('<?xml version="1.0" encoding="utf-8"?><xml></xml>');
// Connexion à la base de données
$db=& JFactory::getDBO();
$my =& JFactory::getuser();
/**
* Crée le code HTML pour les liste relatives aux villes et matières
* @param mixed $sql
* @return string
*/
function filtrageNoms($sql) {
$data = array();
$qry = mysql_query($sql);
$data[] = '<option value=""></option>'; // ligne vide
while($row = mysql_fetch_row($qry)) {
$data[] = '<option value="' . $row[0] . '">' . $row[1] . '</option>';
}
return implode("\n", $data);
}
// Récupération de l'ID
if (isset($_POST['id']) && (ctype_digit("{$_POST['id']}"))) {
$nom = $_POST['id'];
}
// données de la table
$query = "select u.ID, NAME, DESCRIPTION, EXERCICE, MONTANT, MONTANT_REGLE from
`sun_user_cotisation` uc
, sun_cotisations c
, j25_users u
WHERE u.id = uc.id_user
and uc.id_cotisation = c.id
and u.id = $nom";
$data = array();
//$qry = mysql_query($sql);
$db->setQuery($query);
// récupération des résultats dans un tableau
$rows = $db->loadObjectList();
// mise en forme des données
// ici on reconstruit les données de la table
//while($rows = $db->loadObjectList())
/* <td class="alignc">{$row['NAME']}</td>
<td>{$row['DESCRIPTION']}</td>
<td class="alignr">{$row['EXERCICE']}</td>
<td class="alignr">{$row['MONTANT']}</td>
<td class="alignr">{$row['MONTANT_REGLE']}</td>
*/
foreach ($rows as $row) {
if ($row->MONTANT == $row->MONTANT_REGLE ){
$data[] = <<<HTML
<tr BGCOLOR="#C1E19F">
<td>$row->ID</td>
<td>$row->NAME</td>
<td>$row->DESCRIPTION</td>
<td align="center">$row->EXERCICE</td>
<td align="right">$row->MONTANT</td>
<td align="right">$row->MONTANT_REGLE</td>
<td>Réglée</td>
</tr>
HTML;
}
else{
$data[] = <<<HTML
<tr BGCOLOR="#FFBDDF">
<td>$row->ID</td>
<td>$row->NAME</td>
<td>$row->DESCRIPTION</td>
<td align="center">$row->EXERCICE</td>
<td align="right">$row->MONTANT</td>
<td align="right">$row->MONTANT_REGLE</td>
<td>Non Réglée</td>
</tr>
HTML;
}
}
if (empty($data)) { // pas de données correspondant au filtre
$data[] = '<tr></tr>';
}
$xml->addChild('table', implode("\n", $data)); # noeud attendu par jQuery dans filterLists()
// Envoi du header et des données
header('content-type: text/xml');
echo $xml->asXML();
?> |
Partager