* Lists all User models. | * Lists all User models. | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function actionIndex() { | |||||
public function actionIndex($id_point_vente = 0) { | |||||
$params = Yii::$app->request->queryParams; | $params = Yii::$app->request->queryParams; | ||||
if($id_point_vente) | |||||
$params['id_point_vente'] = $id_point_vente ; | |||||
$query = User::findBy($params); | $query = User::findBy($params); | ||||
$dataProvider = new ActiveDataProvider([ | $dataProvider = new ActiveDataProvider([ | ||||
'query' => $query | 'query' => $query | ||||
]); | ]); | ||||
$etablissement = Etablissement::find() | $etablissement = Etablissement::find() | ||||
->where(['id' => Yii::$app->user->identity->id_etablissement]) | ->where(['id' => Yii::$app->user->identity->id_etablissement]) | ||||
->one(); | ->one(); | ||||
$points_vente = PointVente::find()->where(['id_etablissement' => $etablissement->id])->all() ; | |||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'dataProvider' => $dataProvider, | 'dataProvider' => $dataProvider, | ||||
'etablissement' => $etablissement | |||||
'etablissement' => $etablissement, | |||||
'id_point_vente_active' => $id_point_vente, | |||||
'points_vente' => $points_vente | |||||
]); | ]); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public function actionMail() { | |||||
$users = (new \yii\db\Query()) | |||||
->select('*') | |||||
->from('user, user_etablissement') | |||||
->where('user.id = user_etablissement.id_user') | |||||
->andWhere('user_etablissement.actif = 1') | |||||
->andWhere('user_etablissement.id_etablissement = ' . Yii::$app->user->identity->id_etablissement) | |||||
->all(); | |||||
public function actionMail($id_point_vente = 0) { | |||||
$users = User::findBy([ | |||||
'id_etablissement' => Yii::$app->user->identity->id_etablissement, | |||||
'id_point_vente' => $id_point_vente | |||||
])->all() ; | |||||
$arr_users = []; | $arr_users = []; | ||||
foreach ($users as $u) { | foreach ($users as $u) { | ||||
if (isset($u['email'])) | |||||
if (isset($u['email']) && strlen($u['email'])) | |||||
$arr_users[] = $u['email']; | $arr_users[] = $u['email']; | ||||
} | } | ||||
$points_vente = PointVente::find()->where(['id_etablissement' => Yii::$app->user->identity->id_etablissement])->all() ; | |||||
$point_vente = null ; | |||||
if($id_point_vente) { | |||||
$point_vente = PointVente::findOne(['id' => $id_point_vente, 'id_etablissement' => Yii::$app->user->identity->id_etablissement]) ; | |||||
} | |||||
return $this->render('liste_mails', [ | return $this->render('liste_mails', [ | ||||
//'model' => $model, | |||||
'users' => $arr_users | |||||
'users' => $arr_users, | |||||
'points_vente' => $points_vente, | |||||
'point_vente' => $point_vente | |||||
]); | ]); | ||||
} | } | ||||
<h1> | <h1> | ||||
<?= Html::encode($this->title) ?> | <?= Html::encode($this->title) ?> | ||||
<?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?> | <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?> | ||||
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?> | |||||
</h1> | </h1> | ||||
<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist"> | |||||
<li class="<?php if(!$id_point_vente_active): ?>active<?php endif; ?>"> | |||||
<a href="<?= Yii::$app->urlManager->createUrl(['user/index']); ?>">Tous</a> | |||||
</li> | |||||
<?php foreach($points_vente as $pv): ?> | |||||
<li class="<?php if($id_point_vente_active == $pv->id): ?>active<?php endif; ?>"> | |||||
<a href="<?= Yii::$app->urlManager->createUrl(['user/index','id_point_vente'=>$pv->id]); ?>"><?= Html::encode($pv->nom) ?></a> | |||||
</li> | |||||
<?php endforeach; ?> | |||||
</ul> | |||||
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail', 'id_point_vente' => $id_point_vente_active], ['class' => 'btn btn-default btn-liste-emails']) ?> | |||||
<?= GridView::widget([ | <?= GridView::widget([ | ||||
'dataProvider' => $dataProvider, | 'dataProvider' => $dataProvider, | ||||
'filterModel' => true, | 'filterModel' => true, |
?> | ?> | ||||
<h1><?= count($users); ?> clients</h1> | |||||
<h1><?php if(isset($point_vente) && $point_vente): echo Html::encode($point_vente->nom).' : '; endif; ?><?= count($users); ?> clients</h1> | |||||
<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist"> | |||||
<li class="<?php if(!isset($point_vente)): ?>active<?php endif; ?>"> | |||||
<a href="<?= Yii::$app->urlManager->createUrl(['user/mail']); ?>">Tous</a> | |||||
</li> | |||||
<?php foreach($points_vente as $pv): ?> | |||||
<li class="<?php if(isset($point_vente) && $point_vente->id == $pv->id): ?>active<?php endif; ?>"> | |||||
<a href="<?= Yii::$app->urlManager->createUrl(['user/mail','id_point_vente'=>$pv->id]); ?>"><?= Html::encode($pv->nom) ?></a> | |||||
</li> | |||||
<?php endforeach; ?> | |||||
</ul> | |||||
<?= implode(', ', $users); ?> | <?= implode(', ', $users); ?> | ||||
.user-index .input-group .input-credit { | .user-index .input-group .input-credit { | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 1189, ../sass/screen.scss */ | |||||
.user-index #tabs-points-vente { | |||||
margin-bottom: 20px; | |||||
} | |||||
/* line 1193, ../sass/screen.scss */ | |||||
.user-index .btn-liste-emails { | |||||
float: right; | |||||
position: relative; | |||||
top: -8px; | |||||
} | |||||
/* line 1191, ../sass/screen.scss */ | |||||
/* line 1201, ../sass/screen.scss */ | |||||
.user-credit .the-credit { | .user-credit .the-credit { | ||||
float: right; | float: right; | ||||
font-weight: bold; | font-weight: bold; | ||||
} | } | ||||
/* facturation */ | /* facturation */ | ||||
/* line 1206, ../sass/screen.scss */ | |||||
/* line 1216, ../sass/screen.scss */ | |||||
#estimation-facture { | #estimation-facture { | ||||
padding: 20px; | padding: 20px; | ||||
background-color: #F9F9F9; | background-color: #F9F9F9; | ||||
} | } | ||||
/* line 1210, ../sass/screen.scss */ | |||||
/* line 1220, ../sass/screen.scss */ | |||||
#estimation-facture h2 { | #estimation-facture h2 { | ||||
font-family: "myriadpro-it"; | font-family: "myriadpro-it"; | ||||
} | } | ||||
/* line 1214, ../sass/screen.scss */ | |||||
/* line 1224, ../sass/screen.scss */ | |||||
#estimation-facture .montant span { | #estimation-facture .montant span { | ||||
font-size: 25px; | font-size: 25px; | ||||
color: white; | color: white; | ||||
padding-top: 7px; | padding-top: 7px; | ||||
font-family: "myriadpro-regular"; | font-family: "myriadpro-regular"; | ||||
} | } | ||||
/* line 1225, ../sass/screen.scss */ | |||||
/* line 1235, ../sass/screen.scss */ | |||||
#estimation-facture label { | #estimation-facture label { | ||||
text-transform: uppercase; | text-transform: uppercase; | ||||
font-family: "myriadpro-light"; | font-family: "myriadpro-light"; | ||||
font-size: 20px; | font-size: 20px; | ||||
} | } | ||||
/* line 1230, ../sass/screen.scss */ | |||||
/* line 1240, ../sass/screen.scss */ | |||||
#estimation-facture label span { | #estimation-facture label span { | ||||
font-size: 16px; | font-size: 16px; | ||||
} | } | ||||
/* line 1235, ../sass/screen.scss */ | |||||
/* line 1245, ../sass/screen.scss */ | |||||
#estimation-facture #etablissement-prix_libre { | #estimation-facture #etablissement-prix_libre { | ||||
width: 100px; | width: 100px; | ||||
height: 60px; | height: 60px; | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 1245, ../sass/screen.scss */ | |||||
/* line 1255, ../sass/screen.scss */ | |||||
.developpement-index ul#tabs-statuts-developpements { | .developpement-index ul#tabs-statuts-developpements { | ||||
margin-bottom: 30px; | margin-bottom: 30px; | ||||
border-bottom: solid 3px #BB8757; | border-bottom: solid 3px #BB8757; | ||||
} | } | ||||
/* line 1249, ../sass/screen.scss */ | |||||
/* line 1259, ../sass/screen.scss */ | |||||
.developpement-index ul#tabs-statuts-developpements a { | .developpement-index ul#tabs-statuts-developpements a { | ||||
text-transform: uppercase; | text-transform: uppercase; | ||||
} | } | ||||
/* line 1252, ../sass/screen.scss */ | |||||
/* line 1262, ../sass/screen.scss */ | |||||
.developpement-index ul#tabs-statuts-developpements .active { | .developpement-index ul#tabs-statuts-developpements .active { | ||||
border: 0px none; | border: 0px none; | ||||
background: none; | background: none; | ||||
} | } | ||||
/* line 1255, ../sass/screen.scss */ | |||||
/* line 1265, ../sass/screen.scss */ | |||||
.developpement-index ul#tabs-statuts-developpements .active a { | .developpement-index ul#tabs-statuts-developpements .active a { | ||||
background-color: #BB8757; | background-color: #BB8757; | ||||
color: white; | color: white; | ||||
} | } | ||||
/* line 1263, ../sass/screen.scss */ | |||||
/* line 1273, ../sass/screen.scss */ | |||||
.developpement-index #tab-developpements .btn-group-priorite { | .developpement-index #tab-developpements .btn-group-priorite { | ||||
width: 100%; | width: 100%; | ||||
margin-bottom: 5px; | margin-bottom: 5px; | ||||
} | } | ||||
/* line 1267, ../sass/screen.scss */ | |||||
/* line 1277, ../sass/screen.scss */ | |||||
.developpement-index #tab-developpements .btn-group-priorite .btn-priorite { | .developpement-index #tab-developpements .btn-group-priorite .btn-priorite { | ||||
display: block; | display: block; | ||||
float: none; | float: none; | ||||
width: 100%; | width: 100%; | ||||
} | } | ||||
/* line 1274, ../sass/screen.scss */ | |||||
/* line 1284, ../sass/screen.scss */ | |||||
.developpement-index #tab-developpements .label-priorite { | .developpement-index #tab-developpements .label-priorite { | ||||
display: block; | display: block; | ||||
width: 100%; | width: 100%; |
text-align: center ; | text-align: center ; | ||||
} | } | ||||
} | } | ||||
#tabs-points-vente { | |||||
margin-bottom: 20px ; | |||||
} | |||||
.btn-liste-emails { | |||||
float: right ; | |||||
position: relative ; | |||||
top: -8px ; | |||||
} | |||||
} | } | ||||
.user-credit { | .user-credit { |
public static function findBy($params = []) { | public static function findBy($params = []) { | ||||
if (!isset($params['id_etablissement'])) | if (!isset($params['id_etablissement'])) | ||||
$params['id_etablissement'] = Yii::$app->user->identity->id_etablissement; | |||||
$params['id_etablissement'] = Yii::$app->user->identity->id_etablissement; | |||||
$query = (new \yii\db\Query()) | $query = (new \yii\db\Query()) | ||||
->select(['user.id AS user_id', 'user.prenom', 'user.nom', 'user.telephone', 'user.email', 'user.created_at', 'user.date_derniere_connexion', 'user_etablissement.*']) | ->select(['user.id AS user_id', 'user.prenom', 'user.nom', 'user.telephone', 'user.email', 'user.created_at', 'user.date_derniere_connexion', 'user_etablissement.*']) | ||||
->from('user, user_etablissement') | |||||
->where('user.id = user_etablissement.id_user') | |||||
->andWhere('user_etablissement.actif = 1') | |||||
->andWhere('user_etablissement.id_etablissement = ' . $params['id_etablissement']); | |||||
->from('user') | |||||
->innerJoin('user_etablissement','user.id = user_etablissement.id_user AND user_etablissement.actif = 1 AND user_etablissement.id_etablissement = :id_etablissement', [':id_etablissement' => $params['id_etablissement']]) | |||||
; | |||||
if(isset($params['id_point_vente']) && $params['id_point_vente']) { | |||||
$point_vente = PointVente::findOne(['id' => $params['id_point_vente']]) ; | |||||
if($point_vente->acces_restreint) { | |||||
$query->innerJoin('point_vente_user','user.id = point_vente_user.id_user AND point_vente_user.id_point_vente = :id_point_vente',[':id_point_vente' => $params['id_point_vente']]) ; | |||||
} | |||||
else { | |||||
$query->innerJoin( | |||||
'commande', | |||||
'user.id = commande.id_user AND commande.id_point_vente = :id_point_vente', | |||||
[':id_point_vente' => $params['id_point_vente']] | |||||
)->groupBy('user.id') ; | |||||
} | |||||
} | |||||
if (isset($params['nom'])) | if (isset($params['nom'])) | ||||
$query->andFilterWhere(['like', 'nom', $params['nom']]); | $query->andFilterWhere(['like', 'nom', $params['nom']]); | ||||
if (isset($params['prenom'])) | if (isset($params['prenom'])) |