@@ -308,58 +308,58 @@ |
||
| 308 | 308 | include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
| 309 | 309 | include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
| 310 | 310 | |
| 311 | - $objPHPExcel = new PHPExcel(); |
|
| 312 | - // Definimos o estilo da fonte |
|
| 313 | - $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
|
| 314 | - |
|
| 315 | - $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); |
|
| 316 | - |
|
| 317 | - // Criamos as colunas |
|
| 318 | - $objPHPExcel->setActiveSheetIndex(0) |
|
| 319 | - ->setCellValue('A1', "Valor Venda") |
|
| 320 | - ->setCellValue('B1', "Custo Médio ") |
|
| 321 | - ->setCellValue("C1", "Valor Lucro") |
|
| 322 | - ->setCellValue('D1', "ID Venda" ); |
|
| 323 | - |
|
| 324 | - |
|
| 325 | - $vendas = $this->Venda->find('all', |
|
| 326 | - array('conditions' => array( |
|
| 327 | - 'AND' => array( |
|
| 328 | - 'Venda.ativo' => 1, |
|
| 329 | - 'Venda.id_usuario' => $this->instancia, |
|
| 330 | - 'Venda.data_venda' => date('Y-m-d') |
|
| 331 | - ) |
|
| 332 | - ) |
|
| 333 | - ) |
|
| 334 | - ); |
|
| 335 | - |
|
| 336 | - $i = 2; |
|
| 337 | - foreach ($vendas as $key => $venda) { |
|
| 338 | - $objPHPExcel->setActiveSheetIndex(0) |
|
| 339 | - ->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor']) |
|
| 340 | - ->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo']) |
|
| 341 | - ->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
| 342 | - ->setCellValue('D'.$i, $venda['Venda']['id']); |
|
| 343 | - $i++; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas |
|
| 347 | - $objPHPExcel->getActiveSheet()->setTitle('Listagem de vendas'); |
|
| 348 | - |
|
| 349 | - // Cabeçalho do arquivo para ele baixar |
|
| 350 | - header('Content-Type: application/vnd.ms-excel'); |
|
| 351 | - header('Content-Disposition: attachment;filename="relatorio_vendas_'.date('d-m-Y').'.xls"'); |
|
| 352 | - header('Cache-Control: max-age=0'); |
|
| 353 | - // Se for o IE9, isso talvez seja necessário |
|
| 354 | - header('Cache-Control: max-age=1'); |
|
| 355 | - |
|
| 356 | - // Acessamos o 'Writer' para poder salvar o arquivo |
|
| 357 | - $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); |
|
| 358 | - |
|
| 359 | - // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela |
|
| 360 | - $objWriter->save('php://output'); |
|
| 361 | - |
|
| 362 | - exit; |
|
| 311 | + $objPHPExcel = new PHPExcel(); |
|
| 312 | + // Definimos o estilo da fonte |
|
| 313 | + $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
|
| 314 | + |
|
| 315 | + $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); |
|
| 316 | + |
|
| 317 | + // Criamos as colunas |
|
| 318 | + $objPHPExcel->setActiveSheetIndex(0) |
|
| 319 | + ->setCellValue('A1', "Valor Venda") |
|
| 320 | + ->setCellValue('B1', "Custo Médio ") |
|
| 321 | + ->setCellValue("C1", "Valor Lucro") |
|
| 322 | + ->setCellValue('D1', "ID Venda" ); |
|
| 323 | + |
|
| 324 | + |
|
| 325 | + $vendas = $this->Venda->find('all', |
|
| 326 | + array('conditions' => array( |
|
| 327 | + 'AND' => array( |
|
| 328 | + 'Venda.ativo' => 1, |
|
| 329 | + 'Venda.id_usuario' => $this->instancia, |
|
| 330 | + 'Venda.data_venda' => date('Y-m-d') |
|
| 331 | + ) |
|
| 332 | + ) |
|
| 333 | + ) |
|
| 334 | + ); |
|
| 335 | + |
|
| 336 | + $i = 2; |
|
| 337 | + foreach ($vendas as $key => $venda) { |
|
| 338 | + $objPHPExcel->setActiveSheetIndex(0) |
|
| 339 | + ->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor']) |
|
| 340 | + ->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo']) |
|
| 341 | + ->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
| 342 | + ->setCellValue('D'.$i, $venda['Venda']['id']); |
|
| 343 | + $i++; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas |
|
| 347 | + $objPHPExcel->getActiveSheet()->setTitle('Listagem de vendas'); |
|
| 348 | + |
|
| 349 | + // Cabeçalho do arquivo para ele baixar |
|
| 350 | + header('Content-Type: application/vnd.ms-excel'); |
|
| 351 | + header('Content-Disposition: attachment;filename="relatorio_vendas_'.date('d-m-Y').'.xls"'); |
|
| 352 | + header('Cache-Control: max-age=0'); |
|
| 353 | + // Se for o IE9, isso talvez seja necessário |
|
| 354 | + header('Cache-Control: max-age=1'); |
|
| 355 | + |
|
| 356 | + // Acessamos o 'Writer' para poder salvar o arquivo |
|
| 357 | + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); |
|
| 358 | + |
|
| 359 | + // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela |
|
| 360 | + $objWriter->save('php://output'); |
|
| 361 | + |
|
| 362 | + exit; |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | public function recoverDataToDashboardOneWeek($id_usuario){ |
@@ -1,6 +1,6 @@ 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 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | if ($produto[0]['Produto']['estoque'] <= 0) |
| 178 | 178 | { |
| 179 | - $this->Session->setFlash('O produto (' . $produto[0]['Produto']['nome'] .') não tem mais estoque disponivel!'); |
|
| 179 | + $this->Session->setFlash('O produto ('.$produto[0]['Produto']['nome'].') não tem mais estoque disponivel!'); |
|
| 180 | 180 | continue; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | public function s_adicionar_cadastro() { |
| 196 | - $dados_venda = $this->request->data('venda'); |
|
| 196 | + $dados_venda = $this->request->data('venda'); |
|
| 197 | 197 | $dados_lancamento = $this->request->data('lancamento'); |
| 198 | - $produtos = $this->request->data('produto'); |
|
| 198 | + $produtos = $this->request->data('produto'); |
|
| 199 | 199 | |
| 200 | - if (!$this->validar_itens_venda($produtos) && !$dados_venda['orcamento']) { |
|
| 200 | + if ( ! $this->validar_itens_venda($produtos) && ! $dados_venda['orcamento']) { |
|
| 201 | 201 | $this->Session->setFlash('Algum produto adicionado não possui estoque disponivel'); |
| 202 | 202 | $this->redirect('/venda/adicionar_cadastro'); |
| 203 | 203 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $salvar_venda = $this->salvar_venda($produtos, $dados_lancamento, $dados_venda); |
| 209 | 209 | |
| 210 | - if (!$salvar_venda) { |
|
| 210 | + if ( ! $salvar_venda) { |
|
| 211 | 211 | $this->Session->setFlash('Ocorreu um erro ao salvar a venda tente novamento'); |
| 212 | 212 | $this->redirect('/venda/adicionar_cadastro'); |
| 213 | 213 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | $objProdutoEstoqueController = new ProdutoEstoqueController(); |
| 266 | 266 | |
| 267 | - if (!$objProdutoEstoqueController->validar_estoque($produto, $item['quantidade'])) { |
|
| 267 | + if ( ! $objProdutoEstoqueController->validar_estoque($produto, $item['quantidade'])) { |
|
| 268 | 268 | return false; |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $informacoes['valor'] = $informacoes['valor'] - $informacoes['desconto']; |
| 283 | 283 | $informacoes['orcamento'] = @$informacoes['orcamento']; |
| 284 | 284 | |
| 285 | - if (!$this->Venda->save($informacoes)) { |
|
| 285 | + if ( ! $this->Venda->save($informacoes)) { |
|
| 286 | 286 | $this->Session->setFlash('Ocorreu algum erro ao salvar a venda'); |
| 287 | 287 | return false; |
| 288 | 288 | } |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | public function relatorio_diario() { |
| 308 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 309 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 308 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 309 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 310 | 310 | |
| 311 | 311 | $objPHPExcel = new PHPExcel(); |
| 312 | 312 | // Definimos o estilo da fonte |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | ->setCellValue('A1', "Valor Venda") |
| 320 | 320 | ->setCellValue('B1', "Custo Médio ") |
| 321 | 321 | ->setCellValue("C1", "Valor Lucro") |
| 322 | - ->setCellValue('D1', "ID Venda" ); |
|
| 322 | + ->setCellValue('D1', "ID Venda"); |
|
| 323 | 323 | |
| 324 | 324 | |
| 325 | 325 | $vendas = $this->Venda->find('all', |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | $i = 2; |
| 337 | 337 | foreach ($vendas as $key => $venda) { |
| 338 | 338 | $objPHPExcel->setActiveSheetIndex(0) |
| 339 | - ->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor']) |
|
| 340 | - ->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo']) |
|
| 341 | - ->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
| 339 | + ->setCellValue('A'.$i, 'R$ '.$venda['Venda']['valor']) |
|
| 340 | + ->setCellValue('B'.$i, 'R$ '.$venda['Venda']['custo']) |
|
| 341 | + ->setCellValue('C'.$i, 'R$ '.$venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
| 342 | 342 | ->setCellValue('D'.$i, $venda['Venda']['id']); |
| 343 | 343 | $i++; |
| 344 | 344 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | exit; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - public function recoverDataToDashboardOneWeek($id_usuario){ |
|
| 365 | + public function recoverDataToDashboardOneWeek($id_usuario) { |
|
| 366 | 366 | $vendas = $this->Venda->find('all', |
| 367 | 367 | array('conditions' => |
| 368 | 368 | array( |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | $ImpressaoFiscalController->userName = $usuario['Usuario']['nome']; |
| 430 | 430 | |
| 431 | - $ImpressaoFiscalController->corpoTxt .= "Valor: R$ " . number_format($dados_venda['Venda']['valor'], 2, ',', '.') . "\n\n"; |
|
| 431 | + $ImpressaoFiscalController->corpoTxt .= "Valor: R$ ".number_format($dados_venda['Venda']['valor'], 2, ',', '.')."\n\n"; |
|
| 432 | 432 | |
| 433 | 433 | $dados_lancamento = $this->LancamentoVenda->find('first', |
| 434 | 434 | array('conditions' => |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | ) |
| 440 | 440 | ); |
| 441 | 441 | |
| 442 | - $ImpressaoFiscalController->corpoTxt .= "Forma de Pagamento: " . $dados_lancamento['LancamentoVenda']['forma_pagamento'] . "\n\n"; |
|
| 442 | + $ImpressaoFiscalController->corpoTxt .= "Forma de Pagamento: ".$dados_lancamento['LancamentoVenda']['forma_pagamento']."\n\n"; |
|
| 443 | 443 | |
| 444 | 444 | $produtos = $this->VendaItensProduto->find('all', |
| 445 | 445 | array('conditions' => |
@@ -460,10 +460,10 @@ discard block |
||
| 460 | 460 | $total = $produto['Produto']['preco'] * $item['VendaItensProduto']['quantidade_produto']; |
| 461 | 461 | |
| 462 | 462 | $ImpressaoFiscalController->corpoTxt .= "" |
| 463 | - . "Produto: " . $produto['Produto']['nome'] |
|
| 464 | - . "\nQuantidade: " . $item['VendaItensProduto']['quantidade_produto'] |
|
| 465 | - . "\nPreço: R$ " . number_format($produto['Produto']['preco'], 2, ',', '.') |
|
| 466 | - . "\nTotal: R$ " . number_format($total, 2, ',', '.') |
|
| 463 | + . "Produto: ".$produto['Produto']['nome'] |
|
| 464 | + . "\nQuantidade: ".$item['VendaItensProduto']['quantidade_produto'] |
|
| 465 | + . "\nPreço: R$ ".number_format($produto['Produto']['preco'], 2, ',', '.') |
|
| 466 | + . "\nTotal: R$ ".number_format($total, 2, ',', '.') |
|
| 467 | 467 | . "\n--------------------------\n"; |
| 468 | 468 | } |
| 469 | 469 | |
@@ -507,14 +507,14 @@ discard block |
||
| 507 | 507 | $lancamentos = array(); |
| 508 | 508 | |
| 509 | 509 | foreach ($vendas as $i => $venda) { |
| 510 | - $lancamento = $this->LancamentoVenda->find('first', array( |
|
| 510 | + $lancamento = $this->LancamentoVenda->find('first', array( |
|
| 511 | 511 | 'conditions' => array( |
| 512 | 512 | 'LancamentoVenda.venda_id' => $venda['Venda']['id'] |
| 513 | 513 | ) |
| 514 | 514 | ) |
| 515 | 515 | ); |
| 516 | 516 | |
| 517 | - if (!empty($lancamento)) |
|
| 517 | + if ( ! empty($lancamento)) |
|
| 518 | 518 | $lancamentos[] = $lancamento; |
| 519 | 519 | } |
| 520 | 520 | |
@@ -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,7 +76,7 @@ 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 | 81 | $row[] = $btEdit; |
| 82 | 82 | |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | exit; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function listar_cadastros_estoque_minimo(){ |
|
| 90 | + public function listar_cadastros_estoque_minimo() { |
|
| 91 | 91 | $this->layout = 'wadmin'; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function listar_cadastros_estoque_minimo_ajax(){ |
|
| 94 | + public function listar_cadastros_estoque_minimo_ajax() { |
|
| 95 | 95 | |
| 96 | 96 | $this->layout = 'ajax'; |
| 97 | 97 | |
| 98 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
| 98 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
| 99 | 99 | |
| 100 | 100 | $this->loadModel('Usuario'); |
| 101 | 101 | |
@@ -117,30 +117,30 @@ discard block |
||
| 117 | 117 | ) |
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | - $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
| 120 | + $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | - $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"; |
|
| 123 | + $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"; |
|
| 124 | 124 | |
| 125 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 125 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 126 | 126 | { |
| 127 | - $sql .= ' LIMIT ' . $_GET['iDisplayLength'] . ' OFFSET ' . $_GET['iDisplayStart']; |
|
| 127 | + $sql .= ' LIMIT '.$_GET['iDisplayLength'].' OFFSET '.$_GET['iDisplayStart']; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 130 | + if (isset($_GET['iSortCol_0'])) |
|
| 131 | 131 | { |
| 132 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 132 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 133 | 133 | { |
| 134 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 134 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 135 | 135 | { |
| 136 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 136 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 141 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 142 | 142 | { |
| 143 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 143 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $produtos = $this->Produto->query($sql); |
@@ -152,19 +152,19 @@ discard block |
||
| 152 | 152 | "aaData" => array() |
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - foreach ( $produtos as $i => $produto ) |
|
| 155 | + foreach ($produtos as $i => $produto) |
|
| 156 | 156 | { |
| 157 | 157 | $row = array(); |
| 158 | 158 | |
| 159 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 159 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 160 | 160 | { |
| 161 | 161 | $value = $produto['Produto'][$aColumns[$i]]; |
| 162 | 162 | |
| 163 | 163 | if ($aColumns[$i] == "imagem") |
| 164 | 164 | { |
| 165 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
| 165 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
| 166 | 166 | |
| 167 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 167 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 168 | 168 | { |
| 169 | 169 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
| 170 | 170 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | ) |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | - $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
| 207 | + $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
| 208 | 208 | |
| 209 | 209 | $html = $this->getProdutosEstoqueMinimoComoHtml($produtos); |
| 210 | 210 | |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | foreach ($produtos as $i => $produto) { |
| 261 | 261 | $html .= ' <tr>'; |
| 262 | - $html .= ' <td>' . $produto['Produto']['nome'] . '</td>'; |
|
| 263 | - $html .= ' <td>' . $produto['Produto']['estoque'] . '</td>'; |
|
| 264 | - $html .= ' <td>R$ ' . number_format($produto['Produto']['custo'], 2, ',', '.') . '</td>'; |
|
| 262 | + $html .= ' <td>'.$produto['Produto']['nome'].'</td>'; |
|
| 263 | + $html .= ' <td>'.$produto['Produto']['estoque'].'</td>'; |
|
| 264 | + $html .= ' <td>R$ '.number_format($produto['Produto']['custo'], 2, ',', '.').'</td>'; |
|
| 265 | 265 | $html .= ' </tr>'; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | $html .= ''; |
| 274 | 274 | $html .= '</body>'; |
| 275 | 275 | $html .= '</html>'; |
| 276 | - echo $html;exit; |
|
| 276 | + echo $html; exit; |
|
| 277 | 277 | return $html; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -293,15 +293,15 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | public function s_adicionar_cadastro() { |
| 296 | - $dados = $this->request->data('dados'); |
|
| 296 | + $dados = $this->request->data('dados'); |
|
| 297 | 297 | |
| 298 | 298 | $variacoes = $this->request->data('variacao'); |
| 299 | 299 | |
| 300 | - $image = $_FILES['imagem']; |
|
| 300 | + $image = $_FILES['imagem']; |
|
| 301 | 301 | |
| 302 | 302 | $retorno = $this->uploadImage($image); |
| 303 | 303 | |
| 304 | - if (!$retorno['status']) |
|
| 304 | + if ( ! $retorno['status']) |
|
| 305 | 305 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 306 | 306 | |
| 307 | 307 | $dados['imagem'] = $retorno['nome']; |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | $dados['id_alias'] = $this->id_alias(); |
| 311 | 311 | $dados['preco'] = str_replace(',', '', $dados['preco']); |
| 312 | 312 | |
| 313 | - if($this->Produto->save($dados)) { |
|
| 313 | + if ($this->Produto->save($dados)) { |
|
| 314 | 314 | $produto_id = $this->Produto->getLastInsertId(); |
| 315 | 315 | |
| 316 | 316 | require 'VariacaoController.php'; |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $objPluggTo = new PluggtoController(); |
| 326 | 326 | $produto_pluggto = $objPluggTo->enviar_produto($dados, $variacoes); |
| 327 | 327 | |
| 328 | - if (!isset($produto_pluggto->Product->id)) |
|
| 328 | + if ( ! isset($produto_pluggto->Product->id)) |
|
| 329 | 329 | { |
| 330 | 330 | $this->Session->setFlash('Produto não foi enviado para o Plugg.to!'); |
| 331 | 331 | } |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $this->loadModel('Variacao'); |
| 348 | 348 | |
| 349 | - $query = array ( |
|
| 349 | + $query = array( |
|
| 350 | 350 | 'joins' => array( |
| 351 | 351 | array( |
| 352 | 352 | 'table' => 'produtos', |
@@ -389,12 +389,12 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | $variacoes = $this->request->data('variacao'); |
| 391 | 391 | |
| 392 | - $image = $_FILES['imagem']; |
|
| 392 | + $image = $_FILES['imagem']; |
|
| 393 | 393 | |
| 394 | - if (!empty($image['name'])) { |
|
| 394 | + if ( ! empty($image['name'])) { |
|
| 395 | 395 | $retorno = $this->uploadImage($image); |
| 396 | 396 | |
| 397 | - if (!$retorno['status']) |
|
| 397 | + if ( ! $retorno['status']) |
|
| 398 | 398 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 399 | 399 | |
| 400 | 400 | $dados['imagem'] = $retorno['nome']; |
@@ -415,10 +415,10 @@ discard block |
||
| 415 | 415 | $objVariacaoController->desativar_variacoes($id); |
| 416 | 416 | $objVariacaoController->s_adicionar_variacao($variacoes, $id, $this->instancia); |
| 417 | 417 | |
| 418 | - $this->Session->setFlash('Produto editado com sucesso!','default','good'); |
|
| 418 | + $this->Session->setFlash('Produto editado com sucesso!', 'default', 'good'); |
|
| 419 | 419 | return $this->redirect('/produto/listar_cadastros'); |
| 420 | 420 | } else { |
| 421 | - $this->Session->setFlash('Ocorreu um erro ao editar o produto!','default','good'); |
|
| 421 | + $this->Session->setFlash('Ocorreu um erro ao editar o produto!', 'default', 'good'); |
|
| 422 | 422 | return $this->redirect('/produto/listar_cadastros'); |
| 423 | 423 | } |
| 424 | 424 | } |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | ) |
| 461 | 461 | ); |
| 462 | 462 | |
| 463 | - if (!$this->validar_estoque($retorno)) { |
|
| 463 | + if ( ! $this->validar_estoque($retorno)) { |
|
| 464 | 464 | return false; |
| 465 | 465 | } |
| 466 | 466 | |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | if ($user_active[0]['Usuario']['sale_without_stock']) |
| 491 | 491 | return true; |
| 492 | 492 | |
| 493 | - if (empty($produto) && !isset($produto)) { |
|
| 493 | + if (empty($produto) && ! isset($produto)) { |
|
| 494 | 494 | return false; |
| 495 | 495 | } |
| 496 | 496 | |
@@ -502,11 +502,11 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | public function calcular_preco_produto_venda($preco, $qnt) { |
| 505 | - if (empty($preco) || !isset($preco)) { |
|
| 505 | + if (empty($preco) || ! isset($preco)) { |
|
| 506 | 506 | return false; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - if (!is_numeric($qnt)) { |
|
| 509 | + if ( ! is_numeric($qnt)) { |
|
| 510 | 510 | return false; |
| 511 | 511 | } |
| 512 | 512 | |
@@ -517,12 +517,12 @@ discard block |
||
| 517 | 517 | |
| 518 | 518 | public function uploadImage(&$image) { |
| 519 | 519 | $type = substr($image['name'], -4); |
| 520 | - $nameImage = uniqid() . md5($image['name']) . $type; |
|
| 521 | - $dir = APP . 'webroot/uploads/produto/imagens/'; |
|
| 520 | + $nameImage = uniqid().md5($image['name']).$type; |
|
| 521 | + $dir = APP.'webroot/uploads/produto/imagens/'; |
|
| 522 | 522 | |
| 523 | - $returnUpload = move_uploaded_file($image['tmp_name'], $dir . $nameImage); |
|
| 523 | + $returnUpload = move_uploaded_file($image['tmp_name'], $dir.$nameImage); |
|
| 524 | 524 | |
| 525 | - if (!$returnUpload) |
|
| 525 | + if ( ! $returnUpload) |
|
| 526 | 526 | return array('nome' => null, 'status' => false); |
| 527 | 527 | |
| 528 | 528 | return array('nome' => $nameImage, 'status' => true); |
@@ -548,8 +548,8 @@ discard block |
||
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | public function exportar_excel_exemplo() { |
| 551 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 552 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 551 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 552 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 553 | 553 | |
| 554 | 554 | $objPHPExcel = new PHPExcel(); |
| 555 | 555 | // Definimos o estilo da fonte |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | public function importar_produtos_planilha() { |
| 589 | - if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 589 | + if ( ! isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 590 | 590 | { |
| 591 | 591 | $this->Session->setFlash("Erro ao subir a planilha, tente novamente."); |
| 592 | 592 | $this->redirect("/produto/listar_cadastros"); |
@@ -594,13 +594,13 @@ discard block |
||
| 594 | 594 | |
| 595 | 595 | $typesPermissions = ['application/vnd.ms-excel']; |
| 596 | 596 | |
| 597 | - if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 597 | + if ( ! in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 598 | 598 | { |
| 599 | 599 | $this->Session->setFlash("O arquivo deve ser no formato .xls."); |
| 600 | 600 | $this->redirect("/produto/listar_cadastros"); |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - $caminho = APP . 'webroot/uploads/produto/planilhas/' . uniqid() . '.xls'; |
|
| 603 | + $caminho = APP.'webroot/uploads/produto/planilhas/'.uniqid().'.xls'; |
|
| 604 | 604 | |
| 605 | 605 | $inputFileName = $_FILES['arquivo']['tmp_name']; |
| 606 | 606 | |
@@ -641,17 +641,17 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
| 644 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 645 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 644 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 645 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 646 | 646 | |
| 647 | 647 | $objPHPExcel = new PHPExcel(); |
| 648 | 648 | |
| 649 | 649 | try { |
| 650 | - $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 651 | - $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 652 | - $objPHPExcel = $objReader->load($inputFileName); |
|
| 653 | - } catch(Exception $e) { |
|
| 654 | - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
| 650 | + $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 651 | + $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 652 | + $objPHPExcel = $objReader->load($inputFileName); |
|
| 653 | + } catch (Exception $e) { |
|
| 654 | + die('Error loading file "'.pathinfo($inputFileName, PATHINFO_BASENAME).'": '.$e->getMessage()); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | $dados = []; |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | $errors = $this->processar_lista_produtos($dados); |
| 700 | 700 | |
| 701 | - if (isset($errors) && !empty($errors)) |
|
| 701 | + if (isset($errors) && ! empty($errors)) |
|
| 702 | 702 | { |
| 703 | 703 | $this->QueueProduct->planilhaProcessedIncomplete($planilhaId); |
| 704 | 704 | } |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | ) |
| 725 | 725 | ); |
| 726 | 726 | |
| 727 | - if (isset($existProduto) && !empty($existProduto)) |
|
| 727 | + if (isset($existProduto) && ! empty($existProduto)) |
|
| 728 | 728 | { |
| 729 | 729 | $this->Produto->id = $existProduto[0]['Produto']['id']; |
| 730 | 730 | $this->Produto->save($dado); |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | |
| 734 | 734 | $this->Produto->create(); |
| 735 | 735 | |
| 736 | - if (!$this->Produto->save($dado)) |
|
| 736 | + if ( ! $this->Produto->save($dado)) |
|
| 737 | 737 | { |
| 738 | 738 | $errors[] = $dado; |
| 739 | 739 | } |