You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 line
4.1KB

  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\ActiveForm;
  4. use common\models\CreditHistorique;
  5. use common\models\Etablissement;
  6. $this->title = 'Créditer <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>';
  7. $this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
  8. $this->params['breadcrumbs'][] = ['label' => Html::encode($user->nom.' '.$user->prenom)];
  9. $this->params['breadcrumbs'][] = 'Créditer';
  10. ?>
  11. <div class="user-credit">
  12. <?php
  13. $etablissement = Etablissement::find()
  14. ->where(['id' => Yii::$app->user->identity->id_etablissement])
  15. ->one() ;
  16. if(!$etablissement->credit_pain)
  17. {
  18. 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>.'
  19. . ' Pensez à l\'activer si vous souhaitez qu\'elle soit visible de vos clients.</div>' ;
  20. }
  21. ?>
  22. <div class="col-md-12">
  23. <h1><?= $this->title ?></h1>
  24. <?php $form = ActiveForm::begin(); ?>
  25. <?= $form->field($credit_form, 'type')->dropDownList([
  26. CreditHistorique::TYPE_CREDIT => 'Crédit',
  27. CreditHistorique::TYPE_DEBIT => 'Débit',
  28. ]) ?>
  29. <?= $form->field($credit_form, 'montant')->textInput() ?>
  30. <?= $form->field($credit_form, 'moyen_paiement')->dropDownList([
  31. CreditHistorique::MOYEN_ESPECES => 'Espèces',
  32. CreditHistorique::MOYEN_CB => 'Carte bancaire',
  33. CreditHistorique::MOYEN_CHEQUE => 'Chèque',
  34. CreditHistorique::MOYEN_AUTRE => 'Autre',
  35. ]) ?>
  36. <?= $form->field($credit_form, 'commentaire')->textarea() ?>
  37. <?= $form->field($credit_form, 'send_mail')->checkbox() ?>
  38. <div class="form-group">
  39. <?= Html::submitButton( 'Créditer', ['class' => 'btn btn-primary']) ?>
  40. </div>
  41. <?php ActiveForm::end(); ?>
  42. </div>
  43. <div class="col-md-12">
  44. <h2>Historique <span class="the-credit"><?= number_format($user->getCredit($etablissement->id), 2); ?> €</span></h2>
  45. <table class="table table-bordered">
  46. <thead>
  47. <tr>
  48. <th>Date</th>
  49. <th>Utilisateur</th>
  50. <th>Type</th>
  51. <th>- Débit</th>
  52. <th>+ Crédit</th>
  53. <th>Paiement</th>
  54. <th>Commentaire</th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. <?php if(count($historique)): ?>
  59. <?php foreach($historique as $ch): ?>
  60. <tr>
  61. <td><?= $ch->getDate(true) ; ?></td>
  62. <td><?php if(isset($ch->userAction)): echo Html::encode($ch->userAction->nom. ' '.$ch->userAction->prenom) ; else: echo 'Administrateur' ;endif; ?></td>
  63. <td><?= $ch->getStrLibelle(); ?></td>
  64. <td>
  65. <?php if($ch->isTypeDebit()): ?>
  66. - <?= $ch->getMontant(true); ?>
  67. <?php endif; ?>
  68. </td>
  69. <td>
  70. <?php if($ch->isTypeCredit()): ?>
  71. + <?= $ch->getMontant(true); ?>
  72. <?php endif; ?>
  73. </td>
  74. <td>
  75. <?= $ch->getStrMoyenPaiement() ?>
  76. </td>
  77. <td>
  78. <?php if(strlen($ch->commentaire)): ?>
  79. <?= nl2br($ch->commentaire) ; ?>
  80. <?php endif; ?>
  81. </td>
  82. </tr>
  83. <?php endforeach; ?>
  84. <?php else: ?>
  85. <tr><td colspan="4">Aucun résultat</td></tr>
  86. <?php endif; ?>
  87. </tbody>
  88. </table>
  89. </div>
  90. </div>