mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
working on templates
This commit is contained in:
parent
22367c1f19
commit
8256131ea2
@ -744,6 +744,20 @@ class HtmlEngine
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function makeValuesNoPrefix() :array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$values = $this->buildEntityDataArray();
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
$data[str_replace(["$","."],["_","_"],$key)] = $value['value'];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function generateLabelsAndValues()
|
||||
{
|
||||
$data = [];
|
||||
|
@ -230,4 +230,123 @@ class Phantom
|
||||
|
||||
return view('pdf.html', $data);
|
||||
}
|
||||
|
||||
public function blade()
|
||||
{
|
||||
|
||||
$i = \App\Models\Invoice::first();
|
||||
|
||||
$html_variables = (new HtmlEngine($i->invitations->first()))->makeValuesNoPrefix();
|
||||
$variables = (new HtmlEngine($i->invitations->first()))->makeValuesNoPrefix();
|
||||
|
||||
$html_variables = array_merge($html_variables, $variables);
|
||||
// $smarty->assign($html_variables);
|
||||
|
||||
$template_string = '
|
||||
display {$foo} here <?php echo time(); ?>
|
||||
|
||||
{if $invoice.amount > 5}
|
||||
<br>
|
||||
ewwo {$invoice.amount * 5}
|
||||
{/if}
|
||||
<br>
|
||||
{if isset($entry) && is_array($entry)}
|
||||
I am a puppet
|
||||
{/if}
|
||||
<br>
|
||||
{if 1 > 0}
|
||||
1 is greater than 0
|
||||
{/if}
|
||||
<br>
|
||||
{if 0 > 1}
|
||||
0 is greater than 1
|
||||
{/if}
|
||||
<br>
|
||||
{foreach $countries as $country}
|
||||
|
||||
{if $country.name = "Australia"}
|
||||
{$country.name}<br>
|
||||
{/if}
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
{/foreach}
|
||||
|
||||
|
||||
{foreach $invoice.line_items as $item}
|
||||
{$item->quantity} - {$item->cost} - {$item->notes} - {$item->line_total}<br>
|
||||
{/foreach}
|
||||
|
||||
echo "I am a puppet";
|
||||
|
||||
<script
|
||||
src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"
|
||||
type="text/javascript">
|
||||
</script>
|
||||
|
||||
';
|
||||
|
||||
$template_string = '
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ _invoice_number }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ _invoice_number }}</h1>
|
||||
<h3>Athletes list</h3>
|
||||
<ul>
|
||||
{% for item in invoice.line_items %}
|
||||
<li>{{ item.product_key|e }} {{ item.quantity|e }} {{ item.type_id|e }} {{ item.notes|e }} {{ item.line_total|e }}</li>
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
|
||||
{{ _invoiceDate }}<br>
|
||||
{{ _shipping }} <br>
|
||||
{{ _client_address|raw }}<br>
|
||||
{{ xx }}
|
||||
|
||||
$invoice.amount<br>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
';
|
||||
|
||||
$loader = new \Twig\Loader\FilesystemLoader(storage_path());
|
||||
// $tags = ['if','for','raw','html','sandbox'];
|
||||
// $filters = ['upper'];
|
||||
// $methods = [
|
||||
// 'Article' => ['getTitle', 'getBody'],
|
||||
// ];
|
||||
// $properties = [
|
||||
// 'Article' => ['title', 'body'],
|
||||
// ];
|
||||
// $functions = ['range'];
|
||||
// $policy = new \Twig\Sandbox\SecurityPolicy($tags, $filters, $methods, $properties, $functions);
|
||||
// $sandbox = new \Twig\Extension\SandboxExtension($policy);
|
||||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
// $twig->addExtension($sandbox);
|
||||
|
||||
// $twig = new \Twig\Environment(new \Twig\Loader\ArrayLoader([]));
|
||||
$template = $twig->createTemplate($template_string);
|
||||
echo $template->render(array_merge([
|
||||
'invoice' => $i->toArray(),
|
||||
], $html_variables));
|
||||
|
||||
|
||||
// try{
|
||||
// $smarty->display('string:' . $template_string);
|
||||
// }
|
||||
// catch(\Throwable $e){
|
||||
// echo $e->getMessage();
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $smarty->display('string:' . $template_string);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,7 @@
|
||||
"omnipay/paypal": "^3.0",
|
||||
"payfast/payfast-php-sdk": "^1.1",
|
||||
"pragmarx/google2fa": "^8.0",
|
||||
"predis/predis": "^2",
|
||||
"psr/http-message": "^1.0",
|
||||
"pusher/pusher-php-server": "^7.2",
|
||||
"razorpay/razorpay": "2.*",
|
||||
@ -83,6 +84,7 @@
|
||||
"setasign/fpdf": "^1.8",
|
||||
"setasign/fpdi": "^2.3",
|
||||
"shopify/shopify-api": "^4.3",
|
||||
"smarty/smarty": "^4.3",
|
||||
"socialiteproviders/apple": "^5.2",
|
||||
"socialiteproviders/microsoft": "^4.1",
|
||||
"spatie/laravel-data": "^3.5",
|
||||
@ -93,7 +95,7 @@
|
||||
"symfony/mailgun-mailer": "^6.1",
|
||||
"symfony/postmark-mailer": "^6.1",
|
||||
"turbo124/beacon": "^1.5",
|
||||
"predis/predis": "^2",
|
||||
"twig/twig": "^3.0",
|
||||
"twilio/sdk": "^6.40",
|
||||
"webpatser/laravel-countries": "dev-master#75992ad",
|
||||
"wepay/php-sdk": "^0.3",
|
||||
|
139
composer.lock
generated
139
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "fe4e98a48b87b1d62a7c93b6f56c57cc",
|
||||
"content-hash": "22c7a90fc3389d0e5478e03f626d9ddb",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adrienrn/php-mimetyper",
|
||||
@ -9904,6 +9904,72 @@
|
||||
},
|
||||
"time": "2023-08-10T06:11:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "smarty/smarty",
|
||||
"version": "v4.3.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/smarty-php/smarty.git",
|
||||
"reference": "1d9cda2be34fd6edb74924684260636fd0b89288"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/1d9cda2be34fd6edb74924684260636fd0b89288",
|
||||
"reference": "1d9cda2be34fd6edb74924684260636fd0b89288",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.5 || ^7.5",
|
||||
"smarty/smarty-lexer": "^3.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"libs/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-3.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Monte Ohrt",
|
||||
"email": "monte@ohrt.com"
|
||||
},
|
||||
{
|
||||
"name": "Uwe Tews",
|
||||
"email": "uwe.tews@googlemail.com"
|
||||
},
|
||||
{
|
||||
"name": "Rodney Rehm",
|
||||
"email": "rodney.rehm@medialize.de"
|
||||
},
|
||||
{
|
||||
"name": "Simon Wisselink",
|
||||
"homepage": "https://www.iwink.nl/"
|
||||
}
|
||||
],
|
||||
"description": "Smarty - the compiling PHP template engine",
|
||||
"homepage": "https://smarty-php.github.io/smarty/",
|
||||
"keywords": [
|
||||
"templating"
|
||||
],
|
||||
"support": {
|
||||
"forum": "https://github.com/smarty-php/smarty/discussions",
|
||||
"issues": "https://github.com/smarty-php/smarty/issues",
|
||||
"source": "https://github.com/smarty-php/smarty/tree/v4.3.2"
|
||||
},
|
||||
"time": "2023-07-19T10:27:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "socialiteproviders/apple",
|
||||
"version": "5.5.2",
|
||||
@ -13895,6 +13961,77 @@
|
||||
},
|
||||
"time": "2023-08-20T23:18:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v3.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
|
||||
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/polyfill-ctype": "^1.8",
|
||||
"symfony/polyfill-mbstring": "^1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"symfony/phpunit-bridge": "^5.4.9|^6.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Twig\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com",
|
||||
"homepage": "http://fabien.potencier.org",
|
||||
"role": "Lead Developer"
|
||||
},
|
||||
{
|
||||
"name": "Twig Team",
|
||||
"role": "Contributors"
|
||||
},
|
||||
{
|
||||
"name": "Armin Ronacher",
|
||||
"email": "armin.ronacher@active-4.com",
|
||||
"role": "Project Founder"
|
||||
}
|
||||
],
|
||||
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
||||
"homepage": "https://twig.symfony.com",
|
||||
"keywords": [
|
||||
"templating"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/twigphp/Twig/issues",
|
||||
"source": "https://github.com/twigphp/Twig/tree/v3.7.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-08-28T11:09:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twilio/sdk",
|
||||
"version": "6.44.4",
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('clients', function (Blueprint $table) {
|
||||
$table->string('classification')->nullable();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
@ -141,6 +141,7 @@ Route::group(['middleware' => ['invite_db'], 'prefix' => 'client', 'as' => 'clie
|
||||
});
|
||||
|
||||
Route::get('phantom/{entity}/{invitation_key}', [Phantom::class, 'displayInvitation'])->middleware(['invite_db', 'phantom_secret'])->name('phantom_view');
|
||||
Route::get('blade/', [Phantom::class, 'blade'])->name('blade');
|
||||
|
||||
Route::get('.env', function () {
|
||||
})->middleware('throttle:honeypot');
|
||||
|
Loading…
x
Reference in New Issue
Block a user