@@ -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 | return $this->redirect('/venda/adicionar_cadastro'); |
289 | 289 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | |
342 | 342 | $objProdutoEstoqueController = new ProdutoEstoqueController(); |
343 | 343 | |
344 | - if (!$objProdutoEstoqueController->validar_estoque($produto, $item['quantidade'])) { |
|
344 | + if ( ! $objProdutoEstoqueController->validar_estoque($produto, $item['quantidade'])) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $informacoes['valor'] = $informacoes['valor'] - $informacoes['desconto']; |
360 | 360 | $informacoes['orcamento'] = @$informacoes['orcamento']; |
361 | 361 | |
362 | - if (!$this->Venda->save($informacoes)) { |
|
362 | + if ( ! $this->Venda->save($informacoes)) { |
|
363 | 363 | $this->Session->setFlash('Ocorreu algum erro ao salvar a venda'); |
364 | 364 | return false; |
365 | 365 | } |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | public function relatorio_diario() { |
385 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
386 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
385 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
386 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
387 | 387 | |
388 | 388 | $objPHPExcel = new PHPExcel(); |
389 | 389 | // Definimos o estilo da fonte |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | ->setCellValue('A1', "Valor Venda") |
397 | 397 | ->setCellValue('B1', "Custo Médio ") |
398 | 398 | ->setCellValue("C1", "Valor Lucro") |
399 | - ->setCellValue('D1', "ID Venda" ); |
|
399 | + ->setCellValue('D1', "ID Venda"); |
|
400 | 400 | |
401 | 401 | |
402 | 402 | $vendas = $this->Venda->find('all', |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | $i = 2; |
414 | 414 | foreach ($vendas as $key => $venda) { |
415 | 415 | $objPHPExcel->setActiveSheetIndex(0) |
416 | - ->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor']) |
|
417 | - ->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo']) |
|
418 | - ->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
416 | + ->setCellValue('A'.$i, 'R$ '.$venda['Venda']['valor']) |
|
417 | + ->setCellValue('B'.$i, 'R$ '.$venda['Venda']['custo']) |
|
418 | + ->setCellValue('C'.$i, 'R$ '.$venda['Venda']['valor'] - $venda['Venda']['custo']) |
|
419 | 419 | ->setCellValue('D'.$i, $venda['Venda']['id']); |
420 | 420 | $i++; |
421 | 421 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | exit; |
440 | 440 | } |
441 | 441 | |
442 | - public function recoverDataToDashboardOneWeek($id_usuario){ |
|
442 | + public function recoverDataToDashboardOneWeek($id_usuario) { |
|
443 | 443 | $vendas = $this->Venda->find('all', |
444 | 444 | array('conditions' => |
445 | 445 | array( |
@@ -536,19 +536,19 @@ discard block |
||
536 | 536 | $totalGeral += $total; |
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 | |
546 | 546 | $desconto = $totalGeral - $dados_venda['Venda']['valor']; |
547 | 547 | |
548 | - $ImpressaoFiscalController->corpoTxt .= "Valor Total: " . number_format($totalGeral, 2, ',', '.') . "\n\n"; |
|
549 | - $ImpressaoFiscalController->corpoTxt .= "Valor Pago: R$ " . number_format($dados_venda['Venda']['valor'], 2, ',', '.') . "\n"; |
|
550 | - $ImpressaoFiscalController->corpoTxt .= "Desconto: R$ " . number_format($desconto, 2, ',', '.') . "\n\n"; |
|
551 | - $ImpressaoFiscalController->corpoTxt .= "Forma de Pagamento: " . $dados_lancamento['LancamentoVenda']['forma_pagamento'] . "\n\n"; |
|
548 | + $ImpressaoFiscalController->corpoTxt .= "Valor Total: ".number_format($totalGeral, 2, ',', '.')."\n\n"; |
|
549 | + $ImpressaoFiscalController->corpoTxt .= "Valor Pago: R$ ".number_format($dados_venda['Venda']['valor'], 2, ',', '.')."\n"; |
|
550 | + $ImpressaoFiscalController->corpoTxt .= "Desconto: R$ ".number_format($desconto, 2, ',', '.')."\n\n"; |
|
551 | + $ImpressaoFiscalController->corpoTxt .= "Forma de Pagamento: ".$dados_lancamento['LancamentoVenda']['forma_pagamento']."\n\n"; |
|
552 | 552 | |
553 | 553 | $file = $ImpressaoFiscalController->gerar_arquivo(); |
554 | 554 | |
@@ -590,14 +590,14 @@ discard block |
||
590 | 590 | $lancamentos = array(); |
591 | 591 | |
592 | 592 | foreach ($vendas as $i => $venda) { |
593 | - $lancamento = $this->LancamentoVenda->find('first', array( |
|
593 | + $lancamento = $this->LancamentoVenda->find('first', array( |
|
594 | 594 | 'conditions' => array( |
595 | 595 | 'LancamentoVenda.venda_id' => $venda['Venda']['id'] |
596 | 596 | ) |
597 | 597 | ) |
598 | 598 | ); |
599 | 599 | |
600 | - if (!empty($lancamento)) |
|
600 | + if ( ! empty($lancamento)) |
|
601 | 601 | $lancamentos[] = $lancamento; |
602 | 602 | } |
603 | 603 |
@@ -176,22 +176,22 @@ |
||
176 | 176 | 'LancamentoVenda.usuario_id' => $this->instancia |
177 | 177 | ), |
178 | 178 | 'joins' => array( |
179 | - array( |
|
180 | - 'table' => 'lancamento_categorias', |
|
181 | - 'alias' => 'LancamentoCategoria', |
|
182 | - 'type' => 'LEFT', |
|
183 | - 'conditions' => array( |
|
184 | - 'LancamentoVenda.lancamento_categoria_id = LancamentoCategoria.id', |
|
185 | - ), |
|
186 | - ), |
|
187 | - array( |
|
188 | - 'table' => 'fornecedores', |
|
189 | - 'alias' => 'Fornecedore', |
|
190 | - 'type' => 'LEFT', |
|
191 | - 'conditions' => array( |
|
192 | - 'LancamentoVenda.fornecedore_id = Fornecedore.id', |
|
193 | - ), |
|
194 | - ) |
|
179 | + array( |
|
180 | + 'table' => 'lancamento_categorias', |
|
181 | + 'alias' => 'LancamentoCategoria', |
|
182 | + 'type' => 'LEFT', |
|
183 | + 'conditions' => array( |
|
184 | + 'LancamentoVenda.lancamento_categoria_id = LancamentoCategoria.id', |
|
185 | + ), |
|
186 | + ), |
|
187 | + array( |
|
188 | + 'table' => 'fornecedores', |
|
189 | + 'alias' => 'Fornecedore', |
|
190 | + 'type' => 'LEFT', |
|
191 | + 'conditions' => array( |
|
192 | + 'LancamentoVenda.fornecedore_id = Fornecedore.id', |
|
193 | + ), |
|
194 | + ) |
|
195 | 195 | ), |
196 | 196 | 'fields' => array( |
197 | 197 | 'LancamentoCategoria.*', 'LancamentoVenda.*', 'Fornecedore.*' |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | ) |
94 | 94 | ); |
95 | 95 | |
96 | - if (!empty($filter['term'])) { |
|
97 | - $conditions['conditions']['LancamentoCategoria.nome LIKE '] = '%' . $filter['term'] . '%'; |
|
96 | + if ( ! empty($filter['term'])) { |
|
97 | + $conditions['conditions']['LancamentoCategoria.nome LIKE '] = '%'.$filter['term'].'%'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $conditions['limit'] = $this->request->query('page_limit'); |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | ) |
134 | 134 | ); |
135 | 135 | |
136 | - if (!empty($filter['term'])) { |
|
137 | - $conditions['conditions']['Fornecedore.nome LIKE '] = '%' . $filter['term'] . '%'; |
|
136 | + if ( ! empty($filter['term'])) { |
|
137 | + $conditions['conditions']['Fornecedore.nome LIKE '] = '%'.$filter['term'].'%'; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $conditions['limit'] = $this->request->query('page_limit'); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $this->loadModel('LancamentoVenda'); |
169 | 169 | $this->loadModel('LancamentoCategoria'); |
170 | 170 | |
171 | - $aColumns = array( 'id', 'venda_id', 'data_vencimento', 'valor', 'lancamento_categoria_id' ); |
|
171 | + $aColumns = array('id', 'venda_id', 'data_vencimento', 'valor', 'lancamento_categoria_id'); |
|
172 | 172 | |
173 | 173 | $conditions = array( |
174 | 174 | 'conditions' => array( |
@@ -198,19 +198,19 @@ discard block |
||
198 | 198 | ) |
199 | 199 | ); |
200 | 200 | |
201 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
201 | + if (isset($_GET['iSortCol_0'])) |
|
202 | 202 | { |
203 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
203 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
204 | 204 | { |
205 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
205 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
206 | 206 | { |
207 | 207 | $conditions['order'] = array( |
208 | - 'LancamentoVenda.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_' . $i]); |
|
208 | + 'LancamentoVenda.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
213 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
214 | 214 | { |
215 | 215 | $search = explode(':', $_GET['sSearch']); |
216 | 216 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | // pr($conditions); |
234 | 234 | $allLancamentos = $this->LancamentoVenda->find('count', $conditions); |
235 | 235 | |
236 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
236 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
237 | 237 | { |
238 | 238 | $conditions['offset'] = $_GET['iDisplayStart']; |
239 | 239 | $conditions['limit'] = $_GET['iDisplayLength']; |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | "aaData" => array() |
249 | 249 | ); |
250 | 250 | |
251 | - foreach ( $lancamentos as $i => $lancamento ) |
|
251 | + foreach ($lancamentos as $i => $lancamento) |
|
252 | 252 | { |
253 | 253 | $row = array(); |
254 | 254 | |
255 | 255 | $btPaid = ''; |
256 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
256 | + for ($i = 0; $i < count($aColumns); $i++) |
|
257 | 257 | { |
258 | 258 | if ($aColumns[$i] == "lancamento_categoria_id") { |
259 | 259 | |
@@ -267,16 +267,16 @@ discard block |
||
267 | 267 | |
268 | 268 | $categoria_lancamento = $this->LancamentoCategoria->find('first', $conditions); |
269 | 269 | |
270 | - if (!empty($categoria_lancamento)) { |
|
270 | + if ( ! empty($categoria_lancamento)) { |
|
271 | 271 | if ($categoria_lancamento['LancamentoCategoria']['tipo'] == "receita") { |
272 | - $value = '<span class="label label-success">' . $categoria_lancamento['LancamentoCategoria']['nome'] . '</span>'; |
|
272 | + $value = '<span class="label label-success">'.$categoria_lancamento['LancamentoCategoria']['nome'].'</span>'; |
|
273 | 273 | |
274 | 274 | $btPaid = '<a class="btn btn-primary" href="javascript:alert(\'Não é uma despesa.\');"><i class="fa fa-child"></i></a>'; |
275 | 275 | } else { |
276 | - $value = '<span class="label label-danger">' . $categoria_lancamento['LancamentoCategoria']['nome'] . '</span>'; |
|
276 | + $value = '<span class="label label-danger">'.$categoria_lancamento['LancamentoCategoria']['nome'].'</span>'; |
|
277 | 277 | |
278 | 278 | if ($lancamento['LancamentoVenda']['valor_pago'] < $lancamento['LancamentoVenda']['valor']) { |
279 | - $btPaid = '<a class="btn btn-success" href="/produto/imagens/' . $lancamento['LancamentoVenda']['id'] . '"><i class="fa fa-check"></i></a>'; |
|
279 | + $btPaid = '<a class="btn btn-success" href="/produto/imagens/'.$lancamento['LancamentoVenda']['id'].'"><i class="fa fa-check"></i></a>'; |
|
280 | 280 | } else { |
281 | 281 | $btPaid = '<a class="btn btn-default" href="javascript:alert(\'Lançamento já foi pago\');"><i class="fa fa-money"></i></a>'; |
282 | 282 | } |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | |
292 | 292 | if ($aColumns[$i] == "venda_id" && empty($lancamento['LancamentoVenda'][$aColumns[$i]])) { |
293 | 293 | $value = '<b>Não é uma venda</b>'; |
294 | - } elseif ($aColumns[$i] == "venda_id" && !empty($lancamento['LancamentoVenda'][$aColumns[$i]])) { |
|
295 | - $value = '<a href="http://www.ciawn.com.br/venda/listar_cadastros?venda_id=' . $lancamento['LancamentoVenda'][$aColumns[$i]] . '">Ver Pedido</a>'; |
|
294 | + } elseif ($aColumns[$i] == "venda_id" && ! empty($lancamento['LancamentoVenda'][$aColumns[$i]])) { |
|
295 | + $value = '<a href="http://www.ciawn.com.br/venda/listar_cadastros?venda_id='.$lancamento['LancamentoVenda'][$aColumns[$i]].'">Ver Pedido</a>'; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | if ($aColumns[$i] == "valor") { |
299 | - $value = 'R$ ' . number_format($lancamento['LancamentoVenda'][$aColumns[$i]], 2, ',', '.'); |
|
299 | + $value = 'R$ '.number_format($lancamento['LancamentoVenda'][$aColumns[$i]], 2, ',', '.'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | if ($aColumns[$i] == "data_vencimento" && $lancamento['LancamentoVenda'][$aColumns[$i]] != "") { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | $retorno = $this->LancamentoCategoria->save($data); |
331 | 331 | |
332 | - if (!$retorno) { |
|
332 | + if ( ! $retorno) { |
|
333 | 333 | $this->Session->setFlash('Ocorreu um erro ao salvar a categoria tente novamente'); |
334 | 334 | return $this->redirect('/financeiro/listar_cadastros'); |
335 | 335 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $data['usuario_id'] = $this->instancia; |
348 | 348 | $data['ativo'] = 1; |
349 | 349 | |
350 | - if (!$this->Fornecedore->save($data)) { |
|
350 | + if ( ! $this->Fornecedore->save($data)) { |
|
351 | 351 | $this->Session->setFlash('Ocorreu um erro ao inserir o fornecedor'); |
352 | 352 | return $this->redirect('/financeiro/listar_cadastros'); |
353 | 353 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | $this->loadModel('LancamentoVenda'); |
368 | 368 | |
369 | - if (!$this->LancamentoVenda->save($transacao)) { |
|
369 | + if ( ! $this->LancamentoVenda->save($transacao)) { |
|
370 | 370 | $this->Session->setFlash('Ocorreu um erro ao cadastrar o lançamento'); |
371 | 371 | return $this->redirect('/financeiro/listar_cadastros'); |
372 | 372 | } |
@@ -55,8 +55,9 @@ |
||
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | - if (empty($categoria)) |
|
59 | - continue; |
|
58 | + if (empty($categoria)) { |
|
59 | + continue; |
|
60 | + } |
|
60 | 61 | |
61 | 62 | if ($categoria['LancamentoCategoria']['tipo'] == "despesa") { |
62 | 63 | if ($lancamento['LancamentoVenda']['valor'] > $lancamento['LancamentoVenda']['valor_pago']) { |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | $this->EnderecoClienteCadastro->save($endereco); |
37 | 37 | |
38 | 38 | $this->Session->setFlash('Cliente salvo com sucesso!'); |
39 | - return $this->redirect('/cliente/listar_cadastros'); |
|
39 | + return $this->redirect('/cliente/listar_cadastros'); |
|
40 | 40 | } else { |
41 | 41 | $this->Session->setFlash('Ocorreu um erro ao salva o cliente!'); |
42 | - return $this->redirect('/cliente/listar_cadastros'); |
|
42 | + return $this->redirect('/cliente/listar_cadastros'); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | |
92 | 92 | if ($this->Cliente->save($dados)) { |
93 | 93 | $this->Session->setFlash('Cliente editado com sucesso!'); |
94 | - return $this->redirect('/cliente/listar_cadastros'); |
|
94 | + return $this->redirect('/cliente/listar_cadastros'); |
|
95 | 95 | } else { |
96 | 96 | $this->Session->setFlash('Ocorreu um erro ao editar o cliente!'); |
97 | - return $this->redirect('/cliente/listar_cadastros'); |
|
97 | + return $this->redirect('/cliente/listar_cadastros'); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | function exportar_clientes() { |
102 | - $this->layout = 'ajax'; |
|
103 | - $this->set('event', $this->Cliente->find('all')); |
|
102 | + $this->layout = 'ajax'; |
|
103 | + $this->set('event', $this->Cliente->find('all')); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | function listar_pedidos($id) { |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | |
222 | 222 | if (!$this->Venda->save($data)) { |
223 | 223 | $this->Session->setFlash('Erro ao emitir cobrança!'); |
224 | - return $this->redirect('/cliente/listar_pedidos/' . $cliente['Cliente']['id']); |
|
224 | + return $this->redirect('/cliente/listar_pedidos/' . $cliente['Cliente']['id']); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | $this->Session->setFlash('Cobrança emitida com sucesso!'); |
228 | - return $this->redirect('/cliente/listar_pedidos/' . $cliente['Cliente']['id']); |
|
228 | + return $this->redirect('/cliente/listar_pedidos/' . $cliente['Cliente']['id']); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | public function carregar_clientes($id = null) |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | require 'AsaasController.php'; |
4 | 4 | |
5 | -class ClienteController extends AppController{ |
|
5 | +class ClienteController extends AppController { |
|
6 | 6 | // public $helpers = array('Excel'); |
7 | 7 | |
8 | 8 | function home() { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if ($this->Cliente->save($dados)) { |
31 | 31 | $endereco['id_usuario'] = $this->instancia; |
32 | 32 | $endereco['id_cliente'] = $this->Cliente->id; |
33 | - $endereco['ativo'] = 1; |
|
33 | + $endereco['ativo'] = 1; |
|
34 | 34 | |
35 | 35 | $this->loadModel('EnderecoClienteCadastro'); |
36 | 36 | $this->EnderecoClienteCadastro->save($endereco); |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | |
49 | 49 | $id = $this->request->data('id'); |
50 | 50 | |
51 | - $dados = array ('ativo' => '0'); |
|
52 | - $parametros = array ('id' => $id); |
|
51 | + $dados = array('ativo' => '0'); |
|
52 | + $parametros = array('id' => $id); |
|
53 | 53 | |
54 | - if ($this->Cliente->updateAll($dados,$parametros)) { |
|
54 | + if ($this->Cliente->updateAll($dados, $parametros)) { |
|
55 | 55 | echo json_encode(true); |
56 | 56 | } else { |
57 | 57 | echo json_encode(false); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | ) |
127 | 127 | ); |
128 | 128 | |
129 | - if (!isset($lancamento['LancamentoVenda'])) { |
|
129 | + if ( ! isset($lancamento['LancamentoVenda'])) { |
|
130 | 130 | unset($vendas[$i]); |
131 | 131 | continue; |
132 | 132 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | if (empty($cliente['Cliente']['asaas_id'])) { |
178 | 178 | $cliente_data = array( |
179 | - "name" => $cliente['Cliente']['nome1'] . ' ' . $cliente['Cliente']['nome2'], |
|
179 | + "name" => $cliente['Cliente']['nome1'].' '.$cliente['Cliente']['nome2'], |
|
180 | 180 | "email" => $cliente['Cliente']['email'], |
181 | 181 | "cpfCnpj" => $cliente['Cliente']['documento1'], |
182 | 182 | "externalReference" => $cliente['Cliente']['id'] |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | "billingType" => "BOLETO", |
198 | 198 | "dueDate" => date('Y-m-d'), |
199 | 199 | "value" => $venda['Venda']['valor'], |
200 | - "description" => "Boleto referente a venda no sistema winners REFº " . $venda['Venda']['id'], |
|
200 | + "description" => "Boleto referente a venda no sistema winners REFº ".$venda['Venda']['id'], |
|
201 | 201 | "externalReference" => $venda['Venda']['id'] |
202 | 202 | ); |
203 | 203 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $this->Session->setFlash($error->description); |
209 | 209 | } |
210 | 210 | |
211 | - return $this->redirect('/cliente/listar_pedidos/' . $cliente['Cliente']['id']); |
|
211 | + return $this->redirect('/cliente/listar_pedidos/'.$cliente['Cliente']['id']); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | $this->Venda->id = $venda_id; |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | 'asaas_transaction_id' => $response->id |
220 | 220 | ]; |
221 | 221 | |
222 | - if (!$this->Venda->save($data)) { |
|
222 | + if ( ! $this->Venda->save($data)) { |
|
223 | 223 | $this->Session->setFlash('Erro ao emitir cobrança!'); |
224 | - return $this->redirect('/cliente/listar_pedidos/' . $cliente['Cliente']['id']); |
|
224 | + return $this->redirect('/cliente/listar_pedidos/'.$cliente['Cliente']['id']); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | $this->Session->setFlash('Cobrança emitida com sucesso!'); |
228 | - return $this->redirect('/cliente/listar_pedidos/' . $cliente['Cliente']['id']); |
|
228 | + return $this->redirect('/cliente/listar_pedidos/'.$cliente['Cliente']['id']); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | public function carregar_clientes($id = null) |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | ) |
239 | 239 | ); |
240 | 240 | |
241 | - if (!empty($filter['term'])) { |
|
242 | - $conditions['conditions']['Cliente.nome1 LIKE '] = '%' . $filter['term'] . '%'; |
|
241 | + if ( ! empty($filter['term'])) { |
|
242 | + $conditions['conditions']['Cliente.nome1 LIKE '] = '%'.$filter['term'].'%'; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | $conditions['limit'] = $this->request->query('page_limit'); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $i++; |
257 | 257 | |
258 | 258 | $response['results'][$i]['id'] = $cliente['Cliente']['id']; |
259 | - $response['results'][$i]['text'] = $cliente['Cliente']['nome1'] . ' ' . $cliente['Cliente']['nome2']; |
|
259 | + $response['results'][$i]['text'] = $cliente['Cliente']['nome1'].' '.$cliente['Cliente']['nome2']; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | echo json_encode($response); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | public function getProdutosEstoqueMinimoComoHtml($produtos) { |
249 | - ob_start(); |
|
249 | + ob_start(); |
|
250 | 250 | |
251 | 251 | $html = ''; |
252 | 252 | $html .= '<html>'; |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | |
360 | 360 | $this->Session->setFlash('Produto salvo com sucesso!'); |
361 | 361 | |
362 | - return $this->redirect('/produto/listar_cadastros'); |
|
362 | + return $this->redirect('/produto/listar_cadastros'); |
|
363 | 363 | } else { |
364 | 364 | $this->Session->setFlash('Ocorreu um erro ao salva o produto!'); |
365 | 365 | |
366 | - return $this->redirect('/produto/listar_cadastros'); |
|
366 | + return $this->redirect('/produto/listar_cadastros'); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
@@ -374,17 +374,17 @@ discard block |
||
374 | 374 | |
375 | 375 | $query = array ( |
376 | 376 | 'joins' => array( |
377 | - array( |
|
378 | - 'table' => 'produtos', |
|
379 | - 'alias' => 'Produto', |
|
380 | - 'type' => 'LEFT', |
|
381 | - 'conditions' => array( |
|
382 | - 'Variacao.produto_id = Produto.id', |
|
383 | - ), |
|
384 | - ) |
|
377 | + array( |
|
378 | + 'table' => 'produtos', |
|
379 | + 'alias' => 'Produto', |
|
380 | + 'type' => 'LEFT', |
|
381 | + 'conditions' => array( |
|
382 | + 'Variacao.produto_id = Produto.id', |
|
383 | + ), |
|
384 | + ) |
|
385 | 385 | ), |
386 | - 'conditions' => array('Variacao.produto_id' => $id, 'Variacao.ativo' => 1), |
|
387 | - 'fields' => array('Produto.id, Variacao.*'), |
|
386 | + 'conditions' => array('Variacao.produto_id' => $id, 'Variacao.ativo' => 1), |
|
387 | + 'fields' => array('Produto.id, Variacao.*'), |
|
388 | 388 | ); |
389 | 389 | |
390 | 390 | $variacoes = $this->set('variacoes', $this->Variacao->find('all', $query)); |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | $objVariacaoController->s_adicionar_variacao($variacoes, $id, $this->instancia); |
443 | 443 | |
444 | 444 | $this->Session->setFlash('Produto editado com sucesso!','default','good'); |
445 | - return $this->redirect('/produto/listar_cadastros'); |
|
445 | + return $this->redirect('/produto/listar_cadastros'); |
|
446 | 446 | } else { |
447 | 447 | $this->Session->setFlash('Ocorreu um erro ao editar o produto!','default','good'); |
448 | - return $this->redirect('/produto/listar_cadastros'); |
|
448 | + return $this->redirect('/produto/listar_cadastros'); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -577,107 +577,107 @@ discard block |
||
577 | 577 | include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
578 | 578 | include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
579 | 579 | |
580 | - $objPHPExcel = new PHPExcel(); |
|
581 | - // Definimos o estilo da fonte |
|
582 | - $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
|
580 | + $objPHPExcel = new PHPExcel(); |
|
581 | + // Definimos o estilo da fonte |
|
582 | + $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
|
583 | 583 | |
584 | - $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); |
|
584 | + $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); |
|
585 | 585 | |
586 | - // Criamos as colunas |
|
587 | - $objPHPExcel->setActiveSheetIndex(0) |
|
588 | - ->setCellValue('A1', "Nome do Produto") |
|
589 | - ->setCellValue('B1', "Preço ") |
|
590 | - ->setCellValue("C1", "Peso Bruto") |
|
591 | - ->setCellValue("D1", "Peso Liquido") |
|
592 | - ->setCellValue("E1", "Estoque") |
|
593 | - ->setCellValue("F1", "Descrição"); |
|
586 | + // Criamos as colunas |
|
587 | + $objPHPExcel->setActiveSheetIndex(0) |
|
588 | + ->setCellValue('A1', "Nome do Produto") |
|
589 | + ->setCellValue('B1', "Preço ") |
|
590 | + ->setCellValue("C1", "Peso Bruto") |
|
591 | + ->setCellValue("D1", "Peso Liquido") |
|
592 | + ->setCellValue("E1", "Estoque") |
|
593 | + ->setCellValue("F1", "Descrição"); |
|
594 | 594 | |
595 | - // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas |
|
596 | - $objPHPExcel->getActiveSheet()->setTitle('Listagem de produtos'); |
|
595 | + // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas |
|
596 | + $objPHPExcel->getActiveSheet()->setTitle('Listagem de produtos'); |
|
597 | 597 | |
598 | - // Cabeçalho do arquivo para ele baixar |
|
599 | - header('Content-Type: application/vnd.ms-excel'); |
|
600 | - header('Content-Disposition: attachment;filename="planilha_importacao_exemplo.xls"'); |
|
601 | - header('Cache-Control: max-age=0'); |
|
602 | - // Se for o IE9, isso talvez seja necessário |
|
603 | - header('Cache-Control: max-age=1'); |
|
598 | + // Cabeçalho do arquivo para ele baixar |
|
599 | + header('Content-Type: application/vnd.ms-excel'); |
|
600 | + header('Content-Disposition: attachment;filename="planilha_importacao_exemplo.xls"'); |
|
601 | + header('Cache-Control: max-age=0'); |
|
602 | + // Se for o IE9, isso talvez seja necessário |
|
603 | + header('Cache-Control: max-age=1'); |
|
604 | 604 | |
605 | - // Acessamos o 'Writer' para poder salvar o arquivo |
|
606 | - $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); |
|
605 | + // Acessamos o 'Writer' para poder salvar o arquivo |
|
606 | + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); |
|
607 | 607 | |
608 | - // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela |
|
609 | - $objWriter->save('php://output'); |
|
608 | + // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela |
|
609 | + $objWriter->save('php://output'); |
|
610 | 610 | |
611 | - exit; |
|
612 | - } |
|
611 | + exit; |
|
612 | + } |
|
613 | 613 | |
614 | - public function importar_produtos_planilha() { |
|
615 | - if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
616 | - { |
|
614 | + public function importar_produtos_planilha() { |
|
615 | + if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
616 | + { |
|
617 | 617 | $this->Session->setFlash("Erro ao subir a planilha, tente novamente."); |
618 | 618 | $this->redirect("/produto/listar_cadastros"); |
619 | - } |
|
619 | + } |
|
620 | 620 | |
621 | - $typesPermissions = ['application/vnd.ms-excel']; |
|
621 | + $typesPermissions = ['application/vnd.ms-excel']; |
|
622 | 622 | |
623 | - if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
624 | - { |
|
623 | + if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
624 | + { |
|
625 | 625 | $this->Session->setFlash("O arquivo deve ser no formato .xls."); |
626 | 626 | $this->redirect("/produto/listar_cadastros"); |
627 | - } |
|
627 | + } |
|
628 | 628 | |
629 | - $caminho = APP . 'webroot/uploads/produto/planilhas/' . uniqid() . '.xls'; |
|
629 | + $caminho = APP . 'webroot/uploads/produto/planilhas/' . uniqid() . '.xls'; |
|
630 | 630 | |
631 | - $inputFileName = $_FILES['arquivo']['tmp_name']; |
|
631 | + $inputFileName = $_FILES['arquivo']['tmp_name']; |
|
632 | 632 | |
633 | - move_uploaded_file($inputFileName, $caminho); |
|
633 | + move_uploaded_file($inputFileName, $caminho); |
|
634 | 634 | |
635 | - $data = [ |
|
636 | - 'caminho' => $caminho, |
|
637 | - 'usuario_id' => $this->instancia, |
|
638 | - 'processado' => 0, |
|
639 | - 'ativo' => 1 |
|
640 | - ]; |
|
635 | + $data = [ |
|
636 | + 'caminho' => $caminho, |
|
637 | + 'usuario_id' => $this->instancia, |
|
638 | + 'processado' => 0, |
|
639 | + 'ativo' => 1 |
|
640 | + ]; |
|
641 | 641 | |
642 | - $this->loadModel('QueueProduct'); |
|
642 | + $this->loadModel('QueueProduct'); |
|
643 | 643 | |
644 | - if ($this->QueueProduct->save($data)) |
|
645 | - { |
|
644 | + if ($this->QueueProduct->save($data)) |
|
645 | + { |
|
646 | 646 | $this->Session->setFlash("O arquivo está na fila para ser importado, iremos enviar um e-mail quando terminar."); |
647 | 647 | $this->redirect("/produto/listar_cadastros"); |
648 | - } |
|
649 | - else |
|
650 | - { |
|
648 | + } |
|
649 | + else |
|
650 | + { |
|
651 | 651 | $this->Session->setFlash("Ocorreu um erro, tente novamente."); |
652 | 652 | $this->redirect("/produto/listar_cadastros"); |
653 | - } |
|
654 | - } |
|
653 | + } |
|
654 | + } |
|
655 | 655 | |
656 | - public function processar_planilhas_na_fila() { |
|
657 | - $this->loadModel('QueueProduct'); |
|
656 | + public function processar_planilhas_na_fila() { |
|
657 | + $this->loadModel('QueueProduct'); |
|
658 | 658 | |
659 | - $planilhas = $this->QueueProduct->loadPlanilhasNotProcesseds(); |
|
659 | + $planilhas = $this->QueueProduct->loadPlanilhasNotProcesseds(); |
|
660 | 660 | |
661 | - $response = []; |
|
662 | - foreach ($planilhas as $planilha) { |
|
663 | - $response[] = $this->processar_planilhas($planilha['caminho'], $planilha['usuario_id'], $planilha['id']); |
|
664 | - } |
|
661 | + $response = []; |
|
662 | + foreach ($planilhas as $planilha) { |
|
663 | + $response[] = $this->processar_planilhas($planilha['caminho'], $planilha['usuario_id'], $planilha['id']); |
|
664 | + } |
|
665 | 665 | |
666 | - return $response; |
|
667 | - } |
|
666 | + return $response; |
|
667 | + } |
|
668 | 668 | |
669 | - public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
|
669 | + public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
|
670 | 670 | include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
671 | 671 | include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
672 | 672 | |
673 | - $objPHPExcel = new PHPExcel(); |
|
673 | + $objPHPExcel = new PHPExcel(); |
|
674 | 674 | |
675 | 675 | try { |
676 | - $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
677 | - $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
678 | - $objPHPExcel = $objReader->load($inputFileName); |
|
676 | + $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
677 | + $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
678 | + $objPHPExcel = $objReader->load($inputFileName); |
|
679 | 679 | } catch(Exception $e) { |
680 | - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
680 | + die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | $dados = []; |
@@ -733,49 +733,49 @@ discard block |
||
733 | 733 | |
734 | 734 | echo json_encode(array('sucess' => true)); |
735 | 735 | exit; |
736 | - } |
|
736 | + } |
|
737 | 737 | |
738 | - public function processar_lista_produtos($dados) { |
|
739 | - $errors = []; |
|
738 | + public function processar_lista_produtos($dados) { |
|
739 | + $errors = []; |
|
740 | 740 | |
741 | - foreach ($dados as $dado) { |
|
742 | - $this->loadModel('Produto'); |
|
741 | + foreach ($dados as $dado) { |
|
742 | + $this->loadModel('Produto'); |
|
743 | 743 | |
744 | - $existProduto = $this->Produto->find('all', |
|
745 | - array( |
|
746 | - 'conditions' => array( |
|
747 | - 'Produto.sku' => $dado['sku'], |
|
748 | - 'Produto.ativo' => 1 |
|
749 | - ) |
|
750 | - ) |
|
751 | - ); |
|
752 | - |
|
753 | - if (isset($existProduto) && !empty($existProduto)) |
|
754 | - { |
|
755 | - $this->Produto->id = $existProduto[0]['Produto']['id']; |
|
756 | - $this->Produto->save($dado); |
|
757 | - continue; |
|
758 | - } |
|
744 | + $existProduto = $this->Produto->find('all', |
|
745 | + array( |
|
746 | + 'conditions' => array( |
|
747 | + 'Produto.sku' => $dado['sku'], |
|
748 | + 'Produto.ativo' => 1 |
|
749 | + ) |
|
750 | + ) |
|
751 | + ); |
|
752 | + |
|
753 | + if (isset($existProduto) && !empty($existProduto)) |
|
754 | + { |
|
755 | + $this->Produto->id = $existProduto[0]['Produto']['id']; |
|
756 | + $this->Produto->save($dado); |
|
757 | + continue; |
|
758 | + } |
|
759 | 759 | |
760 | 760 | $this->Produto->create(); |
761 | 761 | |
762 | - if (!$this->Produto->save($dado)) |
|
763 | - { |
|
764 | - $errors[] = $dado; |
|
765 | - } |
|
766 | - } |
|
762 | + if (!$this->Produto->save($dado)) |
|
763 | + { |
|
764 | + $errors[] = $dado; |
|
765 | + } |
|
766 | + } |
|
767 | 767 | |
768 | - return $errors; |
|
769 | - } |
|
768 | + return $errors; |
|
769 | + } |
|
770 | 770 | |
771 | - public function salvar_imagem($id) { |
|
771 | + public function salvar_imagem($id) { |
|
772 | 772 | $image = $_FILES['arquivo']; |
773 | 773 | |
774 | 774 | $retorno = $this->uploadImage($image); |
775 | 775 | |
776 | 776 | if (!$retorno['status']) { |
777 | 777 | $this->Session->setFlash('A imagem não foi salva tente novamente ou contate o suporte!'); |
778 | - return $this->redirect('/produto/imagens/' . $id); |
|
778 | + return $this->redirect('/produto/imagens/' . $id); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | $photo = $this->request->data('photo'); |
@@ -796,22 +796,22 @@ discard block |
||
796 | 796 | |
797 | 797 | if (!$retorno) { |
798 | 798 | $this->Session->setFlash('A imagem não foi salva tente novamente ou contate o suporte!'); |
799 | - return $this->redirect('/produto/imagens/' . $id); |
|
799 | + return $this->redirect('/produto/imagens/' . $id); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | $this->Session->setFlash('A salva com sucesso!'); |
803 | - return $this->redirect('/produto/imagens/' . $id); |
|
804 | - } |
|
803 | + return $this->redirect('/produto/imagens/' . $id); |
|
804 | + } |
|
805 | 805 | |
806 | - public function imagem_excluir_cadastro($id) { |
|
807 | - $this->loadModel('Imagen'); |
|
806 | + public function imagem_excluir_cadastro($id) { |
|
807 | + $this->loadModel('Imagen'); |
|
808 | 808 | |
809 | - $this->Imagen->id = $id; |
|
809 | + $this->Imagen->id = $id; |
|
810 | 810 | |
811 | - $this->Imagen->save(['ativo' => 0]); |
|
811 | + $this->Imagen->save(['ativo' => 0]); |
|
812 | 812 | |
813 | - echo json_encode(array('success' => true)); |
|
814 | - exit; |
|
815 | - } |
|
813 | + echo json_encode(array('success' => true)); |
|
814 | + exit; |
|
815 | + } |
|
816 | 816 | |
817 | 817 | } |
@@ -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,11 +76,11 @@ 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 | - $btImage = ' <a class="btn btn-primary" href="/produto/imagens/' . $produto['Produto']['id'] . '"><i class="fa fa-picture-o"></i></a>'; |
|
81 | + $btImage = ' <a class="btn btn-primary" href="/produto/imagens/'.$produto['Produto']['id'].'"><i class="fa fa-picture-o"></i></a>'; |
|
82 | 82 | |
83 | - $row[] = $btEdit . $btImage; |
|
83 | + $row[] = $btEdit.$btImage; |
|
84 | 84 | |
85 | 85 | $output['aaData'][] = $row; |
86 | 86 | } |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $this->set('produto', $produto); |
114 | 114 | } |
115 | 115 | |
116 | - public function listar_cadastros_estoque_minimo(){ |
|
116 | + public function listar_cadastros_estoque_minimo() { |
|
117 | 117 | $this->layout = 'wadmin'; |
118 | 118 | } |
119 | 119 | |
120 | - public function listar_cadastros_estoque_minimo_ajax(){ |
|
120 | + public function listar_cadastros_estoque_minimo_ajax() { |
|
121 | 121 | |
122 | 122 | $this->layout = 'ajax'; |
123 | 123 | |
124 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
124 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
125 | 125 | |
126 | 126 | $this->loadModel('Usuario'); |
127 | 127 | |
@@ -143,30 +143,30 @@ discard block |
||
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | |
146 | - $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
146 | + $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
147 | 147 | |
148 | 148 | |
149 | - $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"; |
|
149 | + $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"; |
|
150 | 150 | |
151 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
151 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
152 | 152 | { |
153 | - $sql .= ' LIMIT ' . $_GET['iDisplayLength'] . ' OFFSET ' . $_GET['iDisplayStart']; |
|
153 | + $sql .= ' LIMIT '.$_GET['iDisplayLength'].' OFFSET '.$_GET['iDisplayStart']; |
|
154 | 154 | } |
155 | 155 | |
156 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
156 | + if (isset($_GET['iSortCol_0'])) |
|
157 | 157 | { |
158 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
158 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
159 | 159 | { |
160 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
160 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
161 | 161 | { |
162 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
162 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
167 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
168 | 168 | { |
169 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
169 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $produtos = $this->Produto->query($sql); |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | "aaData" => array() |
179 | 179 | ); |
180 | 180 | |
181 | - foreach ( $produtos as $i => $produto ) |
|
181 | + foreach ($produtos as $i => $produto) |
|
182 | 182 | { |
183 | 183 | $row = array(); |
184 | 184 | |
185 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
185 | + for ($i = 0; $i < count($aColumns); $i++) |
|
186 | 186 | { |
187 | 187 | $value = $produto['Produto'][$aColumns[$i]]; |
188 | 188 | |
189 | 189 | if ($aColumns[$i] == "imagem") |
190 | 190 | { |
191 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
191 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
192 | 192 | |
193 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
193 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
194 | 194 | { |
195 | 195 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
196 | 196 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ) |
231 | 231 | ); |
232 | 232 | |
233 | - $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
233 | + $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
234 | 234 | |
235 | 235 | $html = $this->getProdutosEstoqueMinimoComoHtml($produtos); |
236 | 236 | |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | |
286 | 286 | foreach ($produtos as $i => $produto) { |
287 | 287 | $html .= ' <tr>'; |
288 | - $html .= ' <td>' . $produto['Produto']['nome'] . '</td>'; |
|
289 | - $html .= ' <td>' . $produto['Produto']['estoque'] . '</td>'; |
|
290 | - $html .= ' <td>R$ ' . number_format($produto['Produto']['custo'], 2, ',', '.') . '</td>'; |
|
288 | + $html .= ' <td>'.$produto['Produto']['nome'].'</td>'; |
|
289 | + $html .= ' <td>'.$produto['Produto']['estoque'].'</td>'; |
|
290 | + $html .= ' <td>R$ '.number_format($produto['Produto']['custo'], 2, ',', '.').'</td>'; |
|
291 | 291 | $html .= ' </tr>'; |
292 | 292 | } |
293 | 293 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $html .= ''; |
300 | 300 | $html .= '</body>'; |
301 | 301 | $html .= '</html>'; |
302 | - echo $html;exit; |
|
302 | + echo $html; exit; |
|
303 | 303 | return $html; |
304 | 304 | } |
305 | 305 | |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | public function s_adicionar_cadastro() { |
322 | - $dados = $this->request->data('dados'); |
|
322 | + $dados = $this->request->data('dados'); |
|
323 | 323 | |
324 | 324 | $variacoes = $this->request->data('variacao'); |
325 | 325 | |
326 | - $image = $_FILES['imagem']; |
|
326 | + $image = $_FILES['imagem']; |
|
327 | 327 | |
328 | 328 | $retorno = $this->uploadImage($image); |
329 | 329 | |
330 | - if (!$retorno['status']) |
|
330 | + if ( ! $retorno['status']) |
|
331 | 331 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
332 | 332 | |
333 | 333 | $dados['imagem'] = $retorno['nome']; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $dados['id_alias'] = $this->id_alias(); |
337 | 337 | $dados['preco'] = str_replace(',', '', $dados['preco']); |
338 | 338 | |
339 | - if($this->Produto->save($dados)) { |
|
339 | + if ($this->Produto->save($dados)) { |
|
340 | 340 | $produto_id = $this->Produto->getLastInsertId(); |
341 | 341 | |
342 | 342 | require 'VariacaoController.php'; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $objPluggTo = new PluggtoController(); |
352 | 352 | $produto_pluggto = $objPluggTo->enviar_produto($dados, $variacoes); |
353 | 353 | |
354 | - if (!isset($produto_pluggto->Product->id)) |
|
354 | + if ( ! isset($produto_pluggto->Product->id)) |
|
355 | 355 | { |
356 | 356 | $this->Session->setFlash('Produto não foi enviado para o Plugg.to!'); |
357 | 357 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | |
373 | 373 | $this->loadModel('Variacao'); |
374 | 374 | |
375 | - $query = array ( |
|
375 | + $query = array( |
|
376 | 376 | 'joins' => array( |
377 | 377 | array( |
378 | 378 | 'table' => 'produtos', |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | |
416 | 416 | $variacoes = $this->request->data('variacao'); |
417 | 417 | |
418 | - $image = $_FILES['imagem']; |
|
418 | + $image = $_FILES['imagem']; |
|
419 | 419 | |
420 | - if (!empty($image['name'])) { |
|
420 | + if ( ! empty($image['name'])) { |
|
421 | 421 | $retorno = $this->uploadImage($image); |
422 | 422 | |
423 | - if (!$retorno['status']) |
|
423 | + if ( ! $retorno['status']) |
|
424 | 424 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
425 | 425 | |
426 | 426 | $dados['imagem'] = $retorno['nome']; |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | $objVariacaoController->desativar_variacoes($id); |
442 | 442 | $objVariacaoController->s_adicionar_variacao($variacoes, $id, $this->instancia); |
443 | 443 | |
444 | - $this->Session->setFlash('Produto editado com sucesso!','default','good'); |
|
444 | + $this->Session->setFlash('Produto editado com sucesso!', 'default', 'good'); |
|
445 | 445 | return $this->redirect('/produto/listar_cadastros'); |
446 | 446 | } else { |
447 | - $this->Session->setFlash('Ocorreu um erro ao editar o produto!','default','good'); |
|
447 | + $this->Session->setFlash('Ocorreu um erro ao editar o produto!', 'default', 'good'); |
|
448 | 448 | return $this->redirect('/produto/listar_cadastros'); |
449 | 449 | } |
450 | 450 | } |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | ) |
487 | 487 | ); |
488 | 488 | |
489 | - if (!$this->validar_estoque($retorno)) { |
|
489 | + if ( ! $this->validar_estoque($retorno)) { |
|
490 | 490 | return false; |
491 | 491 | } |
492 | 492 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | if ($user_active[0]['Usuario']['sale_without_stock']) |
517 | 517 | return true; |
518 | 518 | |
519 | - if (empty($produto) && !isset($produto)) { |
|
519 | + if (empty($produto) && ! isset($produto)) { |
|
520 | 520 | return false; |
521 | 521 | } |
522 | 522 | |
@@ -528,11 +528,11 @@ discard block |
||
528 | 528 | } |
529 | 529 | |
530 | 530 | public function calcular_preco_produto_venda($preco, $qnt) { |
531 | - if (empty($preco) || !isset($preco)) { |
|
531 | + if (empty($preco) || ! isset($preco)) { |
|
532 | 532 | return false; |
533 | 533 | } |
534 | 534 | |
535 | - if (!is_numeric($qnt)) { |
|
535 | + if ( ! is_numeric($qnt)) { |
|
536 | 536 | return false; |
537 | 537 | } |
538 | 538 | |
@@ -543,12 +543,12 @@ discard block |
||
543 | 543 | |
544 | 544 | public function uploadImage(&$image) { |
545 | 545 | $type = substr($image['name'], -4); |
546 | - $nameImage = uniqid() . md5($image['name']) . $type; |
|
547 | - $dir = APP . 'webroot/uploads/produto/imagens/'; |
|
546 | + $nameImage = uniqid().md5($image['name']).$type; |
|
547 | + $dir = APP.'webroot/uploads/produto/imagens/'; |
|
548 | 548 | |
549 | - $returnUpload = move_uploaded_file($image['tmp_name'], $dir . $nameImage); |
|
549 | + $returnUpload = move_uploaded_file($image['tmp_name'], $dir.$nameImage); |
|
550 | 550 | |
551 | - if (!$returnUpload) |
|
551 | + if ( ! $returnUpload) |
|
552 | 552 | return array('nome' => null, 'status' => false); |
553 | 553 | |
554 | 554 | return array('nome' => $nameImage, 'status' => true); |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | } |
575 | 575 | |
576 | 576 | public function exportar_excel_exemplo() { |
577 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
578 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
577 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
578 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
579 | 579 | |
580 | 580 | $objPHPExcel = new PHPExcel(); |
581 | 581 | // Definimos o estilo da fonte |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | public function importar_produtos_planilha() { |
615 | - if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
615 | + if ( ! isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
616 | 616 | { |
617 | 617 | $this->Session->setFlash("Erro ao subir a planilha, tente novamente."); |
618 | 618 | $this->redirect("/produto/listar_cadastros"); |
@@ -620,13 +620,13 @@ discard block |
||
620 | 620 | |
621 | 621 | $typesPermissions = ['application/vnd.ms-excel']; |
622 | 622 | |
623 | - if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
623 | + if ( ! in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
624 | 624 | { |
625 | 625 | $this->Session->setFlash("O arquivo deve ser no formato .xls."); |
626 | 626 | $this->redirect("/produto/listar_cadastros"); |
627 | 627 | } |
628 | 628 | |
629 | - $caminho = APP . 'webroot/uploads/produto/planilhas/' . uniqid() . '.xls'; |
|
629 | + $caminho = APP.'webroot/uploads/produto/planilhas/'.uniqid().'.xls'; |
|
630 | 630 | |
631 | 631 | $inputFileName = $_FILES['arquivo']['tmp_name']; |
632 | 632 | |
@@ -667,17 +667,17 @@ discard block |
||
667 | 667 | } |
668 | 668 | |
669 | 669 | public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
670 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
671 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
670 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
671 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
672 | 672 | |
673 | 673 | $objPHPExcel = new PHPExcel(); |
674 | 674 | |
675 | 675 | try { |
676 | - $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
677 | - $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
678 | - $objPHPExcel = $objReader->load($inputFileName); |
|
679 | - } catch(Exception $e) { |
|
680 | - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
676 | + $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
677 | + $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
678 | + $objPHPExcel = $objReader->load($inputFileName); |
|
679 | + } catch (Exception $e) { |
|
680 | + die('Error loading file "'.pathinfo($inputFileName, PATHINFO_BASENAME).'": '.$e->getMessage()); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | $dados = []; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | $errors = $this->processar_lista_produtos($dados); |
726 | 726 | |
727 | - if (isset($errors) && !empty($errors)) |
|
727 | + if (isset($errors) && ! empty($errors)) |
|
728 | 728 | { |
729 | 729 | $this->QueueProduct->planilhaProcessedIncomplete($planilhaId); |
730 | 730 | } |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | ) |
751 | 751 | ); |
752 | 752 | |
753 | - if (isset($existProduto) && !empty($existProduto)) |
|
753 | + if (isset($existProduto) && ! empty($existProduto)) |
|
754 | 754 | { |
755 | 755 | $this->Produto->id = $existProduto[0]['Produto']['id']; |
756 | 756 | $this->Produto->save($dado); |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | |
760 | 760 | $this->Produto->create(); |
761 | 761 | |
762 | - if (!$this->Produto->save($dado)) |
|
762 | + if ( ! $this->Produto->save($dado)) |
|
763 | 763 | { |
764 | 764 | $errors[] = $dado; |
765 | 765 | } |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | } |
770 | 770 | |
771 | 771 | public function salvar_imagem($id) { |
772 | - $image = $_FILES['arquivo']; |
|
772 | + $image = $_FILES['arquivo']; |
|
773 | 773 | |
774 | 774 | $retorno = $this->uploadImage($image); |
775 | 775 | |
776 | - if (!$retorno['status']) { |
|
776 | + if ( ! $retorno['status']) { |
|
777 | 777 | $this->Session->setFlash('A imagem não foi salva tente novamente ou contate o suporte!'); |
778 | - return $this->redirect('/produto/imagens/' . $id); |
|
778 | + return $this->redirect('/produto/imagens/'.$id); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | $photo = $this->request->data('photo'); |
@@ -794,13 +794,13 @@ discard block |
||
794 | 794 | |
795 | 795 | $retorno = $this->Imagen->save($data); |
796 | 796 | |
797 | - if (!$retorno) { |
|
797 | + if ( ! $retorno) { |
|
798 | 798 | $this->Session->setFlash('A imagem não foi salva tente novamente ou contate o suporte!'); |
799 | - return $this->redirect('/produto/imagens/' . $id); |
|
799 | + return $this->redirect('/produto/imagens/'.$id); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | $this->Session->setFlash('A salva com sucesso!'); |
803 | - return $this->redirect('/produto/imagens/' . $id); |
|
803 | + return $this->redirect('/produto/imagens/'.$id); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | public function imagem_excluir_cadastro($id) { |