Session->setFlash(__('Invalid Item.', true)); $this->redirect(array('controller' => 'accounts', 'action'=>'index')); } // Get the UnitSize and related fields $this->UnitSize->id = $id; $size = $this->UnitSize->find ('first', array ('contain' => array('UnitType'), 'fields' => array('UnitSize.*', 'UnitType.*', 'ROUND(UnitSize.width/12, 1) AS width', 'ROUND(UnitSize.depth/12, 1) AS depth', 'ROUND(UnitSize.height/12, 1) AS height', 'ROUND(UnitSize.width/12 * UnitSize.depth/12, 0) AS sqft', 'ROUND(UnitSize.width/12 * UnitSize.depth/12 * UnitSize.height/12, 0) AS cuft'), )); $size['UnitSize'] = $size[0] + $size['UnitSize']; unset($size[0]); $this->set(compact('size')); $this->set('stats', $this->UnitSize->stats($id)); // Prepare to render. $title = "Unit Size : {$size['UnitSize']['name']}"; $this->set(compact('title')); } /************************************************************************** ************************************************************************** ************************************************************************** * action: edit * - Edit unit_size information */ function edit($id = null) { $this->INTERNAL_ERROR('NOT READY'); if (isset($this->data)) { // Check to see if the operation was cancelled. if (isset($this->params['form']['cancel'])) { if (empty($this->data['UnitSize']['id'])) $this->redirect(array('action'=>'index')); $this->redirect(array('action'=>'view', $this->data['UnitSize']['id'])); } // Make sure we have unit_size data if (empty($this->data['UnitSize']) || empty($this->data['UnitSize']['id'])) $this->redirect(array('action'=>'index')); // Save the unit_size and all associated data $this->UnitSize->create(); $this->UnitSize->id = $this->data['UnitSize']['id']; if (!$this->UnitSize->save($this->data, false)) { $this->Session->setFlash("UNIT_SIZE SAVE FAILED", true); pr("UNIT_SIZE SAVE FAILED"); } $this->redirect(array('action'=>'view', $this->UnitSize->id)); } if ($id) { $this->data = $this->UnitSize->findById($id); } else { $this->redirect(array('action'=>'index')); } // Prepare to render. $title = ('UnitSize ' . $this->data['UnitSize']['name'] . " : Edit"); $this->set(compact('title')); } }