Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

left.php 17KB

il y a 7 mois
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. $countTicketsAdminUnread = $ticketModule->getRepository()->countTicketsAdminUnreadByUser($this->getUserCurrent());
  74. if ($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) {
  75. $countTicketsLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">' . $countTicketsAdminUnread . '</small></span>';
  76. } else {
  77. $countTicketsAdminOpen = $ticketModule->getRepository()->countTicketsAdminStatusOpen();
  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. ['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  119. [
  120. 'label' => 'Statistiques',
  121. 'icon' => 'line-chart',
  122. 'url' => ['/stats-admin/turnover'],
  123. 'visible' => $isUserCurrentGrantedAsAdministrator,
  124. 'items' => [
  125. ['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  126. ['label' => 'Commandes clients', 'icon' => 'line-chart', 'url' => ['/stats-admin/customer-orders'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  127. [
  128. 'label' => 'En ligne',
  129. 'icon' => 'wifi',
  130. 'url' => ['online-admin/index'],
  131. 'visible' => $isUserCurrentGrantedAsAdministrator,
  132. //'template' => '<a href="{url}">{icon} {label}' . $countUsersProducersOnlineLabel . '</a>'
  133. ],
  134. ['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  135. ],
  136. ],
  137. [
  138. 'label' => 'Configuration',
  139. 'icon' => 'cog',
  140. 'url' => ['/setting-admin/index'],
  141. 'visible' => $isUserCurrentGrantedAsAdministrator,
  142. 'items' => [
  143. ['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)],
  144. ['label' => 'Fonctionnalités', 'icon' => 'flag', 'url' => ['/feature-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  145. ['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  146. ['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  147. ],
  148. ],
  149. // Support
  150. ['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  151. [
  152. 'label' => 'Support',
  153. 'icon' => 'comments',
  154. 'url' => ['support/index'],
  155. 'visible' => $isUserCurrentGrantedAsProducer,
  156. 'template' => '<a href="{url}">{icon} {label} <span class="pull-right-container">' . $developerOnlineLabel . $countTicketsProducerUnreadLabel . '</span></a>'
  157. ],
  158. // Producteur
  159. ['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  160. ['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  161. ['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  162. [
  163. 'label' => 'Produits',
  164. 'icon' => 'clone',
  165. 'url' => ['/product/index'],
  166. 'visible' => $isUserCurrentGrantedAsProducer,
  167. 'active' => Yii::$app->controller->id == 'product' || Yii::$app->controller->id == 'product-category',
  168. 'items' => [
  169. ['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  170. ['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  171. ['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $isUserCurrentGrantedAsProducer && $featureChecker->isEnabled(Feature::ALIAS_PRODUCT_PRICE_IMPORT)],
  172. ]
  173. ],
  174. ['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'point-sale'],
  175. [
  176. 'label' => 'Utilisateurs',
  177. 'icon' => 'users',
  178. 'url' => ['/user/index'],
  179. 'items' => [
  180. ['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  181. [
  182. 'label' => 'Cagnotte',
  183. 'icon' => 'euro',
  184. 'url' => ['/credit/index'],
  185. 'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>',
  186. 'visible' => $isUserCurrentGrantedAsProducer && $producerModule->getConfig('credit')
  187. ],
  188. ['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  189. ['label' => 'Import', 'icon' => 'upload', 'url' => ['/user-import/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  190. ],
  191. ],
  192. ['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'subscription'],
  193. [
  194. 'label' => 'Communiquer',
  195. 'icon' => 'bullhorn',
  196. 'url' => ['/communicate/email'],
  197. 'visible' => $isUserCurrentGrantedAsProducer,
  198. 'items' => [
  199. ['label' => 'Email', 'icon' => 'paper-plane', 'url' => ['/communicate/email'], 'visible' => $isUserCurrentGrantedAsProducer],
  200. ['label' => 'Papier', 'icon' => 'print', 'url' => ['/communicate/paper'], 'visible' => $isUserCurrentGrantedAsProducer],
  201. ]
  202. ],
  203. [
  204. 'label' => 'Documents',
  205. 'icon' => 'clone',
  206. 'url' => ['/delivery-note/index'],
  207. 'items' => [
  208. ['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  209. ['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  210. ['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  211. ],
  212. ],
  213. [
  214. 'label' => 'Statistiques',
  215. 'icon' => 'line-chart',
  216. 'url' => ['/stats/index'],
  217. 'items' => [
  218. ['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  219. ['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  220. ['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $isUserCurrentGrantedAsProducer],
  221. ],
  222. ],
  223. ['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $isUserCurrentGrantedAsProducer],
  224. ['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  225. ['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  226. [
  227. 'label' => 'Mes factures',
  228. 'icon' => 'clone',
  229. 'url' => ['/producer-invoice/index'],
  230. 'visible' => $isUserCurrentGrantedAsProducer && Yii::$app->parameterBag->get('dolibarrApiKey'),
  231. 'active' => Yii::$app->controller->id == 'producer-invoice',
  232. 'template' => '<a href="{url}">{icon} {label}' . $countProducerInvoicesUnpaidLabel . '</a>'
  233. ],
  234. ['label' => 'Tarifs & modules', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $isUserCurrentGrantedAsProducer],
  235. [
  236. 'label' => 'Développement',
  237. 'icon' => 'code',
  238. 'url' => ['/development/index'],
  239. 'visible' => $isUserCurrentGrantedAsProducer,
  240. 'active' => Yii::$app->controller->id == 'development',
  241. 'template' => '<a href="{url}">{icon} {label}' . $versionOpendistribLabel . '</a>'
  242. ],
  243. //['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  244. //['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  245. //['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  246. //['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  247. //['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()],
  248. ],
  249. ]
  250. ) ?>
  251. </section>
  252. </aside>