PageRenderTime 34ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/workflow.php

https://bitbucket.org/speedealing/speedealing
PHP | 146 lines | 92 code | 24 blank | 30 comment | 13 complexity | c053b3fcf1aecf64a60673d231b521ac MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  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_fiche_titre($langs->trans("WorkflowSetup"),$linkback,'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. print '<tr class="liste_titre">'."\n";
  59. print ' <td>'.$langs->trans("Description").'</td>';
  60. print ' <td align="center">'.$langs->trans("Status").'</td>';
  61. print "</tr>\n";
  62. clearstatcache();
  63. $workflowcodes=array(
  64. 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
  65. 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'),
  66. 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
  67. 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'),
  68. );
  69. if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
  70. {
  71. foreach($conf->modules_parts['workflow'] as $workflow)
  72. {
  73. $workflowcodes = array_merge($workflowcodes, $workflow);
  74. }
  75. }
  76. $nbqualified=0;
  77. foreach($workflowcodes as $key => $params)
  78. {
  79. $picto=$params['picto'];
  80. $enabled=$params['enabled'];
  81. if (! verifCond($enabled)) continue;
  82. $nbqualified++;
  83. $var = !$var;
  84. print "<tr ".$bc[$var].">\n";
  85. print "<td>".img_object('', $picto).$langs->trans('desc'.$key);
  86. if (! empty($params['warning']))
  87. {
  88. $langs->load("errors");
  89. print ' '.img_warning($langs->transnoentitiesnoconv($params['warning']));
  90. }
  91. print "</td>\n";
  92. print '<td align="center">';
  93. if (! empty($conf->use_javascript_ajax))
  94. {
  95. print ajax_constantonoff($key);
  96. }
  97. else
  98. {
  99. if (! empty($conf->global->$key))
  100. {
  101. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del'.$key.'">';
  102. print img_picto($langs->trans("Activated"),'switch_on');
  103. print '</a>';
  104. }
  105. else
  106. {
  107. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set'.$key.'">';
  108. print img_picto($langs->trans("Disabled"),'switch_off');
  109. print '</a>';
  110. }
  111. }
  112. print '</td>';
  113. print '</tr>';
  114. }
  115. if ($nbqualified == 0)
  116. {
  117. print '<tr><td colspan="3">'.$langs->trans("ThereIsNoWorkflowToModify");
  118. }
  119. print '</table>';
  120. llxFooter();
  121. $db->close();
  122. ?>