page.home.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. global $myUser,$conf;
  3. require_once(__DIR__.SLASH.'Dashboard.class.php');
  4. require_once(__DIR__.SLASH.'DashboardWidget.class.php');
  5. $mandatoryDashboard = Dashboard::load(array('mandatory'=>'1'));
  6. $readonly = false;
  7. if($mandatoryDashboard){
  8. $readonly = !$myUser->can('dashboard','configure');
  9. $dashboards = array($mandatoryDashboard);
  10. }else{
  11. $dashboards = Dashboard::loadAll(array('user'=>$myUser->login));
  12. } ?>
  13. <div class="dashboard-container <?php echo $readonly?'readonly':'' ?>" style="<?php echo count($dashboards)==1 ? 'padding-left: 0px;' : ''; ?>">
  14. <?php if($myUser->connected()): ?>
  15. <ul id="dashboard-view" class="<?php echo count($dashboards)>1?'':'hidden' ?>" >
  16. <li class="dashboard-view-title">DASH</li>
  17. <?php
  18. if(count($dashboards)==0){
  19. $defaultDash = Dashboard::provide();
  20. $defaultDash->user = $myUser->login;
  21. $defaultDash->label = 'Général';
  22. $defaultDash->icon = 'far fa-bookmark';
  23. $defaultDash->default = true;
  24. $defaultDash->save();
  25. $dashboards[] = $defaultDash;
  26. foreach(array('profile','clock','log') as $i=>$widget){
  27. $item = new DashboardWidget();
  28. $item->model = $widget;
  29. $item->position = $i;
  30. $item->dashboard = $defaultDash->id;
  31. $item->save();
  32. }
  33. }
  34. foreach($dashboards as $dashboard): ?>
  35. <li class="dashboard-item" <?php echo $dashboard->default?'data-selected="1"':''; ?> data-id="<?php echo $dashboard->id; ?>" title="<?php echo $dashboard->label; ?>"><span><?php echo $dashboard->label; ?></span><div><i class="<?php echo $dashboard->icon; ?>"></i></div></li>
  36. <?php endforeach; ?>
  37. </ul>
  38. <div class="clear"></div>
  39. <ul class="dashboard-widget-menu">
  40. <li data-toggle="modal" data-target="#addWidgetModal">
  41. <div title="Ajouter un widget"><i class="fas fa-plus"></i> <span>WIDGET</span></div>
  42. </li>
  43. </ul>
  44. <div class="row" id="dashboard">
  45. <!-- MODEL WIDGET -->
  46. <div class="widget hidden" data-width="4" data-id="" >
  47. <div class="widget_window">
  48. <div class="widget_header pl-2">
  49. <i class="fa fa-caret"></i> <span></span>
  50. <ul class="widget_options"></ul>
  51. </div>
  52. <div class="widget_content"></div>
  53. <div class="widget_footer"></div>
  54. <div class="widget_resize"></div>
  55. </div>
  56. </div>
  57. <!-- Add wiget modal -->
  58. <div class="modal fade" id="addWidgetModal" tabindex="-1" role="dialog" aria-labelledby="widget-add-label" aria-hidden="true">
  59. <div class="modal-dialog modal-lg" role="document">
  60. <div class="modal-content">
  61. <div class="modal-header">
  62. <h5 class="modal-title" id="widget-add-label">Ajout d'un widget</h5>
  63. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  64. <span aria-hidden="true">&times;</span>
  65. </button>
  66. </div>
  67. <div class="modal-body">
  68. <div class="row">
  69. <div class="col-md-4">
  70. <?php
  71. $models = array();
  72. Plugin::callHook('widget',array(&$models));
  73. ?>
  74. <select class="form-control" id="widget-list" class="left" size="8">
  75. <option data-description="Sélectionnez le widget que vous souhaitez ajouter" data-width="" data-background="" value="" data-icon="fas fa-plus"> - </option>
  76. <?php
  77. foreach($models as $model): ?>
  78. <option data-description="<?php echo $model->description; ?>" data-width="<?php echo !empty($model->width)?$model->width:1; ?>" data-background="<?php echo $model->background; ?>" data-icon="<?php echo $model->icon; ?>" value="<?php echo $model->model; ?>"><?php echo $model->title; ?></option>
  79. <?php endforeach; ?>
  80. </select>
  81. </div>
  82. <div class="widgetDescription col-md-6">
  83. <h3><i class='fas fa-plus'></i> <span>Sélectionnez un widget</span></h3>
  84. <p>Sélectionnez le widget que vous souhaitez ajouter</p>
  85. <div class="widgetWidth"></div>
  86. <div class='widgetColor'></div>
  87. </div>
  88. </div>
  89. </div>
  90. <div class="modal-footer">
  91. <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
  92. <button type="button" class="btn btn-primary" onclick="dashboard_dashboardwidget_add();"><i class="fas fa-plus"></i> Ajouter</button>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <!-- Configure wiget modal -->
  98. <div class="modal fade" id="configureWidgetModal" tabindex="-1" role="dialog" aria-labelledby="widget-configure-label" aria-hidden="true">
  99. <div class="modal-dialog modal-lg" role="document">
  100. <div class="modal-content">
  101. <div class="modal-header">
  102. <h5 class="modal-title" id="widget-configure-label">Configuration d'un widget</h5>
  103. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  104. <span aria-hidden="true">&times;</span>
  105. </button>
  106. </div>
  107. <div class="modal-body">
  108. <div class="pluginContent">
  109. <!-- Configuration plugin ici -->
  110. </div>
  111. </div>
  112. <div class="modal-footer">
  113. <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
  114. <button type="button" class="btn btn-primary" onclick="dashboard_dashboardwidget_save_configuration();"><i class="fas fa-check"></i> Enregistrer</button>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <?php endif; ?>
  121. </div>