page.sheet.dynamic.form.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. global $myUser;
  3. User::check_access('dynamicform','read');
  4. require_once(__DIR__.SLASH.'DynamicForm.class.php');
  5. $dynamicform = DynamicForm::provide();
  6. $defaultType = base64_encode(json_encode(FieldType::available('text')));
  7. ?>
  8. <div class="dynamicform">
  9. <div id="dynamic-form-form" class="row dynamic-form-form" data-default-type="<?php echo $defaultType; ?>" data-action="dynamicform_form_save" data-id="<?php echo $dynamicform->id; ?>">
  10. <div class="col-md-12">
  11. <h3>Formulaire</h3>
  12. <div class="row">
  13. <div class="input-group col-md-6">
  14. <div class="input-group-text input-group-prepend">Libellé</div>
  15. <input id="label" name="label" class="form-control" placeholder="" value="<?php echo $dynamicform->label; ?>" type="text">
  16. <input id="color" name="color" data-type="color" title="Couleur" class="form-control" placeholder="" value="<?php echo $dynamicform->color; ?>" type="text">
  17. <input id="icon" name="icon" data-type="icon" class="form-control" placeholder="" value="<?php echo $dynamicform->icon; ?>" type="text">
  18. </div>
  19. <div class="input-group col-md-6">
  20. <div class="input-group-text input-group-prepend"><input id="allFirm" name="allFirm" <?php if(!$myUser->can('dynamicForm','configure')) echo 'readonly="readonly"'; ?> type="checkbox" data-type="checkbox" <?php echo $dynamicform->firm == 0 ? 'checked="checked"': ''; ?> >Disponible pour tout les établissements</div>
  21. <div class="input-group-text input-group-prepend ml-1">Slug</div>
  22. <input id="slug" name="slug" <?php if(!$myUser->can('dynamicForm','configure')) echo 'readonly="readonly"'; ?> class="form-control" placeholder="" value="<?php echo $dynamicform->slug; ?>" type="text">
  23. <div onclick="dynamicform_form_save();" class="btn btn-success"><i class="fas fa-check"></i> Enregistrer</div>
  24. </div>
  25. </div>
  26. <br/>
  27. </div>
  28. </div>
  29. <div id="form-layout" class="form-layout" >
  30. <template id="layout-row">
  31. <div class="row">
  32. <div class="col-md column">
  33. <ul class="fields"></ul>
  34. <div class="btn btn-primary btn-field-add shadow-sm p-2 pointer d-inline-block w-100"><i class="fas fa-plus"></i> Ajouter un champ</div>
  35. <ul class="layout-column-menu">
  36. <li class="btn-layout btn-column-add" title="Ajouter une colonne"><i class="fas fa-plus"></i></li>
  37. <li class="btn-layout btn-column-remove" title="Supprimer une colonne"><i class="fas fa-times"></i></li>
  38. </ul>
  39. </div>
  40. <ul class="layout-row-menu">
  41. <li class="btn-layout btn-row-add" title="Ajouter une ligne"><i class="fas fa-plus"></i></li>
  42. <li class="btn-layout btn-row-remove" title="Supprimer une ligne"><i class="fas fa-times"></i></li>
  43. </ul>
  44. </div>
  45. </template>
  46. <template id="field-template">
  47. <li
  48. data-id="{{id}}"
  49. data-label="{{label}}"
  50. data-type="{{type.slug}}"
  51. data-description="{{description}}"
  52. data-mandatory="{{mandatory}}"
  53. data-readonly="{{readonly}}"
  54. data-default="{{default}}"
  55. data-slug="{{slug}}"
  56. data-meta="{{meta}}"
  57. class="shadow-sm bg-white p-2 mb-2 field">
  58. <span class="font-weight-bold"><i title="Type {{type.label}}" class="{{type.icon}}"></i> {{label}}</span>
  59. <small class="text-muted">{{description}}</small>
  60. <span class="mandatory badge badge-pill badge-warning"><i class="fas fa-exclamation-triangle"></i> Obligatoire</span>
  61. <span class="readonly badge badge-pill badge-light"><i class="fas fa-eye"></i> Lecture seule</span>
  62. {{#default}}<span class="badge">Valeur défaut : {{default}}</span>{{/default}}
  63. <span class="right">
  64. <div class="btn-group btn-group-sm" role="group">
  65. <div class="btn btn-field-edit text-muted my-0 py-0 pointer" title="Éditer ce champ" href=""><i class="fas fa-ellipsis-v"></i></div>
  66. <div class="btn btn-field-move text-muted my-0 py-0" title="Déplacer ce champ"><i class="fas fa-arrows-alt"></i></div>
  67. <div class="btn btn-field-remove text-danger my-0 py-0" title="Supprimer ce champ"><i class="far fa-trash-alt"></i></div>
  68. </div>
  69. </span>
  70. <div class="clear"></div>
  71. </li>
  72. </template>
  73. </div>
  74. </div>
  75. <div class="dynamic-field-panel bg-white shadow p-3 fold" id="dynamic-field-form">
  76. <h5 class="text-muted"><i class="fas fa-bars"></i> Propriétés <i class="far fa-times-circle right pointer" onclick="$('.dynamic-field-panel').addClass('fold');"></i></h5>
  77. <div class="dynamic-field-main">
  78. <div class="input-group mb-2">
  79. <div class="input-group-prepend">
  80. <label class="input-group-text" for="label">Libellé</label>
  81. </div>
  82. <input id="label" name="label" class="form-control label" placeholder="" value="" type="text">
  83. </div>
  84. <div class="input-group mb-2">
  85. <div class="input-group-prepend">
  86. <label class="input-group-text" for="type">Type</label>
  87. </div>
  88. <select class="form-control select-control" name="type" id="type" onchange="dynamicform_fieldtype_change();">
  89. <?php
  90. $availableTypes = array();
  91. foreach(FieldType::available() as $key=>$type)
  92. $availableTypes[$key] = $type;
  93. uasort($availableTypes, function($a,$b){
  94. return $a->label > $b->label;
  95. });
  96. foreach($availableTypes as $type):
  97. ?>
  98. <option data-options="<?php echo base64_encode(json_encode($type)); ?>" value="<?php echo $type->slug; ?>"><?php echo $type->label; ?></option>
  99. <?php endforeach; ?>
  100. </select>
  101. </div>
  102. <label for="mandatory">
  103. <input type="checkbox" name="mandatory" id="mandatory" data-type="checkbox"> Obligatoire</label>
  104. <label for="readonly">
  105. <input type="checkbox" name="readonly" id="readonly" data-type="checkbox"> Lecture seule</label>
  106. <br/>
  107. <div class="input-group mb-2">
  108. <div class="input-group-prepend">
  109. <label for="default" class="input-group-text">Valeur par défaut</label>
  110. </div>
  111. <input id="default" name="default" class="form-control" placeholder="" value="" type="text">
  112. </div>
  113. <div class="input-group mb-2">
  114. <div class="input-group-prepend">
  115. <label class="input-group-text" for="description">Description</label>
  116. </div>
  117. <input id="description" name="description" class="form-control" placeholder="" value="" type="text">
  118. </div>
  119. <div class="btn btn-link align-center w-100 mt-2" onclick="$(this).next('.advanced').toggleClass('hidden')">PARAMETRES AVANCÉS</div>
  120. <div class="advanced hidden">
  121. <div class="input-group mb-2">
  122. <div class="input-group-prepend">
  123. <label class="input-group-text" for="slug">Slug</label>
  124. </div>
  125. <input id="slug" name="slug" class="form-control" <?php if(!$myUser->can('dynamicForm','configure')) echo 'readonly="readonly"'; ?> placeholder="" value="" type="text">
  126. </div>
  127. <label class="font-weight-bold mt-2">OPTION DE RECHERCHES</label>
  128. <label><input type="checkbox" data-type="checkbox" id="show-filter">Afficher dans les filtres de recherche</label><br/>
  129. <label class="font-weight-bold text-muted mt-2">Désactiver les opérateurs de recherche suivants</label>
  130. <div id="deleted-operators">
  131. <?php
  132. global $databases_credentials;
  133. $connector = $databases_credentials['local']['connector'];
  134. foreach($connector::operators() as $uid=>$operator): ?>
  135. <label><input type="checkbox" data-type="checkbox" value="<?php echo $uid ?>"><?php echo $operator["label"].' ('.$uid.')' ?></label><br/>
  136. <?php endforeach; ?>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="dynamic-field-settings"></div>
  141. <div onclick="dynamicform_field_save();" class="btn btn-success w-100 mt-2"><i class="fas fa-check"></i> Enregistrer</div>
  142. </div>