Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

view.php 20KB

5 månader sedan
5 månader sedan
5 månader sedan
8 månader sedan
8 månader sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <?php
  2. /**
  3. Copyright Souke (2018)
  4. contact@souke.fr
  5. Ce logiciel est un programme informatique servant à aider les producteurs
  6. à distribuer leur production en circuits courts.
  7. Ce logiciel est régi par la licence CeCILL soumise au droit français et
  8. respectant les principes de diffusion des logiciels libres. Vous pouvez
  9. utiliser, modifier et/ou redistribuer ce programme sous les conditions
  10. de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
  11. sur le site "http://www.cecill.info".
  12. En contrepartie de l'accessibilité au code source et des droits de copie,
  13. de modification et de redistribution accordés par cette licence, il n'est
  14. offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
  15. seule une responsabilité restreinte pèse sur l'auteur du programme, le
  16. titulaire des droits patrimoniaux et les concédants successifs.
  17. A cet égard l'attention de l'utilisateur est attirée sur les risques
  18. associés au chargement, à l'utilisation, à la modification et/ou au
  19. développement et à la reproduction du logiciel par l'utilisateur étant
  20. donné sa spécificité de logiciel libre, qui peut le rendre complexe à
  21. manipuler et qui le réserve donc à des développeurs et des professionnels
  22. avertis possédant des connaissances informatiques approfondies. Les
  23. utilisateurs sont donc invités à charger et tester l'adéquation du
  24. logiciel à leurs besoins dans des conditions permettant d'assurer la
  25. sécurité de leurs systèmes et ou de leurs données et, plus généralement,
  26. à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
  27. Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
  28. pris connaissance de la licence CeCILL, et que vous en avez accepté les
  29. termes.
  30. */
  31. use common\helpers\GlobalParam;
  32. use common\helpers\Price;
  33. use domain\Communication\Email\Email;
  34. use domain\Order\Order\OrderModule;
  35. use domain\Subscription\Subscription\SubscriptionModule;
  36. use domain\User\User\UserModule;
  37. use domain\User\UserProducer\UserProducerModule;
  38. use yii\helpers\Html;
  39. use yii\widgets\ActiveForm;
  40. $userCurrent = GlobalParam::getCurrentUser();
  41. $orderModule = OrderModule::getInstance();
  42. $userModule = UserModule::getInstance();
  43. $userProducerModule = UserProducerModule::getInstance();
  44. $subscriptionModule = SubscriptionModule::getInstance();
  45. $userProducer = $userProducerModule->findOneUserProducer($model);
  46. $username = Html::encode($userModule->getSolver()->getUsername($model));
  47. $producer = GlobalParam::getCurrentProducer();
  48. $this->setTitle($username.' (#'.$model->id.')') ;
  49. $this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
  50. $this->addBreadcrumb(['label' => $username]) ;
  51. $this->addBreadcrumb('Récapitulatif') ;
  52. ?>
  53. <?= $this->render('_menu_navigation', [
  54. 'action' => 'view',
  55. 'user' => $model
  56. ]); ?>
  57. <div class="user-view tab-content">
  58. <div class="col-md-6 col-no-padding-left">
  59. <div class="panel panel-default">
  60. <div class="panel-heading">
  61. <h3 class="panel-title">
  62. <i class="fa fa-user"></i>
  63. Profil
  64. <a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['user/update','id' => $model->id]) ?>">
  65. <span class="glyphicon glyphicon-pencil"></span>
  66. Modifier
  67. </a>
  68. </h3>
  69. </div>
  70. <div class="panel-body">
  71. <ul class="list-group list-group-unbordered">
  72. <li class="list-group-item">
  73. <strong>Type</strong>
  74. <span class="pull-right">
  75. <?= $userModule->getSolver()->getTypeLabel($model->type) ?>
  76. </span>
  77. </li>
  78. <li class="list-group-item">
  79. <strong>Nom</strong>
  80. <span class="pull-right">
  81. <?= $userModule->getSolver()->getUsername($model) ?>
  82. </span>
  83. </li>
  84. <?php if($model->phone): ?>
  85. <li class="list-group-item">
  86. <strong>Téléphone</strong>
  87. <span class="pull-right">
  88. <span class="glyphicon glyphicon-phone"></span>
  89. <?= $userModule->getSolver()->getPhone($model); ?>
  90. </span>
  91. </li>
  92. <?php endif; ?>
  93. <?php if($model->email): ?>
  94. <li class="list-group-item">
  95. <strong>Email</strong>
  96. <span class="pull-right">
  97. <span class="glyphicon glyphicon-envelope"></span>
  98. <a href="mailto:<?= $userModule->getSolver()->getEmail($model) ?>"><?= $userModule->getSolver()->getEmail($model) ?></a>
  99. </span>
  100. </li>
  101. <?php endif; ?>
  102. <?php if($model->address): ?>
  103. <li class="list-group-item list-group-item-address">
  104. <strong>Adresse</strong>
  105. <span class="pull-right">
  106. <?= nl2br($userModule->getSolver()->getAddress($model)) ?>
  107. </span>
  108. <div class="clr"></div>
  109. </li>
  110. <?php endif; ?>
  111. <li class="list-group-item">
  112. <strong>Infolettre</strong>
  113. <span class="pull-right">
  114. <?php $isUserSubscribedNewsletter = $userModule->getNewsletterManager()->isUserSubscribedNewsletter($model, Email::TYPE_NEWSLETTER); ?>
  115. <span class="label label-<?= $isUserSubscribedNewsletter ? 'success' : 'default' ?>">
  116. <?= $isUserSubscribedNewsletter ? 'Oui' : 'Non' ?>
  117. </span>
  118. </span>
  119. </li>
  120. <li class="list-group-item">
  121. <strong>Emails de prise de commande</strong>
  122. <span class="pull-right">
  123. <?php $isUserSubscribedNewsletterOrderTaking = $userModule->getNewsletterManager()->isUserSubscribedNewsletter($model, Email::TYPE_ORDER_TAKING); ?>
  124. <span class="label label-<?= $isUserSubscribedNewsletterOrderTaking ? 'success' : 'default' ?>">
  125. <?= $isUserSubscribedNewsletterOrderTaking ? 'Oui' : 'Non' ?>
  126. </span>
  127. </span>
  128. </li>
  129. <?php if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
  130. <li class="list-group-item">
  131. <strong>Infolettre Souke</strong>
  132. <span class="pull-right">
  133. <?php $isUserSubscribedNewsletterSouke = $model->newsletter_souke; ?>
  134. <span class="label label-<?= $isUserSubscribedNewsletterSouke ? 'success' : 'default' ?>">
  135. <?= $isUserSubscribedNewsletterSouke ? 'Oui' : 'Non' ?>
  136. </span>
  137. </span>
  138. </li>
  139. <?php endif; ?>
  140. <li class="list-group-item">
  141. <strong>Problème réception emails</strong>
  142. <span class="pull-right">
  143. <?php $hasProblemReceivingEmails = $model->problem_receiving_emails; ?>
  144. <span class="label label-<?= $hasProblemReceivingEmails ? 'danger' : 'default' ?>">
  145. <?= $hasProblemReceivingEmails ? 'Oui' : 'Non' ?>
  146. </span>
  147. </span>
  148. </li>
  149. <?php if($model->userPointSale): ?>
  150. <li class="list-group-item">
  151. <strong>Points de vente</strong>
  152. <span class="pull-right">
  153. <?php foreach($model->userPointSale as $userPointSale): ?>
  154. <?php if($userPointSale->pointSale->id_producer == $producer->id): ?>
  155. <span class="label label-default"><?= $userPointSale->pointSale->name; ?></span>
  156. <?php endif; ?>
  157. <?php endforeach; ?>
  158. </span>
  159. </li>
  160. <?php endif; ?>
  161. <?php if($model->userUserGroup): ?>
  162. <li class="list-group-item">
  163. <strong>Groupes d'utilisateurs</strong>
  164. <span class="pull-right">
  165. <?php foreach($model->userUserGroup as $userUserGroup): ?>
  166. <span class="label label-default"><?= $userUserGroup->userGroup->name; ?></span>
  167. <?php endforeach; ?>
  168. </span>
  169. </li>
  170. <?php endif; ?>
  171. </ul>
  172. </div>
  173. </div>
  174. <?php if($userProducer->trust_alert): ?>
  175. <div class="panel panel-default">
  176. <div class="panel-heading">
  177. <h3 class="panel-title">
  178. <i class="fa fa-exclamation-triangle"></i>
  179. Alerte confiance
  180. </h3>
  181. </div>
  182. <div class="panel-body">
  183. <ul class="list-group list-group-unbordered">
  184. <li class="list-group-item">
  185. <strong>Alerte confiance</strong>
  186. <span class="pull-right">
  187. <span class="label label-danger">Oui</span>
  188. </span>
  189. </li>
  190. <?php if($userProducer->trust_alert_comment && strlen($userProducer->trust_alert_comment) > 0): ?>
  191. <li class="list-group-item">
  192. <strong>Commentaire</strong>
  193. <span class="pull-right">
  194. <?= nl2br($userProducer->trust_alert_comment) ?>
  195. </span>
  196. <div class="clr"></div>
  197. </li>
  198. <?php endif; ?>
  199. </ul>
  200. </div>
  201. </div>
  202. <?php endif; ?>
  203. <div class="panel panel-default">
  204. <div class="panel-heading">
  205. <h3 class="panel-title">
  206. <span class="glyphicon glyphicon-log-in"></span>
  207. Dernière connexion et inscription
  208. </h3>
  209. </div>
  210. <div class="panel-body">
  211. <ul class="list-group list-group-unbordered">
  212. <li class="list-group-item">
  213. <strong>Dernière connexion</strong>
  214. <span class="pull-right">
  215. <?php if($model->date_last_connection): ?>
  216. <?= date('d/m/Y à H:i:s', strtotime($model->date_last_connection)) ?>
  217. <?php else: ?>
  218. --
  219. <?php endif; ?>
  220. </span>
  221. </li>
  222. <li class="list-group-item">
  223. <strong>Inscription</strong>
  224. <span class="pull-right">
  225. <?= date('d/m/Y à H:i:s', $model->created_at) ?>
  226. </span>
  227. </li>
  228. </ul>
  229. </div>
  230. </div>
  231. <?php if($model->email): ?>
  232. <div class="panel panel-default">
  233. <div class="panel-heading">
  234. <h3 class="panel-title">
  235. <i class="fa fa-envelope"></i>
  236. Emails accès
  237. </h3>
  238. </div>
  239. <div class="panel-body">
  240. <?php $form = ActiveForm::begin(); ?>
  241. <div class="form-group">
  242. <?= Html::submitButton(
  243. '<i class="fa fa-key"></i> Envoyer un nouveau mot de passe',
  244. ['class' => 'btn btn-default', 'name' => 'submit_new_password', 'value' => 1]
  245. ) ?>
  246. </div>
  247. <?php ActiveForm::end(); ?>
  248. <?php $form = ActiveForm::begin(); ?>
  249. <div class="form-group">
  250. <?= Html::submitButton(
  251. '<i class="fa fa-home"></i> Envoyer l\'email de bienvenue',
  252. ['class' => 'btn btn-default', 'name' => 'submit_mail_welcome', 'value' => 1]
  253. ) ?>
  254. </div>
  255. <?php ActiveForm::end(); ?>
  256. </div>
  257. </div>
  258. <?php endif; ?>
  259. </div>
  260. <div class="col-md-6 col-no-padding-right">
  261. <div class="panel panel-default">
  262. <div class="panel-heading">
  263. <h3 class="panel-title">
  264. <i class="glyphicon glyphicon-piggy-bank"></i>
  265. Cagnotte
  266. <a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['user/credit','id' => $model->id]) ?>">
  267. <span class="glyphicon glyphicon-euro"></span>
  268. Voir / créditer
  269. </a>
  270. </h3>
  271. </div>
  272. <div class="panel-body">
  273. <ul class="list-group list-group-unbordered">
  274. <li class="list-group-item">
  275. <strong>Montant</strong>
  276. <span class="pull-right">
  277. <?php $credit = $userModule->getRepository()->getCredit($model); ?>
  278. <span class="label label-<?= $credit > 0 ? 'success' : 'danger' ?>">
  279. <?= Price::format($credit) ?>
  280. </span>
  281. </span>
  282. </li>
  283. <li class="list-group-item">
  284. <strong>Cagnotte obligatoire</strong>
  285. <span class="pull-right">
  286. <?php $creditActive = $userModule->getRepository()->getCreditActive($model) ?>
  287. <span class="label label-<?= $creditActive ? 'success' : 'default' ?>">
  288. <?= $creditActive ? 'Oui' : 'Non' ?>
  289. </span>
  290. </span>
  291. </li>
  292. </ul>
  293. </div>
  294. </div>
  295. <div class="panel panel-default">
  296. <div class="panel-heading">
  297. <h3 class="panel-title">
  298. <i class="glyphicon glyphicon-th-list"></i>
  299. Commandes
  300. <a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['user/orders','id' => $model->id]) ?>">
  301. <span class="glyphicon glyphicon-eye-open"></span>
  302. Voir
  303. </a>
  304. </h3>
  305. </div>
  306. <div class="panel-body">
  307. <?php $countOrders = $orderModule->getRepository()->countOrdersByUser($model); ?>
  308. <?php if($countOrders): ?>
  309. <ul class="list-group list-group-unbordered">
  310. <li class="list-group-item">
  311. <strong>Nombre</strong>
  312. <span class="pull-right">
  313. <?= $orderModule->getRepository()->countOrdersByUser($model) ?>
  314. </span>
  315. </li>
  316. <li class="list-group-item">
  317. <strong>Panier moyen</strong>
  318. <span class="pull-right">
  319. <?= Price::format($orderModule->getRepository()->getAverageBasketByUser($model)); ?>
  320. </span>
  321. </li>
  322. </ul>
  323. <?php else: ?>
  324. <div class="alert alert-info">
  325. Aucune commande
  326. </div>
  327. <?php endif; ?>
  328. </div>
  329. </div>
  330. <?php $hasSubscription = $subscriptionsArray && count($subscriptionsArray); ?>
  331. <div class="panel panel-default">
  332. <div class="panel-heading">
  333. <h3 class="panel-title">
  334. <i class="glyphicon glyphicon-repeat"></i>
  335. Abonnements
  336. <?php if($hasSubscription): ?>
  337. <a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['subscription/index','SubscriptionSearch[id_user]' => $model->id]) ?>">
  338. <span class="glyphicon glyphicon-eye-open"></span>
  339. Voir
  340. </a>
  341. <?php else: ?>
  342. <a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['subscription/create']) ?>">
  343. <span class="glyphicon glyphicon-plus"></span>
  344. Créer
  345. </a>
  346. <?php endif; ?>
  347. </h3>
  348. </div>
  349. <div class="panel-body">
  350. <?php if($hasSubscription): ?>
  351. <ul class="list-group list-group-unbordered">
  352. <?php foreach($subscriptionsArray as $subscription): ?>
  353. <li class="list-group-item">
  354. <span class="pull-right">
  355. <?= $subscriptionModule->getSolver()->getProductsListAsHtml($subscription) ?>
  356. </span>
  357. <strong><?= $subscriptionModule->getSolver()->getDaysAsHtml($subscription) ?></strong>
  358. (<?= strtolower($subscriptionModule->getSolver()->getWeekFrequencyAsString($subscription)) ?>)<br />
  359. <?= Html::encode($subscription->pointSale->name); ?><br />
  360. <?= $subscriptionModule->getSolver()->getPeriodAsHtml($subscription) ?>
  361. <div class="clr"></div>
  362. </li>
  363. <?php endforeach; ?>
  364. </ul>
  365. <?php else: ?>
  366. <div class="alert alert-info">
  367. Aucun abonnement
  368. </div>
  369. <?php endif; ?>
  370. </div>
  371. </div>
  372. <?php if(isset($pointSaleBillingArray) && $pointSaleBillingArray && count($pointSaleBillingArray) > 0): ?>
  373. <div class="panel panel-default">
  374. <div class="panel-heading">
  375. <h3 class="panel-title">
  376. <i class="fa fa-sticky-note-o"></i>
  377. Contact facturation
  378. </h3>
  379. </div>
  380. <div class="panel-body">
  381. <?php foreach($pointSaleBillingArray as $pointSale): ?>
  382. <a class="btn btn-default btn-sm" href="<?= Yii::$app->urlManager->createUrl(['point-sale/update', 'id' => $pointSale->id]) ?>">
  383. <i class="fa fa-map-marker"></i>
  384. <?= $pointSale->name ?>
  385. </a><br />
  386. <?php endforeach; ?>
  387. </div>
  388. </div>
  389. <?php endif; ?>
  390. </div>
  391. <div class="clr"></div>
  392. </div>