Browse Source

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

refactoring
Guillaume 1 year ago
parent
commit
66809e9684
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      backend/controllers/ProducerAdminController.php

+ 23
- 0
backend/controllers/ProducerAdminController.php View File



namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam;
use Yii; use Yii;
use common\models\User; use common\models\User;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
} }
} }


public function actionUserTransfer($fromProducerId, $toProducerId)
{
$fromProducerId = (int) $fromProducerId;
$toProducerId = (int) $toProducerId;
$count = 0;
$usersArray = User::findBy(['id_producer' => $fromProducerId])->all();

foreach($usersArray as $user) {
Producer::addUser($user->id, $toProducerId);
$count ++;
}

if($count) {
Yii::$app->getSession()->setFlash('success', $count.' clients importés du producteur #'.$fromProducerId.' vers le producteur #'.$toProducerId.'.');
}
else {
Yii::$app->getSession()->setFlash('error', 'Aucun client à importer.');
}

return $this->redirect(['producer-admin/index']);
}

/** /**
* Génère la facture mensuelle d'un producteur. * Génère la facture mensuelle d'un producteur.
* *

Loading…
Cancel
Save