| @@ -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 | } |