fix clear and copy week
This commit is contained in:
@@ -11,7 +11,7 @@ use common\models\Ticket;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Yii;
|
||||
use yii\base\Object;
|
||||
use yii\base\BaseObject;
|
||||
use yii\db\ActiveRecord;
|
||||
use yii\db\Query;
|
||||
use yii\web\BadRequestHttpException;
|
||||
@@ -24,7 +24,7 @@ use yii\web\ServerErrorHttpException;
|
||||
* Date: 2018.12.17.
|
||||
* Time: 6:12
|
||||
*/
|
||||
class EventRegistrationManager extends Object
|
||||
class EventRegistrationManager extends BaseObject
|
||||
{
|
||||
const CARD_NOT_FOUND = 1;
|
||||
const CUSTOMER_NOT_FOUND = 2;
|
||||
@@ -189,21 +189,25 @@ class EventRegistrationManager extends Object
|
||||
|
||||
/**
|
||||
* @param EventRegistration $registration
|
||||
* @throws ServerErrorHttpException
|
||||
* @return bool
|
||||
* @throws \yii\base\Exception
|
||||
*/
|
||||
public function deleteRegistration($registration)
|
||||
{
|
||||
if (isset($registration->deleted_at)) {
|
||||
throw new ServerErrorHttpException('The reservation is already deleted');
|
||||
return false;
|
||||
}
|
||||
|
||||
$ticket = Ticket::findOne(['id_ticket' => $registration->id_ticket]);
|
||||
if( !isset($ticket ) ) {
|
||||
throw new \yii\base\Exception('Ticket not found: ' . $registration->id_ticket);
|
||||
}
|
||||
|
||||
$ticket->restoreReservationCount(1);
|
||||
$ticket->save(false);
|
||||
|
||||
$registration->deleted_at = date('Y-m-d H:i:s');
|
||||
$registration->save(false);
|
||||
return $registration->save(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -221,12 +225,16 @@ class EventRegistrationManager extends Object
|
||||
|
||||
$registrations = $event->getEventRegistrations()->all();
|
||||
// ////////////////////////////////
|
||||
// if even has no registrations
|
||||
// if event has no registrations
|
||||
// we can simply delete it from db
|
||||
// ////////////////////////////////
|
||||
if ( count($registrations) === 0 ) {
|
||||
$event->delete();
|
||||
} else {
|
||||
// /////////////////////////////
|
||||
// otherwise we mark the event deleted
|
||||
// and we have to delete the registrations
|
||||
// /////////////////////////////
|
||||
$event->deleted_at = date('Y-m-d H:i:s');
|
||||
$event->save(false);
|
||||
foreach ($registrations as $registration) {
|
||||
|
||||
Reference in New Issue
Block a user