No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

InitPointSalePaymentMethodsFromSettingsController.php 2.2KB

hace 7 meses
hace 7 meses
hace 7 meses
hace 7 meses
hace 7 meses
hace 7 meses
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace console\commands;
  3. use domain\Distribution\Distribution\DistributionModule;
  4. use domain\PointSale\PointSale\PointSaleModule;
  5. use domain\Producer\Producer\Producer;
  6. use domain\Producer\Producer\ProducerModule;
  7. use yii\console\Controller;
  8. class InitPointSalePaymentMethodsFromSettingsController extends Controller
  9. {
  10. // ./yii init-point-sale-payment-methods-from-settings/index
  11. public function actionIndex()
  12. {
  13. $producerModule = ProducerModule::getInstance();
  14. $pointSaleModule = PointSaleModule::getInstance();
  15. $producersArray = $producerModule->findProducers();
  16. foreach($producersArray as $producer) {
  17. echo '> '.$producer->name."\n";
  18. \Yii::$app->logic->setProducerContext($producer);
  19. $pointSaleArray = $pointSaleModule->getRepository()->findPointSales();
  20. $creditFunctioningProducer = $producerModule->getConfig('credit_functioning');
  21. $isOnlinePaymentActiveAndTypeOrder = $producerModule->isOnlinePaymentActiveAndTypeOrder($producer, false);
  22. foreach($pointSaleArray as $pointSale) {
  23. if($pointSale->payment_method_credit && !$pointSale->credit_functioning) {
  24. $pointSale->credit_functioning = $creditFunctioningProducer;
  25. if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
  26. $pointSale->payment_method_onsite = true;
  27. }
  28. $pointSale->save();
  29. echo 'Point de vente "'.$pointSale->name. '" configuré sur "'.$pointSale->credit_functioning.'"'."\n";
  30. }
  31. $return = $pointSaleModule->getBuilder()->initPaymentMethodsByCreditFunctioning($pointSale);
  32. if($return) {
  33. echo 'Point de vente "'.$pointSale->name. '" : modes de paiements adaptés'."\n";
  34. }
  35. if($isOnlinePaymentActiveAndTypeOrder) {
  36. $pointSale->payment_method_online = true;
  37. $pointSale->save();
  38. echo 'Point de vente "'.$pointSale->name. '" : paiement en ligne activé'."\n";
  39. }
  40. }
  41. }
  42. }
  43. }
  44. ?>