page.list.client.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. global $myUser,$myFirm,$conf;
  3. if(!$myUser->can('client','read') && !$myUser->can('client_sheet','read',0,array('contains'=>true)))
  4. throw new Exception("Permission non accordée");
  5. require_once(__DIR__.SLASH.'Client.class.php');
  6. $filters = array();
  7. Plugin::callHook('client_filter',array(&$filters));
  8. //Colonnes possibles pour la table
  9. $columns = array();
  10. Plugin::callHook('client_search_view',array(&$columns));
  11. //Filtres && colonne tableau en fonction des champs dynamiques
  12. if($myFirm->has_plugin('fr.core.dynamicform') || ($myFirm->id==-1 && Plugin::is_active('fr.core.dynamicform')) ){
  13. Plugin::need('dynamicform/DynamicForm');
  14. $options = array();
  15. if(!empty($_['firm']) && is_numeric($_['firm'])) $options['firm'] = $_['firm'];
  16. //Récuperation des champs custom
  17. $fields = Dynamicform::list('client-sheet-custom',$options);
  18. //Ajout des champs custom en filtres
  19. $filters = array_merge($filters,Dynamicform::get_filters($fields));
  20. //Ajout des champs custom en colonnes dynamiques
  21. $columns = array_merge($columns,Dynamicform::get_dynamic_columns($fields));
  22. }
  23. ?>
  24. <div class="row">
  25. <div class="col-md-12">
  26. <div class="d-flex my-2 w-100">
  27. <h4 class="d-inline-block my-auto mx-0 text-uppercase">Liste des <?php echo $conf->get('client_label_plural'); ?></h4>
  28. <div class="text-left ml-3 d-inline-block noPrint">
  29. <div onclick="window.print();" class="btn btn-info rounded-0 btn-squarred noPrint" title="Imprimer la page"><i class="fas fa-print"></i></div>
  30. <div onclick="client_client_search({exportMode:true,keepChecked:true});" id="export-clients-btn" class="btn btn-info rounded-0 btn-squarred ml-1 noPrint btn-export" title="Exporter tous les résultats recherché"><i class="fas fa-file-export"></i></div>
  31. <?php Plugin::callHook('client_buttons'); ?>
  32. </div>
  33. <div class="my-auto ml-auto mr-0 noPrint">
  34. <?php if($myUser->can('client', 'edit')) : ?>
  35. <a href="index.php?module=client&page=sheet.client" class="btn btn-success right"><i class="fas fa-plus"></i> Ajouter</a>
  36. <?php endif; ?>
  37. </div>
  38. </div>
  39. <div class="clear noPrint"></div>
  40. </div>
  41. <div class="col-md-8 noPrint search-container">
  42. <select id="filters" <?php echo $myUser->connected()?'data-slug="client-search"':''; ?> data-global-shortcut="#clients-shortcuts" data-user-shortcut="#clients-shortcuts" data-type="filter" data-label="Recherche" data-autosearch="false" data-function="client_client_search">
  43. <?php foreach ($filters as $filter): echo $filter; endforeach; ?>
  44. </select>
  45. <!-- bouttons de recherche rapide pré-enregistrées -->
  46. <ul id="clients-shortcuts" class="list-unstyled p-0 m-0 mb-2">
  47. <li class="hidden d-inline-block">
  48. <div class="py-0 btn btn-small btn-link" onclick="$('#filters').data('componentObject').filter_search_execute('{{uid}}');">
  49. <i class="fas fa-search"></i> {{label}}
  50. </div>
  51. </li>
  52. </ul>
  53. </div>
  54. <div class="col-md-4">
  55. </div>
  56. </div>
  57. <h5 class="results-count"><span></span> Résultat(s)
  58. <!-- selection mutliples lignes par checkbox -->
  59. <div class="btn-group btn-checkbox-action" data-count="0">
  60. <button type="button" class="btn btn-small btn-light dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  61. <span class="count font-weight-bold"></span> Selectionnés
  62. </button>
  63. <div class="dropdown-menu">
  64. <?php echo Plugin::callHook('client_list_action',array());
  65. ?>
  66. </div>
  67. </div>
  68. </h5>
  69. <div class="row">
  70. <!-- search results -->
  71. <div class="col-xl-12">
  72. <table id="clients"
  73. data-type="search-table"
  74. data-slug="client-search-table"
  75. data-entity-search="client_client_search"
  76. data-checkbox-action=".btn-checkbox-action"
  77. class="table table-striped table-clients"
  78. >
  79. <thead>
  80. <tr>
  81. <?php foreach($columns as $row): echo $row['head']; endforeach; ?>
  82. <th></th>
  83. </tr>
  84. </thead>
  85. <tbody>
  86. <tr data-id="{{id}}" class="hidden client-state-{{state}}">
  87. <?php foreach($columns as $row): echo $row['body']; endforeach; ?>
  88. <td class="align-middle text-right">
  89. <div class="btn-group btn-group-sm" role="group">
  90. <a class="btn text-info noPrint" title="Consulter le client" href="index.php?module=client&page=sheet.client&id={{id}}<?php echo isset($_['embedded'])?'&embedded':'' ?>"><i class="<?php echo $myUser->can('client','edit')?'fas fa-pencil-alt':'fas fa-eye'; ?>"></i></a>
  91. {{#deletable}}
  92. <div class="btn text-danger noPrint" title="Supprimer le client" onclick="client_client_delete(this);">
  93. <i class="far fa-trash-alt"></i>
  94. </div>
  95. {{/deletable}}
  96. </div>
  97. </td>
  98. </tr>
  99. </tbody>
  100. </table><br>
  101. <!-- Pagination (data-range définit le nombre de pages max affichées avant et après la page courante) -->
  102. <ul class="pagination justify-content-center noPrint" data-range="5">
  103. <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');client_client_search({keepChecked:true});">
  104. <span class="page-link">{{label}}</span>
  105. </li>
  106. </ul>
  107. </div>
  108. </div>