Browse Source

Correction bug : les commandes automatiques ne se payent pas

Problème détecté lors de la génération du récap PDF.
refactoring
Guillaume Bourgeois 5 years ago
parent
commit
ee51357ac9
3 changed files with 44 additions and 8 deletions
  1. +2
    -3
      backend/controllers/CronController.php
  2. +42
    -0
      backend/controllers/DistributionController.php
  3. +0
    -5
      backend/controllers/OrderController.php

+ 2
- 3
backend/controllers/CronController.php View File

$subject = '[distrib] Commandes du ' . date('d/m', strtotime($date)); $subject = '[distrib] Commandes du ' . date('d/m', strtotime($date));


// génération du pdf de commande // génération du pdf de commande
Yii::$app->runAction('order/report-cron', [
Yii::$app->runAction('distribution/report-cron', [
'date' => $date, 'date' => $date,
'save' => true, 'save' => true,
'id_producer' => $producer['id'],
'idProducer' => $producer['id'],
'key' => '64ac0bdab7e9f5e48c4d991ec5201d57' 'key' => '64ac0bdab7e9f5e48c4d991ec5201d57'
]); ]);
$mail->attach(Yii::getAlias('@app/web/pdf/Orders-' . $date . '-' . $producer['id'] . '.pdf')); $mail->attach(Yii::getAlias('@app/web/pdf/Orders-' . $date . '-' . $producer['id'] . '.pdf'));
} }
} }
} }

} }

+ 42
- 0
backend/controllers/DistributionController.php View File



class DistributionController extends BackendController class DistributionController extends BackendController
{ {
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['report-cron'],
'allow' => true,
'roles' => ['?']
],
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return User::getCurrentStatus() == USER::STATUS_ADMIN
|| User::getCurrentStatus() == USER::STATUS_PRODUCER;
}
]
],
],
];
}
public function actionIndex($date = '') public function actionIndex($date = '')
{ {
$format = 'Y-m-d' ; $format = 'Y-m-d' ;
return $json ; return $json ;
} }
/**
* Génére un PDF récapitulatif des des commandes d'un producteur pour une
* date donnée (Méthode appelable via CRON)
*
* @param string $date
* @param boolean $save
* @param integer $idProducer
* @param string $key
* @return PDF|null
*/
public function actionReportCron($date = '', $save = false, $idProducer = 0, $key = '')
{
if($key == '64ac0bdab7e9f5e48c4d991ec5201d57') {
$this->actionReport($date, $save, $idProducer) ;
}
}
/** /**
* Génére un PDF récapitulatif des commandes d'un producteur pour une * Génére un PDF récapitulatif des commandes d'un producteur pour une
* date donnée. * date donnée.

+ 0
- 5
backend/controllers/OrderController.php View File

'access' => [ 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::className(),
'rules' => [ 'rules' => [
[
'actions' => ['report-cron'],
'allow' => true,
'roles' => ['?']
],
[ [
'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],

Loading…
Cancel
Save