|
|
|
|
|
|
|
|
] ; |
|
|
] ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function actionForceProcessOrders($key = '') |
|
|
|
|
|
{ |
|
|
|
|
|
$this->actionProcessOrders($key, date('Y-m-d', strtotime('-5 day'))) ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Routine quotidienne concernant les commandes : paiement et envoi d'un |
|
|
* Routine quotidienne concernant les commandes : paiement et envoi d'un |
|
|
* récap aux producteurs. |
|
|
* récap aux producteurs. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($arrayProducers as $producer) { |
|
|
foreach ($arrayProducers as $producer) { |
|
|
|
|
|
|
|
|
Yii::error('Producteur : '.$producer->name, 'log-cron'); |
|
|
|
|
|
|
|
|
|
|
|
$countOrders = 0; |
|
|
$countOrders = 0; |
|
|
$mailOrdersSend = false; |
|
|
$mailOrdersSend = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($distribution) { |
|
|
if($distribution) { |
|
|
|
|
|
|
|
|
Yii::error('Distribution : '.$date, 'log-cron'); |
|
|
|
|
|
|
|
|
|
|
|
if ($hour == $producer->order_deadline || strlen($forceDate)) { |
|
|
if ($hour == $producer->order_deadline || strlen($forceDate)) { |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
|
|
|
|
|
|
'conditions' => 'date_delete IS NULL' |
|
|
'conditions' => 'date_delete IS NULL' |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
Yii::error('Commandes : ' . count($arrayOrders), 'log-cron'); |
|
|
|
|
|
|
|
|
|
|
|
$configCredit = Producer::getConfig('credit', $producer->id); |
|
|
$configCredit = Producer::getConfig('credit', $producer->id); |
|
|
|
|
|
|
|
|
if ($arrayOrders && is_array($arrayOrders)) { |
|
|
if ($arrayOrders && is_array($arrayOrders)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*$mail->setTo('contact@opendistrib.net') |
|
|
/*$mail->setTo('contact@opendistrib.net') |
|
|
->send();*/ |
|
|
->send();*/ |
|
|
|
|
|
|
|
|
Yii::error('Envoi du mail avec les commandes', 'log-cron'); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($producer->active) { |
|
|
if ($producer->active) { |
|
|
Yii::error('Producteur actif : log', 'log-cron'); |
|
|
|
|
|
$messageLog = $producer->name . ' : Distribution du ' . $date . ', ' . count($arrayOrders) . ' commande(s) enregistrée(s), ' . $countOrders . ' commande(s) payée(s), ' . ($mailOrdersSend ? 'Récapitulatif de commandes envoyé' : 'Aucun email envoyé'); |
|
|
$messageLog = $producer->name . ' : Distribution du ' . $date . ', ' . count($arrayOrders) . ' commande(s) enregistrée(s), ' . $countOrders . ' commande(s) payée(s), ' . ($mailOrdersSend ? 'Récapitulatif de commandes envoyé' : 'Aucun email envoyé'); |
|
|
|
|
|
|
|
|
/*Yii::$app->mailer->compose() |
|
|
/*Yii::$app->mailer->compose() |
|
|
|
|
|
|
|
|
->setTextBody($messageLog) |
|
|
->setTextBody($messageLog) |
|
|
->send();*/ |
|
|
->send();*/ |
|
|
|
|
|
|
|
|
Yii::error($messageLog, 'cron-process-orders'); |
|
|
|
|
|
} else { |
|
|
|
|
|
Yii::error('Producteur non actif', 'log-cron'); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
|
|
|
Yii::error('L\'heure ne correspond pas.', 'log-cron'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
Yii::error('La distribution n\'existe pas', 'log-cron'); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |