mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 5.0
Conflicts: htdocs/compta/bank/card.php htdocs/compta/bank/class/account.class.php
This commit is contained in:
@@ -62,6 +62,7 @@ $extrafields = new ExtraFields($db);
|
|||||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
@@ -152,6 +153,7 @@ if ($action == 'add')
|
|||||||
else {
|
else {
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
|
||||||
$action='create'; // Force chargement page en mode creation
|
$action='create'; // Force chargement page en mode creation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,15 +249,24 @@ if ($action == 'update')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
|
if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
|
||||||
{
|
{
|
||||||
// Delete
|
// Delete
|
||||||
$object = new Account($db);
|
$object = new Account($db);
|
||||||
$object->fetch(GETPOST("id","int"));
|
$object->fetch(GETPOST("id","int"));
|
||||||
$object->delete();
|
$result = $object->delete($user);
|
||||||
|
|
||||||
header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
|
if ($result > 0)
|
||||||
exit;
|
{
|
||||||
|
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||||
|
header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($account->error, $account->errors, 'errors');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ if ($categid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ class Account extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Add an entry into table ".MAIN_DB_PREFIX."bank
|
* Add an entry into table ".MAIN_DB_PREFIX."bank
|
||||||
*
|
*
|
||||||
* @param int $date Date operation
|
* @param int $date Date operation
|
||||||
* @param string $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ...
|
* @param string $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ...
|
||||||
* @param string $label Descripton
|
* @param string $label Descripton
|
||||||
* @param float $amount Amount
|
* @param float $amount Amount
|
||||||
@@ -604,6 +604,7 @@ class Account extends CommonObject
|
|||||||
$accline->datec = $this->db->idate($now);
|
$accline->datec = $this->db->idate($now);
|
||||||
$accline->label = '('.$langs->trans("InitialBankBalance").')';
|
$accline->label = '('.$langs->trans("InitialBankBalance").')';
|
||||||
$accline->amount = price2num($this->solde);
|
$accline->amount = price2num($this->solde);
|
||||||
|
$accline->fk_user_author = $user->id;
|
||||||
$accline->fk_account = $this->id;
|
$accline->fk_account = $this->id;
|
||||||
$accline->datev = $this->db->idate($this->date_solde);
|
$accline->datev = $this->db->idate($this->date_solde);
|
||||||
$accline->dateo = $this->db->idate($this->date_solde);
|
$accline->dateo = $this->db->idate($this->date_solde);
|
||||||
@@ -611,6 +612,8 @@ class Account extends CommonObject
|
|||||||
|
|
||||||
if ($accline->insert() < 0) {
|
if ($accline->insert() < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
|
$this->error = $accline->error;
|
||||||
|
$this->errors = $accline->errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@@ -982,29 +985,60 @@ class Account extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account";
|
$error=0;
|
||||||
$sql.= " WHERE rowid = ".$this->rowid;
|
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$this->db->begin();
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
// Delete link between tag and bank account
|
||||||
$result = $this->db->query($sql);
|
if (! $error)
|
||||||
if ($result) {
|
{
|
||||||
|
//$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; // No more used
|
||||||
// Remove extrafields
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
|
||||||
if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
|
$sql.= " WHERE fk_account = ".$this->id;
|
||||||
{
|
|
||||||
$result=$this->deleteExtraFields();
|
$resql = $this->db->query($sql);
|
||||||
if ($result < 0)
|
if (!$resql)
|
||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
|
$error++;
|
||||||
return -1;
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account";
|
||||||
|
$sql.= " WHERE rowid = ".$this->rowid;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
// Remove extrafields
|
||||||
|
if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$result=$this->deleteExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
dol_print_error($this->db);
|
{
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,29 +188,47 @@ class BankCateg // extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Delete object in database
|
* Delete object in database
|
||||||
*
|
*
|
||||||
* @param User $user User that delete
|
* @param User $user User that delete
|
||||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function delete(User $user, $notrigger = 0)
|
public function delete(User $user, $notrigger = 0)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
|
|
||||||
$sql .= " WHERE rowid=".$this->id;
|
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
// Delete link between tag and bank account
|
||||||
$resql = $this->db->query($sql);
|
if (! $error)
|
||||||
if (!$resql) {
|
{
|
||||||
$error++;
|
//$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; // No more used
|
||||||
$this->errors[] = "Error ".$this->db->lasterror();
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
|
||||||
|
$sql.= " WHERE fk_categorie = ".$this->id;
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (!$resql)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->errors[] = "Error ".$this->db->lasterror();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Delete bank categ
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
|
||||||
|
$sql .= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (!$resql)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->errors[] = "Error ".$this->db->lasterror();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit or rollback
|
||||||
if ($error) {
|
if ($error) {
|
||||||
foreach ($this->errors as $errmsg) {
|
foreach ($this->errors as $errmsg) {
|
||||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||||
|
|||||||
Reference in New Issue
Block a user