- <?php
-
-
-
- use yii\helpers\Html;
- use yii\widgets\ActiveForm;
- use common\helpers\GlobalParam;
- use common\logic\User\CreditHistory\Model\CreditHistory;
- use common\helpers\MeanPayment;
-
- $creditHistoryManager = $this->getCreditHistoryManager();
- $producerManager = $this->getProducerManager();
- $userManager = $this->getUserManager();
-
- $this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ;
- $this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
- $this->addBreadcrumb(['label' => Html::encode($user->lastname.' '.$user->name)]) ;
- $this->addBreadcrumb('Créditer') ;
-
- ?>
-
- <div class="user-credit">
-
- <?php
- $producer = $producerManager->findOneProducerById(GlobalParam::getCurrentProducerId());
-
- if(!$producer->credit)
- {
- 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 utilisateurs.</div>' ;
- }
- ?>
-
- <div class="col-md-4">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- Crédit obligatoire
- <?= Html::a($userProducer->credit_active ? 'Désactiver' : 'Activer', ['user/state-credit', 'idUser' => $user->id,'state' => !$userProducer->credit_active], ['class' => 'btn btn-default btn-xs']); ?>
- </h3>
- </div>
- <div class="panel-body">
- <?php if($userProducer->credit_active): ?>
- <div class="alert alert-success">Activé</div>
- <?php else: ?>
- <div class="alert alert-danger">Désactivé</div>
- <?php endif; ?>
- </div>
- </div>
-
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Crédit / débit</h3>
- </div>
- <div class="panel-body">
- <?php $form = ActiveForm::begin(); ?>
- <?= $form->field($creditForm, 'type')->dropDownList([
- CreditHistory::TYPE_CREDIT => 'Crédit',
- CreditHistory::TYPE_DEBIT => 'Débit',
- ]) ?>
- <?= $form->field($creditForm, 'amount')->textInput() ?>
- <?= $form->field($creditForm, 'mean_payment')->dropDownList([
- MeanPayment::MONEY => MeanPayment::getStrBy(MeanPayment::MONEY),
- MeanPayment::CREDIT_CARD => MeanPayment::getStrBy(MeanPayment::CREDIT_CARD),
- MeanPayment::CHEQUE => MeanPayment::getStrBy(MeanPayment::CHEQUE),
- MeanPayment::TRANSFER => MeanPayment::getStrBy(MeanPayment::TRANSFER),
- MeanPayment::OTHER => MeanPayment::getStrBy(MeanPayment::OTHER),
- ]) ?>
- <?= $form->field($creditForm, 'comment')->textarea() ?>
- <?= $form->field($creditForm, 'send_mail')->checkbox() ?>
-
- <div class="form-group">
- <?= Html::submitButton( 'Créditer', ['class' => 'btn btn-primary']) ?>
- </div>
- <?php ActiveForm::end(); ?>
- </div>
- </div>
- </div>
-
- <div class="col-md-8">
- <h2>Historique <span class="the-credit"><?= number_format($userManager->getCredit($user, $producer), 2); ?> €</span></h2>
- <table class="table table-bordered">
- <thead>
- <tr>
- <th>Date</th>
- <th>Utilisateur</th>
- <th>Type</th>
- <th>- Débit</th>
- <th>+ Crédit</th>
- <th>Paiement</th>
- <th>Commentaire</th>
- </tr>
- </thead>
- <tbody>
- <?php if(count($history)): ?>
- <?php foreach($history as $creditHistory): ?>
-
- <tr>
- <td><?= $creditHistoryManager->getDate($creditHistory, true) ; ?></td>
- <td><?= Html::encode($creditHistoryManager->getStrUserAction($creditHistory)); ?></td>
- <td><?= $creditHistoryManager->getStrWording($creditHistory); ?></td>
- <td>
- <?php if($creditHistoryManager->isTypeDebit($creditHistory)): ?>
- - <?= $creditHistoryManager->getAmount($creditHistory, true); ?>
- <?php endif; ?>
- </td>
- <td>
- <?php if($creditHistoryManager->isTypeCredit($creditHistory)): ?>
- + <?= $creditHistoryManager->getAmount($creditHistory, true); ?>
- <?php endif; ?>
- </td>
- <td>
- <?= $creditHistoryManager->getStrMeanPayment($creditHistory) ?>
- </td>
- <td>
- <?php if(strlen($creditHistory->getComment())): ?>
- <?= nl2br($creditHistory->getComment()); ?>
- <?php endif; ?>
- </td>
- </tr>
- <?php endforeach; ?>
- <?php else: ?>
- <tr><td colspan="4">Aucun résultat</td></tr>
- <?php endif; ?>
- </tbody>
- </table>
- </div>
-
- </div>
|