@@ -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 | } |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | if ($aColumns[$i] == "preco") |
| 77 | 77 | { |
| 78 | - $value = 'R$ ' . number_format($value, 2, ',', '.'); |
|
| 78 | + $value = 'R$ '.number_format($value, 2, ',', '.'); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $row[] = $value; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $btEdit = '<a class="btn btn-info" href="/produto/editar_cadastro/' . $produto['Produto']['id'] . '"><i class="fa fa-pencil"></i></a>'; |
|
| 84 | + $btEdit = '<a class="btn btn-info" href="/produto/editar_cadastro/'.$produto['Produto']['id'].'"><i class="fa fa-pencil"></i></a>'; |
|
| 85 | 85 | |
| 86 | - $btMove = '<a class="btn btn-primary" href="/produto/movimentacoes_estoque/' . $produto['Produto']['id'] . '"><i class="fa fa-bars"></i></a>'; |
|
| 86 | + $btMove = '<a class="btn btn-primary" href="/produto/movimentacoes_estoque/'.$produto['Produto']['id'].'"><i class="fa fa-bars"></i></a>'; |
|
| 87 | 87 | |
| 88 | - $btImage = ' <a class="btn btn-primary" href="/produto/imagens/' . $produto['Produto']['id'] . '"><i class="fa fa-picture-o"></i></a>'; |
|
| 88 | + $btImage = ' <a class="btn btn-primary" href="/produto/imagens/'.$produto['Produto']['id'].'"><i class="fa fa-picture-o"></i></a>'; |
|
| 89 | 89 | |
| 90 | - $row[] = $btEdit . ' ' . $btMove . ' ' . $btImage; |
|
| 90 | + $row[] = $btEdit.' '.$btMove.' '.$btImage; |
|
| 91 | 91 | |
| 92 | 92 | $output['aaData'][] = $row; |
| 93 | 93 | } |
@@ -120,15 +120,15 @@ discard block |
||
| 120 | 120 | $this->set('produto', $produto); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function listar_cadastros_estoque_minimo(){ |
|
| 123 | + public function listar_cadastros_estoque_minimo() { |
|
| 124 | 124 | $this->layout = 'wadmin'; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - public function listar_cadastros_estoque_minimo_ajax(){ |
|
| 127 | + public function listar_cadastros_estoque_minimo_ajax() { |
|
| 128 | 128 | |
| 129 | 129 | $this->layout = 'ajax'; |
| 130 | 130 | |
| 131 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
| 131 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
| 132 | 132 | |
| 133 | 133 | $this->loadModel('Usuario'); |
| 134 | 134 | |
@@ -150,30 +150,30 @@ discard block |
||
| 150 | 150 | ) |
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | - $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
| 153 | + $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
| 154 | 154 | |
| 155 | 155 | |
| 156 | - $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"; |
|
| 156 | + $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"; |
|
| 157 | 157 | |
| 158 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 158 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 159 | 159 | { |
| 160 | - $sql .= ' LIMIT ' . $_GET['iDisplayLength'] . ' OFFSET ' . $_GET['iDisplayStart']; |
|
| 160 | + $sql .= ' LIMIT '.$_GET['iDisplayLength'].' OFFSET '.$_GET['iDisplayStart']; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 163 | + if (isset($_GET['iSortCol_0'])) |
|
| 164 | 164 | { |
| 165 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 165 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 166 | 166 | { |
| 167 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 167 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 168 | 168 | { |
| 169 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 169 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 174 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 175 | 175 | { |
| 176 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 176 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | $produtos = $this->Produto->query($sql); |
@@ -185,19 +185,19 @@ discard block |
||
| 185 | 185 | "aaData" => array() |
| 186 | 186 | ); |
| 187 | 187 | |
| 188 | - foreach ( $produtos as $i => $produto ) |
|
| 188 | + foreach ($produtos as $i => $produto) |
|
| 189 | 189 | { |
| 190 | 190 | $row = array(); |
| 191 | 191 | |
| 192 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 192 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 193 | 193 | { |
| 194 | 194 | $value = $produto['Produto'][$aColumns[$i]]; |
| 195 | 195 | |
| 196 | 196 | if ($aColumns[$i] == "imagem") |
| 197 | 197 | { |
| 198 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
| 198 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
| 199 | 199 | |
| 200 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 200 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 201 | 201 | { |
| 202 | 202 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
| 203 | 203 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | ) |
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | - $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
| 240 | + $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
| 241 | 241 | |
| 242 | 242 | $html = $this->getProdutosEstoqueMinimoComoHtml($produtos); |
| 243 | 243 | |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | foreach ($produtos as $i => $produto) { |
| 294 | 294 | $html .= ' <tr>'; |
| 295 | - $html .= ' <td>' . $produto['Produto']['nome'] . '</td>'; |
|
| 296 | - $html .= ' <td>' . $produto['Produto']['estoque'] . '</td>'; |
|
| 297 | - $html .= ' <td>R$ ' . number_format($produto['Produto']['custo'], 2, ',', '.') . '</td>'; |
|
| 295 | + $html .= ' <td>'.$produto['Produto']['nome'].'</td>'; |
|
| 296 | + $html .= ' <td>'.$produto['Produto']['estoque'].'</td>'; |
|
| 297 | + $html .= ' <td>R$ '.number_format($produto['Produto']['custo'], 2, ',', '.').'</td>'; |
|
| 298 | 298 | $html .= ' </tr>'; |
| 299 | 299 | } |
| 300 | 300 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $html .= ''; |
| 307 | 307 | $html .= '</body>'; |
| 308 | 308 | $html .= '</html>'; |
| 309 | - echo $html;exit; |
|
| 309 | + echo $html; exit; |
|
| 310 | 310 | return $html; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -326,15 +326,15 @@ discard block |
||
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | public function s_adicionar_cadastro() { |
| 329 | - $dados = $this->request->data('dados'); |
|
| 329 | + $dados = $this->request->data('dados'); |
|
| 330 | 330 | |
| 331 | 331 | $variacoes = $this->request->data('variacao'); |
| 332 | 332 | |
| 333 | - $image = $_FILES['imagem']; |
|
| 333 | + $image = $_FILES['imagem']; |
|
| 334 | 334 | |
| 335 | 335 | $retorno = $this->uploadImage($image); |
| 336 | 336 | |
| 337 | - if (!$retorno['status']) |
|
| 337 | + if ( ! $retorno['status']) |
|
| 338 | 338 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 339 | 339 | |
| 340 | 340 | $dados['imagem'] = $retorno['nome']; |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $dados['id_alias'] = $this->id_alias(); |
| 344 | 344 | $dados['preco'] = str_replace(',', '', $dados['preco']); |
| 345 | 345 | |
| 346 | - if($this->Produto->save($dados)) { |
|
| 346 | + if ($this->Produto->save($dados)) { |
|
| 347 | 347 | $produto_id = $this->Produto->getLastInsertId(); |
| 348 | 348 | |
| 349 | 349 | require 'VariacaoController.php'; |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | $objPluggTo = new PluggtoController(); |
| 359 | 359 | $produto_pluggto = $objPluggTo->enviar_produto($dados, $variacoes); |
| 360 | 360 | |
| 361 | - if (!isset($produto_pluggto->Product->id)) |
|
| 361 | + if ( ! isset($produto_pluggto->Product->id)) |
|
| 362 | 362 | { |
| 363 | 363 | $this->Session->setFlash('Produto não foi enviado para o Plugg.to!'); |
| 364 | 364 | } |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | $this->loadModel('Variacao'); |
| 381 | 381 | |
| 382 | - $query = array ( |
|
| 382 | + $query = array( |
|
| 383 | 383 | 'joins' => array( |
| 384 | 384 | array( |
| 385 | 385 | 'table' => 'produtos', |
@@ -422,12 +422,12 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | $variacoes = $this->request->data('variacao'); |
| 424 | 424 | |
| 425 | - $image = $_FILES['imagem']; |
|
| 425 | + $image = $_FILES['imagem']; |
|
| 426 | 426 | |
| 427 | - if (!empty($image['name'])) { |
|
| 427 | + if ( ! empty($image['name'])) { |
|
| 428 | 428 | $retorno = $this->uploadImage($image); |
| 429 | 429 | |
| 430 | - if (!$retorno['status']) |
|
| 430 | + if ( ! $retorno['status']) |
|
| 431 | 431 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 432 | 432 | |
| 433 | 433 | $dados['imagem'] = $retorno['nome']; |
@@ -448,10 +448,10 @@ discard block |
||
| 448 | 448 | $objVariacaoController->desativar_variacoes($id); |
| 449 | 449 | $objVariacaoController->s_adicionar_variacao($variacoes, $id, $this->instancia); |
| 450 | 450 | |
| 451 | - $this->Session->setFlash('Produto editado com sucesso!','default','good'); |
|
| 451 | + $this->Session->setFlash('Produto editado com sucesso!', 'default', 'good'); |
|
| 452 | 452 | return $this->redirect('/produto/listar_cadastros'); |
| 453 | 453 | } else { |
| 454 | - $this->Session->setFlash('Ocorreu um erro ao editar o produto!','default','good'); |
|
| 454 | + $this->Session->setFlash('Ocorreu um erro ao editar o produto!', 'default', 'good'); |
|
| 455 | 455 | return $this->redirect('/produto/listar_cadastros'); |
| 456 | 456 | } |
| 457 | 457 | } |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | ) |
| 494 | 494 | ); |
| 495 | 495 | |
| 496 | - if (!$this->validar_estoque($retorno)) { |
|
| 496 | + if ( ! $this->validar_estoque($retorno)) { |
|
| 497 | 497 | return false; |
| 498 | 498 | } |
| 499 | 499 | |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | if ($user_active[0]['Usuario']['sale_without_stock']) |
| 524 | 524 | return true; |
| 525 | 525 | |
| 526 | - if (empty($produto) && !isset($produto)) { |
|
| 526 | + if (empty($produto) && ! isset($produto)) { |
|
| 527 | 527 | return false; |
| 528 | 528 | } |
| 529 | 529 | |
@@ -535,11 +535,11 @@ discard block |
||
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | public function calcular_preco_produto_venda($preco, $qnt) { |
| 538 | - if (empty($preco) || !isset($preco)) { |
|
| 538 | + if (empty($preco) || ! isset($preco)) { |
|
| 539 | 539 | return false; |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - if (!is_numeric($qnt)) { |
|
| 542 | + if ( ! is_numeric($qnt)) { |
|
| 543 | 543 | return false; |
| 544 | 544 | } |
| 545 | 545 | |
@@ -550,12 +550,12 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | public function uploadImage(&$image) { |
| 552 | 552 | $type = substr($image['name'], -4); |
| 553 | - $nameImage = uniqid() . md5($image['name']) . $type; |
|
| 554 | - $dir = APP . 'webroot/uploads/produto/imagens/'; |
|
| 553 | + $nameImage = uniqid().md5($image['name']).$type; |
|
| 554 | + $dir = APP.'webroot/uploads/produto/imagens/'; |
|
| 555 | 555 | |
| 556 | - $returnUpload = move_uploaded_file($image['tmp_name'], $dir . $nameImage); |
|
| 556 | + $returnUpload = move_uploaded_file($image['tmp_name'], $dir.$nameImage); |
|
| 557 | 557 | |
| 558 | - if (!$returnUpload) |
|
| 558 | + if ( ! $returnUpload) |
|
| 559 | 559 | return array('nome' => null, 'status' => false); |
| 560 | 560 | |
| 561 | 561 | return array('nome' => $nameImage, 'status' => true); |
@@ -581,8 +581,8 @@ discard block |
||
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | public function exportar_excel_exemplo() { |
| 584 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 585 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 584 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 585 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 586 | 586 | |
| 587 | 587 | $objPHPExcel = new PHPExcel(); |
| 588 | 588 | // Definimos o estilo da fonte |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | public function importar_produtos_planilha() { |
| 622 | - if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 622 | + if ( ! isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 623 | 623 | { |
| 624 | 624 | $this->Session->setFlash("Erro ao subir a planilha, tente novamente."); |
| 625 | 625 | $this->redirect("/produto/listar_cadastros"); |
@@ -627,13 +627,13 @@ discard block |
||
| 627 | 627 | |
| 628 | 628 | $typesPermissions = ['application/vnd.ms-excel']; |
| 629 | 629 | |
| 630 | - if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 630 | + if ( ! in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 631 | 631 | { |
| 632 | 632 | $this->Session->setFlash("O arquivo deve ser no formato .xls."); |
| 633 | 633 | $this->redirect("/produto/listar_cadastros"); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - $caminho = APP . 'webroot/uploads/produto/planilhas/' . uniqid() . '.xls'; |
|
| 636 | + $caminho = APP.'webroot/uploads/produto/planilhas/'.uniqid().'.xls'; |
|
| 637 | 637 | |
| 638 | 638 | $inputFileName = $_FILES['arquivo']['tmp_name']; |
| 639 | 639 | |
@@ -674,17 +674,17 @@ discard block |
||
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
| 677 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 678 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 677 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 678 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 679 | 679 | |
| 680 | 680 | $objPHPExcel = new PHPExcel(); |
| 681 | 681 | |
| 682 | 682 | try { |
| 683 | - $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 684 | - $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 685 | - $objPHPExcel = $objReader->load($inputFileName); |
|
| 686 | - } catch(Exception $e) { |
|
| 687 | - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
| 683 | + $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 684 | + $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 685 | + $objPHPExcel = $objReader->load($inputFileName); |
|
| 686 | + } catch (Exception $e) { |
|
| 687 | + die('Error loading file "'.pathinfo($inputFileName, PATHINFO_BASENAME).'": '.$e->getMessage()); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | $dados = []; |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | |
| 732 | 732 | $errors = $this->processar_lista_produtos($dados); |
| 733 | 733 | |
| 734 | - if (isset($errors) && !empty($errors)) |
|
| 734 | + if (isset($errors) && ! empty($errors)) |
|
| 735 | 735 | { |
| 736 | 736 | $this->QueueProduct->planilhaProcessedIncomplete($planilhaId); |
| 737 | 737 | } |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | ) |
| 758 | 758 | ); |
| 759 | 759 | |
| 760 | - if (isset($existProduto) && !empty($existProduto)) |
|
| 760 | + if (isset($existProduto) && ! empty($existProduto)) |
|
| 761 | 761 | { |
| 762 | 762 | $this->Produto->id = $existProduto[0]['Produto']['id']; |
| 763 | 763 | $this->Produto->save($dado); |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | |
| 767 | 767 | $this->Produto->create(); |
| 768 | 768 | |
| 769 | - if (!$this->Produto->save($dado)) |
|
| 769 | + if ( ! $this->Produto->save($dado)) |
|
| 770 | 770 | { |
| 771 | 771 | $errors[] = $dado; |
| 772 | 772 | } |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | |
| 787 | 787 | $this->layout = 'ajax'; |
| 788 | 788 | |
| 789 | - $aColumns = array( 'id', 'produto_id', 'venda_id', 'quantidade_produto' ); |
|
| 789 | + $aColumns = array('id', 'produto_id', 'venda_id', 'quantidade_produto'); |
|
| 790 | 790 | |
| 791 | 791 | $conditions = array( |
| 792 | 792 | 'conditions' => array( |
@@ -808,26 +808,26 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | $allProdutos = $this->VendaItensProduto->find('all', $conditions); |
| 810 | 810 | |
| 811 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 811 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 812 | 812 | { |
| 813 | 813 | $conditions['offset'] = $_GET['iDisplayStart']; |
| 814 | 814 | $conditions['limit'] = $_GET['iDisplayLength']; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 817 | + if (isset($_GET['iSortCol_0'])) |
|
| 818 | 818 | { |
| 819 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 819 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 820 | 820 | { |
| 821 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 821 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 822 | 822 | { |
| 823 | - $conditions['order'] = array('VendaItensProduto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 823 | + $conditions['order'] = array('VendaItensProduto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 824 | 824 | } |
| 825 | 825 | } |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 828 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 829 | 829 | { |
| 830 | - $conditions['conditions']['VendaItensProduto.id LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 830 | + $conditions['conditions']['VendaItensProduto.id LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | $produtos = $this->VendaItensProduto->find('all', $conditions); |
@@ -839,11 +839,11 @@ discard block |
||
| 839 | 839 | "aaData" => array() |
| 840 | 840 | ); |
| 841 | 841 | |
| 842 | - foreach ( $produtos as $i => $produto ) |
|
| 842 | + foreach ($produtos as $i => $produto) |
|
| 843 | 843 | { |
| 844 | 844 | $row = array(); |
| 845 | 845 | |
| 846 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 846 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 847 | 847 | { |
| 848 | 848 | if ($aColumns[$i] == "produto_id") { |
| 849 | 849 | $value = $produto['Produto']['nome']; |
@@ -864,13 +864,13 @@ discard block |
||
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | public function salvar_imagem($id) { |
| 867 | - $image = $_FILES['arquivo']; |
|
| 867 | + $image = $_FILES['arquivo']; |
|
| 868 | 868 | |
| 869 | 869 | $retorno = $this->uploadImage($image); |
| 870 | 870 | |
| 871 | - if (!$retorno['status']) { |
|
| 871 | + if ( ! $retorno['status']) { |
|
| 872 | 872 | $this->Session->setFlash('A imagem não foi salva tente novamente ou contate o suporte!'); |
| 873 | - return $this->redirect('/produto/imagens/' . $id); |
|
| 873 | + return $this->redirect('/produto/imagens/'.$id); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | $photo = $this->request->data('photo'); |
@@ -889,13 +889,13 @@ discard block |
||
| 889 | 889 | |
| 890 | 890 | $retorno = $this->Imagen->save($data); |
| 891 | 891 | |
| 892 | - if (!$retorno) { |
|
| 892 | + if ( ! $retorno) { |
|
| 893 | 893 | $this->Session->setFlash('A imagem não foi salva tente novamente ou contate o suporte!'); |
| 894 | - return $this->redirect('/produto/imagens/' . $id); |
|
| 894 | + return $this->redirect('/produto/imagens/'.$id); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | $this->Session->setFlash('A salva com sucesso!'); |
| 898 | - return $this->redirect('/produto/imagens/' . $id); |
|
| 898 | + return $this->redirect('/produto/imagens/'.$id); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | public function imagem_excluir_cadastro($id) { |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | $search = strip_tags(trim($_GET['q'])); |
| 915 | 915 | |
| 916 | 916 | $conditions['limit'] = 10; |
| 917 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $search . '%'; |
|
| 917 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$search.'%'; |
|
| 918 | 918 | |
| 919 | 919 | $produtos = $this->Produto->find('all', $conditions); |
| 920 | 920 | |