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