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.

InitOrderStatusHistoryController.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace console\commands;
  3. use domain\Order\Order\OrderModule;
  4. use domain\Order\OrderStatus\OrderStatus;
  5. use domain\Producer\Producer\ProducerModule;
  6. use domain\User\User\UserModule;
  7. use yii\console\Controller;
  8. class InitOrderStatusHistoryController extends Controller
  9. {
  10. // ./yii init-order-status-history/index
  11. public function actionIndex()
  12. {
  13. /*
  14. Remettre à zéro :
  15. -----------------
  16. DELETE FROM `order_status_history`;
  17. UPDATE `order` SET `order`.order_status_alias = NULL;
  18. */
  19. $producerModule = ProducerModule::getInstance();
  20. $orderModule = OrderModule::getInstance();
  21. $userSystem = UserModule::getInstance()->getRepository()->findOneUserSystem();
  22. foreach($producerModule->getRepository()->findProducers() as $producer) {
  23. \Yii::$app->logic->setProducerContext($producer);
  24. $ordersArray = $orderModule->getRepository()->findOrdersWithOrderStatusAliasNull();
  25. echo ($ordersArray ? count($ordersArray) : '0').' : '.$producer->name."\n";
  26. while ($ordersArray && count($ordersArray)) {
  27. foreach ($ordersArray as $order) {
  28. $orderModule->getManager()->changeOrderStatus(
  29. $order,
  30. OrderStatus::ALIAS_ORDERED,
  31. $userSystem,
  32. new \DateTime($order->date)
  33. );
  34. if($order->date_update) {
  35. $orderModule->getManager()->changeOrderStatus(
  36. $order,
  37. OrderStatus::ALIAS_UPDATED,
  38. $userSystem,
  39. new \DateTime($order->date_update)
  40. );
  41. }
  42. if($order->date_delete) {
  43. $orderModule->getManager()->changeOrderStatus(
  44. $order,
  45. OrderStatus::ALIAS_DELETED,
  46. $userSystem,
  47. new \DateTime($order->date_delete)
  48. );
  49. }
  50. echo 'Order #'.$order->id."\n";
  51. }
  52. $ordersArray = $orderModule->getRepository()->findOrdersWithOrderStatusAliasNull();
  53. }
  54. }
  55. }
  56. }