Commit e0dcb7a3c42dc132ff22d16e0377866ab3c6d0a8
1 parent
b8583ddf
prices
Showing
2 changed files
with
28 additions
and
0 deletions
Show diff stats
src/app/frontend/controllers/PageController.php
src/lib/models/discount.php
| ... | ... | @@ -55,6 +55,33 @@ class discount extends \db |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | + * Get actual discount | |
| 59 | + * @param $id | |
| 60 | + * @return array | |
| 61 | + */ | |
| 62 | + public function getActiveData($id) | |
| 63 | + { | |
| 64 | + return $this->get( | |
| 65 | + ' | |
| 66 | + SELECT * | |
| 67 | + FROM public.discount | |
| 68 | + WHERE | |
| 69 | + id = :id | |
| 70 | + AND | |
| 71 | + current_timestamp > start_date | |
| 72 | + AND | |
| 73 | + current_timestamp < end_date | |
| 74 | + | |
| 75 | + ', | |
| 76 | + [ | |
| 77 | + 'id' => $id | |
| 78 | + ], | |
| 79 | + -1 | |
| 80 | + ); | |
| 81 | + } | |
| 82 | + | |
| 83 | + | |
| 84 | + /** | |
| 58 | 85 | * Delete discount with `id`=$id |
| 59 | 86 | * @param $id |
| 60 | 87 | * @return bool | ... | ... |