Browse Source

Merge branch 'develop'

master
Guillaume 4 years ago
parent
commit
04deecddf3
7 changed files with 190 additions and 17 deletions
  1. +2
    -1
      ShopBundle/Controller/Backend/AdminController.php
  2. +87
    -0
      ShopBundle/Listener/MailLoggerListener.php
  3. +28
    -0
      ShopBundle/Repository/OrderShopRepository.php
  4. +2
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +7
    -6
      ShopBundle/Resources/views/backend/default/block/form_address.html.twig
  6. +61
    -10
      ShopBundle/Services/CsvGenerator.php
  7. +3
    -0
      ShopBundle/Services/Utils.php

+ 2
- 1
ShopBundle/Controller/Backend/AdminController.php View File

@@ -15,6 +15,7 @@ use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\ShopBundle\Form\Backend\Common\AbstractEditPositionType;
use Lc\ShopBundle\Form\Backend\Filters\ListFilterType;
use Lc\ShopBundle\Model\User;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -517,7 +518,7 @@ class AdminController extends EasyAdminController

$id = $this->request->query->get('id');
$easyadmin = $this->request->attributes->get('easyadmin');
$entity = $easyadmin['item'];
$entity = $easyadmin['item'];

if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) {
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue'));

+ 87
- 0
ShopBundle/Listener/MailLoggerListener.php View File

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

namespace Lc\ShopBundle\Services;

use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Swift_Events_SendEvent;
use Swift_Events_SendListener;

class MailLoggerUtil implements Swift_Events_SendListener
{
protected $logger;

/**
* MailerLoggerUtil constructor.
*
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}

/**
* @param Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
: void
{
}

/**
* @param Swift_Events_SendEvent $evt
*/
public function sendPerformed(Swift_Events_SendEvent $evt)
: void
{

dump('ncnnc');
$level = $this->getLogLevel($evt);
$message = $evt->getMessage();

$this->logger->log(
$level,
$message->getSubject().' - '.$message->getId(),
[
'result' => $evt->getResult(),
'subject' => $message->getSubject(),
'to' => $message->getTo(),
'cc' => $message->getCc(),
'bcc' => $message->getBcc(),
]
);
}

/**
* @param Swift_Events_SendEvent $evt
*
* @return string
*/
private function getLogLevel(Swift_Events_SendEvent $evt)
: string
{
switch ($evt->getResult()) {
// Sending has yet to occur
case Swift_Events_SendEvent::RESULT_PENDING:
return LogLevel::DEBUG;

// Email is spooled, ready to be sent
case Swift_Events_SendEvent::RESULT_SPOOLED:
return LogLevel::DEBUG;

// Sending failed
default:
case Swift_Events_SendEvent::RESULT_FAILED:
return LogLevel::CRITICAL;

// Sending worked, but there were some failures
case Swift_Events_SendEvent::RESULT_TENTATIVE:
return LogLevel::ERROR;

// Sending was successful
case Swift_Events_SendEvent::RESULT_SUCCESS:
return LogLevel::INFO;
}
}
}

+ 28
- 0
ShopBundle/Repository/OrderShopRepository.php View File

@@ -120,6 +120,10 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query->select('count(e.id)');
}

if (isset($params['select'])) {
$query->select( $params['select']);
}

if (isset($params['dateStart']) || isset($params['dateEnd'])) {
$params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate';
}
@@ -161,6 +165,26 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query->andWhere('e.deliveryAddress = :address OR e.invoiceAddress = :address')->setParameter('address', $params['address']);
}

if(isset($params['weekDeliveryTruck'])) {
$query->andWhere('e.weekDeliveryTruck = :weekDeliveryTruck')->setParameter('weekDeliveryTruck', $params['weekDeliveryTruck']);
}

if(isset($params['estimatedDeliveryDateTime'])) {
$query->andWhere('e.estimatedDeliveryDateTime >= :deliveryDateStart');
$query->andWhere('e.estimatedDeliveryDateTime < :deliveryDateEnd');
$date = clone $params['estimatedDeliveryDateTime'];
$query->setParameter('deliveryDateStart', $date->format('Y-m-d 00:00:00'));
$query->setParameter('deliveryDateEnd', $date->modify('+1 day')->format('Y-m-d 00:00:00'));
}

if(isset($params['deliveryDate'])) {
$query->andWhere('e.deliveryDate >= :deliveryDateStart');
$query->andWhere('e.deliveryDate < :deliveryDateEnd');
$date = clone $params['deliveryDate'];
$query->setParameter('deliveryDateStart', $date->format('Y-m-d 00:00:00'));
$query->setParameter('deliveryDateEnd', $date->modify('+1 day')->format('Y-m-d 00:00:00'));
}

if (isset($params['mergeComplementaryOrderShops'])) {
$query->andWhere('e.mainOrderShop IS NULL');
$query->leftJoin('e.complementaryOrderShops', 'complementaryOrderShops');
@@ -229,6 +253,10 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
}


if (isset($params['groupBy'])) {
$query->groupBy( $params['groupBy']);
}

if (isset($params['count']) && $params['count']) {
return $query->getQuery()->getSingleScalarResult();
} else {

+ 2
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml View File

@@ -381,7 +381,9 @@ field:
quantityProduct: Quantité (en rapport à l'unité)
unit: Unité
OrderShop:
deliveryTruck: Véhicule de livraison
createdAt: Date de création
updatedAt: Date de modification
save: Sauvegarder
reference: Référence
mainInfo: Information principal

+ 7
- 6
ShopBundle/Resources/views/backend/default/block/form_address.html.twig View File

@@ -45,17 +45,18 @@
<div class="col-6">
{{ form_row(form.tva) }}
</div>
<div class="col-6">
{{ form_row(form.latitude) }}
</div>
<div class="col-6">
{{ form_row(form.longitude) }}
</div>

</div>
</div>
<div class="col-12">
{{ form_row(form.deliveryInfos) }}
</div>
<div class="col-6">
{{ form_row(form.latitude) }}
</div>
<div class="col-6">
{{ form_row(form.longitude) }}
</div>

{{ form_row(form.country) }}


+ 61
- 10
ShopBundle/Services/CsvGenerator.php View File

@@ -16,33 +16,84 @@ use Lc\ShopBundle\Context\UserPointSaleInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Contracts\Translation\TranslatorInterface;

class CsvGenerator
{
protected $em ;
protected $parameterBag ;
protected $merchantUtils ;
protected $session;
protected $translator;
protected $configManager;

protected $arrayToExport;
protected $columns;
protected $titleDocument;


public function __construct()
{
$this->arrayToExport = array();
$this->titleDocument = 'csv_file';
}

public function setTitle($title, $displayHeader = false){

$this->titleDocument = $this->formatTitle($title);

if($displayHeader){
array_unshift($this->arrayToExport, array(''));
array_unshift($this->arrayToExport, array($title));
}
}

public function setColumns($columns, $displayLegend = true){
$this->columns =array_fill_keys(array_keys($columns), null);;
if($displayLegend)$this->arrayToExport[] = $columns;
}

public function cell($column, $value){
$this->arrayToExport[] = array_merge($this->columns, array($column =>$value));
}

public function setColumns($columns){
$this->columns = $columns;
public function row($values = null, $row = false){

if(!$row){
if($values)$this->arrayToExport[] = array_merge($this->columns, $values);
else $this->arrayToExport[] = array();
}else{
if($values)$this->arrayToExport[$row] = array_merge($this->columns, $values);
else $this->arrayToExport[$row] = array();
}

}

public function setCell($row, $column, $value){
$this->arrayToExport[$row][$column] = $value;
public function dump(){
dump($this->arrayToExport);
}

public function getReponse(){
$response = new StreamedResponse(function () {
$handle = fopen('php://output', 'r+');

foreach ($this->arrayToExport as $line) {
fputcsv($handle, $line, ';', ' ');
}
fclose($handle);
});

$response->headers->set('Content-Type', 'application/force-download');
$response->headers->set('Content-Disposition', 'attachment; filename="'.$this->titleDocument.'.csv"');
return $response;
}
private function formatTitle($str) {
$str = str_replace("-", ' ', $str);
$str = preg_replace('/\s+/', '_',$str);;
//$str = str_replace(" ", '_', $str);
$str = iconv('UTF-8', 'ASCII//TRANSLIT', $str);

return $str;
}






}

+ 3
- 0
ShopBundle/Services/Utils.php View File

@@ -360,6 +360,9 @@ class Utils
return $str;
}

public function csvEscape($str){
return str_replace(array("\r", "\n"), ' ', $str);
}
public function getRemindersByUser($user)
{
$reminderRepo = $this->em->getRepository(ReminderInterface::class);

Loading…
Cancel
Save