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:
Laurent Destailleur
2017-02-27 11:58:35 +01:00
4 changed files with 104 additions and 40 deletions

View File

@@ -62,6 +62,7 @@ $extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
/*
* Actions
*/
@@ -152,6 +153,7 @@ if ($action == 'add')
else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action='create'; // Force chargement page en mode creation
}
}
@@ -247,16 +249,25 @@ 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
$object = new Account($db);
$object->fetch(GETPOST("id","int"));
$object->delete();
$result = $object->delete($user);
if ($result > 0)
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
exit;
}
else
{
setEventMessages($account->error, $account->errors, 'errors');
$action='';
}
}
/*

View File

@@ -72,6 +72,7 @@ if ($categid) {
}
}
/*
* View
*/

View File

@@ -604,6 +604,7 @@ class Account extends CommonObject
$accline->datec = $this->db->idate($now);
$accline->label = '('.$langs->trans("InitialBankBalance").')';
$accline->amount = price2num($this->solde);
$accline->fk_user_author = $user->id;
$accline->fk_account = $this->id;
$accline->datev = $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) {
$error++;
$this->error = $accline->error;
$this->errors = $accline->errors;
}
if (! $error)
@@ -982,29 +985,60 @@ class Account extends CommonObject
{
global $conf;
$error=0;
$this->db->begin();
// Delete link between tag and bank account
if (! $error)
{
//$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; // No more used
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
$sql.= " WHERE fk_account = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
$error++;
$this->error = "Error ".$this->db->lasterror();
}
}
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE rowid = ".$this->rowid;
$sql.= " AND entity = ".$conf->entity;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
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);
return -1;
}
}
}
else
{
$error++;
$this->error = "Error ".$this->db->lasterror();
}
}
if (! $error)
{
$this->db->commit();
return 1;
}
else {
dol_print_error($this->db);
else
{
$this->db->rollback();
return -1;
}
}

View File

@@ -197,18 +197,36 @@ class BankCateg // extends CommonObject
global $conf;
$error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
$sql .= " WHERE rowid=".$this->id;
$sql .= " AND entity = ".$conf->entity;
$this->db->begin();
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
// Delete link between tag and bank account
if (! $error)
{
//$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; // No more used
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
$sql.= " WHERE fk_categorie = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
if (!$resql)
{
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
}
// 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) {