|
|
@@ -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 ++; |
|
|
|
} |
|
|
|
|