Skip to content
Snippets Groups Projects

: dev#64573 work on bootstrap

Files
53
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
@@ -1506,15 +1505,14 @@ class AbonneController extends ZendAfi_Controller_Action {
public function selectionAction() {
if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('id'))) {
$this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']);
if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('selection_id'))) {
return $this->_redirectClose($this->_getReferer());
}
}
public function ajouterALaSelectionAction() {
if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('id'))) {
if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('selection_id'))) {
$this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']);
return $this->_redirectClose($this->_getReferer());
}
@@ -1532,28 +1530,54 @@ class AbonneController extends ZendAfi_Controller_Action {
public function ajouterLeDocumentALaSelectionAction() {
if(!$this->_user)
return $this->_forward('popup-login', 'auth', 'opac');
session_write_close();
$this->getHelper('ViewRenderer')->setNoRender();
if (!$selection = Class_PanierNotice::find($this->_getParam('id')))
return $this->_response->setHttpResponseCode(404);
$selection = (($selection = Class_PanierNotice::find($this->_getParam('selection_id')))
? $selection
: Class_PanierNotice::findFirstBy(['id_user' => $this->_user->getId(),
'libelle' => $this->_getParam('selection_label')]));
if (!$selection) {
$this->getHelper('ViewRenderer')->setNoRender();
return $this->_response->setHttpResponseCode(520);
}
if (!$selection->isMine())
return $this->_response->setHttpResponseCode(404);
if (!$selection->isMine()) {
$this->getHelper('ViewRenderer')->setNoRender();
return $this->_response->setHttpResponseCode(520);
}
if (!$record = Class_Notice::find($this->_getParam('record_id')))
return $this->_response->setHttpResponseCode(404);
if (!$record = Class_Notice::find($this->_getParam('record_id'))) {
$this->getHelper('ViewRenderer')->setNoRender();
return $this->_response->setHttpResponseCode(520);
}
$selection->addNotice($record);
$selection->save();
$this->_helper->json(['anchor' => $this->view->tagAction((new Intonation_Library_Selection)
->setView($this->view)
->setUser($this->_user)
->setRecord($record)
->setTitle($this->_getParam('selection_label'))
->setImage($this->_getParam('image'))
->setRevertImage($this->_getParam('revert-image'))
->getAction())]);
}
public function supprimerDeLaSelectionAction() {
$this->view->titre = $this->_('Retirer un document');
if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('selection_id'))) {
$this->view->selection = (($selection = Class_PanierNotice::find($this->_getParam('selection_id')))
? $selection
: Class_PanierNotice::findFirstBy(['id_user' => $this->_user->getId(),
'libelle' => $this->_getParam('selection_label')]));
if (!$this->view->selection) {
$this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']);
return $this->_redirectClose($this->_getReferer());
}
@@ -1568,6 +1592,22 @@ class AbonneController extends ZendAfi_Controller_Action {
return $this->_redirectClose($this->_getReferer());
}
if ($this->_getParam('ajax')) {
$this->view->selection
->removeNotice($this->view->record)
->save();
return $this->_helper->json(['anchor' =>
$this->view->tagAction((new Intonation_Library_Selection)
->setView($this->view)
->setUser($this->_user)
->setRecord($this->view->record)
->setTitle($this->_getParam('selection_label'))
->setImage($this->_getParam('image'))
->setRevertImage($this->_getParam('revert-image'))
->getAction())]);
}
if ($this->_getParam('delete')) {
$this->view->selection
->removeNotice($this->view->record)
@@ -1605,6 +1645,76 @@ class AbonneController extends ZendAfi_Controller_Action {
}
public function supprimerLaSelectionAction() {
$this->view->titre = $this->_('Supprimer une sélection');
$this->view->selection = (($selection = Class_PanierNotice::find($this->_getParam('selection_id')))
? $selection
: Class_PanierNotice::findFirstBy(['id_user' => $this->_user->getId(),
'libelle' => $this->_getParam('selection_label')]));
if (!$this->view->selection) {
$this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']);
return $this->_redirectClose($this->_getReferer());
}
if (!$this->view->selection->isMine()) {
$this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']);
return $this->_redirectClose($this->_getReferer());
}
if ($this->_getParam('delete')) {
$this->view->selection->delete();
$this->_helper->notify($this->_('La sélection a bien été supprimée'),
['status' => 'delete']);
return $this->_redirectClose($this->view->url(['action' => 'selections']));
}
}
public function renommerLaSelectionAction() {
$this->view->titre = $this->_('Renommer une sélection');
$this->view->selection = (($selection = Class_PanierNotice::find($this->_getParam('selection_id')))
? $selection
: Class_PanierNotice::findFirstBy(['id_user' => $this->_user->getId(),
'libelle' => $this->_getParam('selection_label')]));
if (!$this->view->selection) {
$this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']);
return $this->_redirectClose($this->_getReferer());
}
if (!$this->view->selection->isMine()) {
$this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']);
return $this->_redirectClose($this->_getReferer());
}
$this->view->form = new ZendAfi_Form();
$this->view->form
->addElement('text',
'libelle',
['value' => $this->view->selection->getLibelle(),
'placeholder' => 'Titre de la sélection'])
->addUniqDisplayGroup('group')
->setAction($this->view->url());
if(!$this->_request->isPost())
return;
$this->view->selection->setLibelle($this->_request->getPost('libelle'));
if(!$this->view->form->isValidModelAndArray($selection, $this->_request->getPost()))
return;
$selection->save();
$selection->index();
$this->_helper->notify($this->_('La sélection a bien été renommée.'), ['status' => 'success']);
return $this->_redirectClose($this->_getReferer());
}
public function mesAvisAction() {
}
@@ -1707,4 +1817,34 @@ class AbonneController extends ZendAfi_Controller_Action {
$response->setHeader('Access-Control-Allow-Origin', '*');
$response->setBody($data);
}
public function reserverAction() {
session_write_close();
$this->view->titre = $this->_('Réserver un document');
if (!$record = Class_Notice::find($this->_getParam('record_id', 0)))
return $this->_response->setHttpResponseCode(520);
$nb_notices_oeuvre = Class_Notice::countBy(['clef_oeuvre' => $record->getClefOeuvre(),
'id_notice not' => $record->getId()]);
if (!$record->hasExemplaires())
return $this->_response->setHttpResponseCode(520);
$cond = ['id_notice' => $record->getId()];
$session = Zend_Registry::get('session');
$cond['id_bib'] = $session->id_bibs;
$items = ($items = Class_Exemplaire::findAllBy(array_filter($cond)))
? $items
: Class_Exemplaire::findAllBy($params);
$items = (new Class_Profil_ItemsFilter())->select(Class_Profil::getCurrentProfil(), $items);
$this->view->items = (new Class_CommSigb())->getDispoExemplaires($items);
$record->updateFacetsFromExemplaires();
}
}