@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | if (isset($value) && !empty($value)) |
137 | 137 | $value = ucwords($value); |
138 | 138 | } else if ($aColumns[$i] == "actions") { |
139 | - $value = '<a href="javascript:printNotaNaoFiscal(' . $venda['Venda']['id'] . ');" target="_blank" class="btn btn-info">'; |
|
140 | - $value .= '<i class="fa fa-file-text" aria-hidden="true"></i>'; |
|
141 | - $value .= '</a> '; |
|
139 | + $value = '<a href="javascript:printNotaNaoFiscal(' . $venda['Venda']['id'] . ');" target="_blank" class="btn btn-info">'; |
|
140 | + $value .= '<i class="fa fa-file-text" aria-hidden="true"></i>'; |
|
141 | + $value .= '</a> '; |
|
142 | 142 | |
143 | 143 | $value .= ' <button onclick="remover_venda(' . $venda['Venda']['id'] . ');" type="button" class="btn btn-danger"><i class="fa fa-times"></i></button>'; |
144 | 144 | } else if ($aColumns[$i] == "valor") { |
@@ -384,58 +384,58 @@ discard block |
||
384 | 384 | include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
385 | 385 | include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
386 | 386 | |
387 | - $objPHPExcel = new PHPExcel(); |
|
388 | - // Definimos o estilo da fonte |
|
389 | - $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
|
390 | - |
|
391 | - $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); |
|
392 | - |
|
393 | - // Criamos as colunas |
|
394 | - $objPHPExcel->setActiveSheetIndex(0) |
|
395 | - ->setCellValue('A1', "Valor Venda") |
|
396 | - ->setCellValue('B1', "Custo Médio ") |
|
397 | - ->setCellValue("C1", "Valor Lucro") |
|
398 | - ->setCellValue('D1', "ID Venda" ); |
|
399 | - |
|
400 | - |
|
401 | - $vendas = $this->Venda->find('all', |
|
402 | - array('conditions' => array( |
|
403 | - 'AND' => array( |
|
404 | - 'Venda.ativo' => 1, |
|
405 | - 'Venda.id_usuario' => $this->instancia, |
|
406 | - 'Venda.data_venda' => date('Y-m-d') |
|
407 | - ) |
|
408 | - ) |
|
409 | - ) |
|
410 | - ); |
|
411 | - |
|
412 | - $i = 2; |
|
413 | - foreach ($vendas as $key => $venda) { |
|
414 | - $objPHPExcel->setActiveSheetIndex(0) |
|
415 | - ->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor']) |
|
416 | - ->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo']) |
|
417 | - ->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
418 | - ->setCellValue('D'.$i, $venda['Venda']['id']); |
|
419 | - $i++; |
|
420 | - } |
|
421 | - |
|
422 | - // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas |
|
423 | - $objPHPExcel->getActiveSheet()->setTitle('Listagem de vendas'); |
|
424 | - |
|
425 | - // Cabeçalho do arquivo para ele baixar |
|
426 | - header('Content-Type: application/vnd.ms-excel'); |
|
427 | - header('Content-Disposition: attachment;filename="relatorio_vendas_'.date('d-m-Y').'.xls"'); |
|
428 | - header('Cache-Control: max-age=0'); |
|
429 | - // Se for o IE9, isso talvez seja necessário |
|
430 | - header('Cache-Control: max-age=1'); |
|
431 | - |
|
432 | - // Acessamos o 'Writer' para poder salvar o arquivo |
|
433 | - $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); |
|
434 | - |
|
435 | - // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela |
|
436 | - $objWriter->save('php://output'); |
|
437 | - |
|
438 | - exit; |
|
387 | + $objPHPExcel = new PHPExcel(); |
|
388 | + // Definimos o estilo da fonte |
|
389 | + $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
|
390 | + |
|
391 | + $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); |
|
392 | + |
|
393 | + // Criamos as colunas |
|
394 | + $objPHPExcel->setActiveSheetIndex(0) |
|
395 | + ->setCellValue('A1', "Valor Venda") |
|
396 | + ->setCellValue('B1', "Custo Médio ") |
|
397 | + ->setCellValue("C1", "Valor Lucro") |
|
398 | + ->setCellValue('D1', "ID Venda" ); |
|
399 | + |
|
400 | + |
|
401 | + $vendas = $this->Venda->find('all', |
|
402 | + array('conditions' => array( |
|
403 | + 'AND' => array( |
|
404 | + 'Venda.ativo' => 1, |
|
405 | + 'Venda.id_usuario' => $this->instancia, |
|
406 | + 'Venda.data_venda' => date('Y-m-d') |
|
407 | + ) |
|
408 | + ) |
|
409 | + ) |
|
410 | + ); |
|
411 | + |
|
412 | + $i = 2; |
|
413 | + foreach ($vendas as $key => $venda) { |
|
414 | + $objPHPExcel->setActiveSheetIndex(0) |
|
415 | + ->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor']) |
|
416 | + ->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo']) |
|
417 | + ->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
418 | + ->setCellValue('D'.$i, $venda['Venda']['id']); |
|
419 | + $i++; |
|
420 | + } |
|
421 | + |
|
422 | + // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas |
|
423 | + $objPHPExcel->getActiveSheet()->setTitle('Listagem de vendas'); |
|
424 | + |
|
425 | + // Cabeçalho do arquivo para ele baixar |
|
426 | + header('Content-Type: application/vnd.ms-excel'); |
|
427 | + header('Content-Disposition: attachment;filename="relatorio_vendas_'.date('d-m-Y').'.xls"'); |
|
428 | + header('Cache-Control: max-age=0'); |
|
429 | + // Se for o IE9, isso talvez seja necessário |
|
430 | + header('Cache-Control: max-age=1'); |
|
431 | + |
|
432 | + // Acessamos o 'Writer' para poder salvar o arquivo |
|
433 | + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); |
|
434 | + |
|
435 | + // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela |
|
436 | + $objWriter->save('php://output'); |
|
437 | + |
|
438 | + exit; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | 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 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function listar_cadastros_ajax() { |
68 | 68 | $this->layout = 'ajax'; |
69 | 69 | |
70 | - $aColumns = array( 'id', 'valor', 'forma_pagamento', 'data_venda', 'actions' ); |
|
70 | + $aColumns = array('id', 'valor', 'forma_pagamento', 'data_venda', 'actions'); |
|
71 | 71 | |
72 | 72 | $this->loadModel('LancamentoVenda'); |
73 | 73 | |
@@ -84,26 +84,26 @@ discard block |
||
84 | 84 | array('order' => array('Venda.id DESC')) |
85 | 85 | ); |
86 | 86 | |
87 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
87 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
88 | 88 | { |
89 | 89 | $conditions['offset'] = $_GET['iDisplayStart']; |
90 | 90 | $conditions['limit'] = $_GET['iDisplayLength']; |
91 | 91 | } |
92 | 92 | |
93 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
93 | + if (isset($_GET['iSortCol_0'])) |
|
94 | 94 | { |
95 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
95 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
96 | 96 | { |
97 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
97 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
98 | 98 | { |
99 | - $conditions['order'] = array('Venda.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
99 | + $conditions['order'] = array('Venda.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
104 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
105 | 105 | { |
106 | - $conditions['conditions']['Venda.id LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
106 | + $conditions['conditions']['Venda.id LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | $vendas = $this->Venda->find('all', $conditions); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | foreach ($vendas as $venda) { |
119 | 119 | $row = array(); |
120 | 120 | |
121 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
121 | + for ($i = 0; $i < count($aColumns); $i++) |
|
122 | 122 | { |
123 | 123 | if ($aColumns[$i] == "forma_pagamento") { |
124 | 124 | $lancamento = $this->LancamentoVenda->find('first', array( |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | |
131 | 131 | $value = (isset($lancamento['LancamentoVenda']['forma_pagamento'])) ? $lancamento['LancamentoVenda']['forma_pagamento'] : array(); |
132 | 132 | |
133 | - if (isset($value) && !empty($value)) |
|
133 | + if (isset($value) && ! empty($value)) |
|
134 | 134 | $value = str_replace('_', ' ', $value); |
135 | 135 | |
136 | - if (isset($value) && !empty($value)) |
|
136 | + if (isset($value) && ! empty($value)) |
|
137 | 137 | $value = ucwords($value); |
138 | 138 | } else if ($aColumns[$i] == "actions") { |
139 | - $value = '<a href="javascript:printNotaNaoFiscal(' . $venda['Venda']['id'] . ');" target="_blank" class="btn btn-info">'; |
|
139 | + $value = '<a href="javascript:printNotaNaoFiscal('.$venda['Venda']['id'].');" target="_blank" class="btn btn-info">'; |
|
140 | 140 | $value .= '<i class="fa fa-file-text" aria-hidden="true"></i>'; |
141 | 141 | $value .= '</a> '; |
142 | 142 | |
143 | - $value .= ' <button onclick="remover_venda(' . $venda['Venda']['id'] . ');" type="button" class="btn btn-danger"><i class="fa fa-times"></i></button>'; |
|
143 | + $value .= ' <button onclick="remover_venda('.$venda['Venda']['id'].');" type="button" class="btn btn-danger"><i class="fa fa-times"></i></button>'; |
|
144 | 144 | } else if ($aColumns[$i] == "valor") { |
145 | - $value = 'R$ ' . number_format($venda['Venda'][$aColumns[$i]], 2, ',', '.'); |
|
145 | + $value = 'R$ '.number_format($venda['Venda'][$aColumns[$i]], 2, ',', '.'); |
|
146 | 146 | } else { |
147 | 147 | $value = $venda['Venda'][$aColumns[$i]]; |
148 | 148 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $row[] = $value; |
151 | 151 | } |
152 | 152 | |
153 | - $btEdit = '<a class="btn btn-info" href="/produto/editar_cadastro/' . $venda['Venda']['id'] . '"><i class="fa fa-pencil"></i></a>'; |
|
153 | + $btEdit = '<a class="btn btn-info" href="/produto/editar_cadastro/'.$venda['Venda']['id'].'"><i class="fa fa-pencil"></i></a>'; |
|
154 | 154 | |
155 | 155 | $row[] = $btEdit; |
156 | 156 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | if ($produto[0]['Produto']['estoque'] <= 0) |
254 | 254 | { |
255 | - $this->Session->setFlash('O produto (' . $produto[0]['Produto']['nome'] .') não tem mais estoque disponivel!'); |
|
255 | + $this->Session->setFlash('O produto ('.$produto[0]['Produto']['nome'].') não tem mais estoque disponivel!'); |
|
256 | 256 | continue; |
257 | 257 | } |
258 | 258 | |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | public function s_adicionar_cadastro() { |
272 | - $dados_venda = $this->request->data('venda'); |
|
272 | + $dados_venda = $this->request->data('venda'); |
|
273 | 273 | $dados_lancamento = $this->request->data('lancamento'); |
274 | - $produtos = $this->request->data('produto'); |
|
274 | + $produtos = $this->request->data('produto'); |
|
275 | 275 | |
276 | - if (!$this->validar_itens_venda($produtos) && !$dados_venda['orcamento']) { |
|
276 | + if ( ! $this->validar_itens_venda($produtos) && ! $dados_venda['orcamento']) { |
|
277 | 277 | $this->Session->setFlash('Algum produto adicionado não possui estoque disponivel'); |
278 | 278 | $this->redirect('/venda/adicionar_cadastro'); |
279 | 279 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | $salvar_venda = $this->salvar_venda($produtos, $dados_lancamento, $dados_venda); |
285 | 285 | |
286 | - if (!$salvar_venda) { |
|
286 | + if ( ! $salvar_venda) { |
|
287 | 287 | $this->Session->setFlash('Ocorreu um erro ao salvar a venda tente novamento'); |
288 | 288 | $this->redirect('/venda/adicionar_cadastro'); |
289 | 289 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | |
341 | 341 | $objProdutoEstoqueController = new ProdutoEstoqueController(); |
342 | 342 | |
343 | - if (!$objProdutoEstoqueController->validar_estoque($produto, $item['quantidade'])) { |
|
343 | + if ( ! $objProdutoEstoqueController->validar_estoque($produto, $item['quantidade'])) { |
|
344 | 344 | return false; |
345 | 345 | } |
346 | 346 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | $informacoes['valor'] = $informacoes['valor'] - $informacoes['desconto']; |
359 | 359 | $informacoes['orcamento'] = @$informacoes['orcamento']; |
360 | 360 | |
361 | - if (!$this->Venda->save($informacoes)) { |
|
361 | + if ( ! $this->Venda->save($informacoes)) { |
|
362 | 362 | $this->Session->setFlash('Ocorreu algum erro ao salvar a venda'); |
363 | 363 | return false; |
364 | 364 | } |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | public function relatorio_diario() { |
384 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
385 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
384 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
385 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
386 | 386 | |
387 | 387 | $objPHPExcel = new PHPExcel(); |
388 | 388 | // Definimos o estilo da fonte |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | ->setCellValue('A1', "Valor Venda") |
396 | 396 | ->setCellValue('B1', "Custo Médio ") |
397 | 397 | ->setCellValue("C1", "Valor Lucro") |
398 | - ->setCellValue('D1', "ID Venda" ); |
|
398 | + ->setCellValue('D1', "ID Venda"); |
|
399 | 399 | |
400 | 400 | |
401 | 401 | $vendas = $this->Venda->find('all', |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | $i = 2; |
413 | 413 | foreach ($vendas as $key => $venda) { |
414 | 414 | $objPHPExcel->setActiveSheetIndex(0) |
415 | - ->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor']) |
|
416 | - ->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo']) |
|
417 | - ->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
415 | + ->setCellValue('A'.$i, 'R$ '.$venda['Venda']['valor']) |
|
416 | + ->setCellValue('B'.$i, 'R$ '.$venda['Venda']['custo']) |
|
417 | + ->setCellValue('C'.$i, 'R$ '.$venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
418 | 418 | ->setCellValue('D'.$i, $venda['Venda']['id']); |
419 | 419 | $i++; |
420 | 420 | } |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | exit; |
439 | 439 | } |
440 | 440 | |
441 | - public function recoverDataToDashboardOneWeek($id_usuario){ |
|
441 | + public function recoverDataToDashboardOneWeek($id_usuario) { |
|
442 | 442 | $vendas = $this->Venda->find('all', |
443 | 443 | array('conditions' => |
444 | 444 | array( |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | |
505 | 505 | $ImpressaoFiscalController->userName = $usuario['Usuario']['nome']; |
506 | 506 | |
507 | - $ImpressaoFiscalController->corpoTxt .= "Valor: R$ " . number_format($dados_venda['Venda']['valor'], 2, ',', '.') . "\n\n"; |
|
507 | + $ImpressaoFiscalController->corpoTxt .= "Valor: R$ ".number_format($dados_venda['Venda']['valor'], 2, ',', '.')."\n\n"; |
|
508 | 508 | |
509 | 509 | $dados_lancamento = $this->LancamentoVenda->find('first', |
510 | 510 | array('conditions' => |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | ) |
516 | 516 | ); |
517 | 517 | |
518 | - $ImpressaoFiscalController->corpoTxt .= "Forma de Pagamento: " . $dados_lancamento['LancamentoVenda']['forma_pagamento'] . "\n\n"; |
|
518 | + $ImpressaoFiscalController->corpoTxt .= "Forma de Pagamento: ".$dados_lancamento['LancamentoVenda']['forma_pagamento']."\n\n"; |
|
519 | 519 | |
520 | 520 | $produtos = $this->VendaItensProduto->find('all', |
521 | 521 | array('conditions' => |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | $total = $produto['Produto']['preco'] * $item['VendaItensProduto']['quantidade_produto']; |
537 | 537 | |
538 | 538 | $ImpressaoFiscalController->corpoTxt .= "" |
539 | - . "Produto: " . $produto['Produto']['nome'] |
|
540 | - . "\nQuantidade: " . $item['VendaItensProduto']['quantidade_produto'] |
|
541 | - . "\nPreço: R$ " . number_format($produto['Produto']['preco'], 2, ',', '.') |
|
542 | - . "\nTotal: R$ " . number_format($total, 2, ',', '.') |
|
539 | + . "Produto: ".$produto['Produto']['nome'] |
|
540 | + . "\nQuantidade: ".$item['VendaItensProduto']['quantidade_produto'] |
|
541 | + . "\nPreço: R$ ".number_format($produto['Produto']['preco'], 2, ',', '.') |
|
542 | + . "\nTotal: R$ ".number_format($total, 2, ',', '.') |
|
543 | 543 | . "\n--------------------------\n"; |
544 | 544 | } |
545 | 545 | |
@@ -583,14 +583,14 @@ discard block |
||
583 | 583 | $lancamentos = array(); |
584 | 584 | |
585 | 585 | foreach ($vendas as $i => $venda) { |
586 | - $lancamento = $this->LancamentoVenda->find('first', array( |
|
586 | + $lancamento = $this->LancamentoVenda->find('first', array( |
|
587 | 587 | 'conditions' => array( |
588 | 588 | 'LancamentoVenda.venda_id' => $venda['Venda']['id'] |
589 | 589 | ) |
590 | 590 | ) |
591 | 591 | ); |
592 | 592 | |
593 | - if (!empty($lancamento)) |
|
593 | + if ( ! empty($lancamento)) |
|
594 | 594 | $lancamentos[] = $lancamento; |
595 | 595 | } |
596 | 596 |
@@ -130,11 +130,13 @@ discard block |
||
130 | 130 | |
131 | 131 | $value = (isset($lancamento['LancamentoVenda']['forma_pagamento'])) ? $lancamento['LancamentoVenda']['forma_pagamento'] : array(); |
132 | 132 | |
133 | - if (isset($value) && !empty($value)) |
|
134 | - $value = str_replace('_', ' ', $value); |
|
133 | + if (isset($value) && !empty($value)) { |
|
134 | + $value = str_replace('_', ' ', $value); |
|
135 | + } |
|
135 | 136 | |
136 | - if (isset($value) && !empty($value)) |
|
137 | - $value = ucwords($value); |
|
137 | + if (isset($value) && !empty($value)) { |
|
138 | + $value = ucwords($value); |
|
139 | + } |
|
138 | 140 | } else if ($aColumns[$i] == "actions") { |
139 | 141 | $value = '<a href="javascript:printNotaNaoFiscal(' . $venda['Venda']['id'] . ');" target="_blank" class="btn btn-info">'; |
140 | 142 | $value .= '<i class="fa fa-file-text" aria-hidden="true"></i>'; |
@@ -590,8 +592,9 @@ discard block |
||
590 | 592 | ) |
591 | 593 | ); |
592 | 594 | |
593 | - if (!empty($lancamento)) |
|
594 | - $lancamentos[] = $lancamento; |
|
595 | + if (!empty($lancamento)) { |
|
596 | + $lancamentos[] = $lancamento; |
|
597 | + } |
|
595 | 598 | } |
596 | 599 | |
597 | 600 | $valorTotalPgt = $this->calcularTotalVendas($lancamentos); |