changes to sms packages and option to create user

This commit is contained in:
Simon Pocrnjič
2025-11-06 21:54:07 +01:00
parent ad8e0d5cee
commit 1395b72ae8
102 changed files with 1386 additions and 319 deletions
@@ -37,7 +37,7 @@ public function index(Request $request): Response
->get(['id', 'profile_id', 'sname', 'phone_number']);
$templates = \App\Models\SmsTemplate::query()
->orderBy('name')
->get(['id', 'name']);
->get(['id', 'name', 'content']);
$segments = \App\Models\Segment::query()
->where('active', true)
->orderBy('name')
@@ -121,7 +121,7 @@ public function show(Package $package, SmsService $sms): Response
if (! $rendered) {
$body = isset($payload['body']) ? trim((string) $payload['body']) : '';
if ($body !== '') {
$rendered = $body;
$rendered = $sms->renderContent($body, $vars);
} elseif (! empty($payload['template_id'])) {
$tpl = \App\Models\SmsTemplate::find((int) $payload['template_id']);
if ($tpl) {
@@ -175,7 +175,7 @@ public function show(Package $package, SmsService $sms): Response
if ($body !== '') {
$preview = [
'source' => 'body',
'content' => $body,
'content' => $sms->renderContent($body, $vars),
];
} elseif (! empty($payload['template_id'])) {
/** @var SmsTemplate|null $tpl */
@@ -292,6 +292,8 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
'only_mobile' => ['nullable', 'boolean'],
'only_validated' => ['nullable', 'boolean'],
'start_date_from' => ['nullable', 'date'],
'start_date_to' => ['nullable', 'date'],
]);
$segmentId = (int) $request->input('segment_id');
@@ -321,6 +323,15 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
->where('client_cases.client_id', $clientId);
}
// Date range filters for start_date
if ($startDateFrom = $request->input('start_date_from')) {
$query->where('contracts.start_date', '>=', $startDateFrom);
}
if ($startDateTo = $request->input('start_date_to')) {
$query->where('contracts.start_date', '<=', $startDateTo);
}
// Optional phone filters
if ($request->boolean('only_mobile') || $request->boolean('only_validated')) {
$query->whereHas('clientCase.person.phones', function ($q) use ($request) {
@@ -345,6 +356,7 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
'id' => $contract->id,
'uuid' => $contract->uuid,
'reference' => $contract->reference,
'start_date' => $contract->start_date,
'case' => [
'id' => $contract->clientCase?->id,
'uuid' => $contract->clientCase?->uuid,