Explorar el Código

[Backend] Clients : classement des clients par point de vente (liste classique et liste emails)

dev
keun hace 6 años
padre
commit
220530b99d
Se han modificado 7 ficheros con 106 adiciones y 39 borrados
  1. +26
    -16
      backend/controllers/UserController.php
  2. +13
    -1
      backend/views/user/index.php
  3. +12
    -1
      backend/views/user/liste_mails.php
  4. BIN
      backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc
  5. +24
    -14
      backend/web/css/screen.css
  6. +10
    -0
      backend/web/sass/screen.scss
  7. +21
    -7
      common/models/User.php

+ 26
- 16
backend/controllers/UserController.php Ver fichero

@@ -44,11 +44,11 @@ class UserController extends BackendController {
* Lists all User models.
* @return mixed
*/
public function actionIndex() {
public function actionIndex($id_point_vente = 0) {
$params = Yii::$app->request->queryParams;
if($id_point_vente)
$params['id_point_vente'] = $id_point_vente ;
$query = User::findBy($params);

$dataProvider = new ActiveDataProvider([
'query' => $query
]);
@@ -56,10 +56,14 @@ class UserController extends BackendController {
$etablissement = Etablissement::find()
->where(['id' => Yii::$app->user->identity->id_etablissement])
->one();
$points_vente = PointVente::find()->where(['id_etablissement' => $etablissement->id])->all() ;

return $this->render('index', [
'dataProvider' => $dataProvider,
'etablissement' => $etablissement
'etablissement' => $etablissement,
'id_point_vente_active' => $id_point_vente,
'points_vente' => $points_vente
]);
}

@@ -147,25 +151,31 @@ class UserController extends BackendController {
}
}

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 = [];
foreach ($users as $u) {
if (isset($u['email']))
if (isset($u['email']) && strlen($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', [
//'model' => $model,
'users' => $arr_users
'users' => $arr_users,
'points_vente' => $points_vente,
'point_vente' => $point_vente
]);
}


+ 13
- 1
backend/views/user/index.php Ver fichero

@@ -17,9 +17,21 @@ $this->params['breadcrumbs'][] = $this->title;
<h1>
<?= Html::encode($this->title) ?>
<?= 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>
<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([
'dataProvider' => $dataProvider,
'filterModel' => true,

+ 12
- 1
backend/views/user/liste_mails.php Ver fichero

@@ -15,7 +15,18 @@ $this->params['breadcrumbs'][] = $this->title;

?>

<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); ?>


BIN
backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc Ver fichero


+ 24
- 14
backend/web/css/screen.css Ver fichero

@@ -1176,8 +1176,18 @@ a:hover, a:focus, a:active {
.user-index .input-group .input-credit {
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 {
float: right;
font-weight: bold;
@@ -1193,16 +1203,16 @@ a:hover, a:focus, a:active {
}

/* facturation */
/* line 1206, ../sass/screen.scss */
/* line 1216, ../sass/screen.scss */
#estimation-facture {
padding: 20px;
background-color: #F9F9F9;
}
/* line 1210, ../sass/screen.scss */
/* line 1220, ../sass/screen.scss */
#estimation-facture h2 {
font-family: "myriadpro-it";
}
/* line 1214, ../sass/screen.scss */
/* line 1224, ../sass/screen.scss */
#estimation-facture .montant span {
font-size: 25px;
color: white;
@@ -1214,17 +1224,17 @@ a:hover, a:focus, a:active {
padding-top: 7px;
font-family: "myriadpro-regular";
}
/* line 1225, ../sass/screen.scss */
/* line 1235, ../sass/screen.scss */
#estimation-facture label {
text-transform: uppercase;
font-family: "myriadpro-light";
font-size: 20px;
}
/* line 1230, ../sass/screen.scss */
/* line 1240, ../sass/screen.scss */
#estimation-facture label span {
font-size: 16px;
}
/* line 1235, ../sass/screen.scss */
/* line 1245, ../sass/screen.scss */
#estimation-facture #etablissement-prix_libre {
width: 100px;
height: 60px;
@@ -1233,37 +1243,37 @@ a:hover, a:focus, a:active {
text-align: center;
}

/* line 1245, ../sass/screen.scss */
/* line 1255, ../sass/screen.scss */
.developpement-index ul#tabs-statuts-developpements {
margin-bottom: 30px;
border-bottom: solid 3px #BB8757;
}
/* line 1249, ../sass/screen.scss */
/* line 1259, ../sass/screen.scss */
.developpement-index ul#tabs-statuts-developpements a {
text-transform: uppercase;
}
/* line 1252, ../sass/screen.scss */
/* line 1262, ../sass/screen.scss */
.developpement-index ul#tabs-statuts-developpements .active {
border: 0px none;
background: none;
}
/* line 1255, ../sass/screen.scss */
/* line 1265, ../sass/screen.scss */
.developpement-index ul#tabs-statuts-developpements .active a {
background-color: #BB8757;
color: white;
}
/* line 1263, ../sass/screen.scss */
/* line 1273, ../sass/screen.scss */
.developpement-index #tab-developpements .btn-group-priorite {
width: 100%;
margin-bottom: 5px;
}
/* line 1267, ../sass/screen.scss */
/* line 1277, ../sass/screen.scss */
.developpement-index #tab-developpements .btn-group-priorite .btn-priorite {
display: block;
float: none;
width: 100%;
}
/* line 1274, ../sass/screen.scss */
/* line 1284, ../sass/screen.scss */
.developpement-index #tab-developpements .label-priorite {
display: block;
width: 100%;

+ 10
- 0
backend/web/sass/screen.scss Ver fichero

@@ -1185,6 +1185,16 @@ a {
text-align: center ;
}
}
#tabs-points-vente {
margin-bottom: 20px ;
}
.btn-liste-emails {
float: right ;
position: relative ;
top: -8px ;
}
}

.user-credit {

+ 21
- 7
common/models/User.php Ver fichero

@@ -157,15 +157,29 @@ class User extends ActiveRecord implements IdentityInterface {

public static function findBy($params = []) {
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())
->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']))
$query->andFilterWhere(['like', 'nom', $params['nom']]);
if (isset($params['prenom']))

Cargando…
Cancelar
Guardar