workflow.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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-2016 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. // Automatic creation
  61. 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
  62. 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
  63. // Automatic classification
  64. 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'),
  65. 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'),
  66. // 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.
  67. 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>40, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'),
  68. 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>50, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'),
  69. 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
  70. );
  71. if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
  72. {
  73. foreach($conf->modules_parts['workflow'] as $workflow)
  74. {
  75. $workflowcodes = array_merge($workflowcodes, $workflow);
  76. }
  77. }
  78. // TODO We must sort on position here
  79. $nbqualified=0;
  80. $oldfamily='';
  81. foreach($workflowcodes as $key => $params)
  82. {
  83. $picto=$params['picto'];
  84. $enabled=$params['enabled'];
  85. $family=$params['family'];
  86. if (! verifCond($enabled)) continue;
  87. $nbqualified++;
  88. if ($oldfamily != $family)
  89. {
  90. print '<tr class="liste_titre">'."\n";
  91. print ' <td>';
  92. if ($family == 'create') print $langs->trans("AutomaticCreation");
  93. elseif ($family == 'classify') print $langs->trans("AutomaticClassification");
  94. else print $langs->trans("Description");
  95. print '</td>';
  96. print ' <td align="center">'.$langs->trans("Status").'</td>';
  97. print "</tr>\n";
  98. $oldfamily = $family;
  99. }
  100. print "<tr class=\"oddeven\">\n";
  101. print "<td>".img_object('', $picto).$langs->trans('desc'.$key);
  102. if (! empty($params['warning']))
  103. {
  104. $langs->load("errors");
  105. print ' '.img_warning($langs->transnoentitiesnoconv($params['warning']));
  106. }
  107. print "</td>\n";
  108. print '<td align="center">';
  109. if (! empty($conf->use_javascript_ajax))
  110. {
  111. print ajax_constantonoff($key);
  112. }
  113. else
  114. {
  115. if (! empty($conf->global->$key))
  116. {
  117. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del'.$key.'">';
  118. print img_picto($langs->trans("Activated"),'switch_on');
  119. print '</a>';
  120. }
  121. else
  122. {
  123. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set'.$key.'">';
  124. print img_picto($langs->trans("Disabled"),'switch_off');
  125. print '</a>';
  126. }
  127. }
  128. print '</td>';
  129. print '</tr>';
  130. }
  131. if ($nbqualified == 0)
  132. {
  133. print '<tr><td colspan="3">'.$langs->trans("ThereIsNoWorkflowToModify");
  134. }
  135. print '</table>';
  136. llxFooter();
  137. $db->close();