Commit 973691c6 authored by Patrick Barroca's avatar Patrick Barroca 🎮

hotline #71154 : add last 5 loans

parent 8db2c4d1
......@@ -65,6 +65,14 @@ class Class_Loan_PnbLoader extends Storm_Model_Loader {
}
public function findLastPastLoansForItem($item) {
return Class_Loan_Pnb::findAllBy(['order_line_id' => $item->getOrderLineId(),
'order' => 'expected_return_date desc',
'limit' => 5,
'where' => sprintf('expected_return_date <= "%s"', $this->_getDate())]);
}
protected function _applyOngoingAndDo($params, $closure) {
$prefix = isset($params['where']) ? '(' . $params['where'] . ') and ' : '';
$params['where'] = $prefix . 'expected_return_date > "' . $this->_getDate() . '"';
......
......@@ -22,9 +22,9 @@
class ZendAfi_View_Helper_Album_Loans extends ZendAfi_View_Helper_BaseHelper {
public function Album_Loans($item) {
if(!$loans = Class_Loan_Pnb::findAllOngoingOfItem($item))
if(!$loans = $this->_getLoans($item))
return $this->_tag('p',
$this->_('Aucun prêt en cours'),
$this->_getEmptyMessage(),
['class' => 'error']);
$html = [];
......@@ -35,6 +35,16 @@ class ZendAfi_View_Helper_Album_Loans extends ZendAfi_View_Helper_BaseHelper {
}
protected function _getEmptyMessage() {
return $this->_('Aucun prêt en cours');
}
protected function _getLoans($item) {
return Class_Loan_Pnb::findAllOngoingOfItem($item);
}
protected function _renderLoan($loan) {
$fields =
[
......
<?php
/**
* Copyright (c) 2012-2017, 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 ZendAfi_View_Helper_Album_OldLoans extends ZendAfi_View_Helper_Album_Loans {
public function Album_OldLoans($item) {
return $this->Album_Loans($item);
}
protected function _getEmptyMessage() {
return $this->_('Le document n\'a pas encore été emprunté');
}
protected function _getLoans($item) {
return Class_Loan_Pnb::findLastPastLoansForItem($item);
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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 ZendAfi_View_Helper_ModelProperties extends ZendAfi_View_Helper_BaseHelper{
public function modelProperties($model, $properties) {
$lines = [];
foreach ($properties as $field => $label)
$lines[] = $this->_tag('tr',
$this->_tag('th', $label,
['scope' => 'row'])
. $this->_tag('td',
str_replace(['"', '\\'], '', json_encode($model->callGetterByAttributeName($field), JSON_PRETTY_PRINT))));
return $this->_tag('table', implode('', $lines));
}
}
......@@ -72,17 +72,23 @@ class ZendAfi_View_Helper_Notice_Dilicom extends ZendAfi_View_Helper_BaseHelper
return $this->_tag('div',
implode([$this->_renderTabs(),
$this->_renderOrders(),
$this->_renderLoans()]),
$this->_renderLoans(),
$this->_renderOldLoans()]),
['class' => 'ig-tabs']);
}
protected function _renderTabs() {
return $this->_tag('ul',
$this->_tag('li', $this->_tag('a', $this->_('Commandes'),
['href' => '#ig-tab-orders']))
. $this->_tag('li', $this->_tag('a', $this->_('Prêts en cours'),
['href' => '#ig-tab-loans'])));
$tabs = [$this->_tag('li', $this->_tag('a', $this->_('Commandes'),
['href' => '#ig-tab-orders'])),
$this->_tag('li', $this->_tag('a', $this->_('Prêts en cours'),
['href' => '#ig-tab-loans'])),
$this->_tag('li', $this->_tag('a', $this->_('Historique des 5 derniers prêts'),
['href' => '#ig-tab-old-loans']))];
return $this->_tag('ul', implode($tabs));
}
......@@ -120,6 +126,17 @@ class ZendAfi_View_Helper_Notice_Dilicom extends ZendAfi_View_Helper_BaseHelper
}
protected function _renderOldLoans() {
return $this->_withItemsDo(
function($item) {
return $this->view->Album_OldLoans($item);
},
['id' => 'ig-tab-old-loans',
'class' => 'ig-accordion'],
$this->_('Cet album n\'a pas encore été emprunté'));
}
protected function _loginForm() {
$preferences = (new Class_Profil_Preferences_Login())
->getPreferencesFromWidgetOrModule(Class_Profil::getCurrentProfil());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment