Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
83c0b44468
@ -9,6 +9,7 @@
|
|||||||
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||||
* Copyright (C) 2019 JC Prieto <jcprieto@virtual20.com><prietojc@gmail.com>
|
* Copyright (C) 2019 JC Prieto <jcprieto@virtual20.com><prietojc@gmail.com>
|
||||||
|
* Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -852,7 +853,7 @@ class Account extends CommonObject
|
|||||||
|
|
||||||
$sql .= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null");
|
$sql .= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null");
|
||||||
$sql .= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null");
|
$sql .= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null");
|
||||||
$sql .= ",comment = '".$this->db->escape($this->comment)."'";
|
$sql .= ",comment = '".$this->db->escape($this->comment)."'";
|
||||||
|
|
||||||
$sql .= ",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) : "null");
|
$sql .= ",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) : "null");
|
||||||
$sql .= ",fk_pays = ".($this->country_id > 0 ? ((int) $this->country_id) : "null");
|
$sql .= ",fk_pays = ".($this->country_id > 0 ? ((int) $this->country_id) : "null");
|
||||||
@ -1926,18 +1927,18 @@ class AccountLine extends CommonObject
|
|||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
if ($obj) {
|
if ($obj) {
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
$this->rowid = $obj->rowid;
|
$this->rowid = $obj->rowid;
|
||||||
$this->ref = $obj->rowid;
|
$this->ref = $obj->rowid;
|
||||||
|
|
||||||
$this->datec = $obj->datec;
|
$this->datec = $obj->datec;
|
||||||
$this->datev = $obj->datev;
|
$this->datev = $obj->datev;
|
||||||
$this->dateo = $obj->dateo;
|
$this->dateo = $obj->dateo;
|
||||||
$this->amount = $obj->amount;
|
$this->amount = $obj->amount;
|
||||||
$this->label = $obj->label;
|
$this->label = $obj->label;
|
||||||
$this->note = $obj->note;
|
$this->note = $obj->note;
|
||||||
|
|
||||||
$this->fk_user_author = $obj->fk_user_author;
|
$this->fk_user_author = $obj->fk_user_author;
|
||||||
$this->fk_user_rappro = $obj->fk_user_rappro;
|
$this->fk_user_rappro = $obj->fk_user_rappro;
|
||||||
|
|
||||||
$this->fk_type = $obj->fk_type; // Type of transaction
|
$this->fk_type = $obj->fk_type; // Type of transaction
|
||||||
$this->rappro = $obj->rappro;
|
$this->rappro = $obj->rappro;
|
||||||
@ -1948,9 +1949,13 @@ class AccountLine extends CommonObject
|
|||||||
$this->fk_bordereau = $obj->fk_bordereau;
|
$this->fk_bordereau = $obj->fk_bordereau;
|
||||||
|
|
||||||
$this->fk_account = $obj->fk_account;
|
$this->fk_account = $obj->fk_account;
|
||||||
$this->bank_account_ref = $obj->bank_account_ref;
|
$this->bank_account_ref = $obj->bank_account_ref;
|
||||||
$this->bank_account_label = $obj->bank_account_label;
|
$this->bank_account_label = $obj->bank_account_label;
|
||||||
|
|
||||||
|
// Retrieve all extrafield
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
$this->fetch_optionals();
|
||||||
|
|
||||||
$ret = 1;
|
$ret = 1;
|
||||||
}
|
}
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
@ -1967,6 +1972,10 @@ class AccountLine extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function insert()
|
public function insert()
|
||||||
{
|
{
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (";
|
||||||
$sql .= "datec";
|
$sql .= "datec";
|
||||||
$sql .= ", dateo";
|
$sql .= ", dateo";
|
||||||
@ -2002,15 +2011,26 @@ class AccountLine extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
|
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
if (!$resql) {
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'bank');
|
||||||
|
// Actions on extra fields (by external module or standard code)
|
||||||
|
$result = $this->insertExtraFields();
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
return -1;
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'bank');
|
if (!$error) {
|
||||||
|
$this->db->commit();
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
} else {
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1 * $error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2064,6 +2084,12 @@ class AccountLine extends CommonObject
|
|||||||
$nbko++;
|
$nbko++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_extrafields WHERE fk_object=".(int) $this->rowid;
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
$nbko++;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".(int) $this->rowid;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".(int) $this->rowid;
|
||||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|||||||
@ -35,6 +35,7 @@ require '../../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other'));
|
$langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other'));
|
||||||
@ -77,7 +78,9 @@ if (empty($user->rights->banque->lire) && empty($user->rights->banque->consolida
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hookmanager->initHooks(array('bankline'));
|
$hookmanager->initHooks(array('bankline'));
|
||||||
|
$object = new AccountLine($db);
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
$extrafields->fetch_name_optionals_label($object->element);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -125,18 +128,17 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban
|
|||||||
if ($user->rights->banque->modifier && $action == "update") {
|
if ($user->rights->banque->modifier && $action == "update") {
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$acline = new AccountLine($db);
|
$result = $object->fetch($rowid);
|
||||||
$result = $acline->fetch($rowid);
|
|
||||||
if ($result <= 0) {
|
if ($result <= 0) {
|
||||||
dol_syslog('Failed to read bank line with id '.$rowid, LOG_WARNING); // This happens due to old bug that has set fk_account to null.
|
dol_syslog('Failed to read bank line with id '.$rowid, LOG_WARNING); // This happens due to old bug that has set fk_account to null.
|
||||||
$acline->id = $rowid;
|
$object->id = $rowid;
|
||||||
}
|
}
|
||||||
|
|
||||||
$acsource = new Account($db);
|
$acsource = new Account($db);
|
||||||
$acsource->fetch($accountoldid);
|
$acsource->fetch($accountoldid);
|
||||||
|
|
||||||
$actarget = new Account($db);
|
$actarget = new Account($db);
|
||||||
if (GETPOST('accountid', 'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta()) { // We ask to change bank account
|
if (GETPOST('accountid', 'int') > 0 && !$object->rappro && !$object->getVentilExportCompta()) { // We ask to change bank account
|
||||||
$actarget->fetch(GETPOST('accountid', 'int'));
|
$actarget->fetch(GETPOST('accountid', 'int'));
|
||||||
} else {
|
} else {
|
||||||
$actarget->fetch($accountoldid);
|
$actarget->fetch($accountoldid);
|
||||||
@ -173,7 +175,7 @@ if ($user->rights->banque->modifier && $action == "update") {
|
|||||||
$sql .= " emetteur='".$db->escape(GETPOST("emetteur"))."',";
|
$sql .= " emetteur='".$db->escape(GETPOST("emetteur"))."',";
|
||||||
}
|
}
|
||||||
// Blocked when conciliated
|
// Blocked when conciliated
|
||||||
if (!$acline->rappro) {
|
if (!$object->rappro) {
|
||||||
if (GETPOSTISSET('label')) {
|
if (GETPOSTISSET('label')) {
|
||||||
$sql .= " label = '".$db->escape(GETPOST("label"))."',";
|
$sql .= " label = '".$db->escape(GETPOST("label"))."',";
|
||||||
}
|
}
|
||||||
@ -188,7 +190,7 @@ if ($user->rights->banque->modifier && $action == "update") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql .= " fk_account = ".((int) $actarget->id);
|
$sql .= " fk_account = ".((int) $actarget->id);
|
||||||
$sql .= " WHERE rowid = ".((int) $acline->id);
|
$sql .= " WHERE rowid = ".((int) $object->id);
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -214,6 +216,11 @@ if ($user->rights->banque->modifier && $action == "update") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
|
||||||
|
$object->insertExtraFields();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||||
$db->commit();
|
$db->commit();
|
||||||
@ -601,6 +608,13 @@ if ($result) {
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Other attributes
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $bankline, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
if (empty($reshook)) {
|
||||||
|
print $bankline->showOptionals($extrafields, ($objp->rappro ? 'view' : 'create'), $parameters);
|
||||||
|
}
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
// Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
|
// Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
|
||||||
|
|||||||
@ -9364,7 +9364,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
|
|||||||
|
|
||||||
// No need to make a return $head. Var is modified as a reference
|
// No need to make a return $head. Var is modified as a reference
|
||||||
if (!empty($hookmanager)) {
|
if (!empty($hookmanager)) {
|
||||||
$parameters = array('object' => $object, 'mode' => $mode, 'head' => &$head);
|
$parameters = array('object' => $object, 'mode' => $mode, 'head' => &$head, 'filterorigmodule' => $filterorigmodule);
|
||||||
$reshook = $hookmanager->executeHooks('completeTabsHead', $parameters);
|
$reshook = $hookmanager->executeHooks('completeTabsHead', $parameters);
|
||||||
if ($reshook > 0) { // Hook ask to replace completely the array
|
if ($reshook > 0) { // Hook ask to replace completely the array
|
||||||
$head = $hookmanager->resArray;
|
$head = $hookmanager->resArray;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user