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.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. ini_set('memory_limit', '-1');
  14. /*
  15. Remettre à zéro :
  16. -----------------
  17. DELETE FROM `order_status_history`;
  18. UPDATE `order` SET `order`.order_status_alias = NULL;
  19. */
  20. $producerModule = ProducerModule::getInstance();
  21. $orderModule = OrderModule::getInstance();
  22. $userSystem = UserModule::getInstance()->getRepository()->findOneUserSystem();
  23. foreach($producerModule->getRepository()->findProducers() as $producer) {
  24. \Yii::$app->logic->setProducerContext($producer);
  25. $ordersArray = $orderModule->getRepository()->findOrdersWithOrderStatusAliasNull();
  26. echo ($ordersArray ? count($ordersArray) : '0').' : '.$producer->name."\n";
  27. while ($ordersArray && count($ordersArray)) {
  28. foreach ($ordersArray as $order) {
  29. $orderModule->getManager()->changeOrderStatus(
  30. $order,
  31. OrderStatus::ALIAS_ORDERED,
  32. $userSystem,
  33. new \DateTime($order->date)
  34. );
  35. if($order->date_update) {
  36. $orderModule->getManager()->changeOrderStatus(
  37. $order,
  38. OrderStatus::ALIAS_UPDATED,
  39. $userSystem,
  40. new \DateTime($order->date_update)
  41. );
  42. }
  43. if($order->date_delete) {
  44. $orderModule->getManager()->changeOrderStatus(
  45. $order,
  46. OrderStatus::ALIAS_DELETED,
  47. $userSystem,
  48. new \DateTime($order->date_delete)
  49. );
  50. }
  51. echo 'Order #'.$order->id."\n";
  52. }
  53. $ordersArray = $orderModule->getRepository()->findOrdersWithOrderStatusAliasNull();
  54. }
  55. }
  56. }
  57. }