Browse Source

Cron paiement automatique des commandes

dev
keun 6 years ago
parent
commit
6777a6458b
1 changed files with 28 additions and 0 deletions
  1. +28
    -0
      backend/controllers/CronController.php

+ 28
- 0
backend/controllers/CronController.php View File

@@ -224,5 +224,33 @@ class CronController extends BackendController {
}
}
}
public function actionPaiementAutoCommandes($key = '') {
if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') {
$commandes = Commande::find()
->with('commandeProduits', 'user')
->joinWith('production')
->where(['production.date' => date('Y-m-d')])
->orderBy('date ASC')
->all();
foreach($commandes as $c) {
if($c->paiement_automatique && Etablissement::getConfig('credit_pain', $c->production->id_etablissement)) {
$c->init() ;
if ($c->getMontant() > 0) {
$c->creditHistorique(
CreditHistorique::TYPE_PAIEMENT,
$c->getMontant(),
$c->production->id_etablissement,
$c->id_user,
User::ID_USER_SYSTEM
);
}
}
}
}
}

}

Loading…
Cancel
Save