public function deleteAction() { $this->_disableRender(); if ($this->getRequest()->getParam('all')) { $json = new ZendT_Json_Result(); try { if (!$this->getRequest()->getParam('confirmacao')) { $form = new ZendT_Form(); $form->setAction(ZendT_Url::getUri()); $params = $this->getRequest()->getParams(); $params['confirmacao'] = '1'; foreach ($params as $key => $val) { $element = new ZendT_Form_Element_Hidden($key); $element->setValue($val); $form->addElement($element); } $msg = "Deseja remover todas as notificações?"; throw new ZendT_Exception_Confirm($msg . $form->render()); } else { if (Auth_Session_User::getInstance()->authenticated()) { $this->getMapper()->setIdUsuario(Zend_Auth::getInstance()->getStorage()->read()->getId())->delete(); } $json->setResult(true); } } catch (Exception $ex) { $json->setException($ex); } echo $json->render(); } else { parent::deleteAction(); } }
public function changePasswordAction() { $this->_disableRender(); $this->setLayout(ZendT_Controller_Action::LAYOUT_AJAX); $_result = new ZendT_Json_Result(); $user = $this->getRequest()->getParam('user'); $pass = $this->getRequest()->getParam('pass'); $newPass = $this->getRequest()->getParam('new_pass'); try { $message = $this->_mapper->changePassword($user, $pass, $newPass); $_result->setResult(array('message' => _i18n('Senha alterada com sucesso!'))); } catch (Exception $ex) { $_result->setException($ex); } echo $_result->render(); }
public function mirrorAction() { $this->_disableRender(); $_json = new ZendT_Json_Result(); try { $adapter = $this->getRequest()->getParam('adapter'); $adapterMirror = $this->getRequest()->getParam('adapter_mirror'); $table = $this->getRequest()->getParam('table'); $where = $this->getRequest()->getParam('where'); $_table = new Sync_Model_Table(); $result = $_table->mirror($table, $adapter, $adapterMirror, $where); $_json->setResult('Sincronizado!'); } catch (Exception $ex) { $_json->setException($ex); } echo $_json->render(); }
public function retrieveAction() { //parent::retrieveAction(); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $json = new ZendT_Json_Result(); try { $row = $this->_retrieve(); $this->_setConfig($row); if (!$row) { $row = array('found' => false); } $json->setResult($row); } catch (Exception $Ex) { $json->setException($Ex); } echo $json->render(); }
public function cancelarAction() { $this->_disableRender(true, true); $idPedido = $this->getRequest()->getParam('id'); $_json = new ZendT_Json_Result(); $this->getModel()->getAdapter()->beginTransaction(); try { if (!$idPedido) { throw new ZendT_Exception_Alert(_i18n('Necessário informar um pedido')); } $this->getMapper()->setId($idPedido)->retrieve()->cancelar(); $this->getModel()->getAdapter()->commit(); $_json->setResult(array('ok' => 1)); } catch (Exception $ex) { $_json->setException($ex); $this->getModel()->getAdapter()->rollBack(); } echo $_json->render(); }
protected function _quote() { $this->_disableRender(); $fields = $this->getRequest()->getParam('fields'); $values = $this->getRequest()->getParam('values'); $mapper = $this->getRequest()->getParam('mapper'); /** * @var Automacao_DataView_RegraAltoValor_MapperView */ $_mapper = new $mapper(); $columns = $_mapper->getColumns()->toArray(); $_json = new ZendT_Json_Result(); try { $result = array(); $result['values'] = array(); foreach ($fields as $index => $field) { if (stripos($values[$index], 'SELECT') !== false) { $result['values'][$index] = $values[$index]; } else { $data = explode(';', $values[$index]); $parseValue = ''; $column = $columns[strtolower($field)]; foreach ($data as $value) { $column['mapperName']->set($value); $value = $column['mapperName']->getValueToDb(); $value = $_mapper->getAdapter()->quote($value); $parseValue .= ',' . $value; } $result['values'][$index] = substr($parseValue, 1); } } $_json->setResult($result); } catch (Exception $ex) { $_json->setException($ex); } echo $_json->render(); }
public function uploadImagemAction() { $file = $this->getRequest()->getParam('imagem'); if (!$file) { $this->_defineLayout(); #Zend_Layout::getMvcInstance()->setLayout('window'); $form = new Cms_Form_Conteudo_UploadImagem(); $form->loadElements(); $this->view->form = $form->render(); } else { $this->_disableRender(); $json = new ZendT_Json_Result(); try { $size = $this->getRequest()->getParam('tamanho'); $_conteudo = new Cms_Model_Conteudo_Imagem(); $_fileSystem = new Ged_Model_Arquivo_FileSystem(); if (!$file['file']) { throw new ZendT_Exception_Alert("Favor selecionar um arquivo!"); } $files = array(); $files['file'] = explode(',', $file['file']); $files['type'] = explode(',', $file['type']); $files['name'] = explode(',', $file['name']); $url = array(); for ($i = 0; $i < count($files['file']); $i++) { $file['file'] = $files['file'][$i]; $file['type'] = $files['type'][$i]; $file['name'] = $files['name'][$i]; $_conteudo->setImage($file, $size); $id = $_conteudo->getImage()->getValueToDb(); $url[] = $_fileSystem->getDirectoryAdress($id); } $json->setResult(array('url' => $url)); } catch (Exception $ex) { $json->setException($ex); } echo $json->render(); } }
public function existsFieldAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $json = new ZendT_Json_Result(); try { $param = $this->getRequest()->getParams(); if ($param['id']) { $count = $this->getMapper()->getCountPrivilege($param['id']); } } catch (Exception $Ex) { $json->setException($Ex); } $json->setResult(array("count" => $count)); echo $json->render(); }
public function deleteAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $json = new ZendT_Json_Result(); try { $filename = $this->getRequest()->getParam('filename'); $decode = $this->getRequest()->getParam('decode'); $files = explode(',', $filename); foreach ($files as $hashName) { if ($decode) { $file = base64_decode($hashName); if (file_exists($file)) { unlink($file); } } else { $file = ZendT_File::fromFilenameCrypt($hashName); $file->delete(); } } $id = $this->getRequest()->getParam('id'); if (!$id) { $id = 1; } $json->setResult(array('id' => $id)); } catch (Exception $Ex) { $json->setException($Ex); } echo $json->render(); }