New: Ajout fonction delete pour supprimer un compte
This commit is contained in:
parent
f34e030c3e
commit
1ebba35536
@ -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)
|
* \brief Renvoi si un compte peut etre supprimer ou non (sans mouvements)
|
||||||
* \return boolean vrai si peut etre supprimé, faux sinon
|
* \return boolean vrai si peut etre supprimé, faux sinon
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -38,9 +38,9 @@ if (!$user->admin && !$user->rights->banque)
|
|||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
llxHeader();
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
if ($_POST["action"] == 'add')
|
if ($_POST["action"] == 'add')
|
||||||
{
|
{
|
||||||
// Creation compte
|
// Creation compte
|
||||||
@ -101,27 +101,42 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
|
|||||||
$account->proprio = $_POST["proprio"];
|
$account->proprio = $_POST["proprio"];
|
||||||
$account->adresse_proprio = $_POST["adresse_proprio"];
|
$account->adresse_proprio = $_POST["adresse_proprio"];
|
||||||
|
|
||||||
if ($account->label) {
|
if ($account->label)
|
||||||
|
{
|
||||||
$result = $account->update($user);
|
$result = $account->update($user);
|
||||||
if (! $result) {
|
if (! $result)
|
||||||
|
{
|
||||||
$message=$account->error();
|
$message=$account->error();
|
||||||
$_GET["action"]='edit'; // Force chargement page edition
|
$_GET["action"]='edit'; // Force chargement page edition
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
|
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("LabelBankCashAccount")).'</div>';
|
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("LabelBankCashAccount")).'</div>';
|
||||||
$_GET["action"]='create'; // Force chargement page en mode creation
|
$_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);
|
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 '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
||||||
@ -257,15 +281,22 @@ else
|
|||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Barre d'actions
|
* Barre d'actions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if ($user->rights->banque->configurer)
|
if ($user->rights->banque->configurer)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?action=edit&id='.$account->id.'">'.$langs->trans("Edit").'</a>';
|
print '<a class="butAction" href="fiche.php?action=edit&id='.$account->id.'">'.$langs->trans("Edit").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$canbedeleted=$account->can_be_deleted(); // Renvoi vrai si compte sans mouvements
|
||||||
|
if ($user->rights->banque->configurer && $canbedeleted)
|
||||||
|
{
|
||||||
|
print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$account->id.'">'.$langs->trans("Delete").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -284,8 +315,6 @@ else
|
|||||||
$account = new Account($db, $_GET["id"]);
|
$account = new Account($db, $_GET["id"]);
|
||||||
$account->fetch($_GET["id"]);
|
$account->fetch($_GET["id"]);
|
||||||
|
|
||||||
$form = new Form($db);
|
|
||||||
|
|
||||||
print_titre($langs->trans("EditFinancialAccount"));
|
print_titre($langs->trans("EditFinancialAccount"));
|
||||||
print "<br>";
|
print "<br>";
|
||||||
|
|
||||||
|
|||||||
@ -131,7 +131,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
|
|||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
|
print '<tr '.$bc[$var].'><td><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("Showcompany"),"company").' '.$obj->nom.'</a></td></tr>';
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("Showcompany"),"company").' '.dolibarr_trunc($obj->nom,50).'</a></td></tr>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ if ($conf->commande->enabled && $user->rights->commande->lire)
|
|||||||
print "<a href=\"commande/fiche.php?id=$obj->rowid\">".$obj->ref.'</a></td>';
|
print "<a href=\"commande/fiche.php?id=$obj->rowid\">".$obj->ref.'</a></td>';
|
||||||
|
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> ';
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> ';
|
||||||
print '<a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
|
print '<a href="fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,50).'</a></td>';
|
||||||
print '<td align="right">'.price($obj->total_ht).'</td>';
|
print '<td align="right">'.price($obj->total_ht).'</td>';
|
||||||
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
||||||
print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td></tr>';
|
print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td></tr>';
|
||||||
@ -289,10 +289,11 @@ if ($conf->commande->enabled && $user->rights->commande->lire)
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</i></td>';
|
|
||||||
print '<td align="right"><i>'.price($tot_ht).'</i></td>';
|
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</font> </td>';
|
||||||
print '<td align="right"><i>'.price($tot_ttc).'</i></td>';
|
print '<td align="right">'.price($tot_ht).'</td>';
|
||||||
print '<td align="right"><i>'.price($tot_tobill).'</i></td>';
|
print '<td align="right">'.price($tot_ttc).'</td>';
|
||||||
|
print '<td align="right">'.price($tot_tobill).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
}
|
}
|
||||||
@ -345,7 +346,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
|
|||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td nowrap><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
|
print '<tr '.$bc[$var].'><td nowrap><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.$obj->nom.'</a></td>';
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,50).'</a></td>';
|
||||||
print '<td align="right">'.price($obj->total).'</td>';
|
print '<td align="right">'.price($obj->total).'</td>';
|
||||||
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
||||||
print '<td align="right">'.price($obj->am).'</td></tr>';
|
print '<td align="right">'.price($obj->am).'</td></tr>';
|
||||||
@ -357,9 +358,12 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
|
|||||||
}
|
}
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')</i></td><td align="right"><i>'.price($total)."</i></td><td align=\"right\"><i>".price($total_ttc)."</i></td><td align=\"right\"><i>".price($totalam)."</i></td></tr>";
|
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')</font> </td>';
|
||||||
|
print '<td align="right">'.price($total).'</td>';
|
||||||
print "</table><br>";
|
print '<td align="right">'.price($total_ttc).'</td>';
|
||||||
|
print '<td align="right">'.price($totalam).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
print '</table><br>';
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
@ -423,7 +427,7 @@ if ($conf->facture->enabled) {
|
|||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
$var = !$var;
|
$var = !$var;
|
||||||
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
|
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>';
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'</a></td>';
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.dolibarr_trunc($obj->nom,50).'</a></td>';
|
||||||
print '<td align="right">'.price($obj->total_ht).'</td>';
|
print '<td align="right">'.price($obj->total_ht).'</td>';
|
||||||
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
print '<td align="right">'.price($obj->total_ttc).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -433,8 +437,11 @@ if ($conf->facture->enabled) {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td colspan="2" align="left"><i>'.$langs->trans("Total").' ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')</td>';
|
|
||||||
print '<td align="right"><i>'.price($total).'</i></td><td align="right"><i>'.price($total_ttc).'</i></td></tr>';
|
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')</font> </td>';
|
||||||
|
print '<td align="right">'.price($total).'</td>';
|
||||||
|
print '<td align="right">'.price($total_ttc).'</td>';
|
||||||
|
print '</tr>';
|
||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,5 +460,6 @@ print '</table>';
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
|
||||||
|
llxFooter('$Date$ - $Revision$');
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user