Merge pull request #22484 from Easya-Solutions/new-societe-set-thirdparty-type-with-trigger

NEW set thirdparty type with company modify trigger
This commit is contained in:
Laurent Destailleur 2022-10-06 11:58:02 +02:00 committed by GitHub
commit 1560228d9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -2072,7 +2072,7 @@ abstract class CommonObject
if ($resql) {
if ($trigkey) {
// call trigger with updated object values
if (empty($this->fields) && method_exists($this, 'fetch')) {
if (method_exists($this, 'fetch')) {
$result = $this->fetch($id);
} else {
$result = $this->fetchCommon($id);

View File

@ -4932,15 +4932,16 @@ class Societe extends CommonObject
*/
public function setThirdpartyType($typent_id)
{
global $user;
dol_syslog(__METHOD__, LOG_DEBUG);
if ($this->id) {
$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql .= " SET fk_typent = ".($typent_id > 0 ? $typent_id : "null");
$sql .= " WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this).'::setThirdpartyType', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$result = $this->setValueFrom('fk_typent', $typent_id, '', null, '', '', $user, 'COMPANY_MODIFY');
if ($result > 0) {
$this->typent_id = $typent_id;
$this->typent_code = dol_getIdFromCode($this->db, $this->$typent_id, 'c_typent', 'id', 'code');
$this->typent_code = dol_getIdFromCode($this->db, $this->typent_id, 'c_typent', 'id', 'code');
return 1;
} else {
return -1;