Completed
Push — master ( 17c1a3...d21531 )
by Reginaldo
18:10
created
app/Controller/VendaController.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 					$value = str_replace('_', ' ', $value);
133 133
 					$value = ucwords($value);
134 134
 				} else if ($aColumns[$i] == "actions") {
135
-		            $value = '<a href="javascript:printNotaNaoFiscal(' . $venda['Venda']['id'] . ');" target="_blank" class="btn btn-info">';
136
-		            $value .= '<i class="fa fa-file-text" aria-hidden="true"></i>';
137
-		            $value .= '</a> ';
135
+					$value = '<a href="javascript:printNotaNaoFiscal(' . $venda['Venda']['id'] . ');" target="_blank" class="btn btn-info">';
136
+					$value .= '<i class="fa fa-file-text" aria-hidden="true"></i>';
137
+					$value .= '</a> ';
138 138
 
139 139
 					$value .= ' <button onclick="remover_venda(' . $venda['Venda']['id'] . ');" type="button" class="btn btn-danger"><i class="fa fa-times"></i></button>';
140 140
 				} else if ($aColumns[$i] == "valor") { 
@@ -380,58 +380,58 @@  discard block
 block discarded – undo
380 380
 		include(APP . 'Vendor/PHPExcel/PHPExcel.php');
381 381
 		include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php');
382 382
 
383
-        $objPHPExcel = new PHPExcel();
384
-        // Definimos o estilo da fonte
385
-        $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
386
-
387
-        $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
388
-
389
-        // Criamos as colunas
390
-        $objPHPExcel->setActiveSheetIndex(0)
391
-                    ->setCellValue('A1', "Valor Venda")
392
-                    ->setCellValue('B1', "Custo Médio ")
393
-                    ->setCellValue("C1", "Valor Lucro")
394
-                    ->setCellValue('D1', "ID Venda" );
395
-
396
-
397
-        $vendas = $this->Venda->find('all',
398
-        	array('conditions' => array(
399
-        			'AND' => array(
400
-        				'Venda.ativo' => 1,
401
-        				'Venda.id_usuario' => $this->instancia,
402
-        				'Venda.data_venda' => date('Y-m-d')
403
-        			)
404
-        		)
405
-        	)
406
-        );
407
-
408
-        $i = 2;
409
-        foreach ($vendas as $key => $venda) {
410
-        	$objPHPExcel->setActiveSheetIndex(0)
411
-        				->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor'])
412
-        				->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo'])
413
-        				->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo'])
414
-        				->setCellValue('D'.$i, $venda['Venda']['id']);
415
-        	$i++;
416
-        }
417
-
418
-        // Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas
419
-        $objPHPExcel->getActiveSheet()->setTitle('Listagem de vendas');
420
-
421
-        // Cabeçalho do arquivo para ele baixar
422
-        header('Content-Type: application/vnd.ms-excel');
423
-        header('Content-Disposition: attachment;filename="relatorio_vendas_'.date('d-m-Y').'.xls"');
424
-        header('Cache-Control: max-age=0');
425
-        // Se for o IE9, isso talvez seja necessário
426
-        header('Cache-Control: max-age=1');
427
-
428
-        // Acessamos o 'Writer' para poder salvar o arquivo
429
-        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
430
-
431
-        // Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela
432
-        $objWriter->save('php://output'); 
433
-
434
-        exit;
383
+		$objPHPExcel = new PHPExcel();
384
+		// Definimos o estilo da fonte
385
+		$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
386
+
387
+		$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
388
+
389
+		// Criamos as colunas
390
+		$objPHPExcel->setActiveSheetIndex(0)
391
+					->setCellValue('A1', "Valor Venda")
392
+					->setCellValue('B1', "Custo Médio ")
393
+					->setCellValue("C1", "Valor Lucro")
394
+					->setCellValue('D1', "ID Venda" );
395
+
396
+
397
+		$vendas = $this->Venda->find('all',
398
+			array('conditions' => array(
399
+					'AND' => array(
400
+						'Venda.ativo' => 1,
401
+						'Venda.id_usuario' => $this->instancia,
402
+						'Venda.data_venda' => date('Y-m-d')
403
+					)
404
+				)
405
+			)
406
+		);
407
+
408
+		$i = 2;
409
+		foreach ($vendas as $key => $venda) {
410
+			$objPHPExcel->setActiveSheetIndex(0)
411
+						->setCellValue('A'.$i, 'R$ ' . $venda['Venda']['valor'])
412
+						->setCellValue('B'.$i, 'R$ ' . $venda['Venda']['custo'])
413
+						->setCellValue('C'.$i, 'R$ ' . $venda['Venda']['valor'] - $venda['Venda']['custo'])
414
+						->setCellValue('D'.$i, $venda['Venda']['id']);
415
+			$i++;
416
+		}
417
+
418
+		// Podemos renomear o nome das planilha atual, lembrando que um único arquivo pode ter várias planilhas
419
+		$objPHPExcel->getActiveSheet()->setTitle('Listagem de vendas');
420
+
421
+		// Cabeçalho do arquivo para ele baixar
422
+		header('Content-Type: application/vnd.ms-excel');
423
+		header('Content-Disposition: attachment;filename="relatorio_vendas_'.date('d-m-Y').'.xls"');
424
+		header('Cache-Control: max-age=0');
425
+		// Se for o IE9, isso talvez seja necessário
426
+		header('Cache-Control: max-age=1');
427
+
428
+		// Acessamos o 'Writer' para poder salvar o arquivo
429
+		$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
430
+
431
+		// Salva diretamente no output, poderíamos mudar arqui para um nome de arquivo em um diretório ,caso não quisessemos jogar na tela
432
+		$objWriter->save('php://output'); 
433
+
434
+		exit;
435 435
 	}
436 436
 
437 437
 	public function recoverDataToDashboardOneWeek($id_usuario){
Please login to merge, or discard this patch.