diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index aed83d641f3..146ae3d40b6 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -183,7 +183,7 @@ $langs->load("cashdesk"); else print ''; print ''; print '
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) { $langs->load("errors"); print ''; @@ -191,7 +191,7 @@ $langs->load("cashdesk"); else print ''; print '
'; print '
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) { $langs->load("errors"); print ''; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 0caf056eab6..47af9ba4ae0 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -753,7 +753,7 @@ class CMailFile $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector); - $this->message->attachSigner($signer); + $this->message->attachSigner($signer->ignoreHeader('Return-Path')); } if (! empty($conf->global->MAIN_MAIL_DEBUG)) { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index d4ffc513521..a6473eaeb8e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -591,6 +591,7 @@ class ImportCsv extends ModeleImports if (!empty($updatekeys)) { // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) + if (empty($lastinsertid)) { $sqlSelect = 'SELECT rowid FROM '.$tablename; @@ -626,6 +627,34 @@ class ImportCsv extends ModeleImports $this->errors[$error]['type']='SQL'; $error++; } + } else { + // We have a last INSERT ID. Check if we have a row referencing this foreign key. + // This is required when updating table with some extrafields. When inserting a record in parent table, we can make + // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record + // may already exists. So we rescan the extrafield table to be know if record exists or not for the rowid. + $sqlSelect = 'SELECT rowid FROM '.$tablename; + + if(empty($keyfield)) $keyfield = 'rowid'; + $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; + + $resql=$this->db->query($sqlSelect); + if($resql) { + $res = $this->db->fetch_object($resql); + if($resql->num_rows == 1) { + // We have a row referencing this last foreign key, continue with UPDATE. + } else { + // No record found referencing this last foreign key, + // force $lastinsertid to 0 so we INSERT below. + $lastinsertid = 0; + } + } + else + { + //print 'E'; + $this->errors[$error]['lib']=$this->db->lasterror(); + $this->errors[$error]['type']='SQL'; + $error++; + } } if (!empty($lastinsertid)) { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 214ce91b032..7f222f523ca 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -651,6 +651,34 @@ class ImportXlsx extends ModeleImports $this->errors[$error]['type']='SQL'; $error++; } + } else { + // We have a last INSERT ID. Check if we have a row referencing this foreign key. + // This is required when updating table with some extrafields. When inserting a record in parent table, we can make + // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record + // may already exists. So we rescan the extrafield table to be know if record exists or not for the rowid. + $sqlSelect = 'SELECT rowid FROM '.$tablename; + + if(empty($keyfield)) $keyfield = 'rowid'; + $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; + + $resql=$this->db->query($sqlSelect); + if($resql) { + $res = $this->db->fetch_object($resql); + if($resql->num_rows == 1) { + // We have a row referencing this last foreign key, continue with UPDATE. + } else { + // No record found referencing this last foreign key, + // force $lastinsertid to 0 so we INSERT below. + $lastinsertid = 0; + } + } + else + { + //print 'E'; + $this->errors[$error]['lib']=$this->db->lasterror(); + $this->errors[$error]['type']='SQL'; + $error++; + } } if (!empty($lastinsertid)) {