@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | if (count($resposta) < 1) { |
| 32 | 32 | $this->Session->setFlash('Ocorreu um erro ao logar na sua conta, verifique seus dados!'); |
| 33 | - return $this->redirect('/home/login'); |
|
| 33 | + return $this->redirect('/home/login'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | //faz o foreach com o array de dados do usuario |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $this->Session->setFlash('Bem vindo, '.$this->Session->read('Usuario.nome').'!'); |
| 49 | - return $this->redirect('/dashboard/home'); |
|
| 49 | + return $this->redirect('/dashboard/home'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function processar_logout() { |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | if(!$retorno) { |
| 194 | 194 | $this->Session->setFlash('Ocorreu um erro ao salvar as novas infomações, tente novamente!'); |
| 195 | 195 | |
| 196 | - return $this->redirect('/usuario/meus_dados'); |
|
| 196 | + return $this->redirect('/usuario/meus_dados'); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $this->Session->setFlash('Dados atualizados com sucesso!'); |
| 200 | 200 | |
| 201 | - return $this->redirect('/usuario/meus_dados'); |
|
| 201 | + return $this->redirect('/usuario/meus_dados'); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | public function meus_dados() { |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | ) |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - $this->set('modulos', $this->modulos); |
|
| 217 | - $this->set('usuario', $dadosUsuario); |
|
| 216 | + $this->set('modulos', $this->modulos); |
|
| 217 | + $this->set('usuario', $dadosUsuario); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | public function new_token() { |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class UsuarioController extends AppController{ |
|
| 4 | - public function beforeFilter(){ |
|
| 3 | +class UsuarioController extends AppController { |
|
| 4 | + public function beforeFilter() { |
|
| 5 | 5 | return true; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | //faz o login no sistema, com a função autentica_email |
| 9 | - public function login(){ |
|
| 10 | - $this->layout = 'ajax';//chama o layout para executar uma função ajax |
|
| 9 | + public function login() { |
|
| 10 | + $this->layout = 'ajax'; //chama o layout para executar uma função ajax |
|
| 11 | 11 | |
| 12 | - $login_email = $this->request->data['email'];//recebe o post email |
|
| 13 | - $login_senha = $this->request->data['senha'];//recebe o post senha |
|
| 12 | + $login_email = $this->request->data['email']; //recebe o post email |
|
| 13 | + $login_senha = $this->request->data['senha']; //recebe o post senha |
|
| 14 | 14 | echo json_encode(true); |
| 15 | 15 | } |
| 16 | 16 | |
@@ -34,15 +34,15 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | //faz o foreach com o array de dados do usuario |
| 37 | - foreach($resposta as $valor) { |
|
| 37 | + foreach ($resposta as $valor) { |
|
| 38 | 38 | //escreve a sessao do usuario |
| 39 | - $this->Session->write('Usuario.id', $valor['Usuario']['id']); |
|
| 40 | - $this->Session->write('Usuario.nome', $valor['Usuario']['nome']);//nome do usuario |
|
| 41 | - $this->Session->write('Usuario.email',$valor['Usuario']['email']);//email do usuario |
|
| 42 | - $this->Session->write('Usuario.senha',$valor['Usuario']['senha']);//senha do usuario criptografada |
|
| 43 | - $this->Session->write('Usuario.erp', $valor['Usuario']['erp']);//situacao ativa(1) ou nao(0) no erp |
|
| 44 | - $this->Session->write('Usuario.ead', $valor['Usuario']['ead']);//situacao ativa(1) ou nao(0) no ead |
|
| 45 | - $this->Session->write('Usuario.site', $valor['Usuario']['site']);//situacao ativa(1) ou nao(0) no site |
|
| 39 | + $this->Session->write('Usuario.id', $valor['Usuario']['id']); |
|
| 40 | + $this->Session->write('Usuario.nome', $valor['Usuario']['nome']); //nome do usuario |
|
| 41 | + $this->Session->write('Usuario.email', $valor['Usuario']['email']); //email do usuario |
|
| 42 | + $this->Session->write('Usuario.senha', $valor['Usuario']['senha']); //senha do usuario criptografada |
|
| 43 | + $this->Session->write('Usuario.erp', $valor['Usuario']['erp']); //situacao ativa(1) ou nao(0) no erp |
|
| 44 | + $this->Session->write('Usuario.ead', $valor['Usuario']['ead']); //situacao ativa(1) ou nao(0) no ead |
|
| 45 | + $this->Session->write('Usuario.site', $valor['Usuario']['site']); //situacao ativa(1) ou nao(0) no site |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $this->Session->setFlash('Bem vindo, '.$this->Session->read('Usuario.nome').'!'); |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | return $this->redirect('/home/login'); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function logout(){ |
|
| 57 | + public function logout() { |
|
| 58 | 58 | $this->Session->Destroy(); |
| 59 | 59 | |
| 60 | 60 | echo '<script>location.href="/winners/framework/"</script>'; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | //autentica email verifica se o email e senha existem para efetuar o login, ou outra acao. |
| 64 | - public function autentica_email($email,$senha){ |
|
| 64 | + public function autentica_email($email, $senha) { |
|
| 65 | 65 | $this->loadModel('Usuario'); |
| 66 | 66 | $resposta = $this->Usuario->find('count', |
| 67 | 67 | array('conditions' => array('AND' => array('Usuario.email' => $email, 'Usuario.senha' => sha1($senha)) |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //se o email estiver livre retorna false, senão retorna true |
| 77 | - public function verificar_email($email){ |
|
| 77 | + public function verificar_email($email) { |
|
| 78 | 78 | $this->layout = 'ajax'; |
| 79 | 79 | |
| 80 | - if(empty($email)){ |
|
| 80 | + if (empty($email)) { |
|
| 81 | 81 | $email = $this->request->data['email']; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | ); |
| 88 | 88 | $this->set('resposta', $resposta); |
| 89 | 89 | |
| 90 | - if($resposta >= 1){ |
|
| 90 | + if ($resposta >= 1) { |
|
| 91 | 91 | return true; |
| 92 | - }else{ |
|
| 92 | + } else { |
|
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function recuperar_dados($email,$senha){ |
|
| 97 | + public function recuperar_dados($email, $senha) { |
|
| 98 | 98 | $this->loadModel('Usuario'); |
| 99 | 99 | $resposta = $this->Usuario->find('all', |
| 100 | 100 | array('conditions' => array('AND' => array('Usuario.email' => $email, 'Usuario.senha' => sha1($senha)) |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public function notificar_cadastro($nome, $email) { |
| 144 | 144 | $headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]. |
| 145 | 145 | $headers .= "Reply-To: $email_address"; |
| 146 | - mail('[email protected], [email protected], [email protected], [email protected]', 'Notificação de cadastro', 'O usuario ' . $nome . ' email ' . $email . ' ', $headers); |
|
| 146 | + mail('[email protected], [email protected], [email protected], [email protected]', 'Notificação de cadastro', 'O usuario '.$nome.' email '.$email.' ', $headers); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public function relacionar_modulos_teste($id) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $retorno = $this->Usuario->save(array('estoque_minimo' => $estoque_minimo)); |
| 192 | 192 | |
| 193 | - if(!$retorno) { |
|
| 193 | + if ( ! $retorno) { |
|
| 194 | 194 | $this->Session->setFlash('Ocorreu um erro ao salvar as novas infomações, tente novamente!'); |
| 195 | 195 | |
| 196 | 196 | return $this->redirect('/usuario/meus_dados'); |
@@ -2,12 +2,12 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | ini_set('max_execution_time', 300); |
| 4 | 4 | |
| 5 | -require_once(ROOT . DS . 'vendor' . DS . 'autoload.php'); |
|
| 5 | +require_once(ROOT.DS.'vendor'.DS.'autoload.php'); |
|
| 6 | 6 | |
| 7 | 7 | use Dompdf\Dompdf; |
| 8 | 8 | |
| 9 | 9 | |
| 10 | -class ProdutoController extends AppController{ |
|
| 10 | +class ProdutoController extends AppController { |
|
| 11 | 11 | |
| 12 | 12 | public function listar_cadastros() { |
| 13 | 13 | $this->layout = 'wadmin'; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | public function listar_cadastros_ajax() { |
| 17 | 17 | $this->layout = 'ajax'; |
| 18 | 18 | |
| 19 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
| 19 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
| 20 | 20 | |
| 21 | 21 | $conditions = array('conditions' => |
| 22 | 22 | array( |
@@ -27,26 +27,26 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $allProdutos = $this->Produto->find('all', $conditions); |
| 29 | 29 | |
| 30 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 30 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 31 | 31 | { |
| 32 | 32 | $conditions['offset'] = $_GET['iDisplayStart']; |
| 33 | 33 | $conditions['limit'] = $_GET['iDisplayLength']; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 36 | + if (isset($_GET['iSortCol_0'])) |
|
| 37 | 37 | { |
| 38 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 38 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 39 | 39 | { |
| 40 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 40 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 41 | 41 | { |
| 42 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 42 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 47 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 48 | 48 | { |
| 49 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 49 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $produtos = $this->Produto->find('all', $conditions); |
@@ -58,19 +58,19 @@ discard block |
||
| 58 | 58 | "aaData" => array() |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | - foreach ( $produtos as $i => $produto ) |
|
| 61 | + foreach ($produtos as $i => $produto) |
|
| 62 | 62 | { |
| 63 | 63 | $row = array(); |
| 64 | 64 | |
| 65 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 65 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 66 | 66 | { |
| 67 | 67 | $value = $produto['Produto'][$aColumns[$i]]; |
| 68 | 68 | |
| 69 | 69 | if ($aColumns[$i] == "imagem") |
| 70 | 70 | { |
| 71 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
| 71 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
| 72 | 72 | |
| 73 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 73 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 74 | 74 | { |
| 75 | 75 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
| 76 | 76 | } |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | exit; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function listar_cadastros_estoque_minimo(){ |
|
| 89 | + public function listar_cadastros_estoque_minimo() { |
|
| 90 | 90 | $this->layout = 'wadmin'; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function listar_cadastros_estoque_minimo_ajax(){ |
|
| 93 | + public function listar_cadastros_estoque_minimo_ajax() { |
|
| 94 | 94 | |
| 95 | 95 | $this->layout = 'ajax'; |
| 96 | 96 | |
| 97 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
| 97 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
| 98 | 98 | |
| 99 | 99 | $this->loadModel('Usuario'); |
| 100 | 100 | |
@@ -116,26 +116,26 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $allProdutos = $this->Produto->find('all', $conditions); |
| 118 | 118 | |
| 119 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 119 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 120 | 120 | { |
| 121 | 121 | $conditions['offset'] = $_GET['iDisplayStart']; |
| 122 | 122 | $conditions['limit'] = $_GET['iDisplayLength']; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 125 | + if (isset($_GET['iSortCol_0'])) |
|
| 126 | 126 | { |
| 127 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 127 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 128 | 128 | { |
| 129 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 129 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 130 | 130 | { |
| 131 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 131 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 136 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 137 | 137 | { |
| 138 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 138 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $produtos = $this->Produto->find('all', $conditions); |
@@ -147,19 +147,19 @@ discard block |
||
| 147 | 147 | "aaData" => array() |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | - foreach ( $produtos as $i => $produto ) |
|
| 150 | + foreach ($produtos as $i => $produto) |
|
| 151 | 151 | { |
| 152 | 152 | $row = array(); |
| 153 | 153 | |
| 154 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 154 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 155 | 155 | { |
| 156 | 156 | $value = $produto['Produto'][$aColumns[$i]]; |
| 157 | 157 | |
| 158 | 158 | if ($aColumns[$i] == "imagem") |
| 159 | 159 | { |
| 160 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
| 160 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
| 161 | 161 | |
| 162 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 162 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 163 | 163 | { |
| 164 | 164 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
| 165 | 165 | } |
@@ -250,8 +250,8 @@ discard block |
||
| 250 | 250 | foreach ($produtos as $i => $produto) { |
| 251 | 251 | |
| 252 | 252 | $html .= ' <tr>'; |
| 253 | - $html .= ' <td>' . $produto['Produto']['nome'] . '</td>'; |
|
| 254 | - $html .= ' <td>' . $produto['Produto']['estoque'] . '</td>'; |
|
| 253 | + $html .= ' <td>'.$produto['Produto']['nome'].'</td>'; |
|
| 254 | + $html .= ' <td>'.$produto['Produto']['estoque'].'</td>'; |
|
| 255 | 255 | $html .= ' </tr>'; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -283,15 +283,15 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | public function s_adicionar_cadastro() { |
| 286 | - $dados = $this->request->data('dados'); |
|
| 286 | + $dados = $this->request->data('dados'); |
|
| 287 | 287 | |
| 288 | 288 | $variacoes = $this->request->data('variacao'); |
| 289 | 289 | |
| 290 | - $image = $_FILES['imagem']; |
|
| 290 | + $image = $_FILES['imagem']; |
|
| 291 | 291 | |
| 292 | 292 | $retorno = $this->uploadImage($image); |
| 293 | 293 | |
| 294 | - if (!$retorno['status']) |
|
| 294 | + if ( ! $retorno['status']) |
|
| 295 | 295 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 296 | 296 | |
| 297 | 297 | $dados['imagem'] = $retorno['nome']; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $dados['ativo'] = 1; |
| 300 | 300 | $dados['id_alias'] = $this->id_alias(); |
| 301 | 301 | |
| 302 | - if($this->Produto->save($dados)) { |
|
| 302 | + if ($this->Produto->save($dados)) { |
|
| 303 | 303 | $produto_id = $this->Produto->getLastInsertId(); |
| 304 | 304 | |
| 305 | 305 | require 'VariacaoController.php'; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | $this->loadModel('Variacao'); |
| 325 | 325 | |
| 326 | - $query = array ( |
|
| 326 | + $query = array( |
|
| 327 | 327 | 'joins' => array( |
| 328 | 328 | array( |
| 329 | 329 | 'table' => 'produtos', |
@@ -366,12 +366,12 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | $variacoes = $this->request->data('variacao'); |
| 368 | 368 | |
| 369 | - $image = $_FILES['imagem']; |
|
| 369 | + $image = $_FILES['imagem']; |
|
| 370 | 370 | |
| 371 | - if (!empty($image['name'])) { |
|
| 371 | + if ( ! empty($image['name'])) { |
|
| 372 | 372 | $retorno = $this->uploadImage($image); |
| 373 | 373 | |
| 374 | - if (!$retorno['status']) |
|
| 374 | + if ( ! $retorno['status']) |
|
| 375 | 375 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 376 | 376 | |
| 377 | 377 | $dados['imagem'] = $retorno['nome']; |
@@ -391,10 +391,10 @@ discard block |
||
| 391 | 391 | $objVariacaoController->desativar_variacoes($id); |
| 392 | 392 | $objVariacaoController->s_adicionar_variacao($variacoes, $id, $this->instancia); |
| 393 | 393 | |
| 394 | - $this->Session->setFlash('Produto editado com sucesso!','default','good'); |
|
| 394 | + $this->Session->setFlash('Produto editado com sucesso!', 'default', 'good'); |
|
| 395 | 395 | return $this->redirect('/produto/listar_cadastros'); |
| 396 | 396 | } else { |
| 397 | - $this->Session->setFlash('Ocorreu um erro ao editar o produto!','default','good'); |
|
| 397 | + $this->Session->setFlash('Ocorreu um erro ao editar o produto!', 'default', 'good'); |
|
| 398 | 398 | return $this->redirect('/produto/listar_cadastros'); |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | ) |
| 437 | 437 | ); |
| 438 | 438 | |
| 439 | - if (!$this->validar_estoque($retorno)) { |
|
| 439 | + if ( ! $this->validar_estoque($retorno)) { |
|
| 440 | 440 | return false; |
| 441 | 441 | } |
| 442 | 442 | |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | public function validar_estoque($produto) { |
| 451 | - if (empty($produto) && !isset($produto)) { |
|
| 451 | + if (empty($produto) && ! isset($produto)) { |
|
| 452 | 452 | return false; |
| 453 | 453 | } |
| 454 | 454 | |
@@ -460,11 +460,11 @@ discard block |
||
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | public function calcular_preco_produto_venda($preco, $qnt) { |
| 463 | - if (empty($preco) || !isset($preco)) { |
|
| 463 | + if (empty($preco) || ! isset($preco)) { |
|
| 464 | 464 | return false; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - if (!is_numeric($qnt)) { |
|
| 467 | + if ( ! is_numeric($qnt)) { |
|
| 468 | 468 | return false; |
| 469 | 469 | } |
| 470 | 470 | |
@@ -475,12 +475,12 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | public function uploadImage(&$image) { |
| 477 | 477 | $type = substr($image['name'], -4); |
| 478 | - $nameImage = uniqid() . md5($image['name']) . $type; |
|
| 479 | - $dir = APP . 'webroot/uploads/produto/imagens/'; |
|
| 478 | + $nameImage = uniqid().md5($image['name']).$type; |
|
| 479 | + $dir = APP.'webroot/uploads/produto/imagens/'; |
|
| 480 | 480 | |
| 481 | - $returnUpload = move_uploaded_file($image['tmp_name'], $dir . $nameImage); |
|
| 481 | + $returnUpload = move_uploaded_file($image['tmp_name'], $dir.$nameImage); |
|
| 482 | 482 | |
| 483 | - if (!$returnUpload) |
|
| 483 | + if ( ! $returnUpload) |
|
| 484 | 484 | return array('nome' => null, 'status' => false); |
| 485 | 485 | |
| 486 | 486 | return array('nome' => $nameImage, 'status' => true); |
@@ -506,8 +506,8 @@ discard block |
||
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | public function exportar_excel_exemplo() { |
| 509 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 510 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 509 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 510 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 511 | 511 | |
| 512 | 512 | $objPHPExcel = new PHPExcel(); |
| 513 | 513 | // Definimos o estilo da fonte |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | public function importar_produtos_planilha() { |
| 547 | - if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 547 | + if ( ! isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 548 | 548 | { |
| 549 | 549 | $this->Session->setFlash("Erro ao subir a planilha, tente novamente."); |
| 550 | 550 | $this->redirect("/produto/listar_cadastros"); |
@@ -552,13 +552,13 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | $typesPermissions = ['application/vnd.ms-excel']; |
| 554 | 554 | |
| 555 | - if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 555 | + if ( ! in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 556 | 556 | { |
| 557 | 557 | $this->Session->setFlash("O arquivo deve ser no formato .xls."); |
| 558 | 558 | $this->redirect("/produto/listar_cadastros"); |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | - $caminho = APP . 'webroot/uploads/produto/planilhas/' . uniqid() . '.xls'; |
|
| 561 | + $caminho = APP.'webroot/uploads/produto/planilhas/'.uniqid().'.xls'; |
|
| 562 | 562 | |
| 563 | 563 | $inputFileName = $_FILES['arquivo']['tmp_name']; |
| 564 | 564 | |
@@ -599,17 +599,17 @@ discard block |
||
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
| 602 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 603 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 602 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 603 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 604 | 604 | |
| 605 | 605 | $objPHPExcel = new PHPExcel(); |
| 606 | 606 | |
| 607 | 607 | try { |
| 608 | - $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 609 | - $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 610 | - $objPHPExcel = $objReader->load($inputFileName); |
|
| 611 | - } catch(Exception $e) { |
|
| 612 | - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
| 608 | + $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 609 | + $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 610 | + $objPHPExcel = $objReader->load($inputFileName); |
|
| 611 | + } catch (Exception $e) { |
|
| 612 | + die('Error loading file "'.pathinfo($inputFileName, PATHINFO_BASENAME).'": '.$e->getMessage()); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | $dados = []; |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | $errors = $this->processar_lista_produtos($dados); |
| 658 | 658 | |
| 659 | - if (isset($errors) && !empty($errors)) |
|
| 659 | + if (isset($errors) && ! empty($errors)) |
|
| 660 | 660 | { |
| 661 | 661 | $this->QueueProduct->planilhaProcessedIncomplete($planilhaId); |
| 662 | 662 | } |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | ) |
| 683 | 683 | ); |
| 684 | 684 | |
| 685 | - if (isset($existProduto) && !empty($existProduto)) |
|
| 685 | + if (isset($existProduto) && ! empty($existProduto)) |
|
| 686 | 686 | { |
| 687 | 687 | $this->Produto->id = $existProduto[0]['Produto']['id']; |
| 688 | 688 | $this->Produto->save($dado); |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | $this->Produto->create(); |
| 693 | 693 | |
| 694 | - if (!$this->Produto->save($dado)) |
|
| 694 | + if ( ! $this->Produto->save($dado)) |
|
| 695 | 695 | { |
| 696 | 696 | $errors[] = $dado; |
| 697 | 697 | } |