{{-- Skapa SMS-utskick form (DESIGN.md Page patterns 3: numbered step cards, summary panel, mobile bar; #2957 slice 5b, card #3019). Posts the same fields as the old form to sms-sendout.store: name, start_time, message, parts, receiverList[] and _token. "nh_when" and the date/time inputs are UI only: resources/assets/js/nuhet/sms-form.js writes start_time as "Y-m-d H:i:s" (the old datetimepicker format) and parts from the SMS splitter (/js/split-sms.min.js, the same counting as before). Param: $company. --}} @php // Lists are shown with their receiver count and how many of them have a mobile number; lists // where nobody has one cannot be ticked, as before. $lists = $company->receiverLists() ->withCount(['receivers', 'receivers as phone_count' => fn ($query) => $query->hasPhone()]) ->orderBy('name')->get(); $checkedIds = array_map('intval', (array) old('receiverList', [])); $checked = $lists->filter(fn ($list) => $list->phone_count > 0 && in_array((int) $list->id, $checkedIds, true)); $checkedCount = $checked->sum('phone_count'); $nowValue = now()->format('Y-m-d H:i:s'); $oldStart = old('start_time'); $oldStartTime = is_string($oldStart) ? \DateTime::createFromFormat('Y-m-d H:i:s', $oldStart) : false; $scheduled = $oldStartTime && $oldStartTime > new \DateTime(); $later = $scheduled ? \Illuminate\Support\Carbon::instance($oldStartTime) : now()->addHour()->startOfHour(); $expire = $company->expire_date ? \Illuminate\Support\Carbon::parse($company->expire_date) : null; $paid = optional($company->package)->monthly_cost > 0; $i18n = [ 'notChosen' => __('sendout.create.notChosen'), 'receiversValue' => __('sendout.create.receiversValue'), 'receiversValueOne' => __('sendout.create.receiversValueOne'), 'receiversShort' => __('sendout.create.receiversShort'), 'asap' => __('sendout.create.asap'), 'priceValue' => __('sms.nhForm.priceValue'), 'confirmText' => __('sms.nhForm.confirmText'), 'confirmExpire' => __('sms.nhForm.confirmExpire'), ]; $invalid = fn ($key) => $errors->has($key) ? 'true' : null; $describedBy = fn ($key) => $errors->has($key) ? $key.'-error' : null; @endphp
{{-- Replaces the old SweetAlert confirmation; sms-form.js fills the texts and submits on [data-nh-confirm]. --}}