Commit 17f1786a authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #72825 add print action

parent a1cdb47c
Pipeline #4432 failed with stage
in 35 minutes and 30 seconds
......@@ -23,6 +23,12 @@
class AbonneController extends ZendAfi_Controller_Action {
protected $_user = null; // Le user connecté
public function getPlugins() {
return ['ZendAfi_Controller_Plugin_Printer_Loans'];
}
public function init() {
parent::init();
if ('authenticate' == $this->getRequest()->getActionName())
......
......@@ -75,7 +75,8 @@ class Class_ModeleFusionLoader extends Storm_Model_Loader {
return ['' => $this->_('Aucun'),
Class_ModeleFusion::ARTICLES_TEMPLATE => $this->_('Page d\'articles'),
Class_ModeleFusion::RECORDS_TEMPLATE => $this->_('Resultats de recherche'),
Class_ModeleFusion::RECORD_TEMPLATE => $this->_('Page de notice')];
Class_ModeleFusion::RECORD_TEMPLATE => $this->_('Page de notice'),
Class_ModeleFusion::LOANS_TEMPLATE => $this->_('Liste des prêts')];
}
......@@ -92,7 +93,9 @@ class Class_ModeleFusionLoader extends Storm_Model_Loader {
public function getDefaultTemplates() {
return [Class_ModeleFusion::RECORDS_TEMPLATE => $this->_('Modèle par défaut : résultat de recherche'),
Class_ModeleFusion::RECORD_TEMPLATE => $this->_('Modèle par défaut : une notice'),
Class_ModeleFusion::ARTICLES_TEMPLATE => $this->_('Modèle par défaut : liste d\'articles')];
Class_ModeleFusion::ARTICLES_TEMPLATE => $this->_('Modèle par défaut : liste d\'articles'),
Class_ModeleFusion::LOANS_TEMPLATE => $this->_('Modèle par défaut : liste de prêts')];
}
......@@ -114,7 +117,8 @@ class Class_ModeleFusion extends Storm_Model_Abstract {
TRAINING_TEMPLATE = 'ACTIVITY_',
RECORDS_TEMPLATE = 'Notice_List',
ARTICLES_TEMPLATE = 'Article_List',
RECORD_TEMPLATE = 'Notice_View';
RECORD_TEMPLATE = 'Notice_View',
LOANS_TEMPLATE = 'Loans_List';
protected $_table_name = 'modele_fusion',
$_loader_class = 'Class_ModeleFusionLoader',
......@@ -176,11 +180,14 @@ class Class_ModeleFusion extends Storm_Model_Abstract {
}
public function getTagValueForInstance($match,$instance) {
if (strpos($match,'.') === false)
public function getTagValueForInstance($match, $instance) {
if (false !== strpos($match, '.'))
return $this->getTagValueForCollectionInstance($match,$instance);
if(method_exists($instance, 'callGetterByAttributeName'))
return $instance->callGetterByAttributeName($match);
return $this->getTagValueForCollectionInstance($match,$instance);
return call_user_func([$instance, $match]);
}
......
......@@ -223,6 +223,18 @@ class Class_Profil_Preferences_Loans {
'action' => 'barcodes-export']),
$this->_('Export des codes barres'),
['class' => 'loan-export']);
}),
(new Class_Entity(['Id' => 'print',
'Label' => $this->_('Imprimer')]))
->whenCalledDo('renderWith', function($view_helper)
{
$loans = $view_helper->getLoans();
$view = $view_helper->view;
$config = new Class_Entity(['Models' => $loans->getArrayCopy(),
'Ids' => 'reload',
'Strategy' => Class_ModeleFusion::LOANS_TEMPLATE]);
return $view->tagPrintLink($config);
})];
}
......@@ -312,7 +324,6 @@ class Class_Profil_Preferences_LoansDoctype extends Class_Profil_Preferences_Loa
}
public function renderWith($view_helper, $loan) {
return $view_helper->renderDocTypeLabel($loan, $view_helper->getLinkUrl());
}
......
......@@ -63,10 +63,12 @@ class Class_WebService_SIGB_Emprunt extends Class_WebService_SIGB_ExemplaireOper
$this->_exemplaire->setOnHold($onhold);
}
public function getOnHold() {
return $this->_exemplaire->onHold();
}
public function onParseAttributes() {
if( !$this->type = $this->getAttribute('Type'))
$this->type = '';
......
<?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_Controller_Plugin_Printer_Loans extends ZendAfi_Controller_Plugin_Printer_ModelFusion {
protected function _getPrinterConfig() {
$cards = new Class_User_Cards(Class_Users::getIdentity());
$loans = $cards->getLoansWithOutPNB($this->_request->getParams());
$humans_loans = [];
foreach($loans as $loan)
$humans_loans [] = new Class_Entity(['LoanedBy' => $loan->getUserFullName(),
'BarCode' => $loan->getCodeBarre(),
'DocType' => $this->_view->Loan_DocType($loan),
'Title' => $loan->getTitre(),
'Author' => $loan->getAuteur(),
'IssueDate' => $loan->getIssueDate(),
'ReturnDate' => $loan->getDateRetour(),
'Thumbnail' => $this->_view->Loan_Thumbnail($loan),
'Informations' => $loan->getType()]);
return parent::_getPrinterConfig()
->setModels($humans_loans)
->setKey('loans');
}
}
\ No newline at end of file
......@@ -24,16 +24,17 @@ class ZendAfi_Controller_Plugin_Printer_ModelFusion extends ZendAfi_Controller_P
public function printAction() {
if ($this->_response->isRedirect())
return;
$this->_helper->getHelper('viewRenderer')->setLayoutScript('empty.phtml');
$this->_view->params = $this->_getPrinterConfig();
$this->renderScript('print.phtml');
}
$this->_view->params = (new Class_Entity())
protected function _getPrinterConfig() {
return (new Class_Entity())
->setStrategy($this->_getParam('strategy', 'Article_List'))
->setId($this->_getParam('id',0))
->setModelFusion($this->_getParam('modele_fusion'))
->setIds($this->_getParam('ids', 0));
$this->renderScript('print.phtml');
}
}
?>
\ No newline at end of file
}
\ 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_Loan_Abstract extends ZendAfi_View_Helper_BaseHelper {
protected function _getRecord($operation) {
return ($item = $operation->getExemplaireOPAC())
? $item->getNotice()
: new Class_Entity();
}
}
\ 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_Loan_DocType extends ZendAfi_View_Helper_Loan_Abstract {
public function Loan_DocType($operation) {
return (string) $this->_getRecord($operation)
->getTypeDocLabel();
}
}
\ 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_Loan_Thumbnail extends ZendAfi_View_Helper_Loan_Abstract {
public function Loan_Thumbnail($operation) {
$record = $this->_getRecord($operation);
return ($record->getId())
? $this->view->Notice_Vignette($record,
[],
ZendAfi_View_Helper_Notice_Vignette::MODE_VIEW)
: '';
}
}
\ No newline at end of file
......@@ -54,6 +54,9 @@ class ZendAfi_View_Helper_ModeleFusion_Template extends ZendAfi_View_Helper_Base
if($template == Class_ModeleFusion::ARTICLES_TEMPLATE)
return $this->view->ModeleFusion_Template_Articles();
if($template == Class_ModeleFusion::LOANS_TEMPLATE)
return $this->view->ModeleFusion_Template_Loans();
return '';
}
......
<?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_ModeleFusion_Template_Loans extends ZendAfi_View_Helper_ModeleFusion_Template {
public function ModeleFusion_Template_Loans() {
return sprintf('{loans.each[%s]}', $this->_getRow());
}
protected function _getRow() {
$html = [$this->_tag('h1',
$this->_('Titre : {getTitle}')),
$this->_tag('span', '{getThumbnail}'),
$this->_tag('span', $this->_('emprunté par : {getLoanedBy}')),
$this->_tag('span', $this->_('code barre : {getBarCode}')),
$this->_tag('span', $this->_('Auteur : {getAuthor}')),
$this->_tag('span', $this->_('date de prêt : {getIssueDate}')),
$this->_tag('span', $this->_('dates de retour prévu : {getReturnDate}')),
];
return $this->_getRowWrapper(implode(BR, $html));
}
}
\ No newline at end of file
......@@ -21,14 +21,19 @@
class ZendAfi_View_Helper_TagModelFusion extends ZendAfi_View_Helper_BaseHelper {
protected $_fusion;
public function tagModelFusion($params) {
if(!$params)
return '';
if(!$fusion = Class_ModeleFusion::find($params->getModelFusion()))
if(!$fusion = $this->_fusion = Class_ModeleFusion::find($params->getModelFusion()))
return '';
if($models = $params->getModels())
return $this->_render($params);
$models = [];
$strategy = $params->getStrategy();
......@@ -50,7 +55,15 @@ class ZendAfi_View_Helper_TagModelFusion extends ZendAfi_View_Helper_BaseHelper
return $this->_tag('div',
$fusion->getContenuFusionne(),
['class' => 'models_fusion']);
}
protected function _render($config) {
return $this->_tag('div',
$this->_fusion
->setDataSource([
$config->getKey() => new Class_CollectionFusion($config->getModels())])
->getContenuFusionne(),
['class' => 'models_fusion']);
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -1134,3 +1134,34 @@ class AbonneControllerBarcodesExportThreePretsTest extends AbonneControllerPrets
$this->assertEquals($this->_json, file_get_contents($this->_dl_file));
}
}
class AbonneControllerPrintActionPretsTest extends AbonneControllerPretsListThreePretsTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_ModeleFusion',
['id' => 9,
'type' => 'Loans_List',
'nom' => 'loans',
'contenu' => '<div style="page-break-inside:auto">{loans.each[
<div style="page-break-inside:avoid; page-break-after:auto;overflow:hidden;float:left;clear:both;padding: 0.5em;margin: 0.5em 0;border: 1px solid black;width:190mm;box-shadow: 0px 0px 5px;">
<h1>Titre : {getTitle}</h1>
<br />
<span>{getThumbnail}</span><br />
<span>emprunt&eacute; par : {getLoanedBy}</span><br />
<span>code barre : {getBarCode}</span><br />
<span>Auteur : {getAuthor}</span><br />
<span>date de pr&ecirc;t : {getIssueDate}</span><br />
<span>dates de retour pr&eacute;vu : {getReturnDate}</span></div>
]}</div>']);
$this->dispatch('abonne/print/ids/reload/strategy/Loans_List/modele_fusion/9', true);
}
/** @test */
public function responseShouldContainsSomethings() {
$this->assertXPathContentContains('//div', 'Titre : Alice au royaume de ');
}
}
......@@ -47,15 +47,15 @@ abstract class HandleOnholdTestCase extends AbstractControllerTestCase {
(new Class_Entity())
->setController('abonne')
->setAction('prets'),
['tools_composition' => 'search_tool;export_barcodes;export_unimarc;extend_all',
['tools_composition' => 'search_tool;export_barcodes;export_unimarc;extend_all;print',
'table_composition' => 'loaned_by;doctype;thumbnail;title;author;library;return_date;onhold']);
$this->_ilsdi = 'http://chamb.com/koha/ilsdi.pl';
$this->_mock_web_client = $this->mock()
->whenCalled('open_url')
->with($this->_ilsdi . '?service=AuthenticatePatron&username=Chambelle&password=upw')
->answers(ChamberyKohaFixtures::authenticatePatronChambelle());
->whenCalled('open_url')
->with($this->_ilsdi . '?service=AuthenticatePatron&username=Chambelle&password=upw')
->answers(ChamberyKohaFixtures::authenticatePatronChambelle());
Class_WebService_SIGB_Koha::getService(['url_serveur' => $this->_ilsdi,
'id_bib' => 3,
......@@ -81,13 +81,17 @@ abstract class HandleOnholdTestCase extends AbstractControllerTestCase {
'int_bib' => $sigb_gb]);
$user = $this->fixture('Class_Users',
['id' => 78,
'login' => 'Chambelle',
'password' => 'upw',
'idabon' => '93658',
'id_site' => 12,
'int_bib' => $sigb_gb,
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]);
['id' => 78,
'login' => 'Chambelle',
'password' => 'upw',
'idabon' => '93658',
'id_site' => 12,
'int_bib' => $sigb_gb,
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]);
Class_ModeleFusion::build('Loans_List',
'loans',
'<h1>999</h1>')->save();
ZendAfi_Auth::getInstance()->logUser($user);
}
......@@ -206,6 +210,13 @@ abstract class HandleOnholdDispatchTestCase extends HandleOnholdTestCase {
$this->dispatch('/opac/abonne/prets/onhold/yes', true);
$this->assertXPathContentContains('//a[contains(@href, "abonne/barcodes-export/onhold/yes")]', 'Export des codes barres');
}
/** @test */
public function printShouldBeDisplay() {
$this->dispatch('/opac/abonne/prets/onhold/yes', true);
$this->assertXPathContentContains('//a[contains(@href, "abonne/print")]', 'Imprimer');
}
}
......
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