page.sheet.workflow.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. User::check_access('workflow','read');
  3. require_once(__DIR__.SLASH.'Workflow.class.php');
  4. require_once(__DIR__.SLASH.'WorkflowEvent.class.php');
  5. require_once(__DIR__.SLASH.'WorkflowEffect.class.php');
  6. $workflow = Workflow::provide();
  7. global $conf;
  8. if(!$workflow) throw new Exception("Ce workflow n'existe pas ou a été supprimé");
  9. ?>
  10. <div class="workflow">
  11. <div id="workflow-form" class="row workflow-form" data-action="workflow_workflow_save" data-id="<?php echo $workflow->id; ?>">
  12. <div class="col-md-12">
  13. <div class="row">
  14. <div class="col-md-9">
  15. <h3>Workflow</h3>
  16. </div>
  17. <div class="col-md-3 text-right">
  18. <a class="btn px-1 visible-on-update" title="Historique" data-scope="workflow" data-uid="<?php echo $workflow->id; ?>" data-type="history"><i class="far fa-comment-dots"></i></a>
  19. <a href="index.php?module=workflow" class="btn btn-dark btn-small mr-1">Retour</a>
  20. <div onclick="workflow_workflow_save();" class="btn btn-success btn-small"><i class="fas fa-check"></i> Enregistrer</div>
  21. </div>
  22. </div>
  23. <div class="row">
  24. <div class="col-md-7">
  25. <!-- Nom, couleur, icone du workflow -->
  26. <div class="input-group">
  27. <input id="icon" name="icon" data-type="icon" class="form-control input-group-prepend" placeholder="" value="<?php echo $workflow->icon; ?>" type="text">
  28. <input id="label" name="label" class="form-control" placeholder="Libellé" value="<?php echo $workflow->label; ?>" type="text">
  29. <input id="color" name="color" data-type="color" title="Couleur" class="form-control" placeholder="" value="<?php echo $workflow->color; ?>" type="text">
  30. </div>
  31. <!-- Type de workflow -->
  32. <div class="input-group mt-1">
  33. <div class="input-group-prepend">
  34. <div class="input-group-text">Type</div>
  35. </div>
  36. <select id="type" name="label" class="form-control create-only" onchange="workflow_workflow_type_change()">
  37. <?php foreach(Workflow::types() as $slug=>$type):
  38. if($slug == Workflow::TYPE_ALL) continue;
  39. ?>
  40. <option <?php echo $slug==$workflow->type?'selected="selected"':''; ?> value="<?php echo $slug; ?>">
  41. <?php echo $type['label']; ?>
  42. </option>
  43. <?php endforeach; ?>
  44. </select>
  45. </div>
  46. <!-- Entité de workflow -->
  47. <div class="input-group mt-1">
  48. <div class="input-group-prepend entity-group">
  49. <div class="input-group-text">Entité</div>
  50. </div>
  51. <select id="entity" name="label" class="form-control entity-group create-only" >
  52. <option value="">-</option>
  53. <?php foreach(WorkflowEvent::events(null,Workflow::TYPE_ENTITY) as $event): ?>
  54. <option <?php echo $event['entity']['slug']==$workflow->entity?'selected="selected"':''; ?> value="<?php echo $event['entity']['slug']; ?>">
  55. <?php echo $event['entity']['label']; ?>
  56. </option>
  57. <?php endforeach; ?>
  58. </select>
  59. </div>
  60. </div>
  61. <div class="col-md-5">
  62. <!-- Evenements -->
  63. <div class="workflow-event-bloc visible-on-update">
  64. <div id="workflow-event-form" data-action="workflow_workflow_event_save" data-id="">
  65. <div class="input-group input-group-sm">
  66. <div class="input-group-prepend">
  67. <div class="input-group-text">
  68. Lancer le workflow
  69. </div>
  70. </div>
  71. <select id="event" name="label" class="form-control" onchange="workflow_workflow_event_save()"></select>
  72. </div>
  73. </div>
  74. <ul id="workflow-events" class="table table-striped workflow-events" data-entity-search="workflow_event_search">
  75. <li data-id="{{id}}" data-slug="{{slug}}" class="hidden">
  76. {{label}}
  77. <div class="right">
  78. <i title="Supprimer l'événement" onclick="workflow_workflow_event_delete(this);" class="far fa-trash-alt text-danger mr-1 pointer"></i>
  79. <i title="Executer le workflow" onclick="workflow_workflow_run(this);" class="fas fa-cog pointer text-muted"></i>
  80. </div>
  81. </li>
  82. </ul>
  83. </div>
  84. </div>
  85. </div>
  86. <hr>
  87. <div class="row visible-on-update">
  88. <!-- causes -->
  89. <div class="col-md-7 workflow-causes">
  90. <h6>CAUSES</h6>
  91. <select id="cause-filters-template" class="hidden" data-only-advanced="true" data-default='{{enabled}}'>{{{filters}}}</select>
  92. </div>
  93. <!-- effets -->
  94. <div class="col-md-5 workflow-effects">
  95. <h6>EFFETS</h6>
  96. <table id="workflow-effects" class="table table-striped " data-entity-search="workflow_cause_effect_search">
  97. <thead>
  98. <tr id="workflow-effect-form" data-action="workflow_workflow_effect_save" data-id="">
  99. <th colspan="2">Ajouter un effet :
  100. <select data-type="dropdown-select" class="d-inline-block" id="effect-type">
  101. <?php
  102. foreach(WorkflowEffect::types() as $effect): ?>
  103. <option selected="selected" value="<?php echo $effect::manifest('slug'); ?>" style="background-color:#333;color:#fff;" data-icon="<?php echo $effect::manifest('icon'); ?>"><?php echo $effect::manifest('label'); ?></option>
  104. <?php endforeach; ?>
  105. </select>
  106. <div onclick="workflow_workflow_effect_save();" class="btn btn-success btn-small right"><i class="fas fa-plus"></i></div>
  107. <div class="clear"></div>
  108. </th>
  109. </tr>
  110. </thead>
  111. <tbody>
  112. <tr data-id="{{id}}" data-slug="{{type.slug}}" class="hidden">
  113. <td class="align-middle"><i class="{{type.icon}}"></i> {{type.label}}
  114. <div class="btn-group btn-group-sm right" role="group">
  115. <div class="btn btn-edit" title="Éditer workflow_effect" onclick="workflow_workflow_effect_edit(this);"><i class="fas fa-pencil-alt text-muted"></i></div>
  116. <div class="btn" title="Déplacer"><i class="fas fa-arrows-alt text-muted"></i></div>
  117. <div class="btn text-danger" title="Supprimer workflow_effect" onclick="workflow_workflow_effect_delete(this);"><i class="far fa-trash-alt"></i></div>
  118. </div>
  119. <div class="workflow-effect-form">
  120. {{{form}}}
  121. </div>
  122. </td>
  123. </tr>
  124. </tbody>
  125. </table>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <!-- Les filtres custom de causes sont contenus ici -->
  132. <div class="workflow-cause-filters"></div>