debug: click to refresh when creating auction
[namibia] / module / Auction / src / Auction / Service / OpenDay.php
1 <?php
2 namespace Auction\Service;
3
4
5
6 /**
7  * Manage open saturdays.
8  * @author andre.fourie
9  */
10 class OpenDay extends \Auction\DataBin\OpenDay
11 {
12         /**
13          *
14          * @param array $meta
15          * @param object|null $jobRecord
16          * @param \Workspace\Utility\ServiceInputParams $contract
17          * @param array $data
18          */
19         public function canDelete(array $meta, $jobRecord, $contract, array $data)
20         {
21                 $items = $this->em->createQuery(
22                                 "SELECT auction FROM \\Auction\\Entity\\Auction auction "
23                                 . "WHERE auction.endDate LIKE :endDate AND auction.jobState = :status"
24                         )
25                         ->setParameter('endDate', $jobRecord->openDate->format('Y-m-d') . '%')
26                         ->setParameter('status', 'Active')
27                         ->getArrayResult();
28                 if (0 < count($items))
29                 {
30                         throw new \Exception('There are auctions ending on this date, please remove auction items before deleting.');
31                 }
32         }
33
34
35 }