@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | public function getProdutosEstoqueMinimoComoHtml($produtos) { |
| 256 | - ob_start(); |
|
| 256 | + ob_start(); |
|
| 257 | 257 | |
| 258 | 258 | $html = ''; |
| 259 | 259 | $html .= '<html>'; |
@@ -366,11 +366,11 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | $this->Session->setFlash('Produto salvo com sucesso!'); |
| 368 | 368 | |
| 369 | - return $this->redirect('/produto/listar_cadastros'); |
|
| 369 | + return $this->redirect('/produto/listar_cadastros'); |
|
| 370 | 370 | } else { |
| 371 | 371 | $this->Session->setFlash('Ocorreu um erro ao salva o produto!'); |
| 372 | 372 | |
| 373 | - return $this->redirect('/produto/listar_cadastros'); |
|
| 373 | + return $this->redirect('/produto/listar_cadastros'); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
@@ -381,17 +381,17 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | $query = array ( |
| 383 | 383 | 'joins' => array( |
| 384 | - array( |
|
| 385 | - 'table' => 'produtos', |
|
| 386 | - 'alias' => 'Produto', |
|
| 387 | - 'type' => 'LEFT', |
|
| 388 | - 'conditions' => array( |
|
| 389 | - 'Variacao.produto_id = Produto.id', |
|
| 390 | - ), |
|
| 391 | - ) |
|
| 384 | + array( |
|
| 385 | + 'table' => 'produtos', |
|
| 386 | + 'alias' => 'Produto', |
|
| 387 | + 'type' => 'LEFT', |
|
| 388 | + 'conditions' => array( |
|
| 389 | + 'Variacao.produto_id = Produto.id', |
|
| 390 | + ), |
|
| 391 | + ) |
|
| 392 | 392 | ), |
| 393 | - 'conditions' => array('Variacao.produto_id' => $id, 'Variacao.ativo' => 1), |
|
| 394 | - 'fields' => array('Produto.id, Variacao.*'), |
|
| 393 | + 'conditions' => array('Variacao.produto_id' => $id, 'Variacao.ativo' => 1), |
|
| 394 | + 'fields' => array('Produto.id, Variacao.*'), |
|
| 395 | 395 | ); |
| 396 | 396 | |
| 397 | 397 | $variacoes = $this->set('variacoes', $this->Variacao->find('all', $query)); |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | $objVariacaoController->s_adicionar_variacao($variacoes, $id, $this->instancia); |
| 450 | 450 | |
| 451 | 451 | $this->Session->setFlash('Produto editado com sucesso!','default','good'); |
| 452 | - return $this->redirect('/produto/listar_cadastros'); |
|
| 452 | + return $this->redirect('/produto/listar_cadastros'); |
|
| 453 | 453 | } else { |
| 454 | 454 | $this->Session->setFlash('Ocorreu um erro ao editar o produto!','default','good'); |
| 455 | - return $this->redirect('/produto/listar_cadastros'); |
|
| 455 | + return $this->redirect('/produto/listar_cadastros'); |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
@@ -584,107 +584,107 @@ discard block |
||
| 584 | 584 | include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
| 585 | 585 | include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
| 586 | 586 | |
| 587 | - $objPHPExcel = new PHPExcel(); |
|
| 588 | - // Definimos o estilo da fonte |
|
| 589 | - $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
|
| 587 | + $objPHPExcel = new PHPExcel(); |
|
| 588 | + // Definimos o estilo da fonte |
|
| 589 | + $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
|
| 590 | 590 | |
| 591 | - $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); |
|
| 591 | + $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); |
|
| 592 | 592 | |
| 593 | - // Criamos as colunas |
|
| 594 | - $objPHPExcel->setActiveSheetIndex(0) |
|
| 595 | - ->setCellValue('A1', "Nome do Produto") |
|
| 596 | - ->setCellValue('B1', "Preço ") |
|
| 597 | - ->setCellValue("C1", "Peso Bruto") |
|
| 598 | - ->setCellValue("D1", "Peso Liquido") |
|
| 599 | - ->setCellValue("E1", "Estoque") |
|
| 600 | - ->setCellValue("F1", "Descrição"); |
|
| 593 | + // Criamos as colunas |
|
| 594 | + $objPHPExcel->setActiveSheetIndex(0) |
|
| 595 | + ->setCellValue('A1', "Nome do Produto") |
|
| 596 | + ->setCellValue('B1', "Preço ") |
|
| 597 | + ->setCellValue("C1", "Peso Bruto") |
|
| 598 | + ->setCellValue("D1", "Peso Liquido") |
|
| 599 | + ->setCellValue("E1", "Estoque") |
|
| 600 | + ->setCellValue("F1", "Descrição"); |
|
| 601 | 601 | |
| 602 | - // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas |
|
| 603 | - $objPHPExcel->getActiveSheet()->setTitle('Listagem de produtos'); |
|
| 602 | + // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas |
|
| 603 | + $objPHPExcel->getActiveSheet()->setTitle('Listagem de produtos'); |
|
| 604 | 604 | |
| 605 | - // Cabeçalho do arquivo para ele baixar |
|
| 606 | - header('Content-Type: application/vnd.ms-excel'); |
|
| 607 | - header('Content-Disposition: attachment;filename="planilha_importacao_exemplo.xls"'); |
|
| 608 | - header('Cache-Control: max-age=0'); |
|
| 609 | - // Se for o IE9, isso talvez seja necessário |
|
| 610 | - header('Cache-Control: max-age=1'); |
|
| 605 | + // Cabeçalho do arquivo para ele baixar |
|
| 606 | + header('Content-Type: application/vnd.ms-excel'); |
|
| 607 | + header('Content-Disposition: attachment;filename="planilha_importacao_exemplo.xls"'); |
|
| 608 | + header('Cache-Control: max-age=0'); |
|
| 609 | + // Se for o IE9, isso talvez seja necessário |
|
| 610 | + header('Cache-Control: max-age=1'); |
|
| 611 | 611 | |
| 612 | - // Acessamos o 'Writer' para poder salvar o arquivo |
|
| 613 | - $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); |
|
| 612 | + // Acessamos o 'Writer' para poder salvar o arquivo |
|
| 613 | + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); |
|
| 614 | 614 | |
| 615 | - // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela |
|
| 616 | - $objWriter->save('php://output'); |
|
| 615 | + // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela |
|
| 616 | + $objWriter->save('php://output'); |
|
| 617 | 617 | |
| 618 | - exit; |
|
| 619 | - } |
|
| 618 | + exit; |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | - public function importar_produtos_planilha() { |
|
| 622 | - if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 623 | - { |
|
| 621 | + public function importar_produtos_planilha() { |
|
| 622 | + if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 623 | + { |
|
| 624 | 624 | $this->Session->setFlash("Erro ao subir a planilha, tente novamente."); |
| 625 | 625 | $this->redirect("/produto/listar_cadastros"); |
| 626 | - } |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - $typesPermissions = ['application/vnd.ms-excel']; |
|
| 628 | + $typesPermissions = ['application/vnd.ms-excel']; |
|
| 629 | 629 | |
| 630 | - if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 631 | - { |
|
| 630 | + if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 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 | - $inputFileName = $_FILES['arquivo']['tmp_name']; |
|
| 638 | + $inputFileName = $_FILES['arquivo']['tmp_name']; |
|
| 639 | 639 | |
| 640 | - move_uploaded_file($inputFileName, $caminho); |
|
| 640 | + move_uploaded_file($inputFileName, $caminho); |
|
| 641 | 641 | |
| 642 | - $data = [ |
|
| 643 | - 'caminho' => $caminho, |
|
| 644 | - 'usuario_id' => $this->instancia, |
|
| 645 | - 'processado' => 0, |
|
| 646 | - 'ativo' => 1 |
|
| 647 | - ]; |
|
| 642 | + $data = [ |
|
| 643 | + 'caminho' => $caminho, |
|
| 644 | + 'usuario_id' => $this->instancia, |
|
| 645 | + 'processado' => 0, |
|
| 646 | + 'ativo' => 1 |
|
| 647 | + ]; |
|
| 648 | 648 | |
| 649 | - $this->loadModel('QueueProduct'); |
|
| 649 | + $this->loadModel('QueueProduct'); |
|
| 650 | 650 | |
| 651 | - if ($this->QueueProduct->save($data)) |
|
| 652 | - { |
|
| 651 | + if ($this->QueueProduct->save($data)) |
|
| 652 | + { |
|
| 653 | 653 | $this->Session->setFlash("O arquivo está na fila para ser importado, iremos enviar um e-mail quando terminar."); |
| 654 | 654 | $this->redirect("/produto/listar_cadastros"); |
| 655 | - } |
|
| 656 | - else |
|
| 657 | - { |
|
| 655 | + } |
|
| 656 | + else |
|
| 657 | + { |
|
| 658 | 658 | $this->Session->setFlash("Ocorreu um erro, tente novamente."); |
| 659 | 659 | $this->redirect("/produto/listar_cadastros"); |
| 660 | - } |
|
| 661 | - } |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | 662 | |
| 663 | - public function processar_planilhas_na_fila() { |
|
| 664 | - $this->loadModel('QueueProduct'); |
|
| 663 | + public function processar_planilhas_na_fila() { |
|
| 664 | + $this->loadModel('QueueProduct'); |
|
| 665 | 665 | |
| 666 | - $planilhas = $this->QueueProduct->loadPlanilhasNotProcesseds(); |
|
| 666 | + $planilhas = $this->QueueProduct->loadPlanilhasNotProcesseds(); |
|
| 667 | 667 | |
| 668 | - $response = []; |
|
| 669 | - foreach ($planilhas as $planilha) { |
|
| 670 | - $response[] = $this->processar_planilhas($planilha['caminho'], $planilha['usuario_id'], $planilha['id']); |
|
| 671 | - } |
|
| 668 | + $response = []; |
|
| 669 | + foreach ($planilhas as $planilha) { |
|
| 670 | + $response[] = $this->processar_planilhas($planilha['caminho'], $planilha['usuario_id'], $planilha['id']); |
|
| 671 | + } |
|
| 672 | 672 | |
| 673 | - return $response; |
|
| 674 | - } |
|
| 673 | + return $response; |
|
| 674 | + } |
|
| 675 | 675 | |
| 676 | - public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
|
| 676 | + public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
|
| 677 | 677 | include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
| 678 | 678 | include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
| 679 | 679 | |
| 680 | - $objPHPExcel = new PHPExcel(); |
|
| 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); |
|
| 683 | + $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 684 | + $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 685 | + $objPHPExcel = $objReader->load($inputFileName); |
|
| 686 | 686 | } catch(Exception $e) { |
| 687 | - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
| 687 | + die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | $dados = []; |
@@ -740,46 +740,46 @@ discard block |
||
| 740 | 740 | |
| 741 | 741 | echo json_encode(array('sucess' => true)); |
| 742 | 742 | exit; |
| 743 | - } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - public function processar_lista_produtos($dados) { |
|
| 746 | - $errors = []; |
|
| 745 | + public function processar_lista_produtos($dados) { |
|
| 746 | + $errors = []; |
|
| 747 | 747 | |
| 748 | - foreach ($dados as $dado) { |
|
| 749 | - $this->loadModel('Produto'); |
|
| 748 | + foreach ($dados as $dado) { |
|
| 749 | + $this->loadModel('Produto'); |
|
| 750 | 750 | |
| 751 | - $existProduto = $this->Produto->find('all', |
|
| 752 | - array( |
|
| 753 | - 'conditions' => array( |
|
| 754 | - 'Produto.sku' => $dado['sku'], |
|
| 755 | - 'Produto.ativo' => 1 |
|
| 756 | - ) |
|
| 757 | - ) |
|
| 758 | - ); |
|
| 759 | - |
|
| 760 | - if (isset($existProduto) && !empty($existProduto)) |
|
| 761 | - { |
|
| 762 | - $this->Produto->id = $existProduto[0]['Produto']['id']; |
|
| 763 | - $this->Produto->save($dado); |
|
| 764 | - continue; |
|
| 765 | - } |
|
| 751 | + $existProduto = $this->Produto->find('all', |
|
| 752 | + array( |
|
| 753 | + 'conditions' => array( |
|
| 754 | + 'Produto.sku' => $dado['sku'], |
|
| 755 | + 'Produto.ativo' => 1 |
|
| 756 | + ) |
|
| 757 | + ) |
|
| 758 | + ); |
|
| 759 | + |
|
| 760 | + if (isset($existProduto) && !empty($existProduto)) |
|
| 761 | + { |
|
| 762 | + $this->Produto->id = $existProduto[0]['Produto']['id']; |
|
| 763 | + $this->Produto->save($dado); |
|
| 764 | + continue; |
|
| 765 | + } |
|
| 766 | 766 | |
| 767 | 767 | $this->Produto->create(); |
| 768 | 768 | |
| 769 | - if (!$this->Produto->save($dado)) |
|
| 770 | - { |
|
| 771 | - $errors[] = $dado; |
|
| 772 | - } |
|
| 773 | - } |
|
| 769 | + if (!$this->Produto->save($dado)) |
|
| 770 | + { |
|
| 771 | + $errors[] = $dado; |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | 774 | |
| 775 | - return $errors; |
|
| 776 | - } |
|
| 775 | + return $errors; |
|
| 776 | + } |
|
| 777 | 777 | |
| 778 | - public function movimentacoes_estoque($produtoId) { |
|
| 779 | - $this->layout = 'wadmin'; |
|
| 778 | + public function movimentacoes_estoque($produtoId) { |
|
| 779 | + $this->layout = 'wadmin'; |
|
| 780 | 780 | |
| 781 | - $this->set('id', $produtoId); |
|
| 782 | - } |
|
| 781 | + $this->set('id', $produtoId); |
|
| 782 | + } |
|
| 783 | 783 | |
| 784 | 784 | public function listar_cadastros_estoque_ajax($produtoId) { |
| 785 | 785 | $this->loadModel('VendaItensProduto'); |
@@ -794,16 +794,16 @@ discard block |
||
| 794 | 794 | 'VendaItensProduto.produto_id' => $produtoId |
| 795 | 795 | ), |
| 796 | 796 | 'joins' => array( |
| 797 | - array( |
|
| 798 | - 'table' => 'produtos', |
|
| 799 | - 'alias' => 'Produto', |
|
| 800 | - 'type' => 'LEFT', |
|
| 801 | - 'conditions' => array( |
|
| 802 | - 'VendaItensProduto.produto_id = Produto.id', |
|
| 803 | - ), |
|
| 804 | - ) |
|
| 797 | + array( |
|
| 798 | + 'table' => 'produtos', |
|
| 799 | + 'alias' => 'Produto', |
|
| 800 | + 'type' => 'LEFT', |
|
| 801 | + 'conditions' => array( |
|
| 802 | + 'VendaItensProduto.produto_id = Produto.id', |
|
| 803 | + ), |
|
| 804 | + ) |
|
| 805 | 805 | ), |
| 806 | - 'fields' => array('VendaItensProduto.*, Produto.*'), |
|
| 806 | + 'fields' => array('VendaItensProduto.*, Produto.*'), |
|
| 807 | 807 | ); |
| 808 | 808 | |
| 809 | 809 | $allProdutos = $this->VendaItensProduto->find('all', $conditions); |
@@ -863,14 +863,14 @@ discard block |
||
| 863 | 863 | exit; |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | - public function salvar_imagem($id) { |
|
| 866 | + public function salvar_imagem($id) { |
|
| 867 | 867 | $image = $_FILES['arquivo']; |
| 868 | 868 | |
| 869 | 869 | $retorno = $this->uploadImage($image); |
| 870 | 870 | |
| 871 | 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'); |
@@ -891,26 +891,26 @@ discard block |
||
| 891 | 891 | |
| 892 | 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); |
|
| 899 | - } |
|
| 898 | + return $this->redirect('/produto/imagens/' . $id); |
|
| 899 | + } |
|
| 900 | 900 | |
| 901 | - public function imagem_excluir_cadastro($id) { |
|
| 902 | - $this->loadModel('Imagen'); |
|
| 901 | + public function imagem_excluir_cadastro($id) { |
|
| 902 | + $this->loadModel('Imagen'); |
|
| 903 | 903 | |
| 904 | - $this->Imagen->id = $id; |
|
| 904 | + $this->Imagen->id = $id; |
|
| 905 | 905 | |
| 906 | - $this->Imagen->save(['ativo' => 0]); |
|
| 906 | + $this->Imagen->save(['ativo' => 0]); |
|
| 907 | 907 | |
| 908 | - echo json_encode(array('success' => true)); |
|
| 909 | - exit; |
|
| 910 | - } |
|
| 908 | + echo json_encode(array('success' => true)); |
|
| 909 | + exit; |
|
| 910 | + } |
|
| 911 | 911 | |
| 912 | - public function produto_item() |
|
| 913 | - { |
|
| 912 | + public function produto_item() |
|
| 913 | + { |
|
| 914 | 914 | $search = strip_tags(trim($_GET['q'])); |
| 915 | 915 | |
| 916 | 916 | $conditions['limit'] = 25; |
@@ -928,6 +928,6 @@ discard block |
||
| 928 | 928 | |
| 929 | 929 | echo json_encode($data); |
| 930 | 930 | exit; |
| 931 | - } |
|
| 931 | + } |
|
| 932 | 932 | |
| 933 | 933 | } |
@@ -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'] = 25; |
| 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 | |