jQuery(document).ready(function () { | |||||
jQuery(document).ready(function () { | |||||
initDeleteAction(); | initDeleteAction(); | ||||
initResetFilters(); | initResetFilters(); |
</tr> | </tr> | ||||
{% endfor %} | {% endfor %} | ||||
{# {% if _number_of_hidden_results > 0 %} | |||||
{# {% if _number_of_hidden_results > 0 %} | |||||
<tr class="datagrid-row-empty"> | <tr class="datagrid-row-empty"> | ||||
<td class="text-center" colspan="{{ _fields_visible_by_user|length + 1 }}"> | <td class="text-center" colspan="{{ _fields_visible_by_user|length + 1 }}"> | ||||
<span class="datagrid-row-empty-message"><i | <span class="datagrid-row-empty-message"><i | ||||
class="fa fa-lock mr-1"></i> {{ 'security.list.hidden_results'|trans({}, 'EasyAdminBundle') }}</span> | class="fa fa-lock mr-1"></i> {{ 'security.list.hidden_results'|trans({}, 'EasyAdminBundle') }}</span> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
{% endif %}#} | |||||
{% endif %} #} | |||||
{% endblock table_body %} | {% endblock table_body %} | ||||
</tbody> | </tbody> | ||||
</table> | </table> | ||||
{% set _action = easyadmin_get_action_for_edit_view('list', _entity_config.name) %} | {% set _action = easyadmin_get_action_for_edit_view('list', _entity_config.name) %} | ||||
<div class="button-action"> | <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) }} | {{ _action.label is defined and not _action.label is empty ? _action.label|trans(_trans_parameters) }} | ||||
</a> | </a> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
{{ form_end(postion_form) }} | {{ form_end(postion_form) }} | ||||
{% endblock main %} | {% endblock main %} | ||||
{% block head_stylesheets %} | {% block head_stylesheets %} |
{% trans_default_domain 'lcshop' %} | {% trans_default_domain 'lcshop' %} | ||||
{% macro product_sales_statistic(productsSalesStatistic, productFamily=false) %} | {% 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-success"><i class="fa fa-calendar"></i> {{ weekNumber }}</span> | ||||
<span class="text-info"><i class="fa fa-shopping-basket"></i> | <span class="text-info"><i class="fa fa-shopping-basket"></i> | ||||
<strong> | <strong> | ||||
{% for weekNumber, weekNumberQuantity in productsSalesStatistic['data']['total_sales']['data']|reverse(true) %} | {% 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-success"><i class="fa fa-calendar"></i> {{ weekNumber }}</span> | ||||
<span class="text-info"><i class="fa fa-shopping-basket"></i> | <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/> | <br/> | ||||
{% endfor %} | {% endfor %} | ||||
</button> | </button> | ||||
{% endif %} | {% endif %} | ||||
{% endmacro product_family_sales_statistic %} | {% endmacro product_family_sales_statistic %} | ||||
<?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; | |||||
} | |||||
} |
protected $pointLocationUtils ; | protected $pointLocationUtils ; | ||||
protected $sectionUtils ; | protected $sectionUtils ; | ||||
protected $mailjetSmsUtils ; | protected $mailjetSmsUtils ; | ||||
protected $smsFactorUtils ; | |||||
public function __construct( | public function __construct( | ||||
Utils $utils, | Utils $utils, | ||||
PointLocationUtils $pointLocationUtils, | PointLocationUtils $pointLocationUtils, | ||||
UtilsProcess $utilsProcess, | UtilsProcess $utilsProcess, | ||||
SectionUtilsInterface $sectionUtils, | SectionUtilsInterface $sectionUtils, | ||||
MailjetSmsUtils $mailjetSmsUtils | |||||
MailjetSmsUtils $mailjetSmsUtils, | |||||
SmsFactorUtils $smsFactorUtils | |||||
) | ) | ||||
{ | { | ||||
$this->utils = $utils ; | $this->utils = $utils ; | ||||
$this->utilsProcess = $utilsProcess ; | $this->utilsProcess = $utilsProcess ; | ||||
$this->sectionUtils = $sectionUtils ; | $this->sectionUtils = $sectionUtils ; | ||||
$this->mailjetSmsUtils = $mailjetSmsUtils ; | $this->mailjetSmsUtils = $mailjetSmsUtils ; | ||||
$this->smsFactorUtils = $smsFactorUtils ; | |||||
} | } | ||||
public function getUtils(): Utils | public function getUtils(): Utils | ||||
return $this->mailjetSmsUtils ; | return $this->mailjetSmsUtils ; | ||||
} | } | ||||
public function getSmsFactorUtils(): SmsFactorUtils | |||||
{ | |||||
return $this->smsFactorUtils ; | |||||
} | |||||
} | } |
public function getInterval() | public function getInterval() | ||||
{ | { | ||||
return $this->interval; | return $this->interval; | ||||
} | } | ||||
public function configurePropertyOptions(OptionsResolver $resolver) | public function configurePropertyOptions(OptionsResolver $resolver) |