@@ -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 .= ' <a onclick="remover_venda(' . $venda['Venda']['id'] . ');" id="' . $venda['Venda']['id'] . '" type="button" class="btn btn-danger"><i class="fa fa-times"></i></a>'; |
|
143 | + $value .= ' <a onclick="remover_venda('.$venda['Venda']['id'].');" id="'.$venda['Venda']['id'].'" type="button" class="btn btn-danger"><i class="fa fa-times"></i></a>'; |
|
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,8 +504,8 @@ 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"; |
|
508 | - $ImpressaoFiscalController->corpoTxt .= "Desconto: R$ " . number_format($dados_venda['Venda']['desconto'], 2, ',', '.') . "\n\n"; |
|
507 | + $ImpressaoFiscalController->corpoTxt .= "Valor: R$ ".number_format($dados_venda['Venda']['valor'], 2, ',', '.')."\n"; |
|
508 | + $ImpressaoFiscalController->corpoTxt .= "Desconto: R$ ".number_format($dados_venda['Venda']['desconto'], 2, ',', '.')."\n\n"; |
|
509 | 509 | |
510 | 510 | $dados_lancamento = $this->LancamentoVenda->find('first', |
511 | 511 | array('conditions' => |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | ) |
517 | 517 | ); |
518 | 518 | |
519 | - $ImpressaoFiscalController->corpoTxt .= "Forma de Pagamento: " . $dados_lancamento['LancamentoVenda']['forma_pagamento'] . "\n\n"; |
|
519 | + $ImpressaoFiscalController->corpoTxt .= "Forma de Pagamento: ".$dados_lancamento['LancamentoVenda']['forma_pagamento']."\n\n"; |
|
520 | 520 | |
521 | 521 | $produtos = $this->VendaItensProduto->find('all', |
522 | 522 | array('conditions' => |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | $total = $produto['Produto']['preco'] * $item['VendaItensProduto']['quantidade_produto']; |
538 | 538 | |
539 | 539 | $ImpressaoFiscalController->corpoTxt .= "" |
540 | - . "Produto: " . $produto['Produto']['nome'] |
|
541 | - . "\nQuantidade: " . $item['VendaItensProduto']['quantidade_produto'] |
|
542 | - . "\nPreço: R$ " . number_format($produto['Produto']['preco'], 2, ',', '.') |
|
543 | - . "\nTotal: R$ " . number_format($total, 2, ',', '.') |
|
540 | + . "Produto: ".$produto['Produto']['nome'] |
|
541 | + . "\nQuantidade: ".$item['VendaItensProduto']['quantidade_produto'] |
|
542 | + . "\nPreço: R$ ".number_format($produto['Produto']['preco'], 2, ',', '.') |
|
543 | + . "\nTotal: R$ ".number_format($total, 2, ',', '.') |
|
544 | 544 | . "\n--------------------------\n"; |
545 | 545 | } |
546 | 546 | |
@@ -584,14 +584,14 @@ discard block |
||
584 | 584 | $lancamentos = array(); |
585 | 585 | |
586 | 586 | foreach ($vendas as $i => $venda) { |
587 | - $lancamento = $this->LancamentoVenda->find('first', array( |
|
587 | + $lancamento = $this->LancamentoVenda->find('first', array( |
|
588 | 588 | 'conditions' => array( |
589 | 589 | 'LancamentoVenda.venda_id' => $venda['Venda']['id'] |
590 | 590 | ) |
591 | 591 | ) |
592 | 592 | ); |
593 | 593 | |
594 | - if (!empty($lancamento)) |
|
594 | + if ( ! empty($lancamento)) |
|
595 | 595 | $lancamentos[] = $lancamento; |
596 | 596 | } |
597 | 597 |