diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index 01f91262d11..7e8d13d0595 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -323,6 +323,25 @@ class Account /* + * \brief Efface le compte + * + */ + function delete() + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; + $sql .= " WHERE rowid = ".$this->rowid; + $result = $this->db->query($sql); + if ($result) { + return 1; + } + else { + dolibarr_print_error($this->db); + return -1; + } + } + + + /* * \brief Renvoi si un compte peut etre supprimer ou non (sans mouvements) * \return boolean vrai si peut etre supprimé, faux sinon */ diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index 2b61a4c22eb..3cebc79e529 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -38,9 +38,9 @@ if (!$user->admin && !$user->rights->banque) accessforbidden(); -llxHeader(); - - +/* + * Actions + */ if ($_POST["action"] == 'add') { // Creation compte @@ -101,27 +101,42 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) $account->proprio = $_POST["proprio"]; $account->adresse_proprio = $_POST["adresse_proprio"]; - if ($account->label) { + if ($account->label) + { $result = $account->update($user); - if (! $result) { + if (! $result) + { $message=$account->error(); $_GET["action"]='edit'; // Force chargement page edition } - else { + else + { $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu } - } else { - $message='
'.$langs->trans("ErrorFieldRequired",$langs->trans("LabelBankCashAccount")).'
'; - $_GET["action"]='create'; // Force chargement page en mode creation - } - + } else { + $message='
'.$langs->trans("ErrorFieldRequired",$langs->trans("LabelBankCashAccount")).'
'; + $_GET["action"]='create'; // Force chargement page en mode creation } +} + +if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer) +{ + // Modification + $account = new Account($db, $_GET["id"]); + $account->delete($_GET["id"]); + + header("Location: ".DOL_URL_ROOT."/compta/bank/index.php"); + exit; +} +llxHeader(); + +$form = new Form($db); /* ************************************************************************** */ /* */ -/* Nouvel compte */ +/* Affichage page en mode création */ /* */ /* ************************************************************************** */ @@ -212,6 +227,15 @@ else dolibarr_fiche_head($head, $hselected, $langs->trans("FinancialAccount")." ".$account->number); + /* + * Confirmation de la suppression + */ + if ($_GET["action"] == 'delete') + { + $form->form_confirm($_SERVER["PHP_SELF"]."?id=$account->id",$langs->trans("DeleteAccount"),$langs->trans("ConfirmDeleteAccount"),"confirm_delete"); + print '
'; + } + print ''; print ''; @@ -256,16 +280,23 @@ else print '
'; print ''; - + + /* * Barre d'actions * */ print '
'; - if ($user->rights->banque->configurer) + if ($user->rights->banque->configurer) { - print ''.$langs->trans("Edit").''; + print ''.$langs->trans("Edit").''; + } + + $canbedeleted=$account->can_be_deleted(); // Renvoi vrai si compte sans mouvements + if ($user->rights->banque->configurer && $canbedeleted) + { + print ''.$langs->trans("Delete").''; } print '
'; @@ -284,8 +315,6 @@ else $account = new Account($db, $_GET["id"]); $account->fetch($_GET["id"]); - $form = new Form($db); - print_titre($langs->trans("EditFinancialAccount")); print "
"; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 44455d32a4f..f68b6e31405 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -131,7 +131,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire) $obj = $db->fetch_object($resql); $var=!$var; print ''; - print ''; + print ''; $i++; } @@ -279,7 +279,7 @@ if ($conf->commande->enabled && $user->rights->commande->lire) print "rowid\">".$obj->ref.''; print ''; + print ''.dolibarr_trunc($obj->nom,50).''; print ''; print ''; print ''; @@ -289,10 +289,11 @@ if ($conf->commande->enabled && $user->rights->commande->lire) $i++; } $var=!$var; - print ''; - print ''; - print ''; - print ''; + + print ''; + print ''; + print ''; + print ''; print ''; print '
'.$langs->trans("Label").'
'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.''.img_object($langs->trans("Showcompany"),"company").' '.$obj->nom.'
'.img_object($langs->trans("Showcompany"),"company").' '.dolibarr_trunc($obj->nom,50).'
'.img_object($langs->trans("ShowCompany"),"company").' '; - print ''.$obj->nom.''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->total_ttc-$obj->tot_fttc).'
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')'.price($tot_ht).''.price($tot_ttc).''.price($tot_tobill).'
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).') '.price($tot_ht).''.price($tot_ttc).''.price($tot_tobill).'

'; } @@ -345,7 +346,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire) { $var=!$var; print ''.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.''; - print ''.img_object($langs->trans("ShowCustomer"),"company").' '.$obj->nom.''; + print ''.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,50).''; print ''.price($obj->total).''; print ''.price($obj->total_ttc).''; print ''.price($obj->am).''; @@ -357,9 +358,12 @@ if ($conf->facture->enabled && $user->rights->facture->lire) } $var=!$var; - print ''.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')'.price($total)."".price($total_ttc)."".price($totalam).""; - - print "
"; + print ''.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).') '; + print ''.price($total).''; + print ''.price($total_ttc).''; + print ''.price($totalam).''; + print ''; + print '
'; } $db->free($resql); } @@ -423,7 +427,7 @@ if ($conf->facture->enabled) { $obj = $db->fetch_object($result); $var = !$var; print ''.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.''; - print ''.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.''; + print ''.img_object($langs->trans("ShowSupplier"),"company").' '.dolibarr_trunc($obj->nom,50).''; print ''.price($obj->total_ht).''; print ''.price($obj->total_ttc).''; print ''; @@ -433,8 +437,11 @@ if ($conf->facture->enabled) { $i++; } $var=!$var; - print ''.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')'; - print ''.price($total).''.price($total_ttc).''; + + print ''.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).') '; + print ''.price($total).''; + print ''.price($total_ttc).''; + print ''; print '
'; } } @@ -452,6 +459,7 @@ print ''; print ''; $db->close(); + -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?>