Kaynağa Gözat

Refactoring/traduction vues backend/views/user

dev
Guillaume Bourgeois 6 yıl önce
ebeveyn
işleme
8a111de06b
10 değiştirilmiş dosya ile 194 ekleme ve 351 silme
  1. +75
    -81
      backend/controllers/UserController.php
  2. +4
    -4
      backend/views/user/_form.php
  3. +34
    -33
      backend/views/user/credit.php
  4. +8
    -8
      backend/views/user/emails.php
  5. +36
    -40
      backend/views/user/index.php
  6. +0
    -78
      backend/views/user/mail.php
  7. +6
    -6
      backend/views/user/orders.php
  8. +1
    -1
      backend/views/user/update.php
  9. +0
    -83
      backend/views/user/view.php
  10. +30
    -17
      common/models/CreditHistory.php

+ 75
- 81
backend/controllers/UserController.php Dosyayı Görüntüle

@@ -38,6 +38,8 @@ termes.

namespace backend\controllers;

use common\models\User ;

/**
* UserController implements the CRUD actions for User model.
*/
@@ -59,8 +61,7 @@ class UserController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
return User::hasAccessBackend();
}
]
],
@@ -74,32 +75,35 @@ class UserController extends BackendController
* @return mixed
*/
public function actionIndex(
$id_point_vente = 0, $section_clients_inactifs = false)
$idPointSale = 0, $sectionInactiveUsers = false)
{
$params = Yii::$app->request->queryParams;
if($id_point_vente)
$params['id_point_vente'] = $id_point_vente ;
if($section_clients_inactifs)
$params['inactifs'] = true ;
if($idPointSale) {
$params['id_point_sale'] = $idPointSale ;
}
if($sectionInactiveUsers) {
$params['inactive'] = true ;
}
$query = User::findBy($params);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => ['attributes' => ['nom','prenom']],
'sort' => ['attributes' => ['lastname','name']],
]);
$etablissement = Etablissement::find()
->where(['id' => Yii::$app->user->identity->id_etablissement])
->one();
$producer = Producer::searchOne([
'id' => Producer::getId()
]) ;
$points_vente = PointVente::find()->where(['id_etablissement' => $etablissement->id])->all() ;
$pointsSaleArray = PointSale::searchAll() ;

return $this->render('index', [
'dataProvider' => $dataProvider,
'etablissement' => $etablissement,
'id_point_vente_active' => $id_point_vente,
'points_vente' => $points_vente,
'section_clients_inactifs' => $section_clients_inactifs,
'producer' => $producer,
'idPointSaleActive' => $idPointSale,
'pointsSaleArray' => $pointsSaleArray,
'sectionInactiveUsers' => $sectionInactiveUsers,
]);
}
@@ -119,19 +123,19 @@ class UserController extends BackendController
$model->setPassword($password);
$model->generateAuthKey();
$model->username = $model->email;
$model->confiance = 1;
if (!strlen($model->email))
if (!strlen($model->email)) {
$model->username = 'inconnu@laboiteapain.net';

}
$model->save();

// liaison etablissement / user
$user_etablissement = new UserEtablissement();
$user_etablissement->id_user = $model->id;
$user_etablissement->id_etablissement = Yii::$app->user->identity->id_etablissement;
$user_etablissement->credit = 0;
$user_etablissement->actif = 1;
$user_etablissement->save();
$useProducer = new UserProducer();
$useProducer->id_user = $model->id;
$useProducer->id_producer = Producer::getId();
$useProducer->credit = 0;
$useProducer->active = 1;
$useProducer->save();

$model->sendMailWelcome($password) ;

@@ -153,15 +157,15 @@ class UserController extends BackendController
{
$model = $this->findModel($id);

$previous_mail = $model->email ;
$previousMail = $model->email ;
$user = User::find()->with('userEtablissement')->where(['id' => $model['id']])->one();
$user_appartient_etablissement = UserEtablissement::findOne(['id_user' => $id, 'id_etablissement' => Yii::$app->user->identity->id_etablissement]);
if (($user_appartient_etablissement && count($user->userEtablissement) == 1) || Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
$user = User::find()->with('userProducer')->where(['id' => $model['id']])->one();
$userBelongToProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => Producer::getId()]);
if (($userBelongToProducer && count($user->userProducer) == 1) || User::getStatus() == USER::STATUS_ADMIN) {
if ($model->load(Yii::$app->request->post()) && $model->save()) {
// on envoie le mail de bienvenue si le mail vient d'être défini
if(!strlen($previous_mail) && strlen($model->email)) {
if(!strlen($previousMail) && strlen($model->email)) {
$password = Password::generate();
$model->setPassword($password);
$model->username = $model->email;
@@ -186,14 +190,14 @@ class UserController extends BackendController
*/
public function actionDelete($id)
{
$user_etablissement = UserEtablissement::findOne([
$userProducer = UserProducer::findOne([
'id_user' => $id,
'id_etablissement' => Yii::$app->user->identity->id_etablissement
'id_producer' => Producer::getId()
]) ;
if($user_etablissement) {
$user_etablissement->actif = 0 ;
$user_etablissement->favoris = 0 ;
$user_etablissement->save() ;
if($userProducer) {
$userProducer->active = 0 ;
$userProducer->bookmark = 0 ;
$userProducer->save() ;
}
else {
throw new \yii\web\NotFoundHttpException('L\'enregistrement UserEtablissement est introuvable', 404) ;
@@ -209,33 +213,33 @@ class UserController extends BackendController
* Affiche la liste des emails des utilisateurs liés à un point de vente
* donné.
*
* @param integer $id_point_vente
* @param integer $idPointSale
* @return mixed
*/
public function actionMail($id_point_vente = 0)
public function actionMail($idPointSale = 0)
{
$users = User::findBy([
'id_etablissement' => Yii::$app->user->identity->id_etablissement,
'id_point_vente' => $id_point_vente
'id_producer' => Producer::getId(),
'id_point_sale' => $idPointSale
])->all() ;

$arr_users = [];
foreach ($users as $u) {
if (isset($u['email']) && strlen($u['email']))
$arr_users[] = $u['email'];
$usersArray = [];
foreach ($usersArray as $user) {
if (isset($user['email']) && strlen($user['email']))
$usersArray[] = $user['email'];
}
$points_vente = PointVente::find()->where(['id_etablissement' => Yii::$app->user->identity->id_etablissement])->all() ;
$pointsSaleArray = PointSale::find()->where(['id_producer' => Producer::getId()])->all() ;
$point_vente = null ;
if($id_point_vente) {
$point_vente = PointVente::findOne(['id' => $id_point_vente, 'id_etablissement' => Yii::$app->user->identity->id_etablissement]) ;
$pointSale = null ;
if($idPointSale) {
$pointSale = PointSale::findOne(['id' => $idPointSale, 'id_producer' => Producer::getId()]) ;
}

return $this->render('liste_mails', [
'users' => $arr_users,
'points_vente' => $points_vente,
'point_vente' => $point_vente
return $this->render('emails', [
'usersArray' => $usersArray,
'pointsSaleArray' => $pointsSaleArray,
'pointSale' => $pointSale
]);
}

@@ -249,31 +253,31 @@ class UserController extends BackendController
*/
public function actionCredit($id)
{
$user = User::find()->with('userEtablissement')->where(['id' => $id])->one();
$user_etablissement = UserEtablissement::findOne(['id_user' => $id, 'id_etablissement' => Yii::$app->user->identity->id_etablissement]);
$user = User::find()->with('userProducer')->where(['id' => $id])->one();
$userProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => Producer::getId()]);
if (($user_etablissement) || Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
if (($userProducer) || User::getStatus() == User::STATUS_ADMIN) {
$credit_form = new CreditForm;
if ($credit_form->load(Yii::$app->request->post()) && $credit_form->validate()) {
$credit_form->id_user = $id ;
$credit_form->save();
$credit_form = new CreditForm;
$creditForm = new CreditForm;
if ($creditForm->load(Yii::$app->request->post()) && $creditForm->validate()) {
$creditForm->id_user = $id ;
$creditForm->save();
$creditForm = new CreditForm;
}

$historique = CreditHistorique::find()
->with(['commande', 'userAction'])
$history = CreditHistory::find()
->with(['order', 'userAction'])
->where([
'id_user' => $user->id,
'id_etablissement' => Yii::$app->user->identity->id_etablissement,
'id_producer' => Producer::getId(),
])
->orderBy('date DESC')
->all();

return $this->render('credit', [
'user' => $user,
'credit_form' => $credit_form,
'historique' => $historique
'creditForm' => $creditForm,
'history' => $history
]);
}
else {
@@ -287,26 +291,16 @@ class UserController extends BackendController
* @param integer $id
* @return mixed
*/
public function actionCommandes($id)
public function actionOrders($id)
{

$user = User::findOne($id);

$commandes = Commande::find()
->with('commandeProduits', 'pointVente', 'creditHistorique')
->joinWith('production', 'production.etablissement')
->where([
'id_user' => $id,
'production.id_etablissement' => Yii::$app->user->identity->id_etablissement
])
->orderBy('production.date DESC')
->all();

foreach ($commandes as $c)
$c->init();
$orders = Order::searchAll([
'id_user' => $id
], ['orderby' => 'distribution.date DESC']) ;

return $this->render('commandes', [
'commandes' => $commandes,
'ordersArray' => $ordersArray,
'user' => $user
]);
}

+ 4
- 4
backend/views/user/_form.php Dosyayı Görüntüle

@@ -48,11 +48,11 @@ use yii\widgets\ActiveForm;

<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'nom')->textInput() ?>
<?= $form->field($model, 'prenom')->textInput() ?>
<?= $form->field($model, 'telephone')->textInput() ?>
<?= $form->field($model, 'lastname')->textInput() ?>
<?= $form->field($model, 'name')->textInput() ?>
<?= $form->field($model, 'phone')->textInput() ?>
<?= $form->field($model, 'email')->textInput() ?>
<?= $form->field($model, 'adresse')->textarea() ?>
<?= $form->field($model, 'address')->textarea() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

+ 34
- 33
backend/views/user/credit.php Dosyayı Görüntüle

@@ -38,12 +38,12 @@ termes.

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\CreditHistorique;
use common\models\Etablissement;
use common\models\CreditHistory;
use common\models\Producer;

$this->title = 'Créditer <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>';
$this->title = 'Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>';
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($user->nom.' '.$user->prenom)];
$this->params['breadcrumbs'][] = ['label' => Html::encode($user->lastname.' '.$user->name)];
$this->params['breadcrumbs'][] = 'Créditer';

?>
@@ -51,12 +51,13 @@ $this->params['breadcrumbs'][] = 'Créditer';
<div class="user-credit">
<?php
$etablissement = Etablissement::find()
->where(['id' => Yii::$app->user->identity->id_etablissement])
->one() ;
if(!$etablissement->credit_pain)
$producer = Producer::searchOne([
'id' => Producer::getId()
]);
if(!$producer->credit)
{
echo '<div class="alert alert-warning">Attention, la fonctionnalité <strong>Crédit Pain</strong> est désactivée dans vos <a href="'.Yii::$app->urlManager->createurl(['etablissement/update']).'">paramètres</a>.'
echo '<div class="alert alert-warning">Attention, la fonctionnalité <strong>Crédit</strong> est désactivée dans vos <a href="'.Yii::$app->urlManager->createurl(['producer/update']).'">paramètres</a>.'
. ' Pensez à l\'activer si vous souhaitez qu\'elle soit visible de vos clients.</div>' ;
}
?>
@@ -64,19 +65,19 @@ $this->params['breadcrumbs'][] = 'Créditer';
<div class="col-md-12">
<h1><?= $this->title ?></h1>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($credit_form, 'type')->dropDownList([
CreditHistorique::TYPE_CREDIT => 'Crédit',
CreditHistorique::TYPE_DEBIT => 'Débit',
<?= $form->field($creditForm, 'type')->dropDownList([
CreditHistory::TYPE_CREDIT => 'Crédit',
CreditHistory::TYPE_DEBIT => 'Débit',
]) ?>
<?= $form->field($credit_form, 'montant')->textInput() ?>
<?= $form->field($credit_form, 'moyen_paiement')->dropDownList([
CreditHistorique::MOYEN_ESPECES => 'Espèces',
CreditHistorique::MOYEN_CB => 'Carte bancaire',
CreditHistorique::MOYEN_CHEQUE => 'Chèque',
CreditHistorique::MOYEN_AUTRE => 'Autre',
<?= $form->field($creditForm, 'amount')->textInput() ?>
<?= $form->field($creditForm, 'mean_payment')->dropDownList([
CreditHistory::MEAN_PAYMENT_MONEYS => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_MONEYS),
CreditHistory::MOYEN_CB => CreditHistory::getStrMeanPaymentBy(CreditHistory::MOYEN_CB),
CreditHistory::MOYEN_CHEQUE => CreditHistory::getStrMeanPaymentBy(CreditHistory::MOYEN_CHEQUE),
CreditHistory::MOYEN_AUTRE => CreditHistory::getStrMeanPaymentBy(CreditHistory::MOYEN_AUTRE),
]) ?>
<?= $form->field($credit_form, 'commentaire')->textarea() ?>
<?= $form->field($credit_form, 'send_mail')->checkbox() ?>
<?= $form->field($creditForm, 'comment')->textarea() ?>
<?= $form->field($creditForm, 'sendMail')->checkbox() ?>
<div class="form-group">
<?= Html::submitButton( 'Créditer', ['class' => 'btn btn-primary']) ?>
@@ -85,7 +86,7 @@ $this->params['breadcrumbs'][] = 'Créditer';
</div>
<div class="col-md-12">
<h2>Historique <span class="the-credit"><?= number_format($user->getCredit($etablissement->id), 2); ?> €</span></h2>
<h2>Historique <span class="the-credit"><?= number_format($user->getCredit($producer->id), 2); ?> €</span></h2>
<table class="table table-bordered">
<thead>
<tr>
@@ -99,28 +100,28 @@ $this->params['breadcrumbs'][] = 'Créditer';
</tr>
</thead>
<tbody>
<?php if(count($historique)): ?>
<?php foreach($historique as $ch): ?>
<?php if(count($history)): ?>
<?php foreach($history as $creditHistory): ?>
<tr>
<td><?= $ch->getDate(true) ; ?></td>
<td><?= Html::encode($ch->strUserAction()); ?></td>
<td><?= $ch->getStrLibelle(); ?></td>
<td><?= $creditHistory->getDate(true) ; ?></td>
<td><?= Html::encode($creditHistory->strUserAction()); ?></td>
<td><?= $creditHistory->getStrWording(); ?></td>
<td>
<?php if($ch->isTypeDebit()): ?>
- <?= $ch->getMontant(true); ?>
<?php if($creditHistory->isTypeDebit()): ?>
- <?= $creditHistory->getAmount(true); ?>
<?php endif; ?>
</td>
<td>
<?php if($ch->isTypeCredit()): ?>
+ <?= $ch->getMontant(true); ?>
<?php if($creditHistory->isTypeCredit()): ?>
+ <?= $creditHistory->getAmount(true); ?>
<?php endif; ?>
</td>
<td>
<?= $ch->getStrMoyenPaiement() ?>
<?= $creditHistory->getStrMeanPayment() ?>
</td>
<td>
<?php if(strlen($ch->commentaire)): ?>
<?= nl2br($ch->commentaire) ; ?>
<?php if(strlen($creditHistory->comment)): ?>
<?= nl2br($creditHistory->comment) ; ?>
<?php endif; ?>
</td>
</tr>

backend/views/user/liste_mails.php → backend/views/user/emails.php Dosyayı Görüntüle

@@ -39,24 +39,24 @@ termes.
use yii\helpers\Html ;

$this->title = 'Liste des emails';
$this->params['breadcrumbs'][] = ['label' => 'Clients',
$this->params['breadcrumbs'][] = ['label' => 'Utilisateurs',
'url' => ['user/index']] ;
$this->params['breadcrumbs'][] = $this->title;

?>

<h1><?php if(isset($point_vente) && $point_vente): echo Html::encode($point_vente->nom).' : '; endif; ?><?= count($users); ?> clients</h1>
<h1><?php if(isset($pointSale) && $pointSale): echo Html::encode($pointSale->name).' : '; endif; ?><?= count($usersArray); ?> utilisateurs</h1>

<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist">
<li class="<?php if(!isset($point_vente)): ?>active<?php endif; ?>">
<ul id="tabs-points-sale" class="nav nav-tabs" role="tablist">
<li class="<?php if(!isset($pointSale)): ?>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>
<?php foreach($pointsSaleArray as $pointSale): ?>
<li class="<?php if(isset($pointSale) && $pointSale->id == $pointSale->id): ?>active<?php endif; ?>">
<a href="<?= Yii::$app->urlManager->createUrl(['user/mail','idPointSale'=>$pointSale->id]); ?>"><?= Html::encode($pointSale->name) ?></a>
</li>
<?php endforeach; ?>
</ul>

<?= implode(', ', $users); ?>
<?= implode(', ', $usersArray); ?>


+ 36
- 40
backend/views/user/index.php Dosyayı Görüntüle

@@ -39,12 +39,12 @@ termes.
use yii\helpers\Html;
use yii\grid\GridView;
use common\models\User ;
use common\models\Commande ;
use common\models\Order ;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Clients';
$this->title = 'Utilisateurs';
$this->params['breadcrumbs'][] = $this->title;
?>

@@ -56,49 +56,49 @@ $this->params['breadcrumbs'][] = $this->title;
</h1>
<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist">
<li class="<?php if(!$id_point_vente_active && !$section_clients_inactifs): ?>active<?php endif; ?>">
<li class="<?php if(!$idPointSaleActive && !$sectionInactiveUsers): ?>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>
<?php foreach($pointsSaleArray as $pointSale): ?>
<li class="<?php if($idPointSaleActive == $pointSale->id): ?>active<?php endif; ?>">
<a href="<?= Yii::$app->urlManager->createUrl(['user/index','idPointSale' => $pointSale->id]); ?>"><?= Html::encode($pointSale->name) ?></a>
</li>
<?php endforeach; ?>
<li class="<?php if($section_clients_inactifs): ?>active<?php endif; ?>">
<a href="<?= Yii::$app->urlManager->createUrl(['user/index','section_clients_inactifs' => 1]); ?>">Inactifs</a>
<li class="<?php if($sectionInactiveUsers): ?>active<?php endif; ?>">
<a href="<?= Yii::$app->urlManager->createUrl(['user/index','sectionInactiveUsers' => 1]); ?>">Inactifs</a>
</li>
</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']) ?>
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail', 'idPointSale' => $idPointSaleActive], ['class' => 'btn btn-default btn-liste-emails']) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => true,
'columns' => [
[
'attribute' => 'nom',
'attribute' => 'lastname',
'filter' => Html::input(
'string',
'nom',
isset(Yii::$app->request->queryParams['nom']) ? Html::encode(Yii::$app->request->queryParams['nom']) : '',
'lastname',
isset(Yii::$app->request->queryParams['lastname']) ? Html::encode(Yii::$app->request->queryParams['lastname']) : '',
[ 'class' => 'form-control']
)
],
[
'attribute' => 'prenom',
'attribute' => 'name',
'filter' => Html::input(
'string',
'prenom',
isset(Yii::$app->request->queryParams['prenom']) ? Html::encode(Yii::$app->request->queryParams['prenom']) : '',
'name',
isset(Yii::$app->request->queryParams['name']) ? Html::encode(Yii::$app->request->queryParams['name']) : '',
['class' => 'form-control']
)
],
[
'attribute' => 'telephone',
'attribute' => 'phone',
'filter' => Html::input(
'string',
'telephone',
isset(Yii::$app->request->queryParams['telephone']) ? Html::encode(Yii::$app->request->queryParams['telephone']) : '',
'phone',
isset(Yii::$app->request->queryParams['phone']) ? Html::encode(Yii::$app->request->queryParams['phone']) : '',
['class' => 'form-control']
)
],
@@ -120,35 +120,31 @@ $this->params['breadcrumbs'][] = $this->title;
}
],
[
'attribute' => 'date_derniere_connexion',
'attribute' => 'date_last_connection',
'label' => 'Dernière connexion',
'value' => function($model) {
if(isset($model['date_derniere_connexion']))
return date('d/m/Y à H:i', strtotime($model['date_derniere_connexion']));
if(isset($model['date_last_connection']))
return date('d/m/Y à H:i', strtotime($model['date_last_connection']));
else
return '' ;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{commandes}',
'template' => '{orders}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'commandes' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/commandes','id' => $model['user_id']]) ;
$count_commandes = Commande::find()
->joinWith('production')
->where([
'id_user' => $model['user_id'],
'production.id_etablissement' => Yii::$app->user->identity->id_etablissement])
->andWhere('date_delete IS NULL')
->count() ;
'orders' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/orders','id' => $model['user_id']]) ;
$countOrders = Order::searchCount([
'id_user' => $model['user_id']
], ['conditions' => 'date_delete IS NULL']) ;
$html = '' ;
if($count_commandes)
{
if($countOrders) {
$s = '' ;
if($count_commandes > 1) $s = 's' ;
$html .= Html::a('<span class="glyphicon glyphicon-eye-open"></span> '.$count_commandes.' commande'.$s, $url, [
if($countOrders > 1) $s = 's' ;
$html .= Html::a('<span class="glyphicon glyphicon-eye-open"></span> '.$countOrders.' commande'.$s, $url, [
'title' => Yii::t('app', 'Commandes'), 'class' => 'btn btn-default '
]); ;
}
@@ -163,11 +159,11 @@ $this->params['breadcrumbs'][] = $this->title;
[
'attribute' => 'credit',
'format' => 'raw',
'value' => function($model) use($etablissement) {
'value' => function($model) use($producer) {
if(!isset($model['credit'])) $model['credit'] = 0 ;
$user = User::findOne($model['user_id']) ;
$html = '<div class="input-group">
<input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($user->getCredit($etablissement->id),2).' €" placeholder="">
<input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($user->getCredit($producer->id),2).' €" placeholder="">
<span class="input-group-btn">
'.Html::a(
'<span class="glyphicon glyphicon-euro"></span> Crédit',
@@ -189,8 +185,8 @@ $this->params['breadcrumbs'][] = $this->title;
'buttons' => [
'update' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['user_id']]) ;
$user = User::find()->with('userEtablissement')->where(['id' => $model['user_id']])->one() ;
if(count($user->userEtablissement) <= 1)
$user = User::find()->with('userProducer')->where(['id' => $model['user_id']])->one() ;
if(count($user->userProducer) <= 1)
{
return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
@@ -201,7 +197,7 @@ $this->params['breadcrumbs'][] = $this->title;
}
},
'delete' => function($url, $model) {
if($model['actif']) {
if($model['active']) {
return Html::a('<span class="glyphicon glyphicon-trash"></span> Supprimer', Yii::$app->urlManager->createUrl(array_merge(['user/delete','id' => $model['user_id']], Yii::$app->getRequest()->getQueryParams())), [
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
]);

+ 0
- 78
backend/views/user/mail.php Dosyayı Görüntüle

@@ -1,78 +0,0 @@
<?php

/**
Copyright La boîte à pain (2018)

contact@laboiteapain.net

Ce logiciel est un programme informatique servant à aider les producteurs
à distribuer leur production en circuits courts.

Ce logiciel est régi par la licence CeCILL soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".

En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.

A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe à
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités à charger et tester l'adéquation du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.

Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

$this->title = 'Envoi d\'un email à tous les utilisateurs';

?>

<h1><?= Html::encode($this->title) ?></h1>

<?php

$form = ActiveForm::begin(['id' => 'email-masse-form','enableClientValidation' => false]); ?>
<?= $form->field($model, 'subject') ?>
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>

<div class="form-group">
<label class="control-label">Envoyer à</label>
<p>Cliquer sur les utilisateurs pour modifier leur état.<br />
Légende : <span class="label label-default">à envoyer</span> <span class="label label-danger">ne pas envoyer</span> <span class="label label-success">envoyé</span></p>
<div id="ids-users">
<?php foreach($users as $u): ?>
<a href="javascript:void(0);" class="label <?php if($u->no_mail): ?>label-danger<?php else: ?>label-default<?php endif; ?>" data-send="0" data-id="<?php echo $u->id; ?>"><?php echo Html::encode($u->prenom.' '.$u->nom); ?></a>
<?php endforeach; ?>
</div>
<input name="id_user" type="hidden" value="" />
</div>
<br />

<div class="form-group">
<?= Html::submitButton('Envoyer', ['class' => 'btn btn-default', 'name' => 'email-masse-button']) ?>
</div>
<?php ActiveForm::end(); ?>



backend/views/user/commandes.php → backend/views/user/orders.php Dosyayı Görüntüle

@@ -38,18 +38,18 @@ termes.

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\CreditHistorique;
use common\models\Etablissement;
use common\models\Commande;
use common\models\CreditHistory;
use common\models\Producer;
use common\models\Order;

$this->title = 'Commandes <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>';
$this->title = 'Commandes <small>'.Html::encode($user->lastname.' '.$user->name).'</small>';
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($user->nom.' '.$user->prenom)];
$this->params['breadcrumbs'][] = ['label' => Html::encode($user->lastname.' '.$user->name)];
$this->params['breadcrumbs'][] = 'Créditer';

?>

<div class="user-commandes">
<div class="user-orders">
<h1><?= $this->title ?> </h1>

+ 1
- 1
backend/views/user/update.php Dosyayı Görüntüle

@@ -43,7 +43,7 @@ use yii\helpers\Html;

$this->title = 'Modifier un client' ;
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($model->nom.' '.$model->prenom)];
$this->params['breadcrumbs'][] = ['label' => Html::encode($model->lastname.' '.$model->name)];
$this->params['breadcrumbs'][] = 'Modifier';
?>
<div class="user-update">

+ 0
- 83
backend/views/user/view.php Dosyayı Görüntüle

@@ -1,83 +0,0 @@
<?php

/**
Copyright La boîte à pain (2018)

contact@laboiteapain.net

Ce logiciel est un programme informatique servant à aider les producteurs
à distribuer leur production en circuits courts.

Ce logiciel est régi par la licence CeCILL soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".

En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.

A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe à
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités à charger et tester l'adéquation du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.

Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\User */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-view">

<h1><?= Html::encode($this->title) ?></h1>

<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>

<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'username',
'auth_key',
'password_hash',
'password_reset_token',
'email:email',
'status',
'created_at',
'updated_at',
'nom',
'prenom',
'telephone',
'confiance',
],
]) ?>

</div>

+ 30
- 17
common/models/CreditHistory.php Dosyayı Görüntüle

@@ -54,7 +54,7 @@ use yii\helpers\Html;
* @property double $amount
* @property string $type
* @property integer $id_producer
* @property string $means_payement
* @property string $mean_payement
*/
class CreditHistory extends ActiveRecord
{
@@ -65,10 +65,10 @@ class CreditHistory extends ActiveRecord
const TYPE_REFUND = 'refund';
const TYPE_DEBIT = 'debit';
const MEANS_PAYMENT_CREDIT_CARD = 'credit-card';
const MEANS_PAYMENT_MONEY = 'money';
const MEANS_PAYMENT_CHEQUE = 'cheque';
const MEANS_PAYMENT_OTHER = 'other';
const MEAN_PAYMENT_CREDIT_CARD = 'credit-card';
const MEAN_PAYMENT_MONEY = 'money';
const MEAN_PAYMENT_CHEQUE = 'cheque';
const MEAN_PAYMENT_OTHER = 'other';
/**
* @inheritdoc
@@ -88,7 +88,7 @@ class CreditHistory extends ActiveRecord
[['id_user', 'id_user_action', 'id_order', 'id_producer'], 'integer'],
[['date'], 'safe'],
[['amount'], 'double'],
[['type', 'means_payment', 'comment'], 'string', 'max' => 255],
[['type', 'mean_payment', 'comment'], 'string', 'max' => 255],
];
}

@@ -106,7 +106,7 @@ class CreditHistory extends ActiveRecord
'amount' => 'Montant',
'type' => 'Type',
'id_producer' => 'Producteur',
'means_payment' => 'Moyen de paiement',
'mean_payment' => 'Moyen de paiement',
'comment' => 'Commentaire',
];
}
@@ -230,10 +230,12 @@ class CreditHistory extends ActiveRecord
*/
public function getAmount($format = false)
{
if($format)
if($format) {
return number_format($this->amount,2) .' €' ;
else
}
else {
return $this->amount ;
}
}
/**
@@ -316,18 +318,29 @@ class CreditHistory extends ActiveRecord
}
/**
* Retourne le moyen de paiement.
* Retourne le libellé du moyen de paiement du CreditHistory courant.
*
* @return string
*/
public function getStrMeanPayment()
{
self::getStrMeanPaymentBy($this->mean_payement) ;
}
/**
* Retourne le libellé du moyen de paiement.
*
* @param string $meanPayment
* @return string
*/
public function getStrMeansPayment()
public static function getStrMeanPaymentBy($meanPayment)
{
switch($this->means_payment) {
case CreditHistory::MEANS_PAYMENT_MONEY : return 'Espèces' ;
case CreditHistory::MEANS_PAYMENT_CHEQUE : return 'Chèque' ;
case CreditHistory::MEANS_PAYMENT_CREDIT_CARD : return 'Carte bancaire' ;
case CreditHistory::MEANS_PAYMENT_OTHER : return 'Autre' ;
default: return 'Crédit pain' ;
switch($meanPayment) {
case CreditHistory::MEAN_PAYMENT_MONEY : return 'Espèces' ;
case CreditHistory::MEAN_PAYMENT_CHEQUE : return 'Chèque' ;
case CreditHistory::MEAN_PAYMENT_CREDIT_CARD : return 'Carte bancaire' ;
case CreditHistory::MEAN_PAYMENT_OTHER : return 'Autre' ;
default: return 'Crédit' ;
}
}

Yükleniyor…
İptal
Kaydet