Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // current status
     $from = \SpoonFilter::getGetValue('from', array('moderation', 'completed'), 'moderation');
     // action to execute
     $action = \SpoonFilter::getGetValue('action', array('moderation', 'completed', 'delete'), 'completed');
     // no id's provided
     if (!isset($_GET['id'])) {
         $this->redirect(BackendModel::createURLForAction('orders') . '&error=no-orders-selected');
     }
     // redefine id's
     $ids = (array) $_GET['id'];
     // delete comment(s)
     if ($action == 'delete') {
         BackendCatalogModel::deleteOrders($ids);
     }
     if ($action == 'completed') {
         BackendCatalogModel::updateOrderStatuses($ids, $action);
     }
     if ($action == 'moderation') {
         BackendCatalogModel::updateOrderStatuses($ids, $action);
     }
     // define report
     $report = count($ids) > 1 ? 'orders-' : 'order-';
     // init var
     if ($action == 'moderation') {
         $report .= 'moved-moderation';
     }
     if ($action == 'completed') {
         $report .= 'moved-completed';
     }
     if ($action == 'delete') {
         $report .= 'deleted';
     }
     // redirect
     $this->redirect(BackendModel::createURLForAction('orders') . '&report=' . $report . '#tab' . ucfirst($from));
 }