Hold.php 7.36 KB
Newer Older
Ghislain Loas's avatar
Ghislain Loas committed
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
<?php
/**
 * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
 *
 * BOKEH is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation.
 *
 * There are special exceptions to the terms and conditions of the AGPL as it
 * is applied to this software (see README file).
 *
 * BOKEH is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with BOKEH; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */


class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapper_Abstract {

  public function getMainTitle() {
    $desc = $this->_('Réservé par %s %s',
                     $this->_model->getUser()->getIdabon(),
                     $this->_model->getUserFullName());

    if (!$this->_model->getNoticeOPAC())
      return $desc . BR . $this->_model->getTitre();

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

    return $desc . BR . $wrapper->getMainTitle();
  }


  public function getSecondaryTitle() {
    if (!$this->_model->getNoticeOPAC())
      return $this->_model->getAuteur();

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

    return $wrapper->getSecondaryTitle();
  }


  public function getPicture() {
    if (!$this->_model->getNoticeOPAC())
      return '';

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

    return $wrapper->getPicture();
  }


65 66 67 68 69
  public function getPictureAction() {
    return '';
  }


Ghislain Loas's avatar
Ghislain Loas committed
70
  public function getDescription() {
Ghislain Loas's avatar
Ghislain Loas committed
71 72
    $html = [$this->getBadges()];

Ghislain Loas's avatar
Ghislain Loas committed
73
    if (!$this->_model->getNoticeOPAC())
Ghislain Loas's avatar
Ghislain Loas committed
74
      return implode($html);
Ghislain Loas's avatar
Ghislain Loas committed
75 76 77 78 79

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

Ghislain Loas's avatar
Ghislain Loas committed
80 81 82
    $html [] = $wrapper->getDescription();

    return implode($html);
Ghislain Loas's avatar
Ghislain Loas committed
83 84 85
  }


Ghislain Loas's avatar
Ghislain Loas committed
86
  public function getFullDescription() {
Ghislain Loas's avatar
Ghislain Loas committed
87 88
        $html = [$this->getBadges()];

Ghislain Loas's avatar
Ghislain Loas committed
89
    if (!$this->_model->getNoticeOPAC())
Ghislain Loas's avatar
Ghislain Loas committed
90
      return implode($html);
Ghislain Loas's avatar
Ghislain Loas committed
91 92 93 94 95

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

Ghislain Loas's avatar
Ghislain Loas committed
96 97 98
    $html [] = $wrapper->getFullDescription();

    return implode($html);
Ghislain Loas's avatar
Ghislain Loas committed
99 100 101
  }


Ghislain Loas's avatar
Ghislain Loas committed
102 103 104 105 106 107 108
  public function getDescriptionTitle() {
    return '';
  }


  public function getMainLink() {
    if (!$this->_model->getNoticeOPAC())
Ghislain Loas's avatar
Ghislain Loas committed
109
      return null;
Ghislain Loas's avatar
Ghislain Loas committed
110 111 112 113 114 115 116 117

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

    return $wrapper->getMainLink();

    if (!$this->_model->isRenewable())
Ghislain Loas's avatar
Ghislain Loas committed
118
      return null;
Ghislain Loas's avatar
Ghislain Loas committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177

    return new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne',
                                                                    'action' => 'prolongerPret',
                                                                    'id_pret' => $this->_model->getId()]),
                                        'Text' => $this->_('Prolonger'),
                                        'Title' => $this->_('Prolonger l\'emprunt %s',
                                                            $this->_model->getTitre())]);
  }


  public function getSecondaryLink() {
    if (!$this->_model->getNoticeOPAC())
      return null;

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

    return $wrapper->getSecondaryLink();
  }


    public function getSecondaryIco() {
        if (!$this->_model->getNoticeOPAC())
      return null;

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

    return $wrapper->getSecondaryIco();
  }


  public function getDocType() {
    if (!$this->_model->getNoticeOPAC())
      return null;

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

    return $wrapper->getDocType();
  }


  public function getDocTypeLabel() {
    if (!$this->_model->getNoticeOPAC())
      return null;

    $wrapper = (new Intonation_Library_View_Wrapper_Record)
      ->setView($this->_view)
      ->setModel($this->_model->getNoticeOPAC());

    return $wrapper->getDocTypeLabel();
  }


  public function getBadges() {
Ghislain Loas's avatar
Ghislain Loas committed
178 179 180
    $badges = [
               ((new Intonation_Library_Badge)
                ->setTag('span')
Ghislain Loas's avatar
Ghislain Loas committed
181 182 183 184 185 186 187
                ->setClass('success')
                ->setText($this->_model->isWaitingToBePulled() ? $this->_('Prêt !') : '')
                ->setTitle($this->_('Votre réservation %s est prête', $this->_model->getTitre()))),

               ((new Intonation_Library_Badge)
                ->setTag('span')
                ->setClass($this->_model->isWaitingToBePulled() ? 'success' : 'secondary')
Ghislain Loas's avatar
Ghislain Loas committed
188 189 190
                ->setImage(Class_Template::current()->getIco($this->_view,
                                                             'library',
                                                             'library'))
Ghislain Loas's avatar
Ghislain Loas committed
191 192
                ->setText($this->_model->getPickupLocationLabel())
                ->setTitle($this->_('Récupérer la réservation à %s', $this->_model->getPickupLocationLabel()))),
Ghislain Loas's avatar
Ghislain Loas committed
193

Ghislain Loas's avatar
Ghislain Loas committed
194 195 196 197 198 199 200 201 202 203 204 205
               ((new Intonation_Library_Badge)
                ->setTag('span')
                ->setClass('secondary')
                ->setText($this->_model->getEtat())
                ->setTitle($this->_('État de la réservation: %s', $this->_model->getEtat()))),

               ((new Intonation_Library_Badge)
                ->setTag('span')
                ->setClass('secondary')
                ->setText($this->_model->getRang())
                ->setTitle($this->_('Rang de la réservation: %s', $this->_model->getRang())))
    ];
Ghislain Loas's avatar
Ghislain Loas committed
206

Ghislain Loas's avatar
Ghislain Loas committed
207
    return $this->_view->renderBadges($badges);
Ghislain Loas's avatar
Ghislain Loas committed
208 209 210 211
  }


  public function getActions() {
Ghislain Loas's avatar
Ghislain Loas committed
212 213 214 215 216 217 218 219 220
    return [ new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne',
                                                                      'action' => 'reservations',
                                                                      'id_delete' => $this->_model->getId()]),
                                          'Text' => $this->_('Supprimer'),
                                          'Image' => Class_Template::current()->getIco($this->_view,
                                                                                       'delete',
                                                                                       'utils'),
                                          'Title' => $this->_('Supprimer la réservation %s',
                                                              $this->_model->getTitre())])];
Ghislain Loas's avatar
Ghislain Loas committed
221
  }
Ghislain Loas's avatar
Ghislain Loas committed
222 223 224 225 226 227 228 229 230 231


  public function getEmbedMedia() {
    return '';
  }


  public function getHtmlPicture() {
    return '';
  }
Ghislain Loas's avatar
Ghislain Loas committed
232 233 234 235 236 237


  public function getOsmData() {
    return null;
  }
}