@@ -47,7 +47,6 @@ use yii\filters\VerbFilter; | |||
*/ | |||
class CommunicateController extends BackendController | |||
{ | |||
public function behaviors() | |||
{ | |||
return [ |
@@ -269,6 +269,8 @@ class DistributionController extends BackendController | |||
{ | |||
$productManager = $this->getProductManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$distributionJsonData = [ | |||
'id' => $distribution->id, | |||
'active' => $distribution->active, | |||
@@ -281,6 +283,7 @@ class DistributionController extends BackendController | |||
'url_export_shopping_cart_labels' => $this->getUrlManagerBackend()->createUrl( | |||
['distribution/export-shopping-cart-labels', 'date' => $distribution->date] | |||
), | |||
'url_order' => $distributionManager->getLinkOrder($distribution), | |||
]; | |||
// montant et poids des commandes |
@@ -41,6 +41,7 @@ namespace backend\models; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\Mailjet; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Distribution\Distribution\Wrapper\DistributionManager; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
@@ -94,6 +95,7 @@ class MailForm extends Model | |||
{ | |||
$productManager = ProductManager::getInstance(); | |||
$producerManager = ProducerManager::getInstance(); | |||
$distributionManager = DistributionManager::getInstance(); | |||
$mj = new \Mailjet\Client( | |||
Mailjet::getApiKey('public'), | |||
@@ -117,7 +119,7 @@ class MailForm extends Model | |||
if($distribution) { | |||
$linkOrder = Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order','slug_producer' => GlobalParam::getCurrentProducer()->slug, 'date' => $distribution->date]) ; | |||
$linkOrder = $distributionManager->getLinkOrder($distribution); | |||
$dateOrder = strftime('%A %d %B %Y', strtotime($distribution->date)) ; | |||
$messageAutoHtml .= '<a href="'.$linkOrder.'">Passer ma commande du '.$dateOrder.'</a>' ; | |||
$messageAutoText .= 'Suivez ce lien pour passer votre commande du '.$dateOrder.' : |
@@ -90,7 +90,10 @@ $this->setPageTitle('Distributions') ; | |||
<span :class="'info-box-icon '+(distribution.active ? 'bg-green' : 'bg-red')"><i :class="'fa '+(distribution.active ? 'fa-check' : 'fa-remove')"></i></span> | |||
<div class="info-box-content"> | |||
<span class="info-box-text"> | |||
<h4>Distribution du <strong>{{ dateFormat }}</strong></h4> | |||
<h4> | |||
Distribution du <strong>{{ dateFormat }}</strong> | |||
<a class="btn btn-default" :href="distribution.url_order" @click="copyLinkOrder($event, distribution.url_order)"><span class="glyphicon glyphicon-link"></span></a> | |||
</h4> | |||
<a @click="activeWeekDistribution" data-active="0" class="btn btn-default btn-active-week" v-if="oneDistributionWeekActive">Désactiver cette semaine</a> | |||
<a @click="activeWeekDistribution" data-active="1" class="btn btn-default btn-active-week" v-else>Activer cette semaine</a> | |||
@@ -944,6 +944,12 @@ var app = new Vue({ | |||
} | |||
return null; | |||
}, | |||
copyLinkOrder: function($event, urlOrder) { | |||
$event.preventDefault(); | |||
navigator.clipboard.writeText(urlOrder); | |||
appAlerts.alert('success', 'Lien vers la page de commande de la distribution copié.'); | |||
return false; | |||
} | |||
}, | |||
}); |
@@ -114,4 +114,12 @@ class DistributionSolver extends AbstractService implements SolverInterface | |||
return false; | |||
} | |||
public function getLinkOrder(Distribution $distribution): string | |||
{ | |||
return \Yii::$app->urlManagerProducer->createAbsoluteUrl([ | |||
'order/order', | |||
'slug_producer' => $this->getProducerContext()->slug, | |||
'date' => $distribution->date | |||
]) ; | |||
} | |||
} |