workflow.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  4. * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/admin/workflow.php
  22. * \ingroup company
  23. * \brief Workflows setup page
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. $langs->load("admin");
  28. $langs->load("workflow");
  29. if (! $user->admin) accessforbidden();
  30. $action = GETPOST('action', 'alpha');
  31. /*
  32. * Actions
  33. */
  34. if (preg_match('/set(.*)/',$action,$reg))
  35. {
  36. if (! dolibarr_set_const($db, $reg[1], 1, 'chaine', 0, '', $conf->entity) > 0)
  37. {
  38. dol_print_error($db);
  39. }
  40. }
  41. if (preg_match('/del(.*)/',$action,$reg))
  42. {
  43. if (! dolibarr_del_const($db, $reg[1], $conf->entity) > 0)
  44. {
  45. dol_print_error($db);
  46. }
  47. }
  48. /*
  49. * View
  50. */
  51. llxHeader('',$langs->trans("WorkflowSetup"),'');
  52. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  53. print load_fiche_titre($langs->trans("WorkflowSetup"),$linkback,'title_setup');
  54. print $langs->trans("WorkflowDesc").'<br>';
  55. print "<br>";
  56. // List of workflow we can enable
  57. print '<table class="noborder" width="100%">'."\n";
  58. clearstatcache();
  59. $workflowcodes=array(
  60. 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
  61. 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
  62. 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'),
  63. // For the following 2 options, if module invoice is disabled, they does not exists, so "Classify billed" for order must be done manually from order card.
  64. 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>40, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'),
  65. 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>50, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'),
  66. );
  67. if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
  68. {
  69. foreach($conf->modules_parts['workflow'] as $workflow)
  70. {
  71. $workflowcodes = array_merge($workflowcodes, $workflow);
  72. }
  73. }
  74. // TODO We must sort on position here
  75. $nbqualified=0;
  76. $oldfamily='';
  77. foreach($workflowcodes as $key => $params)
  78. {
  79. $picto=$params['picto'];
  80. $enabled=$params['enabled'];
  81. $family=$params['family'];
  82. if (! verifCond($enabled)) continue;
  83. $nbqualified++;
  84. if ($oldfamily != $family)
  85. {
  86. print '<tr class="liste_titre">'."\n";
  87. print ' <td>'.$langs->trans("Description").'</td>';
  88. print ' <td align="center">'.$langs->trans("Status").'</td>';
  89. print "</tr>\n";
  90. $oldfamily = $family;
  91. }
  92. $var = !$var;
  93. print "<tr ".$bc[$var].">\n";
  94. print "<td>".img_object('', $picto).$langs->trans('desc'.$key);
  95. if (! empty($params['warning']))
  96. {
  97. $langs->load("errors");
  98. print ' '.img_warning($langs->transnoentitiesnoconv($params['warning']));
  99. }
  100. print "</td>\n";
  101. print '<td align="center">';
  102. if (! empty($conf->use_javascript_ajax))
  103. {
  104. print ajax_constantonoff($key);
  105. }
  106. else
  107. {
  108. if (! empty($conf->global->$key))
  109. {
  110. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del'.$key.'">';
  111. print img_picto($langs->trans("Activated"),'switch_on');
  112. print '</a>';
  113. }
  114. else
  115. {
  116. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set'.$key.'">';
  117. print img_picto($langs->trans("Disabled"),'switch_off');
  118. print '</a>';
  119. }
  120. }
  121. print '</td>';
  122. print '</tr>';
  123. }
  124. if ($nbqualified == 0)
  125. {
  126. print '<tr><td colspan="3">'.$langs->trans("ThereIsNoWorkflowToModify");
  127. }
  128. print '</table>';
  129. llxFooter();
  130. $db->close();