public function editarproductosAction() { if (!$this->_hasParam('id')) { return $this->_redirect('/administrador/listarproductos'); } $form = new Application_Form_Agregarproducto(); $publi = new Application_Model_DbTable_CartaProductos(); if ($this->getRequest()->isPost()) { if ($form->isValid($this->_getAllParams())) { $model = new Application_Model_DbTable_CartaProductos(); /* Traer Datos desde Formulario */ $nombre = $form->getValue('nombre'); $descripcion = $form->getValue('descripcion'); $tipo = $form->getValue('id_tipo_producto'); $precio = $form->getValue('precio'); $puntos = $form->getValue('puntos_producto'); $nueva_imagen = $form->getValue('element'); if ($nueva_imagen != NULL) { $imagen = strtolower($nueva_imagen); $upload = new Zend_File_Transfer_Adapter_Http(); $upload->setDestination(APPLICATION_PATH . '/../public/images/carta/'); $upload->addFilter('rename', array('target' => APPLICATION_PATH . '/../public/images/carta/' . $imagen, 'overwrite' => true)); try { $upload->receive(); } catch (Zend_File_Transfer_Exception $e) { $e->getMessage(); } } else { $imagen = $form->getValue('imagen'); } $model->editarproductos($nombre, $descripcion, $tipo, $precio, $puntos, $imagen, $this->_getParam('id')); // echo '<script type="text/javascript">alert("El Producto : ' . $nombre . 'a sido editado");</script>'; return $this->_redirect('/administrador/listarproductos/'); } } else { $row = $publi->obtenerRow($this->_getParam('id')); if ($row) { $form->populate($row->toArray()); } } $this->view->form = $form; }