|
|
@@ -38,6 +38,7 @@ termes. |
|
|
|
|
|
|
|
namespace backend\controllers; |
|
|
|
|
|
|
|
use common\helpers\GlobalParam; |
|
|
|
use Yii; |
|
|
|
use common\models\User; |
|
|
|
use yii\web\NotFoundHttpException; |
|
|
@@ -129,6 +130,28 @@ class ProducerAdminController extends BackendController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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. |
|
|
|
* |