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.

208 satır
14KB

  1. <?php
  2. /**
  3. * Copyright distrib (2018)
  4. *
  5. * contact@opendistrib.net
  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 common\logic\Feature\Feature\Feature;
  39. use common\logic\User\User\Module\UserModule;
  40. $producerModule = $this->getProducerModule();
  41. $userModule = UserModule::getInstance();
  42. $userProducerModule = $this->getUserProducerModule();
  43. $ticketModule = $this->getTicketModule();
  44. $featureChecker = $this->getFeatureModule()->getChecker();
  45. $producer = GlobalParam::getCurrentProducer();
  46. $userCurrent = GlobalParam::getCurrentUser();
  47. $isUserCurrentGrantedAsAdministrator = $userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent);
  48. $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent);
  49. ?>
  50. <aside class="main-sidebar">
  51. <section class="sidebar">
  52. <?php
  53. $producer = GlobalParam::getCurrentProducer();
  54. $newVersionOpendistribLabel = '';
  55. if ($producer && !$producerModule->isUpToDateWithOpendistribVersion($producer)) {
  56. $newVersionOpendistribLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.GlobalParam::getOpendistribVersion().'</small></span>';
  57. }
  58. $countTicketsProducerUnreadLabel = '';
  59. $countTicketsProducerUnread = $ticketModule->countTicketsUnreadByUser($this->getUserCurrent());
  60. if($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) {
  61. $countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>';
  62. }
  63. $countTicketsAdminUnreadLabel = '';
  64. $countTicketsAdminUnread = $ticketModule->countTicketsAdminUnreadByUser($this->getUserCurrent());
  65. if($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) {
  66. $countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>';
  67. }
  68. $sumUserProducerCredits = $userProducerModule->sumUserProducerCredits();
  69. $sumUserProducerCreditsLabel = '';
  70. //$sumUserProducerCreditsLabel = '<span class="pull-right-container"><small class="label pull-right '.($sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red') .'">'.number_format($sumUserProducerCredits, 2).' €</small></span>';
  71. ?>
  72. <?= dmstr\widgets\Menu::widget(
  73. [
  74. 'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
  75. 'items' => [
  76. ['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  77. [
  78. 'label' => 'Support',
  79. 'icon' => 'comments',
  80. 'url' => ['support/index'],
  81. 'visible' => $isUserCurrentGrantedAsProducer,
  82. 'template' => '<a href="{url}">{icon} {label}' . $countTicketsProducerUnreadLabel . '</a>'
  83. ],
  84. ['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  85. ['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  86. ['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  87. [
  88. 'label' => 'Produits',
  89. 'icon' => 'clone',
  90. 'url' => ['/product/index'],
  91. 'visible' => $isUserCurrentGrantedAsProducer,
  92. 'active' => Yii::$app->controller->id == 'product' || Yii::$app->controller->id == 'product-category',
  93. 'items' => [
  94. ['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  95. ['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  96. ['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $isUserCurrentGrantedAsProducer && $featureChecker->isEnabled(Feature::ALIAS_PRODUCT_PRICE_IMPORT)],
  97. ]
  98. ],
  99. ['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'point-sale'],
  100. [
  101. 'label' => 'Utilisateurs',
  102. 'icon' => 'users',
  103. 'url' => ['/user/index'],
  104. 'items' => [
  105. ['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  106. [
  107. 'label' => 'Crédit',
  108. 'icon' => 'euro',
  109. 'url' => ['/credit/index'],
  110. 'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>',
  111. 'visible' => $isUserCurrentGrantedAsProducer && $producerModule->getConfig('credit')
  112. ],
  113. ['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  114. ['label' => 'Import', 'icon' => 'upload', 'url' => ['/user-import/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  115. ],
  116. ],
  117. ['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'subscription'],
  118. ['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  119. [
  120. 'label' => 'Documents',
  121. 'icon' => 'clone',
  122. 'url' => ['/delivery-note/index'],
  123. 'items' => [
  124. ['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  125. ['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  126. ['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  127. ],
  128. ],
  129. [
  130. 'label' => 'Statistiques',
  131. 'icon' => 'line-chart',
  132. 'url' => ['/stats/index'],
  133. 'items' => [
  134. ['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  135. ['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  136. ['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $isUserCurrentGrantedAsProducer],
  137. ],
  138. ],
  139. ['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $isUserCurrentGrantedAsProducer],
  140. ['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $isUserCurrentGrantedAsProducer],
  141. ['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
  142. [
  143. 'label' => 'Mes factures',
  144. 'icon' => 'clone',
  145. 'url' => ['/producer-invoice/index'],
  146. 'visible' => $isUserCurrentGrantedAsProducer && Yii::$app->parameterBag->get('dolibarrApiKey'),
  147. 'active' => Yii::$app->controller->id == 'producer-invoice',
  148. ],
  149. ['label' => 'Tarifs & modules', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $isUserCurrentGrantedAsProducer],
  150. [
  151. 'label' => 'Développement',
  152. 'icon' => 'code',
  153. 'url' => ['/development/index'],
  154. 'visible' => $isUserCurrentGrantedAsProducer,
  155. 'active' => Yii::$app->controller->id == 'development',
  156. 'template' => '<a href="{url}">{icon} {label}' . $newVersionOpendistribLabel . '</a>'
  157. ],
  158. ['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  159. [
  160. 'label' => 'Tickets',
  161. 'icon' => 'comments',
  162. 'url' => ['support-admin/index'],
  163. 'visible' => $isUserCurrentGrantedAsAdministrator,
  164. 'template' => '<a href="{url}">{icon} {label}' . $countTicketsAdminUnreadLabel . '</a>'
  165. ],
  166. ['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  167. [
  168. 'label' => 'Statistiques',
  169. 'icon' => 'line-chart',
  170. 'url' => ['/stats-admin/matomo'],
  171. 'visible' => $isUserCurrentGrantedAsAdministrator,
  172. 'items' => [
  173. ['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  174. ['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  175. ['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  176. ],
  177. ],
  178. ['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)],
  179. ['label' => 'Fonctionnalités', 'icon' => 'flag', 'url' => ['/feature-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  180. ['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  181. ['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  182. ['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  183. //['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  184. //['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  185. //['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $isUserCurrentGrantedAsAdministrator],
  186. ['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()],
  187. ],
  188. ]
  189. ) ?>
  190. </section>
  191. </aside>