Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Shipping method with pickup places - zasilkovna #6

Merged
merged 1 commit into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [#9 - Introduced a quick way to improve performance by caching in twig templates](https://github.com/shopsys/demoshop/pull/9)
- cache invalidation is done by 5 minutes interval
- performance improved by ~15%
- [#6 - Shipping method with pickup places](https://github.com/shopsys/demoshop/pull/6)
- added new shipping method Zasilkovna
- pick up places are downloaded by cron

### Changed
- [#1 - Basic changes in docs, readme etc. after copying from project-base](https://github.com/shopsys/demoshop/pull/1) : [@LukasHeinz]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
{% extends '@!ShopsysFramework/Admin/Content/Order/edit.html.twig' %}
{% import '@ShopsysFramework/Admin/Content/Order/orderItem.html.twig' as orderItemMacro %}
{% block main_content %}
{{ form_start(form) }}
{{ form_errors(form) }}
<div class="wrap-border">
<div class="form-group">
<div class="form-group__title">
{{ 'Order Nr.'|trans }} {{ order.number }}
</div>
</div>
<fieldset>
{{ form_id(order) }}
<div class="form-line">
<div class="form-line__line form-line__line--no-space">
<div class="form-line__item form-line__item--text">
<a href="{{ findUrlByDomainId('front_customer_order_detail_unregistered', { urlHash: order.urlHash }, order.domainId) }}" target="_blank">
{{ findUrlByDomainId('front_customer_order_detail_unregistered', { urlHash: order.urlHash }, order.domainId) }}
</a>
</div>
</div>
</div>
{% if isMultidomain() %}
<div class="form-line">
<label class="form-line__label">{{ 'Domain'|trans }}:</label>
<div class="form-line__side">
<div class="form-line__item form-line__item--text">
{{ domainIcon(order.domainId) }} {{ getDomainName(order.domainId) }}
</div>
</div>
</div>
{% endif %}
{{ form_row(form.orderNumber, { label: 'Order number'|trans }) }}
<div class="form-line">
<label class="form-line__label">{{ 'Date of creation and privacy policy agreement'|trans }}:</label>
<div class="form-line__side">
<div class="form-line__item form-line__item--text">
{{ order.createdAt|formatDateTime }}
</div>
</div>
</div>
{{ form_row(form.status, { label: 'Status'|trans }) }}
<div class="form-line">
<label class="form-line__label">{{ 'Customer'|trans }}:</label>
<div class="form-line__side">
<div class="form-line__item form-line__item--text">
{% if order.customer is null%}
{{ 'unregistered customer'|trans }}
{% else %}
<a href="{{ path('admin_customer_edit', { id: order.customer.id }) }}" target="_blank">
{% if order.customer.billingAddress.companyCustomer %}
{{ order.customer.billingAddress.companyName }} -
{% endif %}
{{ order.customer.lastName }}
{{ order.customer.firstName }}
<i class="svg svg-forward-page"></i>
</a>
{% endif %}
</div>
</div>
</div>
{% if order.createdAsAdministrator is not null or order.createdAsAdministratorName is not null %}
<div class="form-line">
<label class="form-line__label">{{ 'Created by administrator'|trans }}:</label>
<div class="form-line__side">
<div class="form-line__item form-line__item--text">
{% if order.createdAsAdministrator is null%}
{{ order.createdAsAdministratorName }}
{% else %}
{{ order.createdAsAdministrator.realName }}
{% endif %}
</div>
</div>
</div>
{% endif %}
</fieldset>
</div>
<div class="wrap-border">
<div class="form-group">
<div class="form-group__title">
{{ 'Personal data'|trans }}
</div>
</div>
<fieldset>
{{ form_row(form.firstName, { label: 'First name'|trans }) }}
{{ form_row(form.lastName, { label: 'Last name'|trans }) }}
{{ form_row(form.email, { label: 'E-mail'|trans }) }}
{{ form_row(form.telephone, { label: 'Telephone'|trans }) }}
</fieldset>
</div>
<div class="wrap-border">
<div class="form-group">
<div class="form-group__title">
{{ 'Company data'|trans }}
</div>
</div>
<fieldset>
{{ form_row(form.companyName, { label: 'Company name'|trans }) }}
{{ form_row(form.companyNumber, { label: 'Company number'|trans }) }}
{{ form_row(form.companyTaxNumber, { label: 'Tax number'|trans }) }}
</fieldset>
</div>
<div class="wrap-border">
<div class="form-group">
<div class="form-group__title">
{{ 'Billing data'|trans }}
</div>
</div>
<fieldset>
{{ form_row(form.street, { label: 'Street'|trans }) }}
{{ form_row(form.city, { label: 'City'|trans }) }}
{{ form_row(form.postcode, { label: 'Postcode'|trans }) }}
{{ form_row(form.country, { label: 'Country'|trans }) }}
</fieldset>
</div>
<div class="wrap-border">
<div class="form-group">
<div class="form-group__title">
{{ 'Shipping address'|trans }}
</div>
</div>
<fieldset>
{{ form_row(form.deliveryAddressSameAsBillingAddress, {
attr: { class: 'js-checkbox-toggle js-checkbox-toggle--inverted', 'data-checkbox-toggle-container-id': 'js-delivery-address-fields' },
label: 'Shipping address is the same as billing address'|trans})
}}
<div id="js-delivery-address-fields" class="form-line__js">
{{ form_row(form.deliveryFirstName, { label: 'First name'|trans }) }}
{{ form_row(form.deliveryLastName, { label: 'Last name'|trans }) }}
{{ form_row(form.deliveryCompanyName, { label: 'Company'|trans }) }}
{{ form_row(form.deliveryTelephone, { label: 'Telephone'|trans }) }}
{{ form_row(form.deliveryStreet, { label: 'Street'|trans }) }}
{{ form_row(form.deliveryCity, { label: 'City'|trans }) }}
{{ form_row(form.deliveryPostcode, { label: 'Postcode'|trans }) }}
{{ form_row(form.deliveryCountry, { label: 'Country'|trans }) }}
</div>
</fieldset>
</div>
{% if order.pickUpPlace is not null %}
<div class="wrap-border">
<div class="form-group">
<div class="form-group__title">
{{ 'Zasilkovna.cz - dispensing point'|trans }}
</div>
</div>
<div class="form-line">
<label class="form-line__label">{{ 'Id'|trans }}:</label>
<div class="form-line__side">
<div class="form-line__item form-line__item--text">
{{ order.pickUpPlace.id }}
</div>
</div>
</div>
<div class="form-line">
<label class="form-line__label">{{ 'Name'|trans }}:</label>
<div class="form-line__side">
<div class="form-line__item form-line__item--text">
{{ order.pickUpPlace.name }}
</div>
</div>
</div>
<div class="form-line">
<label class="form-line__label">{{ 'Address'|trans }}:</label>
<div class="form-line__side">
<div class="form-line__item form-line__item--text">
{{ order.pickUpPlace.fullAddress }}
</div>
</div>
</div>
<div class="form-line">
<label class="form-line__label">{{ 'Description'|trans }}:</label>
<div class="form-line__side">
<div class="form-line__item form-line__item--text">
{{ order.pickUpPlace.description }}
</div>
</div>
</div>
</div>
{% endif %}
<div class="wrap-border">
<div class="form-group">
<div class="form-group__title">
{{ 'Note'|trans }}
</div>
</div>
<fieldset>
{{ form_row(form.note, { label: 'Contact us'|trans, newline: true }) }}
</fieldset>
</div>
<h2>{{ 'Order items'|trans }}</h2>
<fieldset>
<div class="table-touch-always">
{{ form_errors(form.itemsWithoutTransportAndPayment) }}
<div class="table-touch-always__in">
<table id="order_form_items" class="table-main">
<thead>
<tr>
<th class="table-col-30">{{ 'Name'|trans }}</th>
<th class="table-col-5">{{ 'Catalogue number'|trans }}</th>
<th class="table-col-15 text-right">{{ 'Unit price including VAT'|trans }}</th>
<th class="table-col-10 text-right">{{ 'Amount'|trans }}</th>
<th class="table-col-10 text-right">{{ 'Unit'|trans }}</th>
<th class="table-col-10 text-right">{{ 'VAT rate (%)'|trans }}</th>
<th class="table-col-15 text-right text-no-wrap">{{ 'Total including VAT'|trans }}</th>
<th class="table-col-15 text-right text-no-wrap">{{ 'Total excluding VAT'|trans }}</th>
<th ></th>
</tr>
</thead>
<tbody
id="js-order-items"
data-prototype="{{ orderItemMacro.orderItem(form.itemsWithoutTransportAndPayment.vars.prototype)|escape }}"
data-order-product-add-url="{{ url('admin_order_addproduct', { orderId: order.id }) }}"
>
{% for productItem in order.productItems %}
{{ orderItemMacro.orderItem(form.itemsWithoutTransportAndPayment[productItem.id], productItem.id, orderItemTotalPricesById, order.currency, productItem) }}
{% endfor %}
{% for orderItemId, orderItemForm in form.itemsWithoutTransportAndPayment %}
{% if not orderItemForm.rendered %}
{{ orderItemMacro.orderItem(orderItemForm, orderItemId, orderItemTotalPricesById, order.currency, null) }}
{% endif %}
{% endfor %}
{{ orderItemMacro.orderTransport(form.orderTransport, order, transportPricesWithVatByTransportId, transportVatPercentsByTransportId) }}
{{ orderItemMacro.orderPayment(form.orderPayment, order, paymentPricesWithVatByPaymentId, paymentVatPercentsByPaymentId) }}
</tbody>
<tfoot>
<tr>
<td colspan="9">
<a id="js-order-item-add" href="#" class="btn btn--plus">
<i class="btn__icon">+</i>
{{ 'Add item'|trans }}
</a>
<a id="js-order-item-add-product" href="#" class="btn btn--plus" data-product-picker-url="{{ url('admin_productpicker_picksingle', {allowMainVariants: false}) }}">
<i class="btn__icon">+</i>
{{ 'Add product'|trans }}
</a>
</td>
</tr>
<tr>
<th colspan="6">{{ 'Total'|trans }}:</th>
<th class="text-right">{{ order.totalPriceWithVat|priceWithCurrency(order.currency) }}</th>
<th class="text-right">{{ order.totalPriceWithoutVat|priceWithCurrency(order.currency) }}</th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
</fieldset>
{% embed '@ShopsysFramework/Admin/Inline/FixedBar/fixedBar.html.twig' %}
{% block fixed_bar_content %}
<a href="{{ url('admin_order_list') }}" class="btn-link-style">{{ 'Back to overview'|trans }}</a>
{{ form_widget(form.save, { label: 'Save changes'|trans}) }}
{% endblock %}
{% endembed %}
{{ form_end(form) }}
{% endblock %}
2 changes: 2 additions & 0 deletions app/config/parameters_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ parameters:
Shopsys\FrameworkBundle\Model\Product\Product: Shopsys\ShopBundle\Model\Product\Product
Shopsys\FrameworkBundle\Model\Category\Category: Shopsys\ShopBundle\Model\Category\Category
Shopsys\FrameworkBundle\Model\Category\CategoryDomain: Shopsys\ShopBundle\Model\Category\CategoryDomain
Shopsys\FrameworkBundle\Model\Order\Order: Shopsys\ShopBundle\Model\Order\Order
Shopsys\FrameworkBundle\Model\Transport\Transport: Shopsys\ShopBundle\Model\Transport\Transport
1 change: 1 addition & 0 deletions app/config/paths.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ parameters:
shopsys.web_dir: '%shopsys.root_dir%/web'
shopsys.vendor_dir: '%kernel.root_dir%/../vendor'
shopsys.js_form_validator_output_vendor_dir: '../vendor'
shopsys.zasilkovna_feed: 'http://www.zasilkovna.cz/api/v3/41494564a70d6de6/branch.xml'
3 changes: 3 additions & 0 deletions migrations-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,6 @@
20180730101540:
class: Shopsys\ShopBundle\Migrations\Version20180730101540
skip: false
20180724105136:
class: Shopsys\FrameworkBundle\Migrations\Version20180724105136
skip: false
5 changes: 3 additions & 2 deletions src/Shopsys/ShopBundle/Controller/Front/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Shopsys\FrameworkBundle\Model\Customer\User;
use Shopsys\FrameworkBundle\Model\LegalConditions\LegalConditionsFacade;
use Shopsys\FrameworkBundle\Model\Newsletter\NewsletterFacade;
use Shopsys\FrameworkBundle\Model\Order\FrontOrderData;
use Shopsys\FrameworkBundle\Model\Order\Mail\OrderMailFacade;
use Shopsys\FrameworkBundle\Model\Order\OrderData;
use Shopsys\FrameworkBundle\Model\Order\OrderDataMapper;
Expand All @@ -22,6 +21,7 @@
use Shopsys\FrameworkBundle\Model\Transport\TransportFacade;
use Shopsys\FrameworkBundle\Model\Transport\TransportPriceCalculation;
use Shopsys\ShopBundle\Form\Front\Order\DomainAwareOrderFlowFactory;
use Shopsys\ShopBundle\Model\Order\FrontOrderData;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -52,7 +52,7 @@ class OrderController extends FrontBaseController
private $orderMailFacade;

/**
* @var \Shopsys\FrameworkBundle\Model\Order\OrderDataMapper
* @var \Shopsys\ShopBundle\Model\Order\OrderDataMapper
*/
private $orderDataMapper;

Expand Down Expand Up @@ -229,6 +229,7 @@ public function indexAction()
'transport' => $transport,
'payment' => $payment,
'payments' => $payments,
'pickUpPlace' => $orderData->pickUpPlace,
'transportsPrices' => $this->transportPriceCalculation->getCalculatedPricesIndexedByTransportId(
$transports,
$currency,
Expand Down
78 changes: 78 additions & 0 deletions src/Shopsys/ShopBundle/Controller/Front/PickUpPlaceController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace Shopsys\ShopBundle\Controller\Front;

use Shopsys\FrameworkBundle\Component\String\TransformString;
use Shopsys\ShopBundle\Model\Country\CountryFacade;
use Shopsys\ShopBundle\Model\PickUpPlace\PickUpPlaceFacade;
use Symfony\Component\HttpFoundation\Request;

class PickUpPlaceController extends FrontBaseController
{
/**
* @var \Shopsys\ShopBundle\Model\Country\CountryFacade
*/
protected $countryFacade;

/**
* @var \Shopsys\ShopBundle\Model\PickUpPlace\PickUpPlaceFacade
*/
protected $pickUpPlaceFacade;

/**
* @param \Shopsys\ShopBundle\Model\PickUpPlace\PickUpPlaceFacade $pickUpPlaceFacade
* @param \Shopsys\ShopBundle\Model\Country\CountryFacade $countryFacade
*/
public function __construct(PickUpPlaceFacade $pickUpPlaceFacade, CountryFacade $countryFacade)
{
$this->countryFacade = $countryFacade;
$this->pickUpPlaceFacade = $pickUpPlaceFacade;
}

/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function searchAction(Request $request)
{
$pickUpPlaceId = (int)$request->get('pickUpPlaceId');

$pickUpPlaces = [];
if ($pickUpPlaceId > 0) {
$pickUpPlace = $this->pickUpPlaceFacade->getById($pickUpPlaceId);
$pickUpPlaces[] = $pickUpPlace;
}

return $this->render('@ShopsysShop/Front/Inline/PickUpPlace/pickUpPlaceSearch.html.twig', [
'pickUpPlaces' => $pickUpPlaces,
]);
}

/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function autocompleteAction(Request $request)
{
$rawSearchQuery = $request->request->get('searchQuery', '');
$transportType = $request->request->get('transportType');

$searchQuery = TransformString::emptyToNull(trim($rawSearchQuery));

/** @var $countryCodes string[] */
$countryCodes = array_map(function ($country) {
/** @var $country \Shopsys\FrameworkBundle\Model\Country\Country */
return strtolower($country->getCode());
}, $this->countryFacade->getAllOnCurrentDomain());

$pickUpPlaces = $this->pickUpPlaceFacade->findActiveBySearchQueryAndTransportType(
$searchQuery,
$countryCodes,
$transportType
);

return $this->render('@ShopsysShop/Front/Inline/PickUpPlace/autocompleteResult.html.twig', [
'pickUpPlaces' => $pickUpPlaces,
]);
}
}
Loading