From 4804cc47bde10bf2abf896c36a01671cc1bd8c76 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 24 Feb 2017 15:16:53 +0100 Subject: [PATCH] Clean and uniformize code --- htdocs/accountancy/admin/accountmodel.php | 8 ++-- htdocs/comm/card.php | 13 +++--- htdocs/fourn/card.php | 53 +++++++++++++---------- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index ba2643a04b8..75d3be10444 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -736,11 +736,11 @@ if ($id) { if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') { - fieldList($fieldlist,$obj,$tabname[$id],'hide'); + fieldListAccountModel($fieldlist,$obj,$tabname[$id],'hide'); } 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 $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).'"> </a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print ' <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 * @return void */ -function fieldList($fieldlist, $obj='', $tabname='', $context='') +function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='') { global $conf,$langs,$db; global $form; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index bfd90b6909b..126c3fe0f62 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1039,6 +1039,11 @@ if ($id > 0) 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) { $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.'&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)) { 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 { $langs->load("bills"); @@ -1101,7 +1102,7 @@ if ($id > 0) } // 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) { diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 29d2a421b2b..f731fac1684 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -708,32 +708,37 @@ if ($object->id > 0) // modified by hook 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"); 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"); 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"); 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>'; 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 - 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) { @@ -750,29 +755,29 @@ if ($object->id > 0) print '<br>'; - if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) - { - print '<br>'; - // List of contacts - show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } + if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) + { + print '<br>'; + // List of contacts + show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } - // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) - { - $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } - if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); + if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + { + print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - // List of todo actions - show_actions_todo($conf,$langs,$db,$object); + // List of todo actions + show_actions_todo($conf,$langs,$db,$object); - // List of done actions - show_actions_done($conf,$langs,$db,$object); - } + // List of done actions + show_actions_done($conf,$langs,$db,$object); + } } else { -- GitLab