選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

308 行
19KB

  1. <?php
  2. /**
  3. * Copyright Souke (2018)
  4. *
  5. * contact@souke.fr
  6. *
  7. * Ce logiciel est un programme informatique servant à aider les producteurs
  8. * à distribuer leur production en circuits courts.
  9. *
  10. * Ce logiciel est régi par la licence CeCILL soumise au droit français et
  11. * respectant les principes de diffusion des logiciels libres. Vous pouvez
  12. * utiliser, modifier et/ou redistribuer ce programme sous les conditions
  13. * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
  14. * sur le site "http://www.cecill.info".
  15. *
  16. * En contrepartie de l'accessibilité au code source et des droits de copie,
  17. * de modification et de redistribution accordés par cette licence, il n'est
  18. * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
  19. * seule une responsabilité restreinte pèse sur l'auteur du programme, le
  20. * titulaire des droits patrimoniaux et les concédants successifs.
  21. *
  22. * A cet égard l'attention de l'utilisateur est attirée sur les risques
  23. * associés au chargement, à l'utilisation, à la modification et/ou au
  24. * développement et à la reproduction du logiciel par l'utilisateur étant
  25. * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
  26. * manipuler et qui le réserve donc à des développeurs et des professionnels
  27. * avertis possédant des connaissances informatiques approfondies. Les
  28. * utilisateurs sont donc invités à charger et tester l'adéquation du
  29. * logiciel à leurs besoins dans des conditions permettant d'assurer la
  30. * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
  31. * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
  32. *
  33. * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
  34. * pris connaissance de la licence CeCILL, et que vous en avez accepté les
  35. * termes.
  36. */
  37. use common\helpers\GlobalParam;
  38. use domain\Feature\Feature\Feature;
  39. use domain\User\User\UserModule;
  40. $producerModule = $this->getProducerModule();
  41. $userModule = UserModule::getInstance();
  42. $userProducerModule = $this->getUserProducerModule();
  43. $ticketModule = $this->getTicketModule();
  44. $featureChecker = $this->getFeatureModule()->getChecker();
  45. $adminSettingBag = $this->getSettingModule()->getAdminSettingBag();
  46. $producer = GlobalParam::getCurrentProducer();
  47. $userCurrent = GlobalParam::getCurrentUser();
  48. $isUserCurrentGrantedAsAdministrator = $userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent);
  49. $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent);
  50. ?>
  51. <aside class="main-sidebar">
  52. <section class="sidebar">
  53. <?php
  54. $producer = GlobalParam::getCurrentProducer();
  55. $versionOpendistribLabel = '';
  56. if ($producer) {
  57. $backgroundLabelVersionOpendistrib = 'black';
  58. if (!$producerModule->isUpToDateWithOpendistribVersion($producer)) {
  59. $backgroundLabelVersionOpendistrib = 'green';
  60. }
  61. $versionOpendistribLabel = '<span class="pull-right-container"><small class="label pull-right bg-' . $backgroundLabelVersionOpendistrib . '">' . GlobalParam::getSoukeVersion() . '</small></span>';
  62. }
  63. $countTicketsProducerUnreadLabel = '';
  64. $countTicketsProducerUnread = $ticketModule->countTicketsUnreadByUser($this->getUserCurrent());
  65. if ($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) {
  66. $countTicketsProducerUnreadLabel = '<small class="label pull-right bg-blue">' . $countTicketsProducerUnread . '</small>';
  67. }
  68. $developerOnlineLabel = '';
  69. if ($adminSettingBag->get('supportOnline')) {
  70. $developerOnlineLabel = '<small class="label pull-right bg-green"><i class="fa fa-phone"></i></small>';
  71. }
  72. $countTicketsLabel = '';
  73. $countTicketsAdminOpen = $ticketModule->getRepository()->countTicketsAdminStatusOpen();
  74. $countTicketsAdminUnread = $ticketModule->getRepository()->countTicketsAdminUnreadByUser($this->getUserCurrent());
  75. if ($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) {
  76. $countTicketsLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">' . $countTicketsAdminOpen . '</small></span>';
  77. } else {
  78. if($countTicketsAdminOpen) {
  79. $countTicketsLabel = '<span class="pull-right-container"><small class="label pull-right bg-blue">' . $countTicketsAdminOpen . '</small></span>';
  80. }
  81. }
  82. $sumUserProducerCredits = $userProducerModule->sumUserProducerCredits();
  83. $sumUserProducerCreditsLabel = '';
  84. //$sumUserProducerCreditsLabel = '<span class="pull-right-container"><small class="label pull-right '.($sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red') .'">'.number_format($sumUserProducerCredits, 2).' €</small></span>';
  85. $countUsersWithStatusProducerOnline = $userModule->getRepository()->countUsersStatusProducerOnline();
  86. $countUsersWithStatusUserOnline = $userModule->getRepository()->countUsersStatusUserOnline();
  87. $countUsersProducersOnlineLabel = '';
  88. if ($countUsersWithStatusProducerOnline || $countUsersWithStatusUserOnline) {
  89. $countUsersProducersOnlineLabel = '<span class="pull-right-container"><small class="label pull-right bg-blue">' . ($countUsersWithStatusProducerOnline + $countUsersWithStatusUserOnline) . '</small></span>';
  90. }
  91. $countProducerInvoicesUnpaidLabel = '';
  92. $countProducerInvoicesUnpaid = $this->getProducerModule()->getDolibarrUtils()
  93. ->countDolibarrProducerInvoicesUnpaid($producer);
  94. if ($countProducerInvoicesUnpaid > 1) {
  95. $countProducerInvoicesUnpaidLabelColor = ($countProducerInvoicesUnpaid > 2) ? 'red' : 'orange';
  96. $countProducerInvoicesUnpaidLabel = '<span class="pull-right-container"><small class="label pull-right bg-' . $countProducerInvoicesUnpaidLabelColor . '">' . $countProducerInvoicesUnpaid . '</small></span>';
  97. }
  98. ?>
  99. <?= dmstr\widgets\Menu::widget(
  100. [
  101. 'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
  102. 'items' => [
  103. // Administration
  104. ['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  105. [
  106. 'label' => 'Tableau de bord',
  107. 'icon' => 'dashboard',
  108. 'url' => ['dashboard-admin/index'],
  109. 'visible' => $isUserCurrentGrantedAsAdministrator,
  110. ],
  111. [
  112. 'label' => 'Support',
  113. 'icon' => 'comments',
  114. 'url' => ['support-admin/index'],
  115. 'visible' => $isUserCurrentGrantedAsAdministrator,
  116. 'template' => '<a href="{url}">{icon} {label}' . $countTicketsLabel . '</a>'
  117. ],
  118. [
  119. 'label' => 'Producteurs',
  120. 'icon' => 'bookmark',
  121. 'url' => ['/producer-admin/index'],
  122. 'visible' => $isUserCurrentGrantedAsAdministrator
  123. ],
  124. [
  125. 'label' => 'Utilisateurs',
  126. 'icon' => 'users',
  127. 'url' => ['/user-admin/index'],
  128. 'visible' => $isUserCurrentGrantedAsAdministrator
  129. ],
  130. [
  131. 'label' => 'Deliverabilité emails',
  132. 'icon' => 'paper-plane',
  133. 'url' => ['/user-admin/email-deliverability'],
  134. 'visible' => $isUserCurrentGrantedAsAdministrator
  135. ],
  136. [
  137. 'label' => 'Statistiques',
  138. 'icon' => 'line-chart',
  139. 'url' => ['/stats-admin/turnover'],
  140. 'visible' => $isUserCurrentGrantedAsAdministrator,
  141. 'items' => [
  142. ['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  143. ['label' => 'Commandes clients', 'icon' => 'line-chart', 'url' => ['/stats-admin/customer-orders'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  144. [
  145. 'label' => 'En ligne',
  146. 'icon' => 'wifi',
  147. 'url' => ['online-admin/index'],
  148. 'visible' => $isUserCurrentGrantedAsAdministrator,
  149. //'template' => '<a href="{url}">{icon} {label}' . $countUsersProducersOnlineLabel . '</a>'
  150. ],
  151. ['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  152. ],
  153. ],
  154. [
  155. 'label' => 'Configuration',
  156. 'icon' => 'cog',
  157. 'url' => ['/setting-admin/index'],
  158. 'visible' => $isUserCurrentGrantedAsAdministrator,
  159. 'items' => [
  160. ['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)],
  161. ['label' => 'Fonctionnalités', 'icon' => 'flag', 'url' => ['/feature-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  162. ['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  163. ['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  164. ],
  165. ],
  166. // Support
  167. ['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  168. [
  169. 'label' => 'Support',
  170. 'icon' => 'comments',
  171. 'url' => ['support/index'],
  172. 'visible' => $isUserCurrentGrantedAsProducer,
  173. 'template' => '<a href="{url}">{icon} {label} <span class="pull-right-container">' . $developerOnlineLabel . $countTicketsProducerUnreadLabel . '</span></a>'
  174. ],
  175. // Producteur
  176. ['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  177. ['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  178. ['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  179. [
  180. 'label' => 'Produits',
  181. 'icon' => 'clone',
  182. 'url' => ['/product/index'],
  183. 'visible' => $isUserCurrentGrantedAsProducer,
  184. 'active' => Yii::$app->controller->id == 'product' || Yii::$app->controller->id == 'product-category',
  185. 'items' => [
  186. ['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  187. ['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  188. ['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $isUserCurrentGrantedAsProducer && $featureChecker->isEnabled(Feature::ALIAS_PRODUCT_PRICE_IMPORT)],
  189. ]
  190. ],
  191. [
  192. 'label' => 'Points de vente',
  193. 'icon' => 'map-marker',
  194. 'url' => ['/point-sale/index'],
  195. 'visible' => $isUserCurrentGrantedAsProducer,
  196. 'active' => Yii::$app->controller->id == 'point-sale' || Yii::$app->controller->id == 'shared-point-sale',
  197. 'items' => [
  198. ['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  199. ['label' => 'Partages', 'icon' => 'share-alt', 'url' => ['/shared-point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer && $featureChecker->isEnabled(Feature::ALIAS_SHARED_POINT_SALE)],
  200. ]
  201. ],
  202. [
  203. 'label' => 'Utilisateurs',
  204. 'icon' => 'users',
  205. 'url' => ['/user/index'],
  206. 'items' => [
  207. ['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  208. [
  209. 'label' => 'Cagnotte',
  210. 'icon' => 'euro',
  211. 'url' => ['/credit/index'],
  212. 'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>',
  213. 'visible' => $isUserCurrentGrantedAsProducer && $producerModule->getConfig('credit')
  214. ],
  215. ['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  216. ['label' => 'Import', 'icon' => 'upload', 'url' => ['/user-import/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  217. ],
  218. ],
  219. ['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'subscription'],
  220. [
  221. 'label' => 'Communiquer',
  222. 'icon' => 'bullhorn',
  223. 'url' => ['/communicate/email'],
  224. 'visible' => $isUserCurrentGrantedAsProducer,
  225. 'items' => [
  226. ['label' => 'Email', 'icon' => 'paper-plane', 'url' => ['/communicate/email'], 'visible' => $isUserCurrentGrantedAsProducer],
  227. ['label' => 'Papier', 'icon' => 'print', 'url' => ['/communicate/paper'], 'visible' => $isUserCurrentGrantedAsProducer],
  228. ]
  229. ],
  230. [
  231. 'label' => 'Documents',
  232. 'icon' => 'clone',
  233. 'url' => ['/delivery-note/index'],
  234. 'items' => [
  235. ['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  236. ['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  237. ['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  238. ],
  239. ],
  240. [
  241. 'label' => 'Statistiques',
  242. 'icon' => 'line-chart',
  243. 'url' => ['/stats/index'],
  244. 'items' => [
  245. ['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  246. ['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  247. ['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $isUserCurrentGrantedAsProducer],
  248. ],
  249. ],
  250. ['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $isUserCurrentGrantedAsProducer],
  251. ['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  252. ['label' => "Souke", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  253. [
  254. 'label' => 'Mes factures',
  255. 'icon' => 'clone',
  256. 'url' => ['/producer-invoice/index'],
  257. 'visible' => $isUserCurrentGrantedAsProducer && Yii::$app->parameterBag->get('dolibarrApiKey'),
  258. 'active' => Yii::$app->controller->id == 'producer-invoice',
  259. 'template' => '<a href="{url}">{icon} {label}' . $countProducerInvoicesUnpaidLabel . '</a>'
  260. ],
  261. ['label' => 'Tarifs & modules', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $isUserCurrentGrantedAsProducer],
  262. [
  263. 'label' => 'Parrainage',
  264. 'icon' => 'users',
  265. 'url' => ['/sponsorship/index'],
  266. 'visible' => $isUserCurrentGrantedAsProducer && $featureChecker->isEnabled(Feature::ALIAS_SPONSORSHIP),
  267. 'active' => Yii::$app->controller->id == 'sponsorship'
  268. ],
  269. [
  270. 'label' => 'Développement',
  271. 'icon' => 'code',
  272. 'url' => ['/development/index'],
  273. 'visible' => $isUserCurrentGrantedAsProducer,
  274. 'active' => Yii::$app->controller->id == 'development',
  275. 'template' => '<a href="{url}">{icon} {label}' . $versionOpendistribLabel . '</a>'
  276. ],
  277. //['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  278. //['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  279. //['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  280. //['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  281. //['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()],
  282. ],
  283. ]
  284. ) ?>
  285. </section>
  286. </aside>