-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Se han implementado librerias para exportar archivos word, excel y pd…
…f, se han añadido y validado la clase de archivos.
- Loading branch information
Showing
9 changed files
with
605 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,57 @@ | ||
# Lion-Framework-Backend | ||
|
||
## Install | ||
``` | ||
```powershell | ||
composer create-project lion-framework/lion-backend | ||
``` | ||
|
||
## Update packages | ||
``` | ||
```powershell | ||
composer install | ||
``` | ||
|
||
### Libraries used | ||
[Lion-SQL](https://github.com/Sleon4/Lion-SQL) | ||
``` | ||
#####[Lion-SQL](https://github.com/Sleon4/Lion-SQL) | ||
```powershell | ||
composer require lion-framework/lion-sql | ||
``` | ||
|
||
[Lion-Route](https://github.com/Sleon4/Lion-Route) | ||
``` | ||
#####[Lion-Route](https://github.com/Sleon4/Lion-Route) | ||
```powershell | ||
composer require lion-framework/lion-route | ||
``` | ||
|
||
[Lion-Mailer](https://github.com/Sleon4/Lion-Mailer) | ||
``` | ||
#####[Lion-Mailer](https://github.com/Sleon4/Lion-Mailer) | ||
```powershell | ||
composer require lion-framework/lion-mailer | ||
``` | ||
|
||
[Valitron](https://github.com/vlucas/valitron) | ||
``` | ||
#####[Valitron](https://github.com/vlucas/valitron) | ||
```powershell | ||
composer require vlucas/valitron | ||
``` | ||
|
||
[PHP dotenv](https://github.com/vlucas/phpdotenv) | ||
``` | ||
#####[PHP dotenv](https://github.com/vlucas/phpdotenv) | ||
```powershell | ||
composer require vlucas/phpdotenv | ||
``` | ||
|
||
[PHRoute](https://github.com/mrjgreen/phroute) | ||
``` | ||
#####[PHRoute](https://github.com/mrjgreen/phroute) | ||
```powershell | ||
composer require phroute/phroute | ||
``` | ||
|
||
[PHPMailer](https://github.com/PHPMailer/PHPMailer) | ||
``` | ||
#####[PHPMailer](https://github.com/PHPMailer/PHPMailer) | ||
```powershell | ||
composer require phpmailer/phpmailer | ||
``` | ||
|
||
#####[PHPSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet) | ||
```powershell | ||
composer require phpoffice/phpspreadsheet | ||
``` | ||
|
||
#####[Dompdf](https://github.com/dompdf/dompdf) | ||
```powershell | ||
composer require dompdf/dompdf | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
//require_once 'dompdf/autoload.inc.php'; | ||
|
||
namespace App\Http\Functions; | ||
|
||
use Dompdf\Dompdf; | ||
use App\Http\Functions\Files; | ||
|
||
class Pdf { | ||
|
||
private static Dompdf $dompdf; | ||
|
||
public function __construct() { | ||
|
||
} | ||
|
||
public static function load(): void { | ||
self::$dompdf = new Dompdf(); | ||
} | ||
|
||
public static function convertToPdf(string $path, string $url): string { | ||
Files::folder($url); | ||
$file_name = $url . Files::getName($path) . ".pdf"; | ||
self::$dompdf->loadHtml(file_get_contents($path)); | ||
self::$dompdf->render(); | ||
file_put_contents($file_name, self::$dompdf->output()); | ||
|
||
return $file_name; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace App\Http\Functions; | ||
|
||
use PhpOffice\PhpWord\TemplateProcessor; | ||
use PhpOffice\PhpWord\PhpWord; | ||
use PhpOffice\PhpWord\IOFactory; | ||
use PhpOffice\PhpWord\Style\Font; | ||
use PhpOffice\PhpWord\Element\Section; | ||
use App\Http\Functions\Files; | ||
|
||
class Word { | ||
|
||
private static ?TemplateProcessor $templateProcessor = null; | ||
private static ?PhpWord $phpWord = null; | ||
private static ?Section $section = null; | ||
private static ?Font $font = null; | ||
|
||
public function __construct() { | ||
|
||
} | ||
|
||
public static function load(): void { | ||
self::$phpWord = new PhpWord(); | ||
self::$font = new Font(); | ||
} | ||
|
||
public static function save(string $path, string $file_name, array $type = [], bool $rename = false): array { | ||
Files::folder($path); | ||
$list_files = []; | ||
$count = 0; | ||
|
||
foreach ($type as $key => $ext) { | ||
if ($count === 0) { | ||
$file_name = !$rename ? "{$file_name}.{$ext}" : Files::rename("{$file_name}.{$ext}"); | ||
} else { | ||
$file_name = Files::getName($file_name) . ".{$ext}"; | ||
} | ||
|
||
$list_files[$ext] = "{$path}{$file_name}"; | ||
IOFactory::createWriter(self::$phpWord, $key)->save("{$path}{$file_name}"); | ||
|
||
$count++; | ||
} | ||
|
||
return $list_files; | ||
} | ||
|
||
public static function loadTemplate(string $path): void { | ||
self::$font = new Font(); | ||
self::$templateProcessor = new TemplateProcessor($path); | ||
} | ||
|
||
public static function saveTemplate(string $path, string $file_name, bool $option = false): string { | ||
$file_name = !$option ? "{$file_name}.docx" : Files::rename("{$file_name}.docx"); | ||
self::$templateProcessor->saveAs("{$path}{$file_name}"); | ||
self::$templateProcessor = null; | ||
return "{$path}{$file_name}"; | ||
} | ||
|
||
public static function convertToHtml(string $path, string $url, bool $option = false): string { | ||
Files::folder($url); | ||
$file_name = !$option ? Files::getName($path) : Files::getName($path); | ||
$file_name = "{$url}{$file_name}.html"; | ||
|
||
IOFactory::createWriter(IOFactory::load($path), 'HTML')->save($file_name); | ||
return $file_name; | ||
} | ||
|
||
public static function add(array $elements): void { | ||
foreach ($elements as $key => $element) { | ||
self::$templateProcessor->setValue($key, $element); | ||
} | ||
} | ||
|
||
public static function section(array $options = []): void { | ||
self::$section = self::$phpWord->addSection($options); | ||
} | ||
|
||
public static function text(string $text): void { | ||
self::$section->addText($text)->setFontStyle(self::$font); | ||
self::$font = new Font(); | ||
} | ||
|
||
public static function bold(): void { | ||
self::$font->setBold(true); | ||
} | ||
|
||
public static function name(string $name): void { | ||
self::$font->setName($name); | ||
} | ||
|
||
public static function size(int $size): void { | ||
self::$font->setSize($size); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.