Skip to content

Commit

Permalink
Logistics changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrodevog committed Sep 25, 2023
1 parent a679e54 commit c372ec6
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 81 deletions.
53 changes: 52 additions & 1 deletion module/LogisticsBundle/Controller/Admin/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,57 @@ public function viewAction()
)
);

if ($this->getRequest()->isPost()) {
if ($this->getRequest()->getPost()->toArray()['submit'] == 'orderReview') {
$this->initAjax();
$orderForm = $this->getForm('logistics_admin_order_review');
$orderForm->setData($this->getRequest()->getPost());
if ($orderForm->isValid()) {
error_log('Valid: order form');
if ($this->getLastOrderByRequest($order->getRequest())->isReviewed()) {
error_log('existed');
$orderForm->hydrateObject(
$this->recreateOrder(
$this->getLastOrderByRequest($order->getRequest()),
$academic->getUnit($this->getCurrentAcademicYear())->getName())
);
} else {
error_log('didnt exist');
$newOrder = $orderForm->hydrateObject(
$this->recreateOrder($order, $academic->getUnit($this->getCurrentAcademicYear())->getName())
);
$newOrder->review();
$this->getEntityManager()->persist($newOrder);
}
$this->getEntityManager()->flush();

$this->flashMessenger()->success(
'Success',
'The request was succesfully reviewed.'
);
return new ViewModel(
array(
'result' => (object)array('status' => 'success'),
)
);
// return new ViewModel(
// array(
// 'result' => (object)array('status' => json_encode($this->getRequest()->getPost())),
// )
// );
}
} elseif ($this->getRequest()->getPost()->toArray()['submit'] == 'articleReview') {
$articleForm->setData($this->getRequest()->getPost());
if ($orderForm->isValid()) {
error_log('Valid: article form');
$this->flashMessenger()->success(
'Success',
'The request was succesfully reviewed.'
);
}
}
}

return new ViewModel(
array(
'order' => $order,
Expand Down Expand Up @@ -103,7 +154,7 @@ public function reviewOrderAction()
if ($this->getRequest()->isPost()) {
error_log('post');
$orderForm->setData($this->getRequest()->getPost());
error_log($this->getRequest()->getPost()[0]);
error_log(json_encode($this->getRequest()->getPost()));

if ($orderForm->isValid()) {
error_log('valid');
Expand Down
3 changes: 2 additions & 1 deletion module/LogisticsBundle/Controller/InventoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LogisticsBundle\Controller;

use DateTime;
use Laminas\View\Model\ViewModel;
use LogisticsBundle\Entity\Inventory;

Expand All @@ -15,7 +16,7 @@ public function indexAction()
->findAllNotZeroQuery(),
$this->getParam('page')
);

return new ViewModel(
array(
'paginator' => $paginator,
Expand Down
8 changes: 8 additions & 0 deletions module/LogisticsBundle/Entity/Inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LogisticsBundle\Entity;

use DateTime;
use Doctrine\ORM\Mapping as ORM;

/**
Expand Down Expand Up @@ -115,6 +116,13 @@ class Inventory
*/
private $expiryDate;

/**
* @var DateTime The expiry date
*
* @ORM\Column(name="expiry_date", type="DateTime", nullable=true)
*/
private $expiryDate_;

/**
* Inventory constructor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function init()
),
)
);

$this->addSubmit('articleReview', 'articleSubmit hide');
}
}

Expand Down
2 changes: 1 addition & 1 deletion module/LogisticsBundle/Form/Admin/Order/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function init()
{
parent::init();

$this->remove('submit')->addSubmit('review', 'hide');
$this->remove('submit')->addSubmit('orderReview', 'orderSubmit hide');

if ($this->order !== null) {
$this->bind($this->order);
Expand Down
3 changes: 1 addition & 2 deletions module/LogisticsBundle/Form/Inventory/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public function init()
{
parent::init();

$nameField = $this->get('name');
$nameField->setRequired();
$nameField = $this->get('name')->setRequired();

// $this->remove('unit')->remove('perUnit');

Expand Down
11 changes: 6 additions & 5 deletions module/LogisticsBundle/Resources/layouts/logistics/base.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<a href="{{ url('logistics_catalog', {"language": language.getAbbrev()}) }}">{{ translate('Material') }}</a>
</li>
{% endif %}
{% if hasAccess('logistics_inventory', 'index') %}
<li {% if 'logistics_inventory' == getParam('controller') %}class="active"{% endif %}>
<a href="{{ url('logistics_inventory', {"language": language.getAbbrev()}) }}">{{ translate('Flesserke') }}</a>
</li>
{% endif %}
{% if hasAccess('logistics_index', 'index') %}
<li {% if 'logistics_index' == getParam('controller') %} class="active" {% endif %}>
<a href="{{ url("logistics_index", {"language": language.getAbbrev()}) }}">{{ translate('Van') }}</a>
Expand All @@ -42,11 +47,7 @@
{# <a href="{{ url('logistics_lease', {"language": language.getAbbrev()}) }}">{{ translate('Lease') }}</a>#}
{# </li>#}
{# {% endif %}#}
{% if hasAccess('logistics_inventory', 'index') %}
<li {% if 'logistics_inventory' == getParam('controller') %}class="active"{% endif %}>
<a href="{{ url('logistics_inventory', {"language": language.getAbbrev()}) }}">{{ translate('Inventory') }}</a>
</li>
{% endif %}

{# {% if hasAccess('logistics_inventory', 'add') %}#}
{# <li {% if 'logistics_inventory' == getParam('controller') %}class="active"{% endif %}>#}
{# <a href="{{ url('logistics_inventory', {"language": language.getAbbrev(), 'action': 'add'}) }}">{{ translate('Flesserke Form') }}</a>#}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,28 +313,38 @@
var id = $this.data('id');
reviewAll.find('.edit').unbind('click').click(function () {
var reviewOrder = $('#review-order');
var orderSubmit = reviewOrder.find('.orderSubmit');
console.log(orderSubmit);
orderSubmit.click();
if ('success' == orderData.status) {
var reviewArticle = $('#review-article');
var articleSubmit = reviewArticle.find('.articleSubmit');
console.log(articleSubmit);
articleSubmit.click();
}
console.log('click');
$.post('{{ url('logistics_admin_order', {"action": "reviewOrder"})}}' + id, function (orderData) {
console.log(orderData.status);
if (orderData && 'success' == orderData.status) {
$('.flashmessage').addClass('hide');
// $('.article_removed_success').removeClass('hide');
// $('.item-' + id).remove();
reviewAll.modal('hide');
$.post('{{ url('logistics_admin_order', {"action": "reviewArticles"})}}' + id, function (data) {
if (data && 'success' == data.status) {
$('.flashmessage').addClass('hide');
// $('.article_removed_success').removeClass('hide');
// $('.item-' + id).remove();
reviewAll.modal('hide');
} else {
errorRemove();
}
}, 'json').error(errorRemove);
} else {
errorRemove();
}
}, 'json').error(errorRemove);
{# $.post('{{ url('logistics_admin_order', {"action": "reviewOrder"})}}' + id, function (orderData) {#}
{# console.log(orderData.status);#}
{# if (orderData && 'success' == orderData.status) {#}
{# $('.flashmessage').addClass('hide');#}
{# // $('.article_removed_success').removeClass('hide');#}
{# // $('.item-' + id).remove();#}
{# reviewAll.modal('hide');#}
{# $.post('{{ url('logistics_admin_order', {"action": "reviewArticles"})}}' + id, function (data) {#}
{# if (data && 'success' == data.status) {#}
{# $('.flashmessage').addClass('hide');#}
{# // $('.article_removed_success').removeClass('hide');#}
{# // $('.item-' + id).remove();#}
{# reviewAll.modal('hide');#}
{# } else {#}
{# errorRemove();#}
{# }#}
{# }, 'json').error(errorRemove);#}
{# } else {#}
{# errorRemove();#}
{# }#}
{# }, 'json').error(errorRemove);#}
});
reviewAll.modal();
{# {{ url('logistics_admin_order', {"action" : 'review', "id" : order.getId()}) }}#}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{% extends 'logistics/base.twig' %}

{% block content %}
{# {% include 'logistics/inventory/partials/navigation.twig' %}#}

{% include 'admin/partials/flashMessenger.twig' %}

{# Page header + button to add page #}
Expand All @@ -19,11 +17,11 @@
{% endif %}
</div>

{# {% if authenticatedPerson is null %}#}
{# <div>{{ translate('Please login to view Flesserke.') }}</div>#}
{# {% elseif not hasAccess('logistics_inventory', 'index') %}#}
{# <div>{{ translate('You have no access to Flesserke.') }}<br>{{ translate('To ask for access send a mail to [email protected]') }}</div>#}
{# {% else %}#}
{% if authenticatedPerson is null %}
<div>{{ translate('Please login to view Flesserke.') }}</div>
{% elseif not hasAccess('logistics_inventory', 'index') %}
<div>{{ translate('You have no access to Flesserke.') }}<br>{{ translate('To ask for access send a mail to [email protected]') }}</div>
{% else %}
<div id="controller_action">

{# <div id="article_search" style="display:none;">#}
Expand Down Expand Up @@ -67,9 +65,14 @@
{% endif %}
</tr>
</thead>
{% set today = "now"|date('d/m/Y') %}
{% for article in paginator %}
{# {% if article.getExpiryDate() <= date('d/m/y') %}#}
<tr class="item item-{{ article.getId() }}">
{# {% if article.getExpiryDate() %}{% set exp = "19/02/2025"|date('Y-m-d') %}{% endif %}#}
<tr class="item item-{{ article.getId() }}"
{# style="{% if article.getExpiryDate() %}#}
{# {% if exp <= today %}background-color: #fae7e6{% endif %}#}
{# {% endif %}"#}
>
<td>{{ article.getName() }}</td>
<td>{{ article.getCategory() }}</td>
<td>{{ article.getBrand() }}</td>
Expand Down Expand Up @@ -101,35 +104,32 @@
{% include 'admin/partials/paginationControl.twig' %}
</div>

<div class="modal fade" id="removeArticle" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<span>Litus Admin</span>
/Delete Article
</div>
<div class="modal-body">
<p>
You are about to delete the following article: <b class="articleName"></b>!
Please note that this operation cannot be undone!
</p>
<p>
Are you sure you want to continue?
</p>
<div class="footer">
<button class="delete">Yes</button>
<button class="cancel" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
</div>
{# {% endif %}#}
{# <div class="modal fade" id="removeArticle" tabindex="-1">#}
{# <div class="modal-dialog">#}
{# <div class="modal-content">#}
{# <div class="modal-header">#}
{# <span>Litus Admin</span>#}
{# /Delete Article#}
{# </div>#}
{# <div class="modal-body">#}
{# <p>#}
{# You are about to delete the following article: <b class="articleName"></b>!#}
{# Please note that this operation cannot be undone!#}
{# </p>#}
{# <p>#}
{# Are you sure you want to continue?#}
{# </p>#}
{# <div class="footer">#}
{# <button class="delete">Yes</button>#}
{# <button class="cancel" data-dismiss="modal">No</button>#}
{# </div>#}
{# </div>#}
{# </div>#}
{# </div>#}
{# </div>#}
{% endif %}
{% endblock %}

{% block content_script %}
<script type="text/javascript">
$('#sortTable').DataTable();
</script>
{% endblock %}

This file was deleted.

0 comments on commit c372ec6

Please sign in to comment.