Skip to content

Commit

Permalink
Se corrigio la visualización de archivos en pedidos multiinstancia
Browse files Browse the repository at this point in the history
  • Loading branch information
jogianotti committed Dec 18, 2015
1 parent cdc4fef commit effec31
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 108 deletions.
8 changes: 4 additions & 4 deletions src/Celsius3/CoreBundle/Controller/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ protected function baseDoUnion($name, $ids, $main_id, $route, $updateInstance =
}

if ($name === 'BaseUser') {
$this->mergeSecondaryInstances($main,$entities);
$this->mergeSecondaryInstances($main, $entities);
}

$this->get('celsius3_core.union_manager')->union($this->getBundle() . ':' . $name, $main, $entities, $updateInstance);
Expand All @@ -296,12 +296,12 @@ protected function createDeleteForm($id)
protected function ajax(Request $request, Instance $instance = null, $librarian = null)
{
if (!$request->isXmlHttpRequest()) {
return $this->createNotFoundException();
throw $this->createNotFoundException();
}

$target = $request->query->get('target');
if (!$this->validateAjax($target)) {
return $this->createNotFoundException();
throw $this->createNotFoundException();
}

$term = $request->query->get('term');
Expand All @@ -321,7 +321,7 @@ protected function ajax(Request $request, Instance $instance = null, $librarian
foreach ($result as $element) {
$json[] = array(
'id' => $element->getId(),
'value' => ($target === 'BaseUser')? $element->__toString() . " (" . $element->getUsername() . ")" : $element->__toString()
'value' => ($target === 'BaseUser') ? $element->__toString() . " (" . $element->getUsername() . ")" : $element->__toString()
);
}

Expand Down
20 changes: 11 additions & 9 deletions src/Celsius3/CoreBundle/Manager/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ public function registerDownload(Request $request, File $file, HttpRequest $http
public function copyFilesToPreviousRequest(Request $previousRequest, Request $request, Event $event)
{
foreach ($request->getFiles() as $original) {
$file = clone $original;
$file->setInstance($previousRequest->getInstance());
$file->setRequest($previousRequest);
$file->setEvent($event);
if (!copy($original->getUploadRootDir() . DIRECTORY_SEPARATOR . $original->getPath(), $file->getUploadRootDir() . DIRECTORY_SEPARATOR . $file->getPath())) {
throw new \Exception('Copy file error');
if ($original->getEnabled()) {
$file = clone $original;
$file->setInstance($previousRequest->getInstance());
$file->setRequest($previousRequest);
$file->setEvent($event);
if (!copy($original->getUploadRootDir() . DIRECTORY_SEPARATOR . $original->getPath(), $file->getUploadRootDir() . DIRECTORY_SEPARATOR . $file->getPath())) {
throw new \Exception('Copy file error');
}
$this->em->persist($file);
$event->addFile($file);
$this->em->persist($event);
}
$this->em->persist($file);
$event->addFile($file);
$this->em->persist($event);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ orderControllers.controller('OrderCtrl', function ($scope, $http, Upload, $filte

$scope._ = _;

$scope.instance_id = instance_id;

$scope.contains = function (list, item) {
return _.contains(list, item);
};
Expand Down Expand Up @@ -101,13 +103,13 @@ orderControllers.controller('OrderCtrl', function ($scope, $http, Upload, $filte
}));
};

$scope.reclaimedRequests = function() {
$scope.reclaimedRequests = function () {
return $scope.requests.filter(function (item) {
return item.is_reclaimed;
});
};

$scope.reclaimedReceptions = function() {
$scope.reclaimedReceptions = function () {
return $scope.receptions.filter(function (item) {
return item.is_reclaimed;
});
Expand All @@ -131,7 +133,7 @@ orderControllers.controller('OrderCtrl', function ($scope, $http, Upload, $filte
return f.id === file.id;
}).length > 0;
}).length > 0 || $scope.receptions.filter(function (item) {
return item.type === 'sireceive' && item.files.filter(function (f) {
return (item.type === 'sireceive' || item.type === 'mireceive') && item.files.filter(function (f) {
return f.id === file.id;
}).length > 0;
}).length > 0;
Expand Down Expand Up @@ -929,4 +931,5 @@ orderControllers.controller('OrderCtrl', function ($scope, $http, Upload, $filte
return content;
}
};

});
188 changes: 96 additions & 92 deletions src/Celsius3/CoreBundle/Resources/views/AdminOrder/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,24 @@
<!-- file_list.html -->
<script type="text/ng-template" id="file_list.html">
<table class="table table-hover catalog-table">
<thead>
<tr>
<th>{{'name' | translate}}</th>
<th>{{'pages' | translate}}</th>
<th>{{'state' | translate}}</th>
<th>{{'actions' | translate}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="file in files.list">
<td><a ng-href="{{getFileDownloadRoute(file)}}">{{file.name}}</a></td>
<td>{{file.pages}}</td>
<td>{{file | state | translate}}</td>
<td>
<a ng-if="isLocalFile(file)" href ng-click="changeFileState(file)" class="btn">{{'changeState' | translate}}</a>
</td>
</tr>
</tbody>
<thead>
<tr>
<th>{{'name' | translate}}</th>
<th>{{'pages' | translate}}</th>
<th>{{'state' | translate}}</th>
<th>{{'actions' | translate}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="file in files.list">
<td><a ng-href="{{getFileDownloadRoute(file)}}">{{file.name}}</a></td>
<td>{{file.pages}}</td>
<td>{{file | state | translate}}</td>
<td>
<a ng-if="isLocalFile(file)" href ng-click="changeFileState(file)" class="btn">{{'changeState' | translate}}</a>
</td>
</tr>
</tbody>
</table>
</script>

Expand Down Expand Up @@ -202,13 +202,13 @@
<!-- order_upload_form.html -->
<script type="text/ng-template" id="order_upload_form.html">
<div class="alert alert-success" ng-if="request.current_state === 'received'">
{{'filesSuccessUpload' | translate}}
{{'filesSuccessUpload' | translate}}
</div>
<div class="alert alert-danger" ng-if="request.current_state === 'taken' && receptions.length > 0">
{{'requestReclaimed' | translate}}
<ul>
<li ng-repeat="reclaim in getReclaim(receptions[0])">{{reclaim.created_at | date:'shortDate'}} - {{reclaim.observations}}</li>
</ul>
{{'requestReclaimed' | translate}}
<ul>
<li ng-repeat="reclaim in getReclaim(receptions[0])">{{reclaim.created_at | date:'shortDate'}} - {{reclaim.observations}}</li>
</ul>
</div>
<form class="form-horizontal" id="uploadForm" ng-if="request.current_state !== 'delivered'">
<div class="form-group">
Expand Down Expand Up @@ -251,36 +251,36 @@
<script type="text/ng-template" id="request_not_received.html">
<div class="panel2 col-md-1"></div>
<div class="panel3 col-md-3" ng-if="request.type === 'sirequest'">
<div class="relojito">
<a href ng-click="forms.receive.request = request.id" data-target="#receive-modal" role="button" data-toggle="modal">
<img src="/bundles/celsius3core/images/icon_relojito.png" width="11" height="20" alt="waiting" />
</a>
<span ng-if="hasReclaim(request)" class="glyphicon glyphicon-warning-sign"></span>
</div>
<div class="fecha_relojito">
<a href ng-click="forms.receive.request = request.id" data-target="#receive-modal" role="button" data-toggle="modal">
{{request.created_at|date:'mediumDate'}}
</a>
</div>
<div class="relojito">
<a href ng-click="forms.receive.request = request.id" data-target="#receive-modal" role="button" data-toggle="modal">
<img src="/bundles/celsius3core/images/icon_relojito.png" width="11" height="20" alt="waiting" />
</a>
<span ng-if="hasReclaim(request)" class="glyphicon glyphicon-warning-sign"></span>
</div>
<div class="fecha_relojito">
<a href ng-click="forms.receive.request = request.id" data-target="#receive-modal" role="button" data-toggle="modal">
{{request.created_at|date:'mediumDate'}}
</a>
</div>
</div>
<div class="panel3 col-md-3" ng-if="request.type === 'mirequest'">
<div class="relojito">
<img src="/bundles/celsius3core/images/icon_relojito.png" width="11" height="20" alt="waiting" />
<span ng-if="hasReclaim(request)" class="glyphicon glyphicon-warning-sign"></span>
</div>
<div class="fecha_relojito">
{{request.created_at|date:'mediumDate'}}
</div>
<div class="relojito">
<img src="/bundles/celsius3core/images/icon_relojito.png" width="11" height="20" alt="waiting" />
<span ng-if="hasReclaim(request)" class="glyphicon glyphicon-warning-sign"></span>
</div>
<div class="fecha_relojito">
{{request.created_at|date:'mediumDate'}}
</div>
</div>
<div class="panel3 col-md-1 panel3_last">
<ul class="list-unstyled request-actions">
<li>
<a href bs-tooltip="cancelTooltip" ng-click="forms.cancel.request = request.id" data-target="#cancel-modal" data-toggle="modal"><span class="glyphicon glyphicon-remove"></span></a>
</li>
<li>
<a href bs-tooltip="reclaimTooltip" ng-click="forms.reclaim.request = request.id" data-target="#reclaim-modal" data-toggle="modal"><span class="glyphicon glyphicon-repeat"></span></a>
</li>
</ul>
<ul class="list-unstyled request-actions">
<li>
<a href bs-tooltip="cancelTooltip" ng-click="forms.cancel.request = request.id" data-target="#cancel-modal" data-toggle="modal"><span class="glyphicon glyphicon-remove"></span></a>
</li>
<li>
<a href bs-tooltip="reclaimTooltip" ng-click="forms.reclaim.request = request.id" data-target="#reclaim-modal" data-toggle="modal"><span class="glyphicon glyphicon-repeat"></span></a>
</li>
</ul>
</div>
</script>

Expand All @@ -289,15 +289,19 @@
<div class="panel2_ok col-md-1"></div>
<div class="panel3_ok col-md-3">
<div class="relojito">
<a ng-if="!hasApprove(getReceive(request))" ng-repeat="file in getReceive(request).files.slice(0,3)" ng-href="{{getFileDownloadRoute(file)}}" title="{{file.name}}">
<span ng-if="getReceive(request).delivery_type === 'PDF'" class="fa fa-file-pdf-o"></span>
<span ng-if="getReceive(request).delivery_type === 'Printed'" class="fa fa-file-text"></span>
</a>
<a ng-if="hasApprove(getReceive(request))" ng-repeat="file in getApprove(getReceive(request)).files.slice(0,3)" ng-href="{{getFileDownloadRoute(file)}}" title="{{file.name}}">
<span ng-if="getReceive(request).delivery_type === 'PDF'" class="fa fa-file-pdf-o"></span>
<span ng-if="getReceive(request).delivery_type === 'Printed'" class="fa fa-file-text"></span>
</a>
<a href ng-if="!hasApprove(getReceive(request))" bs-tooltip="viewAllTooltip" ng-click="files.list = getReceive(request).files" data-target="#files-modal" role="button" data-toggle="modal">
<span ng-if="!hasApprove(getReceive(request))">
<a ng-if="file.enabled" ng-repeat="file in getReceive(request).files.slice(0,3)" ng-href="{{getFileDownloadRoute(file)}}" title="{{file.name}}">
<span ng-if="getReceive(request).delivery_type === 'PDF'" class="fa fa-file-pdf-o"></span>
<span ng-if="getReceive(request).delivery_type === 'Printed'" class="fa fa-file-text"></span>
</a>
</span>
<span ng-if="hasApprove(getReceive(request))">
<a ng-if="file.enabled" ng-repeat="file in getApprove(getReceive(request)).files.slice(0,3)" ng-href="{{getFileDownloadRoute(file)}}" title="{{file.name}}">
<span ng-if="getReceive(request).delivery_type === 'PDF'" class="fa fa-file-pdf-o"></span>
<span ng-if="getReceive(request).delivery_type === 'Printed'" class="fa fa-file-text"></span>
</a>
</span>
<a href ng-if="!hasApprove(getReceive(request)) && request.type === 'sirequest'" bs-tooltip="viewAllTooltip" ng-click="files.list = getReceive(request).files" data-target="#files-modal" role="button" data-toggle="modal">
<span class="glyphicon glyphicon-list-alt"></span>
</a>
<a href ng-if="hasApprove(getReceive(request))" bs-tooltip="viewAllTooltip" ng-click="files.list = getApprove(getReceive(request)).files" data-target="#files-modal" role="button" data-toggle="modal">
Expand Down Expand Up @@ -335,46 +339,46 @@
</div>
<div class="row">
<div class="col-md-9" ng-if="request.type === 'provision' && take.length === 0 && !advanced && searches.length === 0 && !_.isUndefined(request.previous_request)">
<div class="row">
<div class="col-md-12">
<p>{{'provisionModeText' | translate}}</p>
<p>
<button class="btn btn-success" ng-click="basicMode()">{{'basic' | translate}}</button>
<button class="btn btn-primary" ng-click="advancedMode()">{{'advanced' | translate}}</button>
</p>
</div>
</div>
</div>
<div class="col-md-9" ng-if="request.type === 'provision' && take.length === 0 && !advanced && searches.length === 0 && !_.isUndefined(request.previous_request)">
<div class="row">
<div class="col-md-12">
<p>{{'provisionModeText' | translate}}</p>
<p>
<button class="btn btn-success" ng-click="basicMode()">{{'basic' | translate}}</button>
<button class="btn btn-primary" ng-click="advancedMode()">{{'advanced' | translate}}</button>
</p>
</div>
</div>
</div>
<div class="col-md-9" ng-if="request.type === 'provision' && take.length > 0">
<div class="row">
<div class="col-md-12" ng-include="'order_upload_form.html'">
</div>
</div>
</div>
<div class="col-md-9" ng-if="request.type === 'provision' && take.length > 0">
<div class="row">
<div class="col-md-12" ng-include="'order_upload_form.html'">
</div>
</div>
</div>
<div class="col-md-9" ng-if="request.type === 'search' || advanced || searches.length > 0 || _.isUndefined(request.previous_request)">
<div class="alert alert-danger" ng-if="reclaims.length > 0 && (reclaimedRequests().length > 0 || reclaimedReceptions().length > 0)">
{{'requestReclaimed' | translate}}
<ul>
<li ng-repeat="request in reclaimedRequests()">{{getReclaim(request).created_at | date:'shortDate'}} - {{getReclaim(request).observations}}</li>
<li ng-repeat="reception in reclaimedReceptions()">{{getReclaim(reception).created_at | date:'shortDate'}} - {{getReclaim(reception).observations}}</li>
</ul>
</div>
<div class="col-md-9" ng-if="request.type === 'search' || advanced || searches.length > 0 || _.isUndefined(request.previous_request)">
<div class="alert alert-danger" ng-if="reclaims.length > 0 && (reclaimedRequests().length > 0 || reclaimedReceptions().length > 0)">
{{'requestReclaimed' | translate}}
<ul>
<li ng-repeat="request in reclaimedRequests()">{{getReclaim(request).created_at | date:'shortDate'}} - {{getReclaim(request).observations}}</li>
<li ng-repeat="reception in reclaimedReceptions()">{{getReclaim(reception).created_at | date:'shortDate'}} - {{getReclaim(reception).observations}}</li>
</ul>
</div>
<div class="row">
<state-bar>
<div class="row">
<state-bar>
</state-bar>
</div>
</state-bar>
</div>
<div class="row" ng-include="'show_order_content.html'">
</div>
</div>
<div class="row" ng-include="'show_order_content.html'">
</div>
</div>
<div id="derecha" class="col-md-3" ng-include="'show_order_history.html'">
</div>
<div id="derecha" class="col-md-3" ng-include="'show_order_history.html'">
</div>
</div>
</script>

Expand Down

0 comments on commit effec31

Please sign in to comment.