dolibarr  9.0.0
workflow.php
Go to the documentation of this file.
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@inodbox.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 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 
30 // Load translation files required by the page
31 $langs->loadLangs(array("admin","workflow","propal","workflow","orders","supplier_proposals"));
32 
33 if (! $user->admin) accessforbidden();
34 
35 $action = GETPOST('action', 'alpha');
36 
37 /*
38  * Actions
39  */
40 if (preg_match('/set(.*)/',$action,$reg))
41 {
42  if (! dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0)
43  {
44  dol_print_error($db);
45  }
46 }
47 
48 if (preg_match('/del(.*)/',$action,$reg))
49 {
50  if (! dolibarr_del_const($db, $reg[1], $conf->entity) > 0)
51  {
52  dol_print_error($db);
53  }
54 }
55 
56 
57 /*
58  * View
59  */
60 
61 llxHeader('',$langs->trans("WorkflowSetup"),'');
62 
63 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
64 print load_fiche_titre($langs->trans("WorkflowSetup"),$linkback,'title_setup');
65 
66 print $langs->trans("WorkflowDesc").'<br>';
67 print "<br>";
68 
69 // List of workflow we can enable
70 
71 clearstatcache();
72 
73 $workflowcodes=array(
74  // Automatic creation
75  'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
76  'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
77  'separator1'=>array('family'=>'separator', 'position'=>25),
78  // Automatic classification of proposal
79  'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal','warning'=>''),
80  'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal','warning'=>''),
81  // Automatic classification of order
82  'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
83  'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card.
84  'separator2'=>array('family'=>'separator', 'position'=>50),
85  // Automatic classification supplier proposal
86  'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal','warning'=>''),
87  // Automatic classification supplier order
88  'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order','warning'=>''),
89 );
90 
91 if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
92 {
93  foreach($conf->modules_parts['workflow'] as $workflow)
94  {
95  $workflowcodes = array_merge($workflowcodes, $workflow);
96  }
97 }
98 
99 // Sort on position
100 $workflowcodes = dol_sort_array($workflowcodes, 'position');
101 
102 $nbqualified=0;
103 $oldfamily='';
104 
105 print '<table class="noborder" width="100%">'."\n";
106 
107 foreach($workflowcodes as $key => $params)
108 {
109  $picto=$params['picto'];
110  $enabled=$params['enabled'];
111  $family=$params['family'];
112 
113  if ($family == 'separator')
114  {
115  print '</table><br>';
116  print '<table class="noborder" width="100%">'."\n";
117 
118  continue;
119  }
120 
121  if (! verifCond($enabled)) continue;
122 
123  $nbqualified++;
124 
125 
126  if ($oldfamily != $family)
127  {
128  print '<tr class="liste_titre">'."\n";
129  print ' <td>';
130  if ($family == 'create')
131  {
132  print $langs->trans("AutomaticCreation");
133  }
134  elseif (preg_match('/classify_(.*)/', $family, $reg))
135  {
136  print $langs->trans("AutomaticClassification");
137  if ($reg[1] == 'proposal') print ' - '.$langs->trans('Proposal');
138  if ($reg[1] == 'order') print ' - '.$langs->trans('Order');
139  if ($reg[1] == 'supplier_proposal') print ' - '.$langs->trans('SupplierProposal');
140  if ($reg[1] == 'supplier_order') print ' - '.$langs->trans('SupplierOrder');
141  }
142  else
143  {
144  print $langs->trans("Description");
145  }
146  print '</td>';
147  print ' <td align="center">'.$langs->trans("Status").'</td>';
148  print "</tr>\n";
149  $oldfamily = $family;
150  }
151 
152  print "<tr class=\"oddeven\">\n";
153  print "<td>".img_object('', $picto).$langs->trans('desc'.$key);
154  if (! empty($params['warning']))
155  {
156  $langs->load("errors");
157  print ' '.img_warning($langs->transnoentitiesnoconv($params['warning']));
158  }
159  print "</td>\n";
160  print '<td align="center">';
161  if (! empty($conf->use_javascript_ajax))
162  {
164  }
165  else
166  {
167  if (! empty($conf->global->$key))
168  {
169  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del'.$key.'">';
170  print img_picto($langs->trans("Activated"),'switch_on');
171  print '</a>';
172  }
173  else
174  {
175  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set'.$key.'">';
176  print img_picto($langs->trans("Disabled"),'switch_off');
177  print '</a>';
178  }
179  }
180  print '</td>';
181  print '</tr>';
182 }
183 
184 if ($nbqualified == 0)
185 {
186  print '<tr><td colspan="3">'.$langs->trans("ThereIsNoWorkflowToModify");
187 }
188 print '</table>';
189 
190 // End of page
191 llxFooter();
192 $db->close();
verifCond($strRights)
Verify if condition in string is ok or not.
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:510
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dolibarr_del_const($db, $name, $entity=1)
Effacement d&#39;une constante dans la base de donnees.
Definition: admin.lib.php:435
llxHeader()
Empty header.
Definition: wrapper.php:44
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
On/off button for constant.
Definition: ajax.lib.php:484
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)