tab.home.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. global $myUser,$_,$conf,$myFirm;
  3. if(!$myUser->can('client','read') && $_['id']!=0 && !$myUser->can('client_sheet','read',$_['id'])) throw new Exception("Permission non accordée sur cette fiche");
  4. require_once(__DIR__.SLASH.'Client.class.php');
  5. $client = Client::provide();
  6. $clientType = $conf->get('client_type');
  7. //hook champs de fiche client
  8. Plugin::callHook('client_sheet',array(&$sheet,$client));
  9. $index = 1;
  10. $moreFields = array();
  11. $maxSheetFields = !empty($conf->get('client_sheet_max_field')) ? $conf->get('client_sheet_max_field') : 6;
  12. $sheetOptions = array();
  13. Plugin::callHook('client_sheet_option',array(&$sheetOptions));
  14. ?>
  15. <div id="client-form" class="client-form <?php if($conf->get('client_enable_map')) echo 'client-form-map' ?>" data-action="client_client_save" data-id="<?php echo $client->id; ?>">
  16. <div class="client-map">
  17. <div class="gmap_canvas">
  18. <iframe width="430" height="500" id="gmap_canvas" src="" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
  19. </div>
  20. </div>
  21. <div class="client-info">
  22. <div class="client-thumbnail" title="Editer le logo" style="background-image:url(action.php?action=client_assets_load&type=logo&client=<?php echo $client->id; ?>)"></div>
  23. <?php if(count($sheetOptions) > 0): ?>
  24. <div class="dropdown btn-options btn-delete-client">
  25. <div class="btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  26. <i class="fas fa-ellipsis-v text-muted"></i>
  27. </div>
  28. <div class="dropdown-menu py-1" aria-labelledby="dropdownMenuButton">
  29. <?php
  30. foreach($sheetOptions as $sheetOption) echo $sheetOption;
  31. ?>
  32. </div>
  33. </div>
  34. <?php endif; ?>
  35. <?php $client->type = empty($client->type) ? 'firm' : $client->type; ?>
  36. <label>Type</label>
  37. <div class="type-choice">
  38. <?php foreach(Client::types() as $slug=>$type): ?>
  39. <label>
  40. <input type="radio" onclick="client_type_change()" data-type="data-client-type" <?php echo ($client->type==$slug?'checked="checked"':'') ?> name="type" value="<?php echo $slug ?>"> <?php echo $type['label'] ?>
  41. </label>
  42. <?php endforeach; ?>
  43. </div>
  44. <?php
  45. $types = FieldType::available();
  46. $fields = FieldType::toForm($sheet);
  47. foreach($fields as $key=>$field): ?>
  48. <span class="<?php echo isset($field['data']['block-class'])?$field['data']['block-class']:'';?>">
  49. <?php echo $field['label']; ?>
  50. <?php echo isset($field['data']['before'])?$field['data']['before']:''; ?>
  51. <?php echo $field['input']; ?>
  52. <?php echo isset($field['data']['after'])?$field['data']['after']:''; ?>
  53. </span>
  54. <?php endforeach;
  55. ?>
  56. <?php if(!empty($moreFields)): ?>
  57. <section id="more-fields-container" class="more-fields-container hidden">
  58. <?php foreach ($moreFields as $field)
  59. echo $field; ?>
  60. </section>
  61. <a class="btn btn-link w-100 text-center text-muted btn-more-fields pt-1" title="Afficher plus de champs" id="btn-more-fields" onclick="client_toggle_more_fields(this);"><i class="position-relative fas fa-chevron-down"></i></a>
  62. <?php endif; ?>
  63. <?php
  64. global $myFirm;
  65. if($myFirm->has_plugin('fr.core.dynamicform')){
  66. Plugin::need('dynamicform/DynamicForm');
  67. ?>
  68. <div class="client-dynamic-fields">
  69. <?php echo Dynamicform::show('client-sheet-custom',array(
  70. 'scope'=>'client',
  71. 'uid'=>$client->id
  72. ));
  73. ?></div><?php
  74. }
  75. ?>
  76. <div onclick="client_client_save();" class="btn btn-info w-100 text-uppercase editable-only">
  77. <i class="fas fa-check"></i> Enregistrer
  78. </div>
  79. </div>
  80. <div class="clear"></div>
  81. </div>
  82. <?php if($myUser->can('client_history','read')): ?>
  83. <div class="client-history">
  84. <h4 class="d-inline-block">Historique</h4>
  85. <div class="text-left ml-3 d-inline-block noPrint text-muted">
  86. <span onclick="window.print();" class="ml-1 pointer" title="Imprimer la page"><i class="fas fa-print"></i></span>
  87. <span onclick="client_core_history_search(null,true);" id="export-clients-btn" class="ml-1 pointer" title="Exporter les résultats"><i class="fas fa-file-export"></i></span>
  88. </div>
  89. <div class="row">
  90. <div class="col-md-12">
  91. <textarea data-type="wysiwyg" id="history-comment"></textarea>
  92. <div class="btn btn-success mb-2" onclick="client_core_history_save();"><i class="fas fa-check"></i> Enregistrer</div>
  93. <select id="client-history-filters" data-type="filter" data-label="Recherche" data-function="client_core_history_search">
  94. <option value="comment" data-filter-type="text">Libellé</option>
  95. <option value="created" data-filter-type="date">Date</option>
  96. <option value="creator" data-filter-type="user">Auteur</option>
  97. </select>
  98. </div>
  99. </div>
  100. <div class="row">
  101. <!-- search results -->
  102. <div class="col-xl-12 client-history">
  103. <ul id="historys" data-entity-search="client_core_history_search">
  104. <li class="hidden item-line" data-id="{{id}}">
  105. <div class="d-inline-block client-history-date">
  106. {{created.dayShortName}}
  107. <i class="far fa-calendar"><span>{{created.day}}</span></i>
  108. <small>{{created.monthName}}</small>
  109. </div>
  110. <div class="d-inline-block client-history-content">
  111. <div class="w-100 text-right client-history-author">
  112. <img src="action.php?action=core_account_avatar_download&amp;user={{creator.login}}&amp;extension=jpg" class="avatar-mini avatar-rounded avatar-login" title="{{creator.fullName}}">
  113. <small>{{created.time}}</small>
  114. </div>
  115. {{{comment}}}
  116. {{#editable}}
  117. <ul class="client-history-options">
  118. <li><i class="fas fa-pen" onclick="client_history_edit(this)"></i></li>
  119. <li><i class="fas fa-trash" onclick="client_core_history_delete(this)"></i></li>
  120. </ul>
  121. {{/editable}}
  122. </div>
  123. </li>
  124. </ul>
  125. <br>
  126. <!-- Pagination (data-range définit le nombre de pages max affichées avant et après la page courante) -->
  127. <ul class="pagination justify-content-center" data-range="5">
  128. <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');client_core_history_search();">
  129. <span class="page-link">{{label}}</span>
  130. </li>
  131. </ul>
  132. </div>
  133. </div>
  134. </div>
  135. <?php endif; ?>
  136. <!-- Modal -->
  137. <div class="modal fade" id="client-internet-modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  138. <div class="modal-dialog modal-xl">
  139. <div class="modal-content">
  140. <div class="modal-header">
  141. <h5 class="modal-title">Recherche du client sur le net</h5><div class="modal-preloader" ><i></i></div>
  142. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  143. <span aria-hidden="true">&times;</span>
  144. </button>
  145. </div>
  146. <div class="modal-body">
  147. <ul class="list-group choices">
  148. <li class="list-group-item pointer hidden" onclick="client_api_load(this);">
  149. <h5 class="font-weight-bold">{{label}}</h5>
  150. {{#job}}<div class="text-muted"><i class="fas fa-atom"></i> {{job}}</div>{{/job}}
  151. {{#street}}<div class="text-dark"><i class="fas fa-map-marker-alt"></i> {{street}} {{city}} ({{zip}})</div>{{/street}}
  152. {{#size}}<div class="text-muted"><i class="fas fa-sitemap"></i> {{size}} ~ {{employees}} employé</div>{{/size}}
  153. </li>
  154. </ul>
  155. </div>
  156. <div class="modal-footer">
  157. <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
  158. </div>
  159. </div>
  160. </div>
  161. </div>