Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
8b21a0dbd3
@ -2510,11 +2510,11 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
} elseif ($value == 'block_if_negative') {
|
} elseif ($value == 'block_if_negative') {
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $form->selectyesno("block_if_negative", (!empty($obj->{$value}) ? $obj->{$value}:''), 1);
|
print $form->selectyesno("block_if_negative", (empty($obj->block_if_negative) ? '' : $obj->block_if_negative), 1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
} elseif ($value == 'type_duration') {
|
} elseif ($value == 'type_duration') {
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $form->selectTypeDuration('', $obj->{$value}, array('i','h'));
|
print $form->selectTypeDuration('', (empty($obj->type_duration) ? '' : $obj->type_duration), array('i','h'));
|
||||||
print '</td>';
|
print '</td>';
|
||||||
} else {
|
} else {
|
||||||
$fieldValue = isset($obj->{$value}) ? $obj->{$value}: '';
|
$fieldValue = isset($obj->{$value}) ? $obj->{$value}: '';
|
||||||
|
|||||||
@ -35,6 +35,17 @@ class CompanyBankAccount extends Account
|
|||||||
{
|
{
|
||||||
public $socid;
|
public $socid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string ID to identify managed object
|
||||||
|
*/
|
||||||
|
public $element = 'societe_rib';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Name of table without prefix where object is stored
|
||||||
|
*/
|
||||||
|
public $table_element = 'societe_rib';
|
||||||
|
|
||||||
|
/** @var bool $default_rib 1 = this object is the third party's default bank information */
|
||||||
public $default_rib;
|
public $default_rib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,6 +75,13 @@ class CompanyBankAccount extends Account
|
|||||||
*/
|
*/
|
||||||
public $datem;
|
public $datem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string TRIGGER_PREFIX Dolibarr 16.0 and above use the prefix to prevent the creation of inconsistently
|
||||||
|
* named triggers
|
||||||
|
* @see CommonObject::call_trigger()
|
||||||
|
*/
|
||||||
|
const TRIGGER_PREFIX = 'COMPANY_RIB';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -86,7 +104,7 @@ class CompanyBankAccount extends Account
|
|||||||
*
|
*
|
||||||
* @param User $user User
|
* @param User $user User
|
||||||
* @param int $notrigger 1=Disable triggers
|
* @param int $notrigger 1=Disable triggers
|
||||||
* @return int <0 if KO, >= 0 if OK
|
* @return int <0 if KO, > 0 if OK (ID of newly created company bank account information)
|
||||||
*/
|
*/
|
||||||
public function create(User $user = null, $notrigger = 0)
|
public function create(User $user = null, $notrigger = 0)
|
||||||
{
|
{
|
||||||
@ -97,6 +115,7 @@ class CompanyBankAccount extends Account
|
|||||||
// Check paramaters
|
// Check paramaters
|
||||||
if (empty($this->socid)) {
|
if (empty($this->socid)) {
|
||||||
$this->error = 'BadValueForParameter';
|
$this->error = 'BadValueForParameter';
|
||||||
|
$this->errors[] = $this->error;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +133,9 @@ class CompanyBankAccount extends Account
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
|
||||||
$sql .= " VALUES (".((int) $this->socid).", 'ban', '".$this->db->idate($now)."')";
|
$sql .= " VALUES (".((int) $this->socid).", 'ban', '".$this->db->idate($now)."')";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -128,19 +150,20 @@ class CompanyBankAccount extends Account
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
$this->errors[] = $this->error;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
|
$this->db->commit();
|
||||||
return $this->id;
|
return $this->id;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
$this->db->rollback();
|
||||||
}
|
return -1;
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->error = $this->db->lasterror();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +191,8 @@ class CompanyBankAccount extends Account
|
|||||||
$this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
|
$this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
|
||||||
$sql .= " bank = '".$this->db->escape($this->bank)."'";
|
$sql .= " bank = '".$this->db->escape($this->bank)."'";
|
||||||
$sql .= ",code_banque='".$this->db->escape($this->code_banque)."'";
|
$sql .= ",code_banque='".$this->db->escape($this->code_banque)."'";
|
||||||
@ -203,20 +228,22 @@ class CompanyBankAccount extends Account
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
if (!$error) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$error++;
|
||||||
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||||
$this->error = $langs->trans('ErrorDuplicateField');
|
$this->error = $langs->trans('ErrorDuplicateField');
|
||||||
} else {
|
} else {
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
}
|
}
|
||||||
|
$this->errors[] = $this->error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,8 +183,10 @@ if (empty($reshook)) {
|
|||||||
$companybankaccount->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
|
$companybankaccount->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
|
||||||
|
|
||||||
$result = $companybankaccount->update($user);
|
$result = $companybankaccount->update($user);
|
||||||
if (!$result) {
|
if ($result <= 0) {
|
||||||
|
// Display error message and get back to edit mode
|
||||||
setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
|
setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
|
||||||
|
$action = 'edit';
|
||||||
} else {
|
} else {
|
||||||
// If this account is the default bank account, we disable others
|
// If this account is the default bank account, we disable others
|
||||||
if ($companybankaccount->default_rib) {
|
if ($companybankaccount->default_rib) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user