Sfoglia il codice sorgente

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

refactoring
Guillaume Bourgeois 1 anno fa
parent
commit
2300a426e3
1 ha cambiato i file con 14 aggiunte e 2 eliminazioni
  1. +14
    -2
      backend/controllers/ProducerAdminController.php

+ 14
- 2
backend/controllers/ProducerAdminController.php Vedi File

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


Loading…
Annulla
Salva