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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
<?php
class AjaxController extends Zend_Controller_Action {
/**
* Renvoie la liste de mes noms de client
*/
public function clientAction() {
// désactive le rendu de vue et layout
if($this->_request->isXmlHttpRequest()){
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
// Appel de mon modèle de table
$TClients = new TClients;
// Extraction de mes données
$Clients = $TClients->selectData();
// Création de ma liste (id et text vont être utilisé pour JQuery Suggest)
foreach ($Clients as $Client) {$list[] = array( 'id'=> $Client->numero_client, 'text'=> $Client->nom_client);
}
// Je renvoie ce tableau à ma vue au format JSON
$this->_helper->json($list, array('enableJsonExprFinder' => true));
}//Eof:: clientAction
/**
* Renvoie la fiche d'un client
*/
public function monclientAction() {
// désactive le layout
if($this->_request->isXmlHttpRequest()){
$this->_helper->layout->disableLayout();
}
// Récupère le numéro du client
$numero_client = $this->_request->getParam('id');
// Appel de mon modèle de table
$TClients = new TClients;
// Extraction de mes données
$Clients = $TClients->selectDataByID($numero_client);
$html = '
<table>
tr>
<th>Numéro</th>
<th>Nom</th>
<th>Raison sociale</th>
<th>Responsable</th>
<th>Adresse</th>
<th>Code postal</th>
<th>Ville</th>
<th>Département</th>
<th>Pays</th>
<th>Mail</th>
<th>Telephone Domicile</th>
<th>Action</th>
</tr>
';
foreach($Clients as $client) {
$html .= '<tr>';
$html .= '<td>'.$client->numero_client.'</td>';
$html .= '<td>'.$client->nom_client.'</td>';
$html .= '<td>'.$client->numero_raison_sociale_client.'</td>';
$html .= '<td>'.$client->responsable_client.'</td>';
$html .= '<td>'.$client->adresse_client.'</td>';
$html .= '<td>'.$client->code_postal_client.'</td>';
$html .= '<td>'.$client->ville_client.'</td>';
$html .= '<td>'.$client->numero_departement_client.'</td>';
$html .= '<td>'.$client->numero_pays_client.'</td>';
$html .= '<td>'.$client->mail_client.'</td>';
$html .= '<td>'.$client->telephone_domicile_client.'</td>';
$html .= '<td>';
$html .= '<a href="'.$this->view->url(array('controller'=>'index'
,'action'=>'modifier'
, 'id'=>$client->numero_client))
.'">Modifier</a>';
$html .= '<a href="'.$this->view->url(array('controller'=>'index'
,'action'=>'supprimer'
, 'id'=>$client->numero_client))
.'">Supprimer</a>';
$html .= '<a href="'.$this->view->url(array('controller'=>'index'
,'action'=>'consulter'
, 'id'=>$client->numero_client))
.'">Consulter</a>';
$html .= '</td>';
$html .= '</tr>';
}
$html .= '</table>';
// Assignation de mes différents éléments à ma vue
$this->view->html = $html;
// Appel automatique de ma vue
}//Eof:: clientAction
///////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////// Fournisseur ///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
public function fournisseurAction() {
$TFournisseurs = new TFournisseurs;
$Fournisseurs = $TFournisseurs->selectData();
foreach ($Fournisseurs as $Fournisseur) {$list[] = array( 'id'=> $Fournisseur->numero_fournisseur, 'text'=> $Fournisseur->nom_fournisseur);
}
Zend_Debug::Dump($list);
$this->_helper->json($list, array('enableJsonExprFinder' => true));
}
public function monfournisseurAction()
{
Zend_Debug::Dump($list);
$numero_fournisseur = $this->_request->getParam('id');
$TFournisseurs = new TFournisseurs;
$Fournisseurs = $TFournisseurs->selectDataByID($numero_fournisseur);
foreach ($Fournisseurs as $Fournisseur)
{
$list['fournisseur'][] = array( 'numero_fournisseur' => $Fournisseur->numero_fournisseur
, 'nom_fournisseur' => $Fournisseur->nom_fournisseur
, 'contact_fournisseur' => $Fournisseur->contact_fournisseur
, 'adresse_fournisseur' => $Fournisseur->adresse_fournisseur
, 'code_postal_fournisseur' => $Fournisseur->code_postal_fournisseur
, 'ville_fournisseur' => $Fournisseur->ville_fournisseur
);
}
$this->_helper->json($list, array('enableJsonExprFinder' => true));
}
}//Eof::Class
?> |
Partager