Start bank extrafields
This commit is contained in:
parent
efcc1dc8f5
commit
e9f754395d
@ -343,7 +343,7 @@ class Account extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function create($user='')
|
function create($user='')
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf, $hookmanager;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (! $this->min_allowed) $this->min_allowed=0;
|
if (! $this->min_allowed) $this->min_allowed=0;
|
||||||
@ -441,6 +441,23 @@ class Account extends CommonObject
|
|||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actions on extra fields (by external module or standard code)
|
||||||
|
$hookmanager->initHooks(array('bankdao'));
|
||||||
|
$parameters=array('id'=>$this->id);
|
||||||
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$result=$this->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($reshook < 0) return -5;
|
||||||
}
|
}
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
@ -466,7 +483,7 @@ class Account extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function update($user='')
|
function update($user='')
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf, $hookmanager;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (! $this->min_allowed) $this->min_allowed=0;
|
if (! $this->min_allowed) $this->min_allowed=0;
|
||||||
@ -517,6 +534,25 @@ class Account extends CommonObject
|
|||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Actions on extra fields (by external module or standard code)
|
||||||
|
$hookmanager->initHooks(array('bankdao'));
|
||||||
|
$parameters=array('id'=>$this->id);
|
||||||
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$result=$this->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($reshook < 0) return -1;
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -663,6 +699,15 @@ class Account extends CommonObject
|
|||||||
$this->min_allowed = $obj->min_allowed;
|
$this->min_allowed = $obj->min_allowed;
|
||||||
$this->min_desired = $obj->min_desired;
|
$this->min_desired = $obj->min_desired;
|
||||||
$this->comment = $obj->comment;
|
$this->comment = $obj->comment;
|
||||||
|
|
||||||
|
// Retreive all extrafield for thirdparty
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
|
||||||
|
$extrafields=new ExtraFields($this->db);
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
|
||||||
|
$this->fetch_optionals($this->id,$extralabels);
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -694,6 +739,18 @@ class Account extends CommonObject
|
|||||||
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);
|
||||||
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)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -89,6 +89,39 @@ function bank_prepare_head($object)
|
|||||||
|
|
||||||
return $head;
|
return $head;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Prepare array with list of tabs
|
||||||
|
*
|
||||||
|
* @param Object $object Object related to tabs
|
||||||
|
* @return array Array of tabs to shoc
|
||||||
|
*/
|
||||||
|
function bank_admin_prepare_head($object)
|
||||||
|
{
|
||||||
|
global $langs, $conf, $user;
|
||||||
|
$h = 0;
|
||||||
|
$head = array();
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT . '/admin/bank.php';
|
||||||
|
$head[$h][1] = $langs->trans("Miscellaneous");
|
||||||
|
$head[$h][2] = 'general';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
|
||||||
|
// Show more tabs from modules
|
||||||
|
// Entries must be declared in modules descriptor with line
|
||||||
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||||
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||||
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin');
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/admin/bank_extrafields.php';
|
||||||
|
$head[$h][1] = $langs->trans("ExtraFields");
|
||||||
|
$head[$h][2] = 'attributes';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin', 'remove');
|
||||||
|
|
||||||
|
return $head;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check account number informations for a bank account
|
* Check account number informations for a bank account
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_bank_account_extrafields ADD INDEX idx_bank_account_extrafields (fk_object);
|
||||||
26
htdocs/install/mysql/tables/llx_bank_account_extrafields.sql
Normal file
26
htdocs/install/mysql/tables/llx_bank_account_extrafields.sql
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
-- ========================================================================
|
||||||
|
-- Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ========================================================================
|
||||||
|
|
||||||
|
create table llx_bank_account_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL,
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
) ENGINE=innodb;
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user