mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
wip
This commit is contained in:
parent
8e3875da96
commit
b22825bf17
@ -657,7 +657,6 @@ trait MakesInvoiceValues
|
|||||||
*/
|
*/
|
||||||
private function processReservedKeywords(string $value): ?string
|
private function processReservedKeywords(string $value): ?string
|
||||||
{
|
{
|
||||||
|
|
||||||
$replacements = [
|
$replacements = [
|
||||||
'literal' => [
|
'literal' => [
|
||||||
':MONTH' => now()->localeMonth,
|
':MONTH' => now()->localeMonth,
|
||||||
@ -671,9 +670,33 @@ trait MakesInvoiceValues
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
preg_match_all('/:([^:\s]+)/', $value, $m);
|
// First case, with ranges.
|
||||||
|
preg_match_all('/\[(.*?)]/', $value, $ranges);
|
||||||
|
|
||||||
$matches = array_shift($m);
|
$matches = array_shift($ranges);
|
||||||
|
|
||||||
|
foreach ($matches as $match) {
|
||||||
|
if (!Str::contains($match, '|')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Str::contains($match, '|')) {
|
||||||
|
$replacement = 'PLACEHOLDER FOR REPLACEMENT!';
|
||||||
|
$parts = explode('|', $match);
|
||||||
|
|
||||||
|
info($parts);
|
||||||
|
info($parts[0]);
|
||||||
|
|
||||||
|
$value = preg_replace(
|
||||||
|
sprintf('/%s/', preg_quote($match)), $replacement, $value, 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second case with more common calculations.
|
||||||
|
preg_match_all('/:([^:\s]+)/', $value, $common);
|
||||||
|
|
||||||
|
$matches = array_shift($common);
|
||||||
|
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$matches = collect($replacements['literal'])->filter(function ($value, $key) use ($match) {
|
$matches = collect($replacements['literal'])->filter(function ($value, $key) use ($match) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user