Pārlūkot izejas kodu

Anthély : rappatriement clients depuis le compte Anthéli #793

refactoring
Guillaume Bourgeois pirms 1 gada
vecāks
revīzija
2300a426e3
1 mainītis faili ar 14 papildinājumiem un 2 dzēšanām
  1. +14
    -2
      backend/controllers/ProducerAdminController.php

+ 14
- 2
backend/controllers/ProducerAdminController.php Parādīt failu

@@ -130,7 +130,7 @@ class ProducerAdminController extends BackendController
}
}

public function actionUserTransfer($fromProducerId, $toProducerId)
public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1)
{
$fromProducerId = (int) $fromProducerId;
$toProducerId = (int) $toProducerId;
@@ -138,7 +138,19 @@ class ProducerAdminController extends BackendController
$usersArray = User::findBy(['id_producer' => $fromProducerId])->all();

foreach($usersArray as $user) {
Producer::addUser($user['user_id'], $toProducerId);
$idUser = $user['user_id'];

$countOrders = 0;
if($withOrders) {
$countOrders = Order::searchCount([
'id_user' => $idUser,
], ['conditions' => 'date_delete IS NULL']);
}

if(($withOrders && $countOrders) || !$withOrders) {
Producer::addUser($idUser, $toProducerId);
}

$count ++;
}


Notiek ielāde…
Atcelt
Saglabāt