| @@ -191,11 +191,20 @@ | ||
| 191 | 191 | if (empty($data['status'])) { |
| 192 | 192 | $data['status'] = 'pending'; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - // Create enquiry | |
| 196 | - $enquiryId = $this->enquiryRepository->create($data); | |
| 195 | + // Create enquiry. The repository throws when the INSERT is rejected; | |
| 196 | + // this endpoint is public, so turn that into the same friendly failure | |
| 197 | + // every other rejection returns instead of a 500 that echoes the raw | |
| 198 | + // database error back to the visitor. | |
| 199 | + try { | |
| 200 | + $enquiryId = $this->enquiryRepository->create($data); | |
| 201 | + } catch (\Throwable $e) { | |
| 202 | + error_log('Yatra: failed to create enquiry - ' . $e->getMessage()); | |
| 197 | 203 | |
| 204 | + return ['success' => false, 'message' => __('Failed to submit enquiry.', 'yatra')]; | |
| 205 | + } | |
| 206 | + | |
| 198 | 207 | if (!$enquiryId) { |
| 199 | 208 | return ['success' => false, 'message' => __('Failed to submit enquiry.', 'yatra')]; |
| 200 | 209 | } |
| 201 | 210 | |
| @@ -338,9 +347,14 @@ | ||
| 338 | 347 | */ |
| 339 | 348 | public function bulkUpdateStatus(array $ids, string $status): array |
| 340 | 349 | { |
| 341 | 350 | // Allowed statuses for bulk updates. This list is mirrored in the admin UI. |
| 342 | - $validStatuses = ['pending', 'read', 'responded', 'archived', 'spam', 'trash']; | |
| 351 | + // 'completed' marks enquiries that have been fully handled, distinct from | |
| 352 | + // open/in-progress ones. 'closed' is the "no further action" end state the | |
| 353 | + // enquiry edit screen has always offered; it is accepted here too so the | |
| 354 | + // list's quick status actions and bulk actions can set it without the | |
| 355 | + // operator having to open each enquiry. | |
| 356 | + $validStatuses = ['pending', 'read', 'responded', 'completed', 'closed', 'archived', 'spam', 'trash']; | |
| 343 | 357 | |
| 344 | 358 | if (!in_array($status, $validStatuses, true)) { |
| 345 | 359 | return ['success' => false, 'affected' => 0, 'message' => __('Invalid status.', 'yatra')]; |
| 346 | 360 | } |
| @@ -349,9 +363,13 @@ | ||
| 349 | 363 | |
| 350 | 364 | return [ |
| 351 | 365 | 'success' => true, |
| 352 | 366 | 'affected' => $affected, |
| 353 | - 'message' => sprintf(__('%d enquiries updated.', 'yatra'), $affected), | |
| 367 | + 'message' => sprintf( | |
| 368 | + /* translators: %d: number of enquiries updated. */ | |
| 369 | + __('%d enquiries updated.', 'yatra'), | |
| 370 | + $affected | |
| 371 | + ), | |
| 354 | 372 | ]; |
| 355 | 373 | } |
| 356 | 374 | |
| 357 | 375 | /** |
| @@ -366,9 +384,13 @@ | ||
| 366 | 384 | |
| 367 | 385 | return [ |
| 368 | 386 | 'success' => true, |
| 369 | 387 | 'affected' => $affected, |
| 370 | - 'message' => sprintf(__('%d enquiries deleted.', 'yatra'), $affected), | |
| 388 | + 'message' => sprintf( | |
| 389 | + /* translators: %d: number of enquiries deleted. */ | |
| 390 | + __('%d enquiries deleted.', 'yatra'), | |
| 391 | + $affected | |
| 392 | + ), | |
| 371 | 393 | ]; |
| 372 | 394 | } |
| 373 | 395 | |
| 374 | 396 | /** |