@@ -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 .= ' <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") { |
@@ -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){ |