|
@@ -26,18 +26,36 @@ if($batch_action && $sale_ids && $user->isAdmin()) {
|
|
|
|
|
|
|
|
$user->requireValidCsrfToken();
|
|
$user->requireValidCsrfToken();
|
|
|
|
|
|
|
|
|
|
+ $update_status = static function(int $status) use ($sales) {
|
|
|
|
|
+ foreach($sales as $sale) {
|
|
|
|
|
+ $sale->status = $status;
|
|
|
|
|
+ $sale->commit();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
switch($batch_action) {
|
|
switch($batch_action) {
|
|
|
|
|
+ case "mark-new":
|
|
|
|
|
+ $update_status(SaleStatuses::NEW);
|
|
|
|
|
+ Session::addAlert("success", __("Leads marked as new successfully."));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "mark-confirmed":
|
|
|
|
|
+ $update_status(SaleStatuses::CONFIRMED);
|
|
|
|
|
+ Session::addAlert("success", __("Leads marked as confirmed successfully."));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "mark-shipping":
|
|
|
|
|
+ $update_status(SaleStatuses::SHIPPING);
|
|
|
|
|
+ Session::addAlert("success", __("Leads marked as shipping successfully."));
|
|
|
|
|
+ break;
|
|
|
case "mark-completed":
|
|
case "mark-completed":
|
|
|
- foreach($sales as $sale) {
|
|
|
|
|
- $sale->status = SaleStatuses::COMPLETED;
|
|
|
|
|
- $sale->commit();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $update_status(SaleStatuses::COMPLETED);
|
|
|
Session::addAlert("success", __("Leads marked as completed successfully."));
|
|
Session::addAlert("success", __("Leads marked as completed successfully."));
|
|
|
- Http::redirect($_SERVER["REQUEST_URI"]);
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
+
|
|
|
default:
|
|
default:
|
|
|
throw new RuntimeException(__("Invalid batch action."));
|
|
throw new RuntimeException(__("Invalid batch action."));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ Http::redirect($_SERVER["REQUEST_URI"]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Filters
|
|
// Filters
|