Browse Source

Merge branch 'develop'

master^2
Fab 3 years ago
parent
commit
8e1be88d43
6 changed files with 127 additions and 15 deletions
  1. +1
    -1
      ShopBundle/Resources/public/js/backend/script/default/init-list.js
  2. +5
    -4
      ShopBundle/Resources/views/backend/default/sortable.html.twig
  3. +8
    -9
      ShopBundle/Resources/views/backend/productfamily/macros.html.twig
  4. +103
    -0
      ShopBundle/Services/SmsFactorUtils.php
  5. +9
    -1
      ShopBundle/Services/UtilsManager.php
  6. +1
    -0
      ShopBundle/Statistic/Statistic.php

+ 1
- 1
ShopBundle/Resources/public/js/backend/script/default/init-list.js View File

@@ -1,4 +1,4 @@
jQuery(document).ready(function () {
jQuery(document).ready(function () {
initDeleteAction();

initResetFilters();

+ 5
- 4
ShopBundle/Resources/views/backend/default/sortable.html.twig View File

@@ -73,14 +73,14 @@
</tr>
{% endfor %}

{# {% if _number_of_hidden_results > 0 %}
{# {% if _number_of_hidden_results > 0 %}
<tr class="datagrid-row-empty">
<td class="text-center" colspan="{{ _fields_visible_by_user|length + 1 }}">
<span class="datagrid-row-empty-message"><i
class="fa fa-lock mr-1"></i> {{ 'security.list.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
</td>
</tr>
{% endif %}#}
{% endif %} #}
{% endblock table_body %}
</tbody>
</table>
@@ -101,7 +101,9 @@
{% set _action = easyadmin_get_action_for_edit_view('list', _entity_config.name) %}

<div class="button-action">
<a class=" {{ _action.css_class|default('') }}" href="{{ path('easyadmin', _request_parameters|merge({ action: _action.name })) }}" target="{{ _action.target }}">
<a class=" {{ _action.css_class|default('') }}"
href="{{ path('easyadmin', _request_parameters|merge({ action: _action.name })) }}"
target="{{ _action.target }}">
{{ _action.label is defined and not _action.label is empty ? _action.label|trans(_trans_parameters) }}
</a>

@@ -112,7 +114,6 @@
</div>
</div>
{{ form_end(postion_form) }}

{% endblock main %}

{% block head_stylesheets %}

+ 8
- 9
ShopBundle/Resources/views/backend/productfamily/macros.html.twig View File

@@ -1,7 +1,7 @@
{% trans_default_domain 'lcshop' %}

{% macro product_sales_statistic(productsSalesStatistic, productFamily=false) %}
{% for weekNumber, weekNumberQuantity in productsSalesStatistic %}
{% for weekNumber, weekNumberQuantity in productsSalesStatistic|reverse(true) %}
<span class="text-success"><i class="fa fa-calendar"></i> {{ weekNumber }}</span>
<span class="text-info"><i class="fa fa-shopping-basket"></i>
<strong>
@@ -22,18 +22,17 @@
{% for weekNumber, weekNumberQuantity in productsSalesStatistic['data']['total_sales']['data']|reverse(true) %}
<span class="text-success"><i class="fa fa-calendar"></i> {{ weekNumber }}</span>
<span class="text-info"><i class="fa fa-shopping-basket"></i>
<strong>
{{ weekNumberQuantity is null ? 0 : weekNumberQuantity }}
{% if productFamily and (productFamily.behaviorDisplaySale== constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_DISPLAY_SALE_BY_MEASURE')) %}
{{ productFamily.unit.unitReference }}
{% endif %}
</strong>
</span>
<strong>
{{ weekNumberQuantity is null ? 0 : weekNumberQuantity }}
{% if productFamily and (productFamily.behaviorDisplaySale== constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_DISPLAY_SALE_BY_MEASURE')) %}
{{ productFamily.unit.unitReference }}
{% endif %}
</strong>
</span>
<br/>
{% endfor %}
</button>
{% endif %}

{% endmacro product_family_sales_statistic %}



+ 103
- 0
ShopBundle/Services/SmsFactorUtils.php View File

@@ -0,0 +1,103 @@
<?php

namespace Lc\ShopBundle\Services;

use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Twig\Environment;

class SmsFactorUtils
{
const TO_USER = 'to-user' ;
const CONTENT_MESSAGE = 'content-message' ;
const CONTENT_TEMPLATE = 'content-template' ;
const CONTENT_DATA = 'content-data' ;

protected $client;
protected $parameterBag;
protected $mailUtils ;
protected $utils ;
protected $templating ;

public function __construct(
HttpClientInterface $client,
ParameterBagInterface $parameterBag,
MailUtils $mailUtils,
Utils $utils,
Environment $templating
) {
$this->client = $client;
$this->parameterBag = $parameterBag;
$this->mailUtils = $mailUtils ;
$this->utils = $utils ;
$this->templating = $templating ;
}

public function send($params = [])
{
$user = isset($params[self::TO_USER]) ? $params[self::TO_USER] : null ;

if($user) {
$phone = $this->utils->formatPhoneNumber($user->getPhone()) ;

$message = '' ;
if(isset($params[self::CONTENT_MESSAGE])) {
$message = $params[self::CONTENT_MESSAGE] ;
}
elseif(isset($params[self::CONTENT_TEMPLATE])) {
$template = $params[self::CONTENT_TEMPLATE] ;
$paramsTemplate = [] ;
if(isset($params[self::CONTENT_DATA]) && is_array($params[self::CONTENT_DATA])) {
$paramsTemplate = $params[self::CONTENT_DATA] ;
}
$message = $this->templating->render($template, $paramsTemplate) ;
}

if($this->parameterBag->get('mailjet.dev.redirect.active') == 1) {
$this->mailUtils->send([
MailUtils::SUBJECT => 'Notification par SMS à '.$phone,
MailUtils::TO_EMAIL => $user->getEmail(),
MailUtils::CONTENT_TEMPLATE => 'mail/notification',
MailUtils::CONTENT_DATA => [
'message' => $message
],
]);

return true ;
}
else {
$token = $this->parameterBag->get('smsfactor.token');
$from = $this->parameterBag->get('smsfactor.from');

if ($token && strlen($token) > 0) {

$response = $this->client->request(
'GET',
'https://api.smsfactor.com/send',
[
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/json; charset=utf-8',
'Accept' => 'application/json'
],
'query' => [
'sender' => $from,
'to' => $phone,
'text' => $message,
],
]
);

return $response ;
}
else {
throw new \ErrorException('Le token SMS SmsFactor n\'est pas défini.');
}
}
}

return false;
}

}

+ 9
- 1
ShopBundle/Services/UtilsManager.php View File

@@ -30,6 +30,7 @@ class UtilsManager
protected $pointLocationUtils ;
protected $sectionUtils ;
protected $mailjetSmsUtils ;
protected $smsFactorUtils ;

public function __construct(
Utils $utils,
@@ -46,7 +47,8 @@ class UtilsManager
PointLocationUtils $pointLocationUtils,
UtilsProcess $utilsProcess,
SectionUtilsInterface $sectionUtils,
MailjetSmsUtils $mailjetSmsUtils
MailjetSmsUtils $mailjetSmsUtils,
SmsFactorUtils $smsFactorUtils
)
{
$this->utils = $utils ;
@@ -64,6 +66,7 @@ class UtilsManager
$this->utilsProcess = $utilsProcess ;
$this->sectionUtils = $sectionUtils ;
$this->mailjetSmsUtils = $mailjetSmsUtils ;
$this->smsFactorUtils = $smsFactorUtils ;
}

public function getUtils(): Utils
@@ -141,4 +144,9 @@ class UtilsManager
return $this->mailjetSmsUtils ;
}

public function getSmsFactorUtils(): SmsFactorUtils
{
return $this->smsFactorUtils ;
}

}

+ 1
- 0
ShopBundle/Statistic/Statistic.php View File

@@ -154,6 +154,7 @@ class Statistic
public function getInterval()
{
return $this->interval;

}

public function configurePropertyOptions(OptionsResolver $resolver)

Loading…
Cancel
Save