Commit 60a4059e authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Add view and presenter

parent 14206a74
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle archivesPubliques
*
* Bundle archivesPubliques is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle archivesPubliques 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle archivesPubliques. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\archivesCourrier\presentation\maarchRM\Presenter\archivesCourrier;
/**
* Serializer html of content
*
* @author Alexandre Morin <alexandre.morin@maarch.org>
*/
class content
{
use \presentation\maarchRM\Presenter\exceptions\exceptionTrait;
public $view;
protected $json;
/**
* Constuctor of invoice html serializer
* @param \dependency\html\Document $view The view
* @param \dependency\html\Document $json The json object
*/
public function __construct(
\dependency\html\Document $view,
\dependency\json\JsonObject $json
) {
$this->view = $view;
$this->json = $json;
$this->json->status = true;
}
/**
* Formulaire de recherche d'un contenu d'archive
*
* @return string
*/
public function searchForm()
{
$currentService = \laabs::getToken("ORGANIZATION");
if (!$currentService) {
$this->view->addContentFile("recordsManagement/welcome/noWorkingOrg.html");
return $this->view->saveHtml();
}
$originators = \laabs::callService('organization/organization/readByrole_role_', 'originator');
$userPositionController = \laabs::newController('organization/userPosition');
$orgController = \laabs::newController('organization/organization');
$this->view->addContentFile("archivesCourrier/search.html");
$userServiceOrgRegNumbers = array_merge(array($currentService->registrationNumber), $userPositionController->readDescandantService((string) $currentService->orgId));
$owner = false;
$userServices = [];
foreach ($userServiceOrgRegNumbers as $userServiceOrgRegNumber) {
$userService = $orgController->getOrgByRegNumber($userServiceOrgRegNumber);
$userServices[] = $userService;
if (isset($userService->orgRoleCodes) && strpos($userService->orgRoleCodes, 'owner') >= 0) {
$owner = true;
}
}
$ownerOriginatorOrgs = [];
foreach ($userServices as $userService) {
foreach ($originators as $originator) {
if ($owner || $originator->registrationNumber == $userService->registrationNumber) {
if (!isset($ownerOriginatorOrgs[(string) $originator->ownerOrgId])) {
$orgObject = \laabs::callService('organization/organization/read_orgId_', (string) $originator->ownerOrgId);
$ownerOriginatorOrgs[(string) $orgObject->orgId] = new \stdClass();
$ownerOriginatorOrgs[(string) $orgObject->orgId]->displayName = $orgObject->displayName;
$ownerOriginatorOrgs[(string) $orgObject->orgId]->originators = [];
}
$ownerOriginatorOrgs[(string) $orgObject->orgId]->originators[] = $originator;
}
}
}
$this->view->translate();
$this->view->setSource('ownerOriginatorOrgs', $ownerOriginatorOrgs);
$this->view->merge();
return $this->view->saveHtml();
}
/**
* Resultat de recherche d'un contenu d'archive
* @param array $archives Array of archive object
*
* @return string
*/
public function search(array $archives)
{
$this->view->addContentFile("archivesCourrier/list.html");
$this->view->translate();
$originators = array();
$this->organizationController = \laabs::newController('organization/organization');
foreach ((array) $this->organizationController->getOrgsByRole('originator') as $originator) {
$originators[(string) $originator->registrationNumber] = $originator;
}
$currentDate = \laabs::newDate();
foreach ($archives as $archive) {
$archive->finalDispositionDesc = $this->view->translator->getText($archive->finalDisposition, false, "recordsManagement/messages");
$archive->statusDesc = $this->view->translator->getText($archive->status, false, "recordsManagement/messages");
if ($archive->status == 'disposed' || $archive->status == 'error') {
$archive->statusModif = true;
}
if (!empty($archive->disposalDate) && $archive->disposalDate <= $currentDate) {
$archive->disposable = true;
}
if (isset($originators[$archive->originatorOrgRegNumber])) {
$archive->originator = $originators[$archive->originatorOrgRegNumber];
} else {
$archive->originator = $archive->originatorOrgRegNumber;
}
$archive->actions = array();
}
$this->readPrivilegesOnArchives();
$this->view->setSource('content', $archives);
$this->view->merge();
$dataTable = $this->view->getElementsByClass("dataTable")->item(0)->plugin['dataTable'];
$dataTable->setPaginationType("full_numbers");
$dataTable->setUnsortableColumns(0, 5);
$dataTable->setSorting(array(array(2, 'desc')));
return $this->view->saveHtml();
}
/**
* Read users privileges on archives
*/
protected function readPrivilegesOnArchives()
{
$hasModificationPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveManagement/modify");
$hasIntegrityCheckPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveManagement/checkIntegrity");
$hasDestructionPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "destruction/destructionRequest");
$hasRestitutionPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "restitution/restitutionRequest");
$hasDeliveryPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "delivery/deliveryRequest");
$this->view->setSource('hasModificationPrivilege', $hasModificationPrivilege);
$this->view->setSource('hasIntegrityCheckPrivilege', $hasIntegrityCheckPrivilege);
$this->view->setSource('hasDestructionPrivilege', $hasDestructionPrivilege);
$this->view->setSource('hasRestitutionPrivilege', $hasRestitutionPrivilege);
$this->view->setSource('hasDeliveryPrivilege', $hasDeliveryPrivilege);
}
/**
* Visualisation d'une archive publique
* @param archivesPubliques/content[] $contents The archive description
*
* @return string
*/
public function read($contents)
{
$this->view->addContentFile("archivesPubliques/contentDescription/contentDescription.table.html");
$this->view->translate();
/*$keywordTypesDoc = \laabs::newService('dependency/xml/Document');
$keywordTypesDoc->load('bundle/seda/Resources/xsd/seda/v10/codes/seda_v1-0_keywordtype_code.xsd');
$keywordTypesXpath = \laabs::newService('dependency/xml/XPath', $keywordTypesDoc);
$keywordTypesXpath->registerNamespace('xsd', "http://www.w3.org/2001/XMLSchema");
$keywordTypesXpath->registerNamespace('ccts', "urn:un:unece:uncefact:documentation:standard:CoreComponentsTechnicalSpecification:2");
var_dump($keywordTypesXpath->query('//xsd:enumeration[@value="corpname"]/xsd:annotation/xsd:documentation/ccts:Name')->length);*/
$keywordTypes = array(
'corpname' => 'Collectivité',
'famname' => 'Nom de famille',
'geogname' => 'Nom géographique',
'name' => 'Nom',
'occupation' => 'Fonction',
'persname' => 'Nom de personne',
'subject' => 'Mot-matière',
'genreform' => 'Type de document',
'function' => 'Activité',
);
$descriptionLevels = array(
'class' => 'Classe',
'collection' => 'Collection',
'file' => 'Dossier',
'fonds' => 'Fonds',
'item' => 'Item',
'recordgrp' => 'Groupe de documents',
'series' => 'Serie organique',
'subfonds' => 'Sous fonds',
'subgrp' => 'Sous-groupe de documents',
'subseries' => 'Sous-série organique',
);
if (empty($contents)) {
$this->view->merge();
return $this->view->saveHtml();
}
$content = $contents[0];
if (isset($descriptionLevels[$content->descriptionLevel])) {
$content->descriptionLevel = $descriptionLevels[$content->descriptionLevel];
}
if (count($content->keyword)) {
foreach ($content->keyword as $keyword) {
if (isset($keywordTypes[$keyword->type])) {
$keyword->type = $keywordTypes[$keyword->type];
}
}
}
$this->view->setSource("content", $content);
$this->view->merge();
return $this->view->saveHtml();
}
//JSON
/**
* Exception
* @param archivesPubliques/Exception/contentDescriptionException $contentDescriptionException
*
* @return string
*/
public function contentDescriptionException($contentDescriptionException)
{
$this->json->load($contentDescriptionException);
$this->json->status = false;
return $this->json->save();
}
}
<div class="row" data-translate-catalog="archivesPubliques/messages" id="archiveList">
<div class="panel panel-primary">
<div class="panel-heading clearfix">
<div class="pull-left">
<h4><?merge content.count() ?> archive(s)</h4>
</div>
<div class="dropdown pull-right" data-translate-catalog="recordsManagement/messages">
<button class="btn btn-warning dropdown-toggle" type="button" id="archiveList_actions" data-toggle="dropdown" aria-expanded="true" title="Actions" disabled="disabled">
<i class="fa fa-navicon">&nbsp;</i>&nbsp;Actions
<span class="caret"></span>
</button>
<?hinclude recordsManagement/archive/resultListActionsButton.html ?>
</div>
</div>
<div class="panel-body" style="padding: 0;">
<table class="table dataTable" data-table-paginationtype="two_button" data-table-unsortablecolumns="6">
<thead>
<tr>
<th><input type="checkbox" id="archiveList_selectAll"/></th>
<th>No chrono</th>
<th>Objet</th>
<th>Date</th>
<th>Service</th>
<th style="min-width:150px"></th>
</tr>
</thead>
<tbody>
<?merge content ?>
<div>
<?merge .disposable.bool().then('danger') @class ?>
<tr id="[?merge .archiveId ?]" name="[?merge .archiveName ?]">
<td> <?merge .disposable @data-disposable ?>
<input type="checkbox" data-archive-status="[?merge .status ?]" data-final-disposition='[?merge .finalDisposition ?]' data-visible='[?merge .visible ?]' value="[?merge .archiveId ?]"/>
</td>
<td><?merge .originatorArchiveId ?></td>
<td>
<?merge .archiveName ?>
<?merge .documentType.bool() ?>
<span>
<br><?merge .documentType ?>
</span>
</td>
<td>
<?merge .descriptionLevel.ifeq('RecordGrp') ?>
<?merge .startDate.format('d-m-Y H:i:s') ?> au <?merge .endDate.format('d-m-Y H:i:s') ?>
<?merge .descriptionLevel.ifeq('RecordGrp').not() ?>
<?merge .sentDate.format('d-m-Y H:i:s') ?>
</td>
<td><?merge .originator ?></td>
<td>
<div class="btn-group pull-right">
<button type="button" class="btn btn-success btn-sm viewArchive" title="Info"><span class="fa fa-info-circle"></span></button>
<?merge .statusModif.bool() ?>
<button class="btn btn-warning btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" disabled>
<i class="fa fa-edit">&nbsp;</i>&nbsp;
<span class="caret"></span>
</button>
<?merge .statusModif.bool().not() ?>
<button class="btn btn-warning btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-edit">&nbsp;</i>&nbsp;
<span class="caret"></span>
</button>
<?hinclude recordsManagement/archive/resultActionsButton.html ?>
</div>
</td>
</tr>
</div>
</tbody>
</table>
</div>
<!-- MODALS -->
<?hinclude recordsManagement/archive/archiveManagement.html ?>
</div>
</div>
<script>
/* MULTIPLE ARCHIVE SELECTION*/
$("#archiveList_selectAll").on('click', function () {
$('table.dataTable').find('input[type="checkbox"]').prop('checked', $(this).prop('checked'));
});
$(".paginate_button").on('click', '.paginate_button', function () {
$("archiveList_actions").prop('disabled', true);
$('#archiveList_table').find('input[type="checkbox"]').prop('checked', false);
});
$("table.dataTable").on('click', function() {
if($('input[data-archive-status]:checked').length > 0) {
$("#archiveList_actions").prop('disabled', false);
} else {
$("#archiveList_actions").prop('disabled', true);
}
});
</script>
\ No newline at end of file
<!--#
This file is part of the archivesPubliques package.
(c) Maarch Alexis Ragot <alexis.ragot@maarch.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#-->
<div id="contain" >
<div class="container-fluid" data-translate-catalog="archivesPubliques/messages">
<div class="page-header">
<h1>
<i class="fa fa-search"></i>
Registre des entr&eacute;es
</h1>
</div>
</div>
<div class="container-fluid" lang="en" data-translate-catalog="archivesPubliques/messages">
<div class="panel-group" id="publicArchive_searchFormAccordion">
<div class="panel panel-default">
<div class="panel-heading" data-toggle="collapse" data-parent="#publicArchive_searchFormAccordion" data-target="#publicArchive_searchFormCollapse" style="cursor:pointer;">
<h4 class="panel-title" style="float:left;">
Search form
</h4>
<i class="fa fa-caret-down" style="float:right;"></i>
<div style="clear:both;"></div>
</div>
<div id="publicArchive_searchFormCollapse" class="well panel-collapse collapse in" style="margin-bottom: 0px">
<form class="form-horizontal" id="publicArchive_searchForm">
<div class="col-lg-12">
<div class="col-lg-4">
<div class="form-group">
<label class="col-sm-4 control-label">Terme</label>
<div class="col-md-8">
<input type="text" class="form-control" id="term" name="term" placeholder="Terme"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Dates extr&ecirc;mes</label>
<div class="col-sm-4">
<input type="text" class="form-control datePicker" name="startDate" placeholder="D&eacute;but"/>
</div>
<div class="col-sm-4">
<input type="text" class="form-control datePicker" name="endDate" placeholder="Fin"/>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="form-group">
<label class="col-sm-4 control-label">Service producteur</label>
<div class="col-sm-6">
<select class="form-control" name="originatorOrgRegNumber">
<option value=""></option>
<?merge ownerOriginatorOrgs ?>
<optgroup label="[?merge .displayName ?]">
<?merge .originators ?>
<option value="[?merge .registrationNumber ?]"><?merge .displayName ?></option>
</optgroup>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Type d'objet</label>
<div class="btn-group col-sm-6" data-toggle="buttons">
<label class="btn btn-info active" title="Archive">
<input type="radio" name="hasParent" value="0" checked/> Archive
</label>
<label class="btn btn-default" title="Objet d'archive">
<input type="radio" name="hasParent" value="1"/> Objet
</label>
<label class="btn btn-default" title="Objet d'archive">
<input type="radio" name="hasParent" value="2"/> Document
</label>
</div>
</div>
</div>
</div>
<br>
<div class="clearfix">
<div class="col-md-12">
<button type="button" class="btn btn-primary col-md-offset-4 col-md-4" id="archive_search" title="Search"><i class="fa fa-search">&nbsp;</i>Search</button>
<button type="button" class="btn btn-warning col-md-offset-1" id="publicArchive_resetForm" title="Reset"><i class="fa fa-refresh" title="Reset">&nbsp;</i>Reset</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="container-fluid" id="publicArchive_searchResult"></div>
</div>
<div class="modal fade bs-example-modal-lg" id="viewModalInfo" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" id="modalContainerInfo">
</div>
</div>
</div>
</div>
<script>
$(".document").hide();
urlArchivesPubliques = '/archivesCourrier/Search';
type = 'GET';
$('#publicArchive_searchFormCollapse').on('click', 'label.btn', function() {
var select = $(this);
select.closest('.btn-group').find('.btn-info').removeClass('btn-info').addClass('btn-default');
select.removeClass('btn-default').addClass('btn-info');
});
/* ------ SEARCH FORM ------ */
$('#contain').keypress(function (e) {
if (e.which != 13) {
return;
}
// Prevent form submit
e.preventDefault();
// Submit the form.
$("#archive_search").click();
});
$('#archive_search').on('click', function() {
//$('#archive_search').prop('disabled', true);
type = "GET";
data = JSON.stringify(serialize());
$.ajax({
type : type,
url : urlArchivesPubliques,
data : data,
dataType : 'html',
contentType : 'application/json',
async : false,
success : function (response) {
$('#publicArchive_searchResult').empty().html(response);
}
});
$('#archive_search').prop('disabled', false);
});
$("#publicArchive_resetForm").on("click", function () {
$('#publicArchive_searchForm').find('input[type="text"], select').val('');
$('#publicArchive_searchForm').find('input[type="radio"][value=""]').click();
$('#publicArchive_searchForm').find('input[name="hasParent"][value="0"]').click();
$('#publicArchive_searchResult').empty();
$(".document").hide();
});
/* ------ FUNCTION ------ */
function serialize() {
jsonObject = {
//keyword : []
};
$('#publicArchive_searchForm').find('input[type="text"], input[type="radio"]:checked, select').each(function(){
var name = $(this).attr('name');
var value = $(this).val();
if (name && value != "") {
jsonObject[name] = $(this).val();
}
});
return jsonObject;
}
</script>
......@@ -18,7 +18,7 @@
* along with maarchRM. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\archivesCourrier\presentation\maarchRM\UserStory;
namespace ext\archivesCourrier\presentation\maarchRM\UserStory\archiveRetrieval;
/**
* Interface pour la recherche de courrier
......@@ -26,7 +26,7 @@ namespace ext\archivesCourrier\presentation\maarchRM\UserStory;
* @package archivesCourrier
* @author Alexandre Morin <alexandre.morin@maarch.org>
*/
interface contentInterface
interface indexCourrierInterface
{
/**
......@@ -41,15 +41,15 @@ interface contentInterface
* @param string $query
* @param string $originatorOrgRegNumber
* @param bool $hasParent
* @param date $sentDateForm
* @param date $sentDateTo
* @param date $dateForm
* @param date $dateTo
*
* @return archivesCourrier/content/search
* @uses archivesCourrier/content/createSearch
* @uses archivesCourrier/content/readSearch
*/
public function createArchivescourrierContent(
$sentDateForm,
$sentDateTo,
public function readArchivescourrierSearch(
$dateForm,
$dateTo,
$query,
$originatorOrgRegNumber,
$hasParent
......
Supports Markdown
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