Merge branch 'Dolibarr:develop' into develop

This commit is contained in:
Joachim Kueter 2023-04-12 21:45:30 +02:00 committed by GitHub
commit 7cc62f452b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 333 additions and 373 deletions

View File

@ -383,7 +383,12 @@ if (!is_array($result) && $result < 0) {
print '</td>'; print '</td>';
} }
print '<td></td>'; // Multicompany
print '<td>';
if (isModEnabled('multicompany')) {
print dol_escape_htmltag($defaultvalue->entity);
}
print '</td>';
// Actions // Actions
print '<td class="center">'; print '<td class="center">';

View File

@ -76,7 +76,7 @@ if ($action == 'add') {
$errori[$i] = 0; $errori[$i] = 0;
$tabnum[$i] = 0; $tabnum[$i] = 0;
if (!empty($label[$i]) || !empty($type[$i]) || !($amount[$i] <= 0) || !($accountfrom[$i] < 0) || !($accountto[$i] < 0)) { if (!empty($label[$i]) || !($amount[$i] <= 0) || !($accountfrom[$i] < 0) || !($accountto[$i] < 0)) {
$tabnum[$i] = 1; $tabnum[$i] = 1;
} }
$i++; $i++;
@ -114,17 +114,17 @@ if ($action == 'add') {
if (!$errori[$n]) { if (!$errori[$n]) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$accountfrom = new Account($db); $tmpaccountfrom = new Account($db);
$accountfrom->fetch(GETPOST($n.'_account_from', 'int')); $tmpaccountfrom->fetch(GETPOST($n.'_account_from', 'int'));
$accountto = new Account($db); $tmpaccountto = new Account($db);
$accountto->fetch(GETPOST($n.'_account_to', 'int')); $tmpaccountto->fetch(GETPOST($n.'_account_to', 'int'));
if ($accountto->currency_code == $accountfrom->currency_code) { if ($tmpaccountto->currency_code == $tmpaccountfrom->currency_code) {
$amountto[$n] = $amount[$n]; $amountto[$n] = $amount[$n];
} else { } else {
if (!$amountto[$n]) { if (!$amountto[$n]) {
$error[$n]++; $errori[$n]++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")).' #'.$n, null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")).' #'.$n, null, 'errors');
} }
} }
@ -133,7 +133,7 @@ if ($action == 'add') {
setEventMessages($langs->trans("AmountMustBePositive").' #'.$n, null, 'errors'); setEventMessages($langs->trans("AmountMustBePositive").' #'.$n, null, 'errors');
} }
if ($accountto->id == $accountfrom->id) { if ($tmpaccountto->id == $tmpaccountfrom->id) {
$errori[$n]++; $errori[$n]++;
setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers").' #'.$n, null, 'errors'); setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers").' #'.$n, null, 'errors');
} }
@ -149,45 +149,45 @@ if ($action == 'add') {
// By default, electronic transfert from bank to bank // By default, electronic transfert from bank to bank
$typefrom = $type[$n]; $typefrom = $type[$n];
$typeto = $type[$n]; $typeto = $type[$n];
if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { if ($tmpaccountto->courant == Account::TYPE_CASH || $tmpaccountfrom->courant == Account::TYPE_CASH) {
// This is transfer of change // This is transfer of change
$typefrom = 'LIQ'; $typefrom = 'LIQ';
$typeto = 'LIQ'; $typeto = 'LIQ';
} }
if (!$errori[$n]) { if (!$errori[$n]) {
$bank_line_id_from = $accountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * $amount[$n]), '', '', $user); $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * $amount[$n]), '', '', $user);
} }
if (!($bank_line_id_from > 0)) { if (!($bank_line_id_from > 0)) {
$errori[$n]++; $errori[$n]++;
} }
if (!$errori[$n]) { if (!$errori[$n]) {
$bank_line_id_to = $accountto->addline($dateo[$n], $typeto, $label[$n], $amountto[$n], '', '', $user); $bank_line_id_to = $tmpaccountto->addline($dateo[$n], $typeto, $label[$n], $amountto[$n], '', '', $user);
} }
if (!($bank_line_id_to > 0)) { if (!($bank_line_id_to > 0)) {
$errori[$n]++; $errori[$n]++;
} }
if (!$errori[$n]) { if (!$errori[$n]) {
$result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); $result = $tmpaccountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert');
} }
if (!($result > 0)) { if (!($result > 0)) {
$errori++; $errori[$n]++;
} }
if (!$errori[$n]) { if (!$errori[$n]) {
$result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); $result = $tmpaccountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert');
} }
if (!($result > 0)) { if (!($result > 0)) {
$errori[$n]++; $errori[$n]++;
} }
if (!$errori[$n]) { if (!$errori[$n]) {
$mesgs = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount[$n], $langs->transnoentitiesnoconv("Currency".$conf->currency)); $mesgs = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount[$n], $langs->transnoentitiesnoconv("Currency".$conf->currency));
$mesgs = str_replace('{s1}', '<a href="bankentries_list.php?id='.$accountfrom->id.'&sortfield=b.datev,b.dateo,b.rowid&sortorder=desc">'.$accountfrom->label.'</a>', $mesgs); $mesgs = str_replace('{s1}', '<a href="bankentries_list.php?id='.$tmpaccountfrom->id.'&sortfield=b.datev,b.dateo,b.rowid&sortorder=desc">'.$tmpaccountfrom->label.'</a>', $mesgs);
$mesgs = str_replace('{s2}', '<a href="bankentries_list.php?id='.$accountto->id.'">'.$accountto->label.'</a>', $mesgs); $mesgs = str_replace('{s2}', '<a href="bankentries_list.php?id='.$tmpaccountto->id.'">'.$tmpaccountto->label.'</a>', $mesgs);
setEventMessages($mesgs, null, 'mesgs'); setEventMessages($mesgs, null, 'mesgs');
$db->commit(); $db->commit();
} else { } else {
setEventMessages($accountfrom->error.' '.$accountto->error, null, 'errors'); setEventMessages($tmpaccountfrom->error.' '.$tmpaccountto->error, null, 'errors');
$db->rollback(); $db->rollback();
} }
} }
@ -211,68 +211,38 @@ llxHeader('', $title, $help_url);
print ' <script type="text/javascript"> print ' <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$(".selectbankaccount").change(function() { $(".selectbankaccount").change(function() {
console.log("We change bank account"); console.log("We change bank account. We check if currency differs. If yes, we show multicurrency field");
init_page(); i = $(this).attr("name").replace("_account_to", "").replace("_account_from", "");
console.log(i);
init_page(i);
}); });
function init_page() { function init_page(i) {
console.log("Set fields according to currency"); // TODO Scan all line i and set atleast2differentcurrency if there is 2 different values among all lines
var account1 = $("#selectaccount_from").val(); var account1 = $("#select"+i+"_account_from").val();
var account2 = $("#selectaccount_to").val(); var account2 = $("#select"+i+"_account_to").val();
var currencycode1=""; var currencycode1 = $("#select"+i+"_account_from option:selected").attr("data-currency-code");
var currencycode2=""; var currencycode2 = $("#select"+i+"_account_to option:selected").attr("data-currency-code");
console.log("Set fields according to currencycode found currencycode1="+currencycode1+" currencycode2="+currencycode2);
var atleast2differentcurrency = (currencycode2!==currencycode1 && currencycode1 !== undefined && currencycode2 !== undefined && currencycode2!=="" && currencycode1!=="");
if (atleast2differentcurrency) {
console.log("We show multucurrency field");
$(".multicurrency").show();
} else {
console.log("We hide multucurrency field");
$(".multicurrency").hide();
}
$("select").each(function() { $("select").each(function() {
if( $(this).attr("view")){ if( $(this).attr("view")){
$(this).closest("tr").removeClass("hidejs").removeClass("hideobject"); $(this).closest("tr").removeClass("hidejs").removeClass("hideobject");
} }
}); });
$.get("'.DOL_URL_ROOT.'/core/ajax/getaccountcurrency.php", {id: account1})
.done(function( data ) {
if (data != null)
{
var item= $.parseJSON(data);
if (item.num==-1) {
console.error("Error: "+item.error);
} else if (item.num!==0) {
currencycode1 = item.value;
} }
$.get("'.DOL_URL_ROOT.'/core/ajax/getaccountcurrency.php", {id: account2}) init_page(1);
.done(function( data ) {
if (data != null)
{
var item=$.parseJSON(data);
if (item.num==-1) {
console.error("Error: "+item.error);
} else if (item.num!==0) {
currencycode2 = item.value;
}
if (currencycode2!==currencycode1 && currencycode2!=="" && currencycode1!=="") {
$(".multicurrency").show();
} else {
$(".multicurrency").hide();
}
}
else {
console.error("Error: Ajax url has returned an empty page. Should be an empty json array.");
}
}).fail(function( data ) {
console.error("Error: has returned an empty page. Should be an empty json array.");
});
}
else {
console.error("Error: has returned an empty page. Should be an empty json array.");
}
}).fail(function( data ) {
console.error("Error: has returned an empty page. Should be an empty json array.");
});
}
init_page();
}); });
</script>'; </script>';
@ -298,16 +268,18 @@ print '<th>'.$langs->trans("Type").'</th>';
print '<th>'.$langs->trans("Date").'</th>'; print '<th>'.$langs->trans("Date").'</th>';
print '<th>'.$langs->trans("Description").'</th>'; print '<th>'.$langs->trans("Description").'</th>';
print '<th class="right">'.$langs->trans("Amount").'</th>'; print '<th class="right">'.$langs->trans("Amount").'</th>';
//print '<td class="hideobject" class="multicurrency">'.$langs->trans("AmountToOthercurrency").'</td>'; print '<td class="hideobject multicurrency right">'.$langs->trans("AmountToOthercurrency").'</td>';
print '</tr>'; print '</tr>';
for ($i = 1 ; $i < $MAXLINES; $i++) { for ($i = 1 ; $i < $MAXLINES; $i++) {
$label = ''; $label = '';
$amount = ''; $amount = '';
$amounto = '';
if ($errori[$i]) { if ($errori[$i]) {
$label = GETPOST($i.'_label', 'alpha'); $label = GETPOST($i.'_label', 'alpha');
$amount = GETPOST($i.'_amount', 'alpha'); $amount = GETPOST($i.'_amount', 'alpha');
$amountto = GETPOST($i.'_amountto', 'alpha');
} }
if ($i == 1) { if ($i == 1) {
@ -339,11 +311,14 @@ for ($i = 1 ; $i < $MAXLINES; $i++) {
print $form->selectDate((!empty($dateo[$i]) ? $dateo[$i] : ''), $i.'_', '', '', '', 'add'); print $form->selectDate((!empty($dateo[$i]) ? $dateo[$i] : ''), $i.'_', '', '', '', 'add');
print "</td>\n"; print "</td>\n";
// Description
print '<td><input name="'.$i.'_label" class="flat quatrevingtpercent selectjs" type="text" value="'.dol_escape_htmltag($label).'"></td>'; print '<td><input name="'.$i.'_label" class="flat quatrevingtpercent selectjs" type="text" value="'.dol_escape_htmltag($label).'"></td>';
// Amount
print '<td class="right"><input name="'.$i.'_amount" class="flat right selectjs" type="text" size="6" value="'.dol_escape_htmltag($amount).'"></td>'; print '<td class="right"><input name="'.$i.'_amount" class="flat right selectjs" type="text" size="6" value="'.dol_escape_htmltag($amount).'"></td>';
print '<td class="hideobject" class="multicurrency"><input name="'.$i.'_amountto" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amountto).'"></td>'; // AmountToOthercurrency
print '<td class="hideobject multicurrency right"><input name="'.$i.'_amountto" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amountto).'"></td>';
print '</tr>'; print '</tr>';
} }
@ -352,7 +327,7 @@ print '</table>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '<div id="btncont" style="display: flex; align-items: center">'; print '<div id="btncont" style="display: flex; align-items: center">';
print '<a id="btnincrement" style="margin-left:35%" class="btnTitle btnTitlePlus" onclick="increment()" title="Ajouter écriture"> print '<a id="btnincrement" style="margin-left:35%" class="btnTitle btnTitlePlus" onclick="increment()" title="'.dol_escape_htmltag($langs->trans("Add")).'">
<span class="fa fa-plus-circle valignmiddle btnTitle-icon"> <span class="fa fa-plus-circle valignmiddle btnTitle-icon">
</span> </span>
</a>'; </a>';

View File

@ -1,66 +0,0 @@
<?php
/* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/ajax/getaccountcurrency.php
* \brief File to load currency rates
*/
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
// Load Dolibarr environment
require '../../main.inc.php';
$id = GETPOST('id', 'int');
// Security check
$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account');
/*
* View
*/
top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (!empty($id)) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$account = new Account($db);
$result = $account->fetch($id);
if ($result < 0) {
$return['value'] = '';
$return['num'] = $result;
$return['error'] = $account->errors[0];
} else {
$return['value'] = $account->currency_code;
$return['num'] = $result;
$return['error'] = '';
}
echo json_encode($return);
}

View File

@ -1096,6 +1096,8 @@ class EmailCollector extends CommonObject
$searchfilterisanswer = 0; $searchfilterisanswer = 0;
$searchfilterisnotanswer = 0; $searchfilterisnotanswer = 0;
$searchfilterreplyto = 0; $searchfilterreplyto = 0;
$searchfilterexcludebody = '';
$searchfilterexcludesubject = '';
$operationslog = ''; $operationslog = '';
$now = dol_now(); $now = dol_now();
@ -1285,10 +1287,20 @@ class EmailCollector extends CommonObject
array_push($criteria, array($not."CC" => $rule['rulevalue'])); array_push($criteria, array($not."CC" => $rule['rulevalue']));
} }
if ($rule['type'] == 'subject') { if ($rule['type'] == 'subject') {
array_push($criteria, array($not."SUBJECT" => $rule['rulevalue'])); if (strpos($rule['rulevalue'], '!') === 0) {
//array_push($criteria, array("NOT SUBJECT" => $rule['rulevalue']));
$searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
array_push($criteria, array("SUBJECT" => $rule['rulevalue']));
}
} }
if ($rule['type'] == 'body') { if ($rule['type'] == 'body') {
array_push($criteria, array($not."BODY" => $rule['rulevalue'])); if (strpos($rule['rulevalue'], '!') === 0) {
//array_push($criteria, array("NOT BODY" => $rule['rulevalue']));
$searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
array_push($criteria, array("BODY" => $rule['rulevalue']));
}
} }
if ($rule['type'] == 'header') { if ($rule['type'] == 'header') {
array_push($criteria, array($not."HEADER" => $rule['rulevalue'])); array_push($criteria, array($not."HEADER" => $rule['rulevalue']));
@ -1406,10 +1418,20 @@ class EmailCollector extends CommonObject
$search .= ($search ? ' ' : '').$not.'CC'; $search .= ($search ? ' ' : '').$not.'CC';
} }
if ($rule['type'] == 'subject') { if ($rule['type'] == 'subject') {
$search .= ($search ? ' ' : '').$not.'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; if (strpos($rule['rulevalue'], '!') === 0) {
//$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
$searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
$search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
}
} }
if ($rule['type'] == 'body') { if ($rule['type'] == 'body') {
$search .= ($search ? ' ' : '').$not.'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; if (strpos($rule['rulevalue'], '!') === 0) {
//$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
$searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
$search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
}
} }
if ($rule['type'] == 'header') { if ($rule['type'] == 'header') {
$search .= ($search ? ' ' : '').$not.'HEADER '.$rule['rulevalue']; $search .= ($search ? ' ' : '').$not.'HEADER '.$rule['rulevalue'];
@ -1567,6 +1589,8 @@ class EmailCollector extends CommonObject
$header = $imapemail->getHeader()->raw; $header = $imapemail->getHeader()->raw;
$overview = $imapemail->getAttributes(); $overview = $imapemail->getAttributes();
} else { } else {
$operationslog .= '<br>email = '.((string) $imapemail);
//$header = imap_headerinfo($connection, $imapemail); //$header = imap_headerinfo($connection, $imapemail);
$header = imap_fetchheader($connection, $imapemail, 0); $header = imap_fetchheader($connection, $imapemail, 0);
$overview = imap_fetch_overview($connection, $imapemail, 0); $overview = imap_fetch_overview($connection, $imapemail, 0);
@ -1684,8 +1708,6 @@ class EmailCollector extends CommonObject
$ticketfoundby = ''; $ticketfoundby = '';
$candidaturefoundby = ''; $candidaturefoundby = '';
$this->db->begin();
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
dol_syslog("msgid=".$overview['message_id']." date=".dol_print_date($overview['date'], 'dayrfc', 'gmt')." from=".$overview['from']." to=".$overview['to']." subject=".$overview['subject']); dol_syslog("msgid=".$overview['message_id']." date=".dol_print_date($overview['date'], 'dayrfc', 'gmt')." from=".$overview['from']." to=".$overview['to']." subject=".$overview['subject']);
@ -1719,7 +1741,7 @@ class EmailCollector extends CommonObject
$attachments = []; $attachments = [];
} }
} else { } else {
$this->getmsg($connection, $imapemail); $this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments
} }
//print $plainmsg; //print $plainmsg;
//var_dump($plainmsg); exit; //var_dump($plainmsg); exit;
@ -1729,6 +1751,15 @@ class EmailCollector extends CommonObject
// Removed emojis // Removed emojis
$messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext); $messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext);
if ($searchfilterexcludebody) {
if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) {
$nbemailprocessed++;
$operationslog .= '<br>Discarded - Email body contains string '.$searchfilterexcludebody;
dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody);
continue; // Exclude email
}
}
//var_dump($plainmsg); //var_dump($plainmsg);
//var_dump($htmlmsg); //var_dump($htmlmsg);
//var_dump($messagetext); //var_dump($messagetext);
@ -1812,6 +1843,14 @@ class EmailCollector extends CommonObject
//var_dump($msgid);exit; //var_dump($msgid);exit;
} }
if ($searchfilterexcludesubject) {
if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) {
$nbemailprocessed++;
$operationslog .= '<br>Discarded - Email subject contains string '.$searchfilterexcludesubject;
dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject);
continue; // Exclude email
}
}
$reg = array(); $reg = array();
if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) { if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) {
@ -1830,6 +1869,7 @@ class EmailCollector extends CommonObject
} }
$fk_element_id = 0; $fk_element_type = ''; $fk_element_id = 0; $fk_element_type = '';
$this->db->begin();
$contactid = 0; $thirdpartyid = 0; $projectid = 0; $ticketid = 0; $contactid = 0; $thirdpartyid = 0; $projectid = 0; $ticketid = 0;
@ -3101,11 +3141,16 @@ class EmailCollector extends CommonObject
if (!empty($targetdir) && empty($mode)) { if (!empty($targetdir) && empty($mode)) {
if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG); dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG);
$operationslog .= '<br>Move mail '.((string) $imapemail);
$res = imap_mail_move($connection, $imapemail, $targetdir, 0); $res = imap_mail_move($connection, $imapemail, $targetdir, 0);
if ($res == false) { if ($res == false) {
$errorforemail++; $errorforemail++;
$this->error = imap_last_error(); $this->error = imap_last_error();
$this->errors[] = $this->error; $this->errors[] = $this->error;
$operationslog .= '<br>Error in move '.$this->error;
dol_syslog(imap_last_error()); dol_syslog(imap_last_error());
} }
} else { } else {
@ -3161,6 +3206,7 @@ class EmailCollector extends CommonObject
$output = $langs->trans('NoNewEmailToProcess'); $output = $langs->trans('NoNewEmailToProcess');
} }
// Disconnect
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
$client->disconnect(); $client->disconnect();
} else { } else {

View File

@ -305,7 +305,7 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
if ($object->ismultientitymanaged == 1) { if ($object->ismultientitymanaged == 1) {
$sql .= " WHERE t.entity IN (".getEntity($object->element).")"; $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOST('search_current_entity', 'int') ? 0 : 1)).")";
} else { } else {
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
} }

View File

@ -473,7 +473,7 @@ if ($search_project_contact > 0) {
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
$sql .= " WHERE p.entity IN (".getEntity('project').')'; $sql .= " WHERE p.entity IN (".getEntity('project', (GETPOST('search_current_entity', 'int') ? 0 : 1)).')';
if (empty($user->rights->projet->all->lire)) { if (empty($user->rights->projet->all->lire)) {
$sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
} }