Guest User

Untitled

a guest
Aug 24th, 2012
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. public function admin_add($idCustomer = null) {
  2.         if ($this->request->is('post')) {
  3.             $this->ProductDetail->create();
  4.             if ($this->ProductDetail->save($this->request->data)) {
  5.                 $this->Session->setFlash(
  6.                     __('The %s has been saved', __('product detail')),
  7.                     'alert',
  8.                     array(
  9.                         'plugin' => 'TwitterBootstrap',
  10.                         'class' => 'alert-success'
  11.                     )
  12.                 );
  13.  
  14.                 pr($this->request->data);
  15.  
  16.                 //$id = $this->request->data['ProductDetail']['customer_id'];
  17.                 //pr($id);
  18.                 //die();
  19.                 $this->redirect(array('controller'=>'customers','action' => 'view',$id));
  20.             } else {
  21.                 $this->Session->setFlash(
  22.                     __('The %s could not be saved. Please, try again.', __('product detail')),
  23.                     'alert',
  24.                     array(
  25.                         'plugin' => 'TwitterBootstrap',
  26.                         'class' => 'alert-error'
  27.                     )
  28.                 );
  29.             }
  30.         }
  31.  
  32.         $customers = $this->ProductDetail->Customer->find('list');
  33.  
  34.         if($idCustomer) {
  35.             $customers = $this->ProductDetail->Customer->find(
  36.                 'list',
  37.                 array(
  38.                     'conditions' => array(
  39.                         'Customer.id' => $idCustomer
  40.                     )
  41.                 )
  42.             );
  43.         }  
  44.  
  45.         $products = $this->ProductDetail->Product->find('list');
  46.         $this->set(compact('customers', 'products'));
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment