Clean and uniformize code

This commit is contained in:
Laurent Destailleur 2017-02-24 15:16:53 +01:00
parent 47ea9b57e8
commit 4804cc47bd
3 changed files with 40 additions and 34 deletions

View File

@ -736,11 +736,11 @@ if ($id)
{ {
if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit')
{ {
fieldList($fieldlist,$obj,$tabname[$id],'hide'); fieldListAccountModel($fieldlist,$obj,$tabname[$id],'hide');
} }
else else
{ {
fieldList($fieldlist,$obj,$tabname[$id],'add'); fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add');
} }
} }
@ -928,7 +928,7 @@ if ($id)
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; $error=$hookmanager->error; $errors=$hookmanager->errors;
if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); if (empty($reshook)) fieldListAccountModel($fieldlist,$obj,$tabname[$id],'edit');
print '<td colspan="3" align="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<td colspan="3" align="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>'; print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
@ -1252,7 +1252,7 @@ $db->close();
* @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
* @return void * @return void
*/ */
function fieldList($fieldlist, $obj='', $tabname='', $context='') function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
{ {
global $conf,$langs,$db; global $conf,$langs,$db;
global $form; global $form;

View File

@ -1039,6 +1039,11 @@ if ($id > 0)
if (empty($reshook)) if (empty($reshook))
{ {
if ($object->status != 1)
{
print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
}
if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1) if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1)
{ {
$langs->load("propal"); $langs->load("propal");
@ -1072,16 +1077,12 @@ if ($id > 0)
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>';
} }
if (! empty($conf->facture->enabled)) if (! empty($conf->facture->enabled) && $object->status==1)
{ {
if (empty($user->rights->facture->creer)) if (empty($user->rights->facture->creer))
{ {
print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
} }
else if ($object->status != 1)
{
print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
}
else else
{ {
$langs->load("bills"); $langs->load("bills");
@ -1101,7 +1102,7 @@ if ($id > 0)
} }
// Add action // Add action
if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status==1)
{ {
if ($user->rights->agenda->myactions->create) if ($user->rights->agenda->myactions->create)
{ {

View File

@ -708,32 +708,37 @@ if ($object->id > 0)
// modified by hook // modified by hook
if (empty($reshook)) if (empty($reshook))
{ {
if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer) if ($object->status != 1)
{
print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
}
if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer && $object->status==1)
{ {
$langs->load("supplier_proposal"); $langs->load("supplier_proposal");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddSupplierProposal").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddSupplierProposal").'</a>';
} }
if ($user->rights->fournisseur->commande->creer) if ($user->rights->fournisseur->commande->creer && $object->status==1)
{ {
$langs->load("orders"); $langs->load("orders");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddOrder").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddOrder").'</a>';
} }
if ($user->rights->fournisseur->facture->creer) if ($user->rights->fournisseur->facture->creer && $object->status==1)
{ {
$langs->load("bills"); $langs->load("bills");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
} }
if ($user->rights->fournisseur->facture->creer) if ($user->rights->fournisseur->facture->creer && $object->status==1)
{ {
if (! empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; if (! empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
} }
// Add action // Add action
if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status==1)
{ {
if ($user->rights->agenda->myactions->create) if ($user->rights->agenda->myactions->create)
{ {