public $components = array('RequestHandler');
public function index() {
+
// GETTING ALL VERSIONS
$versions = $this->Version->find('all');
));
}
- public function view($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Mauvaise version'));
- }
-
- $version = $this->Version->findById($id);
- if (!$version) {
- throw new NotFoundException(__('Mauvaise version'));
- }
- $this->set('version', $version);
- }
-
- public function add($produit_id = null) {
+ public function add($product_id = null) {
if ($this->request->is('POST')) {
$this->Version->create();
- $this->Version->value('valeur', $_POST['valeur']);
+ $this->Version->value('value', $_POST['value']);
$this->Version->value('nature', $_POST['nature']);
- $this->Version->value('produit', $_POST['produit']);
+ $this->Version->value('product', $_POST['product']);
if ($this->Version->save($this->request->data)) {
$this->Session->setFlash(__("La version a été enregistrée."));
- return $this->redirect(array('action' => 'index'));
+ $this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__("Enregistrement de la version impossible."));
} else {
- // RECUPÉRATION DU / DES PRODUITS LIÉS
- App::import('Controller', 'Produits');
- $produitsController = new ProduitsController;
- if(isset($produit_id)) {
- $produit = $produitsController->Produit->findById($produit_id);
- $this->set('produit', $produit);
+
+ // GETTING PRODUCT IF ITS ID IS SET IN REQUEST, IF NOT ALL PRODUCTS
+ App::import('Controller', 'Products');
+ $productsController = new ProductsController;
+ if(isset($product_id)) {
+ $product = $productsController->Product->findById($product_id);
+ $this->set('product', $product);
} else {
- $produits = $produitsController->Produit->find('all');
+ $products = $productsController->Product->find('all');
$this->set(array(
- 'produits' => $produits,
- '_serialize' => array('produits')
+ 'products' => $products,
+ '_serialize' => array('products')
));
}
}
$this->Version->id = $id;
if ($this->Version->save($this->request->data)) {
$this->Session->setFlash(__("La version a été mise à jour."));
+
// REDIRECTION
- return $this->redirect(array('controller' => 'produits', 'action' => 'index'));
+ $this->redirect(array('controller' => 'products', 'action' => 'index'));
}
$this->Session->setFlash(__("Mise à jour de la version impossible."));
}
$this->Session->setFlash(
__("La version d'id: %s a été supprimée.", h($id))
);
+
// REDIRECTION
- return $this->redirect(array('controller' => 'produits', 'action' => 'index'));
+ $this->redirect(array('controller' => 'products', 'action' => 'index'));
}
}
}