page.list.contact.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <?php
  2. global $myFirm,$myUser;
  3. User::check_access('example','read');
  4. require_once(__DIR__.SLASH.'ContactExample.class.php');
  5. $solvabilities = array();
  6. foreach (ContactExample::solvabilities() as $key => $solvability) {
  7. $solvabilities[$key] = $solvability['label'];
  8. }
  9. $orientations = array();
  10. foreach (ContactExample::orientations() as $key => $orientation) {
  11. $orientations[$key] = $orientation['label'];
  12. }
  13. $defaultFilters = filters_default(array(
  14. "jean",
  15. array(
  16. 'birth' => "17/09/1998",
  17. 'join' => 'or'
  18. ),
  19. array(
  20. 'phone:like' => "9754"
  21. )
  22. ));
  23. $filters = array();
  24. $columns = array();
  25. //Filtres && colonne tableau en fonction des champs dynamiques
  26. if($myFirm->has_plugin('fr.core.dynamicform')){
  27. Plugin::need('dynamicform/DynamicForm');
  28. //Récuperation des champs custom
  29. $fields = Dynamicform::list('fiche-example');
  30. //Ajout des champs custom en filtres
  31. $filters = array_merge($filters,Dynamicform::get_filters($fields));
  32. //Ajout des champs custom en colonnes dynamiques
  33. $columns = array_merge($columns,Dynamicform::get_dynamic_columns($fields));
  34. }
  35. ?>
  36. <div class="plugin-example">
  37. <div class="row">
  38. <div class="col-md-12">
  39. <div class="d-flex my-2 w-100">
  40. <h4 class="d-inline-block my-auto mx-0 text-uppercase">Liste des contacts</h4>
  41. <div class="text-left ml-3 d-inline-block noPrint">
  42. <!-- impression de la page courante -->
  43. <div onclick="window.print();" class="btn btn-info rounded-0 btn-squarred" data-tootltip title="Imprimer la page"><i class="fas fa-print"></i></div>
  44. <!-- export classique des résultats -->
  45. <div onclick="example_contact_search(null,true);" id="export-examples-btn" class="btn btn-info rounded-0 btn-squarred ml-1 btn-export" data-tootltip title="Exporter les résultats"><i class="fas fa-file-export"></i></div>
  46. <!-- exports modèles si disponibles -->
  47. <?php if($myUser->can('export', 'read') && $myFirm->has_plugin('fr.core.export')) : ?>
  48. <div class="right mr-2 d-inline-block" data-type="export-model" data-default="xlsx2" data-pre-callback="contact_export_pre_callback" data-post-callback="contact_export_post_callback" data-parameters='<?php echo stripslashes(json_encode(array("plugin"=>"example","dataset"=>"contact-list"))); ?>'>
  49. <div data-tootltip title="Exporter selon modèle" class="btn btn-info rounded-0 btn-squarred ml-2"><i class="far fa-file"></i></div>
  50. </div>
  51. <?php endif; ?>
  52. </div>
  53. <div class="my-auto ml-auto mr-0 noPrint">
  54. <?php if($myUser->can('example', 'edit')) : ?>
  55. <a href="index.php?module=example&page=sheet.contact" title="Ajouter" data-tooltip class="btn btn-success right"><i class="fas fa-plus"></i></a>
  56. <?php endif; ?>
  57. </div>
  58. </div>
  59. <div class="clear noPrint"></div>
  60. </div>
  61. <div class="col-md-12">
  62. <!--
  63. voir filter.component.js pour la documentation
  64. data-default='<?php echo json_encode($defaultFilters); ?>'
  65. -->
  66. <select
  67. id="example_contact-filters"
  68. data-type="filter"
  69. data-function="example_contact_search"
  70. data-slug="contact-search"
  71. data-label="Trouver un contact"
  72. data-global-shortcut="#contact-shortcuts"
  73. data-user-shortcut="#contact-shortcuts"
  74. data-show-url-advanced="false"
  75. data-configure="<?php echo $myUser->can('example','configure') ? 1:0 ?>"
  76. >
  77. <!-- pour une recherche simple, ne pas spécifier d'options dans cette liste -->
  78. <option value="main.label" data-filter-type="text">Libellé</option>
  79. <option value="main.phone" data-filter-type="phone">Téléphone</option>
  80. <option value="main.birth" data-filter-type="date">Date de naissance</option>
  81. <option value="main.hour" data-filter-type="hour">Heure de naissance</option>
  82. <option value="main.firm" data-filter-type="firm">Etablissement</option>
  83. <option value="main.manager" data-filter-type="user">Manager</option>
  84. <option value="main.address" data-filter-type="address">Adresse</option>
  85. <option value="main.properties" data-operator-delete='["in","not in"]' data-filter-type="tag">Tags</option>
  86. <option value="main.vehicle" data-slug="example_contact_vehicle" data-depth="1" data-filter-type="dictionary">Véhicule</option>
  87. <option value="main.handicap" data-slug="example_contact_handicap" data-filter-type="list" data-depth="3" data-multi-level-select="true">Handicaps</option>
  88. <option value="main.solvability" data-filter-type="list" data-values='<?php echo json_encode($solvabilities); ?>' >Solvabilité</option>
  89. <option value="main.orientation" data-filter-source='<?php echo json_encode($orientations); ?>' data-filter-type="choice">Orientation</option>
  90. <option value="main.storyshort" data-filter-type="textarea">Histoire résumée</option>
  91. <option value="main.story" data-filter-type="wysiwyg">Histoire riche</option>
  92. <option value="main.password" data-filter-type="password">Mot de passe</option>
  93. <option value="main.icon" data-filter-type="icon">Icone préférée</option>
  94. <option value="main.available" data-filter-type="boolean">Disponible</option>
  95. <option value="main.childs" data-operator-view='{"in":{"view":"tag"}}' data-filter-type="integer">Nb. Enfants</option>
  96. <option value="main.size" data-filter-type="decimal">Taille</option>
  97. <option value="main.color" data-filter-type="color">Couleur préférée</option>
  98. <option value="main.salary" data-filter-type="price">Salaire brut</option>
  99. <option value="main.website" data-filter-type="url">Site perso</option>
  100. <option value="main.mail" data-filter-type="mail">Email</option>
  101. <option value="main.mobile" data-filter-type="phone">Téléphone portable</option>
  102. <?php foreach($filters as $filter):
  103. echo $filter;
  104. endforeach; ?>
  105. </select>
  106. <!-- Exemple de templates de bouttons de recherche rapide pré-enregistrées -->
  107. <div id="contact-shortcuts" class="p-0 m-0 mb-2">
  108. <h4 class="has-shortcut mb-0 text-uppercase user-select-all">Mes recherches</h4>
  109. <ul class="pl-0 list-unstyled">
  110. <li class="hidden d-inline-block">
  111. <div class="btn btn-small btn-link pl-0" onclick="$('#filters').data('componentObject').filter_search_execute('{{uid}}');"><i class="fas fa-search"></i> {{label}}</div>
  112. </li>
  113. </ul>
  114. </div>
  115. </div>
  116. </div>
  117. <h5 class="results-count my-2"><span></span> Résultat(s)
  118. <!-- bloc de preference de pagination -->
  119. <small class="text-muted right text-muted text-small"><div class="d-inline-block mr-1" data-type="pagination-preference" data-table="#contacts" data-value="20" data-max-item="100"></div></small><div class="clear"></div>
  120. </h5>
  121. <div class="row">
  122. <!-- search results -->
  123. <div class="col-xl-12">
  124. <!-- présentation tableau -->
  125. <table
  126. id="contacts"
  127. class="table table-striped "
  128. data-slug="contact-search-table"
  129. data-entity-search="example_contact_search"
  130. data-column-search="example_contact_search"
  131. >
  132. <thead>
  133. <tr>
  134. <th data-sortable="label">Libellé</th>
  135. <th data-sortable="phone">Téléphone</th>
  136. <th data-available="birth" data-sortable="birth">Date de naissance</th>
  137. <th data-available="hour" data-sortable="hour">Heure de naissance</th>
  138. <th data-sortable="firm">Etablissement</th>
  139. <th data-sortable="manager">Manager</th>
  140. <th data-available="address" data-sortable="address">Adresse</th>
  141. <th data-sortable="properties">Tags</th>
  142. <th data-sortable="vehicle">Véhicule</th>
  143. <th data-available="storyshort" data-sortable="storyshort">Histoire résumée</th>
  144. <th data-available="story" data-sortable="story">Histoire riche</th>
  145. <th data-available="password" data-sortable="password">Mot de passe</th>
  146. <th data-sortable="icon">Icone</th>
  147. <th data-sortable="available">Disponible</th>
  148. <th data-sortable="cv">CV</th>
  149. <th data-sortable="avatar">Avatar</th>
  150. <th data-available="solvability" data-sortable="solvability">Solvabilité</th>
  151. <th data-sortable="handicap">Handicaps</th>
  152. <th data-available="childs" data-sortable="childs">Nb. Enfants</th>
  153. <th data-available="size" data-sortable="size">Taille</th>
  154. <th data-sortable="color">Couleur</th>
  155. <th data-available="salary" data-sortable="salary">Salaire</th>
  156. <th data-sortable="orientation">Orientation</th>
  157. <th data-available="website" data-sortable="website">Site perso</th>
  158. <th data-available="mail" data-sortable="mail">Email</th>
  159. <?php foreach($columns as $row): echo $row['head']; endforeach; ?>
  160. <th data-available="created" data-sortable="created">Horodatage</th>
  161. <th></th>
  162. </tr>
  163. </thead>
  164. <tbody>
  165. <tr data-id="{{id}}" class="hidden item-line">
  166. <td class="align-middle">{{label}}</td>
  167. <td class="align-middle">{{phone}}</td>
  168. <td class="align-middle">{{birth-readable}}</td>
  169. <td class="align-middle">{{hour}}</td>
  170. <td class="align-middle">{{firm.label}}</td>
  171. <td class="align-middle"><img src="{{manager.avatar}}" class="avatar-mini avatar-rounded avatar-login" title="{{manager.fullName}}"> {{manager.fullName}}</td>
  172. <td class="align-middle">{{address}}</td>
  173. <td class="align-middle">
  174. {{#properties}}
  175. <span class="badge badge-secondary">{{.}}</span>
  176. {{/properties}}
  177. </td>
  178. <td class="align-middle">{{vehicle.label}}</td>
  179. <td class="align-middle">{{storyshort}}</td>
  180. <td class="align-middle">{{{story}}}</td>
  181. <td class="align-middle">{{password}}</td>
  182. <td class="align-middle"><i class="{{icon}}"></i> {{icon}}</td>
  183. <td class="align-middle">{{#available}} <i class="fas fa-check text-success"></i> OUI{{/available}}{{^available}}<i class="fas fa-times text-danger"></i> Non{{/available}}</td>
  184. <td class="align-middle">
  185. <ul class="list-group list-group-flush shadow-sm">
  186. {{#cv}}
  187. <li class="list-group-item p-1"><a href="{{url}}">{{label}}</a></li>
  188. {{/cv}}
  189. </ul></td>
  190. <td class="align-middle"><img class="shadow-sm rounded-sm avatar-medium" style="max-width: 100px;height: auto;" src="{{avatar}}"></td>
  191. <td class="align-middle">{{solvability.label}}</td>
  192. <td class="align-middle">
  193. {{#handicaps}}
  194. <span class="badge badge-secondary">{{label}}</span>
  195. {{/handicaps}}
  196. </td>
  197. <td class="align-middle">{{childs}}</td>
  198. <td class="align-middle">{{size}}</td>
  199. <td class="align-middle"><i class="fas fa-dot-circle" style="color:{{color}}"></i> {{color}}</td>
  200. <td class="align-middle">{{salary}}</td>
  201. <td class="align-middle">{{orientation.label}}</td>
  202. <td class="align-middle"><a href="{{website}}">{{website}}</a></td>
  203. <td class="align-middle">{{mail}}</td>
  204. <?php foreach($columns as $row): echo $row['body']; endforeach; ?>
  205. <td><small class="text-muted">Créé le {{created}} par {{creator}} <br/> Modifié le {{updated}} par {{updater}}</small></td>
  206. <td class="align-middle text-right">
  207. <div class="btn-group btn-group-sm" role="group">
  208. <a class="btn text-info" title="Éditer contact" href="index.php?module=example&page=sheet.contact&id={{id}}"><i class="fas fa-pencil-alt"></i></a>
  209. <div class="btn text-danger" title="Supprimer contact" onclick="example_contact_delete(this);"><i class="far fa-trash-alt"></i></div>
  210. </div>
  211. </td>
  212. </tr>
  213. </tbody>
  214. </table>
  215. <br>
  216. <!-- Pagination (data-range définit le nombre de pages max affichées avant et après la page courante) -->
  217. <ul class="pagination justify-content-center" data-range="5">
  218. <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');example_contact_search();">
  219. <span class="page-link">{{label}}</span>
  220. </li>
  221. </ul>
  222. </div>
  223. </div>
  224. </div>