-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControllerBase.php
45 lines (36 loc) · 1.23 KB
/
ControllerBase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace controllers;
use models\Basket;
use Ubiquity\controllers\Controller;
use Ubiquity\orm\DAO;
use Ubiquity\utils\http\URequest;
use Ubiquity\utils\http\USession;
/**
* controllers$ControllerBase
*/
abstract class ControllerBase extends Controller {
protected $headerView = "@activeTheme/main/vHeader.html";
protected $footerView = "@activeTheme/main/vFooter.html";
public function initialize() {
$nbProduct = 0;
$montant = 0;
$basket = USession::get('defaultBasket');
$idDuPanier = $basket->getId();
$basket = DAO::getById(Basket::class, $idDuPanier, ['basketdetails.product']);
$basketDetail = $basket->getBasketdetails();
foreach ($basketDetail as $content) {
$montant += (($content->getProduct()->getPrice()+$content->getProduct()->getPromotion()) * $content->getQuantity());
}
foreach ($basketDetail as $content) {
$nbProduct += $content->getQuantity();
}
if (! URequest::isAjax()) {
$this->loadView($this->headerView,['montant'=>$montant, 'nbProduct'=>$nbProduct, 'idDuPanier'=>$idDuPanier]);
}
}
public function finalize() {
if (! URequest::isAjax()) {
$this->loadView($this->footerView);
}
}
}