New: Use a better format for workflow array:
- allow more complex permissions/conditions - allow to define order of options - can define workflow option not using two modules (can use only one, of threee or more...)
This commit is contained in:
parent
86c59a2460
commit
0021f7d98e
@ -76,78 +76,52 @@ print "</tr>\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
$workflowcodes=array();
|
$workflowcodes=array(
|
||||||
$workflow=array(
|
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('enabled'=>($conf->propal->enabled && $conf->commande->enabled),'child'=>'order','parent'=>'propal'),
|
||||||
'propal' => array(
|
'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('enabled'=>($conf->propal->enabled && $conf->commande->enabled),'child'=>'propal','parent'=>'order'),
|
||||||
'order' => array('WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL')
|
'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('enabled'=>($conf->commande->enabled && $conf->facture->enabled),'child'=>'invoice','parent'=>'order'),
|
||||||
),
|
'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('enabled'=>($conf->facture->enabled && $conf->commande->enabled),'child'=>'order','parent'=>'invoice'),
|
||||||
'order' => array(
|
|
||||||
'propal' => array('WORKFLOW_PROPAL_AUTOCREATE_ORDER')
|
|
||||||
,'invoice' => array('WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER')
|
|
||||||
),
|
|
||||||
'invoice' => array (
|
|
||||||
'order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')
|
|
||||||
//,'contract' => array('WORKFLOW_CONTRACT_AUTOCREATE_INVOICE')
|
|
||||||
//, 'propal' => array('WORKFLOW_PROPAL_AUTOCREATE_INVOICE')
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) $workflow = array_merge($workflow, $conf->modules_parts['workflow']);
|
if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) $workflow = array_merge($workflow, $conf->modules_parts['workflow']);
|
||||||
|
|
||||||
foreach($workflow as $child => $parents)
|
$nbqualified=0;
|
||||||
{
|
|
||||||
if ($conf->$child->enabled)
|
|
||||||
{
|
|
||||||
$langs->Load($child.'@'.$child);
|
|
||||||
|
|
||||||
foreach($parents as $parent => $actions)
|
foreach($workflowcodes as $key => $tmparray)
|
||||||
{
|
{
|
||||||
if ($conf->$parent->enabled)
|
$child=$tmparray['child'];
|
||||||
{
|
$parent=$tmparray['parent'];
|
||||||
foreach($actions as $action)
|
if (empty($conf->$child->enabled) || empty($conf->$parent->enabled)) continue;
|
||||||
{
|
|
||||||
$workflowcodes[$child][] = $action;
|
$nbqualified++;
|
||||||
}
|
$var = !$var;
|
||||||
}
|
print "<tr ".$bc[$var].">\n";
|
||||||
}
|
print "<td>".img_object('', $tmparray['child']).$langs->trans('desc'.$key)."</td>\n";
|
||||||
}
|
print '<td align="center">';
|
||||||
|
if ($conf->use_javascript_ajax)
|
||||||
|
{
|
||||||
|
print ajax_constantonoff($key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->$key))
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del'.$key.'">';
|
||||||
|
print img_picto($langs->trans("Activated"),'switch_on');
|
||||||
|
print '</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set'.$key.'">';
|
||||||
|
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||||
|
print '</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($workflowcodes) > 0)
|
if ($nbqualified == 0)
|
||||||
{
|
|
||||||
foreach($workflowcodes as $key => $actions)
|
|
||||||
{
|
|
||||||
foreach($actions as $action)
|
|
||||||
{
|
|
||||||
$var = !$var;
|
|
||||||
print "<tr ".$bc[$var].">\n";
|
|
||||||
print "<td>".img_object('', $key).$langs->trans('desc'.$action)."</td>\n";
|
|
||||||
print '<td align="center">';
|
|
||||||
if ($conf->use_javascript_ajax)
|
|
||||||
{
|
|
||||||
print ajax_constantonoff($action);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (! empty($conf->global->$action))
|
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del'.$action.'">';
|
|
||||||
print img_picto($langs->trans("Activated"),'switch_on');
|
|
||||||
print '</a>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set'.$action.'">';
|
|
||||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
|
||||||
print '</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
print '<tr><td colspan="3">'.$langs->trans("ThereIsNoWorkflowToModify");
|
print '<tr><td colspan="3">'.$langs->trans("ThereIsNoWorkflowToModify");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user