initial commit
[namibia] / module / Retail / src / Retail / Service / Retail.php
1 <?php
2 namespace Retail\Service;
3
4
5
6 /**
7  * Manage Retail data.
8  * @author andre.fourie
9  */
10 class Retail extends \Workspace\Service\DataBin
11 {
12
13         /**
14          * @var array
15          */
16         protected $meta = array(
17                         'Base'        => 'Retail',
18                         'DatasetName' => 'retailers',
19                         'Entity'      => '\Retail\Entity\Retail',
20                         'References'  => array(),
21                         'Dependants'  => array()
22         );
23         /**
24          * @var array
25         */
26         protected $metaSelectList = array(
27                         'Type'          => 'SelectList',
28                         'Contract'      => 'Recurring',
29                         'RequiredInput' => array(),
30                         'OptionalInput' => array(),
31                         'Filter'   => array(),
32                         'Label'    => array(
33                                 'Format' => '[name]',
34                                 'Fields' => array('name')
35                         )
36         );
37
38
39
40         /**
41          * CRON functionality: Move Auction items as needed.
42          * @param arary $meta
43          * @param \Auction\Entity\Auction $record
44          * @param \Workspace\Contract\AbstractBase $contract
45          */
46         public function cronProcess()
47         {
48                 #-> Phase 1.
49                 $date = date('Y-m-d H:i:s');
50                 $result = $this->em->createQuery(
51                                 'SELECT stock FROM \Stock\Entity\Stock stock '
52                                 . 'WHERE stock.jobState = \'Retail\''
53                                 . ' AND stock.reset <= \'' . $date . '\''
54                         )
55                         ->getResult();
56                 foreach ($result as $item)
57                 {
58                         $item->jobState = 'Stock';
59                         $item->reset = null;
60                         $this->em->flush($item);
61                 }
62
63         }
64
65 }