@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once(ROOT . DS . 'vendor' . DS . 'autoload.php'); |
|
| 3 | +require_once(ROOT.DS.'vendor'.DS.'autoload.php'); |
|
| 4 | 4 | |
| 5 | 5 | use Dompdf\Dompdf; |
| 6 | 6 | |
| 7 | -class ProdutoController extends AppController{ |
|
| 7 | +class ProdutoController extends AppController { |
|
| 8 | 8 | |
| 9 | 9 | public function listar_cadastros() { |
| 10 | 10 | $this->layout = 'wadmin'; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | public function listar_cadastros_ajax() { |
| 14 | 14 | $this->layout = 'ajax'; |
| 15 | 15 | |
| 16 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
| 16 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
| 17 | 17 | |
| 18 | 18 | $conditions = array('conditions' => |
| 19 | 19 | array( |
@@ -24,26 +24,26 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $allProdutos = $this->Produto->find('all', $conditions); |
| 26 | 26 | |
| 27 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 27 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 28 | 28 | { |
| 29 | 29 | $conditions['offset'] = $_GET['iDisplayStart']; |
| 30 | 30 | $conditions['limit'] = $_GET['iDisplayLength']; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 33 | + if (isset($_GET['iSortCol_0'])) |
|
| 34 | 34 | { |
| 35 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 35 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 36 | 36 | { |
| 37 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 37 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 38 | 38 | { |
| 39 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 39 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 44 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 45 | 45 | { |
| 46 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 46 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $produtos = $this->Produto->find('all', $conditions); |
@@ -55,19 +55,19 @@ discard block |
||
| 55 | 55 | "aaData" => array() |
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | - foreach ( $produtos as $i => $produto ) |
|
| 58 | + foreach ($produtos as $i => $produto) |
|
| 59 | 59 | { |
| 60 | 60 | $row = array(); |
| 61 | 61 | |
| 62 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 62 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 63 | 63 | { |
| 64 | 64 | $value = $produto['Produto'][$aColumns[$i]]; |
| 65 | 65 | |
| 66 | 66 | if ($aColumns[$i] == "imagem") |
| 67 | 67 | { |
| 68 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
| 68 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
| 69 | 69 | |
| 70 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 70 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 71 | 71 | { |
| 72 | 72 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
| 73 | 73 | } |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | $row[] = $value; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $btEdit = '<a class="btn btn-info" href="/produto/editar_cadastro/' . $produto['Produto']['id'] . '"><i class="fa fa-pencil"></i></a>'; |
|
| 79 | + $btEdit = '<a class="btn btn-info" href="/produto/editar_cadastro/'.$produto['Produto']['id'].'"><i class="fa fa-pencil"></i></a>'; |
|
| 80 | 80 | |
| 81 | - $btImage = ' <a class="btn btn-primary" href="/produto/imagens/' . $produto['Produto']['id'] . '"><i class="fa fa-picture-o"></i></a>'; |
|
| 81 | + $btImage = ' <a class="btn btn-primary" href="/produto/imagens/'.$produto['Produto']['id'].'"><i class="fa fa-picture-o"></i></a>'; |
|
| 82 | 82 | |
| 83 | - $row[] = $btEdit . $btImage; |
|
| 83 | + $row[] = $btEdit.$btImage; |
|
| 84 | 84 | |
| 85 | 85 | $output['aaData'][] = $row; |
| 86 | 86 | } |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | $this->set('produto', $produto); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public function listar_cadastros_estoque_minimo(){ |
|
| 116 | + public function listar_cadastros_estoque_minimo() { |
|
| 117 | 117 | $this->layout = 'wadmin'; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public function listar_cadastros_estoque_minimo_ajax(){ |
|
| 120 | + public function listar_cadastros_estoque_minimo_ajax() { |
|
| 121 | 121 | |
| 122 | 122 | $this->layout = 'ajax'; |
| 123 | 123 | |
| 124 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
| 124 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
| 125 | 125 | |
| 126 | 126 | $this->loadModel('Usuario'); |
| 127 | 127 | |
@@ -143,30 +143,30 @@ discard block |
||
| 143 | 143 | ) |
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | - $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
| 146 | + $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
| 147 | 147 | |
| 148 | 148 | |
| 149 | - $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"; |
|
| 149 | + $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"; |
|
| 150 | 150 | |
| 151 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 151 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 152 | 152 | { |
| 153 | - $sql .= ' LIMIT ' . $_GET['iDisplayLength'] . ' OFFSET ' . $_GET['iDisplayStart']; |
|
| 153 | + $sql .= ' LIMIT '.$_GET['iDisplayLength'].' OFFSET '.$_GET['iDisplayStart']; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 156 | + if (isset($_GET['iSortCol_0'])) |
|
| 157 | 157 | { |
| 158 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 158 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 159 | 159 | { |
| 160 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 160 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 161 | 161 | { |
| 162 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 162 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 167 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 168 | 168 | { |
| 169 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 169 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $produtos = $this->Produto->query($sql); |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | "aaData" => array() |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - foreach ( $produtos as $i => $produto ) |
|
| 181 | + foreach ($produtos as $i => $produto) |
|
| 182 | 182 | { |
| 183 | 183 | $row = array(); |
| 184 | 184 | |
| 185 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 185 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 186 | 186 | { |
| 187 | 187 | $value = $produto['Produto'][$aColumns[$i]]; |
| 188 | 188 | |
| 189 | 189 | if ($aColumns[$i] == "imagem") |
| 190 | 190 | { |
| 191 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
| 191 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
| 192 | 192 | |
| 193 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 193 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 194 | 194 | { |
| 195 | 195 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
| 196 | 196 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | ) |
| 231 | 231 | ); |
| 232 | 232 | |
| 233 | - $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
| 233 | + $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
| 234 | 234 | |
| 235 | 235 | $html = $this->getProdutosEstoqueMinimoComoHtml($produtos); |
| 236 | 236 | |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | foreach ($produtos as $i => $produto) { |
| 287 | 287 | $html .= ' <tr>'; |
| 288 | - $html .= ' <td>' . $produto['Produto']['nome'] . '</td>'; |
|
| 289 | - $html .= ' <td>' . $produto['Produto']['estoque'] . '</td>'; |
|
| 290 | - $html .= ' <td>R$ ' . number_format($produto['Produto']['custo'], 2, ',', '.') . '</td>'; |
|
| 288 | + $html .= ' <td>'.$produto['Produto']['nome'].'</td>'; |
|
| 289 | + $html .= ' <td>'.$produto['Produto']['estoque'].'</td>'; |
|
| 290 | + $html .= ' <td>R$ '.number_format($produto['Produto']['custo'], 2, ',', '.').'</td>'; |
|
| 291 | 291 | $html .= ' </tr>'; |
| 292 | 292 | } |
| 293 | 293 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $html .= ''; |
| 300 | 300 | $html .= '</body>'; |
| 301 | 301 | $html .= '</html>'; |
| 302 | - echo $html;exit; |
|
| 302 | + echo $html; exit; |
|
| 303 | 303 | return $html; |
| 304 | 304 | } |
| 305 | 305 | |
@@ -319,15 +319,15 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | public function s_adicionar_cadastro() { |
| 322 | - $dados = $this->request->data('dados'); |
|
| 322 | + $dados = $this->request->data('dados'); |
|
| 323 | 323 | |
| 324 | 324 | $variacoes = $this->request->data('variacao'); |
| 325 | 325 | |
| 326 | - $image = $_FILES['imagem']; |
|
| 326 | + $image = $_FILES['imagem']; |
|
| 327 | 327 | |
| 328 | 328 | $retorno = $this->uploadImage($image); |
| 329 | 329 | |
| 330 | - if (!$retorno['status']) |
|
| 330 | + if ( ! $retorno['status']) |
|
| 331 | 331 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 332 | 332 | |
| 333 | 333 | $dados['imagem'] = $retorno['nome']; |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $dados['id_alias'] = $this->id_alias(); |
| 337 | 337 | $dados['preco'] = str_replace(',', '', $dados['preco']); |
| 338 | 338 | |
| 339 | - if($this->Produto->save($dados)) { |
|
| 339 | + if ($this->Produto->save($dados)) { |
|
| 340 | 340 | $produto_id = $this->Produto->getLastInsertId(); |
| 341 | 341 | |
| 342 | 342 | require 'VariacaoController.php'; |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $objPluggTo = new PluggtoController(); |
| 352 | 352 | $produto_pluggto = $objPluggTo->enviar_produto($dados, $variacoes); |
| 353 | 353 | |
| 354 | - if (!isset($produto_pluggto->Product->id)) |
|
| 354 | + if ( ! isset($produto_pluggto->Product->id)) |
|
| 355 | 355 | { |
| 356 | 356 | $this->Session->setFlash('Produto não foi enviado para o Plugg.to!'); |
| 357 | 357 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | $this->loadModel('Variacao'); |
| 374 | 374 | |
| 375 | - $query = array ( |
|
| 375 | + $query = array( |
|
| 376 | 376 | 'joins' => array( |
| 377 | 377 | array( |
| 378 | 378 | 'table' => 'produtos', |
@@ -415,12 +415,12 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | $variacoes = $this->request->data('variacao'); |
| 417 | 417 | |
| 418 | - $image = $_FILES['imagem']; |
|
| 418 | + $image = $_FILES['imagem']; |
|
| 419 | 419 | |
| 420 | - if (!empty($image['name'])) { |
|
| 420 | + if ( ! empty($image['name'])) { |
|
| 421 | 421 | $retorno = $this->uploadImage($image); |
| 422 | 422 | |
| 423 | - if (!$retorno['status']) |
|
| 423 | + if ( ! $retorno['status']) |
|
| 424 | 424 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 425 | 425 | |
| 426 | 426 | $dados['imagem'] = $retorno['nome']; |
@@ -441,10 +441,10 @@ discard block |
||
| 441 | 441 | $objVariacaoController->desativar_variacoes($id); |
| 442 | 442 | $objVariacaoController->s_adicionar_variacao($variacoes, $id, $this->instancia); |
| 443 | 443 | |
| 444 | - $this->Session->setFlash('Produto editado com sucesso!','default','good'); |
|
| 444 | + $this->Session->setFlash('Produto editado com sucesso!', 'default', 'good'); |
|
| 445 | 445 | return $this->redirect('/produto/listar_cadastros'); |
| 446 | 446 | } else { |
| 447 | - $this->Session->setFlash('Ocorreu um erro ao editar o produto!','default','good'); |
|
| 447 | + $this->Session->setFlash('Ocorreu um erro ao editar o produto!', 'default', 'good'); |
|
| 448 | 448 | return $this->redirect('/produto/listar_cadastros'); |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | ) |
| 487 | 487 | ); |
| 488 | 488 | |
| 489 | - if (!$this->validar_estoque($retorno)) { |
|
| 489 | + if ( ! $this->validar_estoque($retorno)) { |
|
| 490 | 490 | return false; |
| 491 | 491 | } |
| 492 | 492 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | if ($user_active[0]['Usuario']['sale_without_stock']) |
| 517 | 517 | return true; |
| 518 | 518 | |
| 519 | - if (empty($produto) && !isset($produto)) { |
|
| 519 | + if (empty($produto) && ! isset($produto)) { |
|
| 520 | 520 | return false; |
| 521 | 521 | } |
| 522 | 522 | |
@@ -528,11 +528,11 @@ discard block |
||
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | public function calcular_preco_produto_venda($preco, $qnt) { |
| 531 | - if (empty($preco) || !isset($preco)) { |
|
| 531 | + if (empty($preco) || ! isset($preco)) { |
|
| 532 | 532 | return false; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - if (!is_numeric($qnt)) { |
|
| 535 | + if ( ! is_numeric($qnt)) { |
|
| 536 | 536 | return false; |
| 537 | 537 | } |
| 538 | 538 | |
@@ -543,12 +543,12 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | public function uploadImage(&$image) { |
| 545 | 545 | $type = substr($image['name'], -4); |
| 546 | - $nameImage = uniqid() . md5($image['name']) . $type; |
|
| 547 | - $dir = APP . 'webroot/uploads/produto/imagens/'; |
|
| 546 | + $nameImage = uniqid().md5($image['name']).$type; |
|
| 547 | + $dir = APP.'webroot/uploads/produto/imagens/'; |
|
| 548 | 548 | |
| 549 | - $returnUpload = move_uploaded_file($image['tmp_name'], $dir . $nameImage); |
|
| 549 | + $returnUpload = move_uploaded_file($image['tmp_name'], $dir.$nameImage); |
|
| 550 | 550 | |
| 551 | - if (!$returnUpload) |
|
| 551 | + if ( ! $returnUpload) |
|
| 552 | 552 | return array('nome' => null, 'status' => false); |
| 553 | 553 | |
| 554 | 554 | return array('nome' => $nameImage, 'status' => true); |
@@ -574,8 +574,8 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | public function exportar_excel_exemplo() { |
| 577 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 578 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 577 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 578 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 579 | 579 | |
| 580 | 580 | $objPHPExcel = new PHPExcel(); |
| 581 | 581 | // Definimos o estilo da fonte |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | public function importar_produtos_planilha() { |
| 615 | - if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 615 | + if ( ! isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 616 | 616 | { |
| 617 | 617 | $this->Session->setFlash("Erro ao subir a planilha, tente novamente."); |
| 618 | 618 | $this->redirect("/produto/listar_cadastros"); |
@@ -620,13 +620,13 @@ discard block |
||
| 620 | 620 | |
| 621 | 621 | $typesPermissions = ['application/vnd.ms-excel']; |
| 622 | 622 | |
| 623 | - if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 623 | + if ( ! in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 624 | 624 | { |
| 625 | 625 | $this->Session->setFlash("O arquivo deve ser no formato .xls."); |
| 626 | 626 | $this->redirect("/produto/listar_cadastros"); |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - $caminho = APP . 'webroot/uploads/produto/planilhas/' . uniqid() . '.xls'; |
|
| 629 | + $caminho = APP.'webroot/uploads/produto/planilhas/'.uniqid().'.xls'; |
|
| 630 | 630 | |
| 631 | 631 | $inputFileName = $_FILES['arquivo']['tmp_name']; |
| 632 | 632 | |
@@ -667,17 +667,17 @@ discard block |
||
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
| 670 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 671 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 670 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 671 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 672 | 672 | |
| 673 | 673 | $objPHPExcel = new PHPExcel(); |
| 674 | 674 | |
| 675 | 675 | try { |
| 676 | - $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 677 | - $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 678 | - $objPHPExcel = $objReader->load($inputFileName); |
|
| 679 | - } catch(Exception $e) { |
|
| 680 | - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
| 676 | + $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 677 | + $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 678 | + $objPHPExcel = $objReader->load($inputFileName); |
|
| 679 | + } catch (Exception $e) { |
|
| 680 | + die('Error loading file "'.pathinfo($inputFileName, PATHINFO_BASENAME).'": '.$e->getMessage()); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | $dados = []; |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | $errors = $this->processar_lista_produtos($dados); |
| 726 | 726 | |
| 727 | - if (isset($errors) && !empty($errors)) |
|
| 727 | + if (isset($errors) && ! empty($errors)) |
|
| 728 | 728 | { |
| 729 | 729 | $this->QueueProduct->planilhaProcessedIncomplete($planilhaId); |
| 730 | 730 | } |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | ) |
| 751 | 751 | ); |
| 752 | 752 | |
| 753 | - if (isset($existProduto) && !empty($existProduto)) |
|
| 753 | + if (isset($existProduto) && ! empty($existProduto)) |
|
| 754 | 754 | { |
| 755 | 755 | $this->Produto->id = $existProduto[0]['Produto']['id']; |
| 756 | 756 | $this->Produto->save($dado); |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | |
| 760 | 760 | $this->Produto->create(); |
| 761 | 761 | |
| 762 | - if (!$this->Produto->save($dado)) |
|
| 762 | + if ( ! $this->Produto->save($dado)) |
|
| 763 | 763 | { |
| 764 | 764 | $errors[] = $dado; |
| 765 | 765 | } |
@@ -769,13 +769,13 @@ discard block |
||
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | public function salvar_imagem($id) { |
| 772 | - $image = $_FILES['arquivo']; |
|
| 772 | + $image = $_FILES['arquivo']; |
|
| 773 | 773 | |
| 774 | 774 | $retorno = $this->uploadImage($image); |
| 775 | 775 | |
| 776 | - if (!$retorno['status']) { |
|
| 776 | + if ( ! $retorno['status']) { |
|
| 777 | 777 | $this->Session->setFlash('A imagem não foi salva tente novamente ou contate o suporte!'); |
| 778 | - return $this->redirect('/produto/imagens/' . $id); |
|
| 778 | + return $this->redirect('/produto/imagens/'.$id); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | $photo = $this->request->data('photo'); |
@@ -794,13 +794,13 @@ discard block |
||
| 794 | 794 | |
| 795 | 795 | $retorno = $this->Imagen->save($data); |
| 796 | 796 | |
| 797 | - if (!$retorno) { |
|
| 797 | + if ( ! $retorno) { |
|
| 798 | 798 | $this->Session->setFlash('A imagem não foi salva tente novamente ou contate o suporte!'); |
| 799 | - return $this->redirect('/produto/imagens/' . $id); |
|
| 799 | + return $this->redirect('/produto/imagens/'.$id); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | $this->Session->setFlash('A salva com sucesso!'); |
| 803 | - return $this->redirect('/produto/imagens/' . $id); |
|
| 803 | + return $this->redirect('/produto/imagens/'.$id); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | public function imagem_excluir_cadastro($id) { |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | public $belongsTo = array( |
| 6 | 6 | 'Usuario' => array( |
| 7 | - 'className' => 'Usuario' , |
|
| 7 | + 'className' => 'Usuario', |
|
| 8 | 8 | 'foreignKey' => 'usuario_id' |
| 9 | 9 | ), |
| 10 | 10 | 'Produto' => array( |
| 11 | - 'className' => 'Produto' , |
|
| 11 | + 'className' => 'Produto', |
|
| 12 | 12 | 'foreignKey' => 'produto_id' |
| 13 | 13 | ) |
| 14 | 14 | ); |