view.html.php
90 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | /** |
| 15 | * VikAppointments all orders (profile) view. |
| 16 | * |
| 17 | * @since 1.4 |
| 18 | */ |
| 19 | class VikAppointmentsViewallorders extends JViewVAP |
| 20 | { |
| 21 | /** |
| 22 | * VikAppointments view display method. |
| 23 | * |
| 24 | * @return void |
| 25 | */ |
| 26 | function display($tpl = null) |
| 27 | { |
| 28 | $app = JFactory::getApplication(); |
| 29 | $input = $app->input; |
| 30 | |
| 31 | $this->user = JFactory::getUser(); |
| 32 | |
| 33 | if (!$this->user->guest) |
| 34 | { |
| 35 | $options = array(); |
| 36 | $options['start'] = $app->getUserStateFromRequest('allorders.limitstart', 'limitstart', 0, 'uint'); |
| 37 | $options['limit'] = 5; |
| 38 | |
| 39 | /** |
| 40 | * Load orders through the view model. |
| 41 | * |
| 42 | * @since 1.7 |
| 43 | */ |
| 44 | $model = JModelVAP::getInstance('allorders'); |
| 45 | |
| 46 | // load latest orders |
| 47 | $this->orders = $model->getItems($options); |
| 48 | |
| 49 | if ($this->orders) |
| 50 | { |
| 51 | // get pagination HTML |
| 52 | $this->navbut = $model->getPagination()->getPagesLinks(); |
| 53 | } |
| 54 | else |
| 55 | { |
| 56 | $this->navbut = ''; |
| 57 | } |
| 58 | |
| 59 | // get customer details |
| 60 | $this->customer = VikAppointments::getCustomer(); |
| 61 | |
| 62 | if ($this->customer) |
| 63 | { |
| 64 | // check if the customer owns at least a package order |
| 65 | $this->hasPackages = $model->hasPackages($this->customer->id); |
| 66 | |
| 67 | // check if the customer owns at least a subscription order |
| 68 | $this->hasSubscriptions = $model->hasSubscriptions($this->customer->id); |
| 69 | } |
| 70 | else |
| 71 | { |
| 72 | $this->hasPackages = $this->hasSubscriptions = false; |
| 73 | } |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | // user not logged in, use the login/registration layout |
| 78 | $tpl = 'login'; |
| 79 | } |
| 80 | |
| 81 | $this->itemid = $input->getUint('Itemid', 0); |
| 82 | |
| 83 | // prepare page content |
| 84 | VikAppointments::prepareContent($this); |
| 85 | |
| 86 | // display the template |
| 87 | parent::display($tpl); |
| 88 | } |
| 89 | } |
| 90 |