diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 6b0b722b629..81f1da40615 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -383,7 +383,12 @@ if (!is_array($result) && $result < 0) { print ''; } - print ''; + // Multicompany + print ''; + if (isModEnabled('multicompany')) { + print dol_escape_htmltag($defaultvalue->entity); + } + print ''; // Actions print ''; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 724e09554db..2e7425dca98 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -76,7 +76,7 @@ if ($action == 'add') { $errori[$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; } $i++; @@ -114,17 +114,17 @@ if ($action == 'add') { if (!$errori[$n]) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountfrom = new Account($db); - $accountfrom->fetch(GETPOST($n.'_account_from', 'int')); + $tmpaccountfrom = new Account($db); + $tmpaccountfrom->fetch(GETPOST($n.'_account_from', 'int')); - $accountto = new Account($db); - $accountto->fetch(GETPOST($n.'_account_to', 'int')); + $tmpaccountto = new Account($db); + $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]; } else { if (!$amountto[$n]) { - $error[$n]++; + $errori[$n]++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")).' #'.$n, null, 'errors'); } } @@ -133,7 +133,7 @@ if ($action == 'add') { setEventMessages($langs->trans("AmountMustBePositive").' #'.$n, null, 'errors'); } - if ($accountto->id == $accountfrom->id) { + if ($tmpaccountto->id == $tmpaccountfrom->id) { $errori[$n]++; setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers").' #'.$n, null, 'errors'); } @@ -149,45 +149,45 @@ if ($action == 'add') { // By default, electronic transfert from bank to bank $typefrom = $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 $typefrom = 'LIQ'; $typeto = 'LIQ'; } 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)) { $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)) { $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)) { - $errori++; + $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)) { $errori[$n]++; } if (!$errori[$n]) { $mesgs = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount[$n], $langs->transnoentitiesnoconv("Currency".$conf->currency)); - $mesgs = str_replace('{s1}', ''.$accountfrom->label.'', $mesgs); - $mesgs = str_replace('{s2}', ''.$accountto->label.'', $mesgs); + $mesgs = str_replace('{s1}', ''.$tmpaccountfrom->label.'', $mesgs); + $mesgs = str_replace('{s2}', ''.$tmpaccountto->label.'', $mesgs); setEventMessages($mesgs, null, 'mesgs'); $db->commit(); } else { - setEventMessages($accountfrom->error.' '.$accountto->error, null, 'errors'); + setEventMessages($tmpaccountfrom->error.' '.$tmpaccountto->error, null, 'errors'); $db->rollback(); } } @@ -211,68 +211,38 @@ llxHeader('', $title, $help_url); print ' '; @@ -298,16 +268,18 @@ print ''.$langs->trans("Type").''; print ''.$langs->trans("Date").''; print ''.$langs->trans("Description").''; print ''.$langs->trans("Amount").''; -//print ''.$langs->trans("AmountToOthercurrency").''; +print ''.$langs->trans("AmountToOthercurrency").''; print ''; for ($i = 1 ; $i < $MAXLINES; $i++) { $label = ''; $amount = ''; + $amounto = ''; if ($errori[$i]) { $label = GETPOST($i.'_label', 'alpha'); $amount = GETPOST($i.'_amount', 'alpha'); + $amountto = GETPOST($i.'_amountto', 'alpha'); } if ($i == 1) { @@ -339,11 +311,14 @@ for ($i = 1 ; $i < $MAXLINES; $i++) { print $form->selectDate((!empty($dateo[$i]) ? $dateo[$i] : ''), $i.'_', '', '', '', 'add'); print "\n"; + // Description print ''; + // Amount print ''; - print ''; + // AmountToOthercurrency + print ''; print ''; } @@ -352,7 +327,7 @@ print ''; print ''; print ''; print '
'; -print ' +print ' '; diff --git a/htdocs/core/ajax/getaccountcurrency.php b/htdocs/core/ajax/getaccountcurrency.php deleted file mode 100644 index 20061dcdf2b..00000000000 --- a/htdocs/core/ajax/getaccountcurrency.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * 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 . - */ - -/** - * \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 ''."\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); -} diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f7d8ea37649..3afca8464fa 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -440,15 +440,15 @@ class EmailCollector extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ /* - public function fetchLines() - { - $this->lines=array(); + public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailCollectorLine + // Load lines with object EmailCollectorLine - return count($this->lines)?1:0; - } - */ + return count($this->lines)?1:0; + } + */ /** * Fetch all account and load objects into an array @@ -1096,6 +1096,8 @@ class EmailCollector extends CommonObject $searchfilterisanswer = 0; $searchfilterisnotanswer = 0; $searchfilterreplyto = 0; + $searchfilterexcludebody = ''; + $searchfilterexcludesubject = ''; $operationslog = ''; $now = dol_now(); @@ -1154,7 +1156,7 @@ class EmailCollector extends CommonObject getDolGlobalString('OAUTH_'.$this->oauth_service.'_ID'), getDolGlobalString('OAUTH_'.$this->oauth_service.'_SECRET'), getDolGlobalString('OAUTH_'.$this->oauth_service.'_URLAUTHORIZE') - ); + ); $serviceFactory = new \OAuth\ServiceFactory(); $oauthname = explode('-', $OAUTH_SERVICENAME); // ex service is Google-Emails we need only the first part Google @@ -1285,10 +1287,20 @@ class EmailCollector extends CommonObject array_push($criteria, array($not."CC" => $rule['rulevalue'])); } 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') { - 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') { array_push($criteria, array($not."HEADER" => $rule['rulevalue'])); @@ -1296,12 +1308,12 @@ class EmailCollector extends CommonObject /* seems not used */ /* - if ($rule['type'] == 'notinsubject') { - array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue'])); - } - if ($rule['type'] == 'notinbody') { - array_push($criteria, array($not."BODY NOT" => $rule['rulevalue'])); - }*/ + if ($rule['type'] == 'notinsubject') { + array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue'])); + } + if ($rule['type'] == 'notinbody') { + array_push($criteria, array($not."BODY NOT" => $rule['rulevalue'])); + }*/ if ($rule['type'] == 'seen') { array_push($criteria, array($not."SEEN")); @@ -1406,10 +1418,20 @@ class EmailCollector extends CommonObject $search .= ($search ? ' ' : '').$not.'CC'; } 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') { - $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') { $search .= ($search ? ' ' : '').$not.'HEADER '.$rule['rulevalue']; @@ -1417,12 +1439,12 @@ class EmailCollector extends CommonObject /* seems not used */ /* - if ($rule['type'] == 'notinsubject') { - $search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; - } - if ($rule['type'] == 'notinbody') { - $search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; - }*/ + if ($rule['type'] == 'notinsubject') { + $search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + } + if ($rule['type'] == 'notinbody') { + $search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + }*/ if ($rule['type'] == 'seen') { $search .= ($search ? ' ' : '').$not.'SEEN'; @@ -1538,19 +1560,19 @@ class EmailCollector extends CommonObject if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) { // Loop to get part html and plain /* - 0 multipart/mixed - 1 multipart/alternative - 1.1 text/plain - 1.2 text/html - 2 message/rfc822 - 2 multipart/mixed - 2.1 multipart/alternative - 2.1.1 text/plain - 2.1.2 text/html - 2.2 message/rfc822 - 2.2 multipart/alternative - 2.2.1 text/plain - 2.2.2 text/html + 0 multipart/mixed + 1 multipart/alternative + 1.1 text/plain + 1.2 text/html + 2 message/rfc822 + 2 multipart/mixed + 2.1 multipart/alternative + 2.1.1 text/plain + 2.1.2 text/html + 2.2 message/rfc822 + 2.2 multipart/alternative + 2.2.1 text/plain + 2.2.2 text/html */ dol_syslog("Start of loop on email", LOG_INFO, 1); @@ -1567,6 +1589,8 @@ class EmailCollector extends CommonObject $header = $imapemail->getHeader()->raw; $overview = $imapemail->getAttributes(); } else { + $operationslog .= '
email = '.((string) $imapemail); + //$header = imap_headerinfo($connection, $imapemail); $header = imap_fetchheader($connection, $imapemail, 0); $overview = imap_fetch_overview($connection, $imapemail, 0); @@ -1684,8 +1708,6 @@ class EmailCollector extends CommonObject $ticketfoundby = ''; $candidaturefoundby = ''; - $this->db->begin(); - 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']); @@ -1719,7 +1741,7 @@ class EmailCollector extends CommonObject $attachments = []; } } else { - $this->getmsg($connection, $imapemail); + $this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments } //print $plainmsg; //var_dump($plainmsg); exit; @@ -1729,6 +1751,15 @@ class EmailCollector extends CommonObject // Removed emojis $messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext); + if ($searchfilterexcludebody) { + if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) { + $nbemailprocessed++; + $operationslog .= '
Discarded - Email body contains string '.$searchfilterexcludebody; + dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody); + continue; // Exclude email + } + } + //var_dump($plainmsg); //var_dump($htmlmsg); //var_dump($messagetext); @@ -1738,45 +1769,45 @@ class EmailCollector extends CommonObject // Parse IMAP email structure /* - $structure = imap_fetchstructure($connection, $imapemail, 0); + $structure = imap_fetchstructure($connection, $imapemail, 0); - $partplain = $parthtml = -1; - $encodingplain = $encodinghtml = ''; + $partplain = $parthtml = -1; + $encodingplain = $encodinghtml = ''; - $result = createPartArray($structure, ''); + $result = createPartArray($structure, ''); - foreach($result as $part) - { - // $part['part_object']->type seems 0 for content - // $part['part_object']->type seems 5 for attachment - if (empty($part['part_object'])) continue; - if ($part['part_object']->subtype == 'HTML') - { - $parthtml=$part['part_number']; - if ($part['part_object']->encoding == 4) - { - $encodinghtml = 'aaa'; - } - } - if ($part['part_object']->subtype == 'PLAIN') - { - $partplain=$part['part_number']; - if ($part['part_object']->encoding == 4) - { - $encodingplain = 'rr'; - } - } - } - //var_dump($result); - //var_dump($partplain); - //var_dump($parthtml); + foreach($result as $part) + { + // $part['part_object']->type seems 0 for content + // $part['part_object']->type seems 5 for attachment + if (empty($part['part_object'])) continue; + if ($part['part_object']->subtype == 'HTML') + { + $parthtml=$part['part_number']; + if ($part['part_object']->encoding == 4) + { + $encodinghtml = 'aaa'; + } + } + if ($part['part_object']->subtype == 'PLAIN') + { + $partplain=$part['part_number']; + if ($part['part_object']->encoding == 4) + { + $encodingplain = 'rr'; + } + } + } + //var_dump($result); + //var_dump($partplain); + //var_dump($parthtml); - //var_dump($structure); - //var_dump($parthtml); - //var_dump($partplain); + //var_dump($structure); + //var_dump($parthtml); + //var_dump($partplain); - $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK); - */ + $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK); + */ //var_dump($messagetext); //var_dump($structure->parts[0]->parts); @@ -1812,6 +1843,14 @@ class EmailCollector extends CommonObject //var_dump($msgid);exit; } + if ($searchfilterexcludesubject) { + if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) { + $nbemailprocessed++; + $operationslog .= '
Discarded - Email subject contains string '.$searchfilterexcludesubject; + dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject); + continue; // Exclude email + } + } $reg = array(); if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) { @@ -1830,6 +1869,7 @@ class EmailCollector extends CommonObject } $fk_element_id = 0; $fk_element_type = ''; + $this->db->begin(); $contactid = 0; $thirdpartyid = 0; $projectid = 0; $ticketid = 0; @@ -1918,11 +1958,11 @@ class EmailCollector extends CommonObject $objectemail = new Adherent($this->db); } /*if ($reg[1] == 'leav') { // Leave / Holiday - $objectemail = new Holiday($db); - } - if ($reg[1] == 'exp') { // ExpenseReport - $objectemail = new ExpenseReport($db); - }*/ + $objectemail = new Holiday($db); + } + if ($reg[1] == 'exp') { // ExpenseReport + $objectemail = new ExpenseReport($db); + }*/ } elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) { // This is an external reference, we check if we have it in our database if (!is_object($objectemail)) { @@ -2081,34 +2121,34 @@ class EmailCollector extends CommonObject } /* - if ($replyto) { - if (empty($contactid)) { // Try to find contact using email - $result = $contactstatic->fetch(0, null, '', $replyto); + if ($replyto) { + if (empty($contactid)) { // Try to find contact using email + $result = $contactstatic->fetch(0, null, '', $replyto); - if ($result > 0) { - dol_syslog("We found a contact with the email ".$replyto); - $contactid = $contactstatic->id; - $contactfoundby = 'email of contact ('.$replyto.')'; - if (empty($thirdpartyid) && $contactstatic->socid > 0) { - $result = $thirdpartystatic->fetch($contactstatic->socid); - if ($result > 0) { - $thirdpartyid = $thirdpartystatic->id; - $thirdpartyfoundby = 'email of contact ('.$replyto.')'; - } - } - } - } + if ($result > 0) { + dol_syslog("We found a contact with the email ".$replyto); + $contactid = $contactstatic->id; + $contactfoundby = 'email of contact ('.$replyto.')'; + if (empty($thirdpartyid) && $contactstatic->socid > 0) { + $result = $thirdpartystatic->fetch($contactstatic->socid); + if ($result > 0) { + $thirdpartyid = $thirdpartystatic->id; + $thirdpartyfoundby = 'email of contact ('.$replyto.')'; + } + } + } + } - if (empty($thirdpartyid)) { // Try to find thirdparty using email - $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); - if ($result > 0) { - dol_syslog("We found a thirdparty with the email ".$replyto); - $thirdpartyid = $thirdpartystatic->id;; - $thirdpartyfoundby = 'email ('.$replyto.')'; - } - } - } - */ + if (empty($thirdpartyid)) { // Try to find thirdparty using email + $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); + if ($result > 0) { + dol_syslog("We found a thirdparty with the email ".$replyto); + $thirdpartyid = $thirdpartystatic->id;; + $thirdpartyfoundby = 'email ('.$replyto.')'; + } + } + } + */ // Do operations (extract variables and creating data) if ($mode < 2) { // 0=Mode production, 1=Mode test (read IMAP and try SQL update then rollback), 2=Mode test with no SQL updates @@ -2549,98 +2589,98 @@ class EmailCollector extends CommonObject $this->errors[] = 'User Not allowed to add documents'; } $arrayobject = array( - 'propale' => array('table' => 'propal', - 'fields' => array('ref'), - 'class' => 'comm/propal/class/propal.class.php', - 'object' => 'Propal'), - 'holiday' => array('table' => 'holiday', - 'fields' => array('ref'), - 'class' => 'holiday/class/holiday.class.php', - 'object' => 'Holiday'), - 'expensereport' => array('table' => 'expensereport', - 'fields' => array('ref'), - 'class' => 'expensereport/class/expensereport.class.php', - 'object' => 'ExpenseReport'), - 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition', - 'fields' => array('ref'), - 'class' => 'recruitment/class/recruitmentjobposition.class.php', - 'object' => 'RecruitmentJobPosition'), - 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', - 'fields' => array('ref'), - 'class' => 'recruitment/class/recruitmentcandidature.class.php', - 'object' => ' RecruitmentCandidature'), - 'societe' => array('table' => 'societe', - 'fields' => array('code_client', 'code_fournisseur'), - 'class' => 'societe/class/societe.class.php', - 'object' => 'Societe'), - 'commande' => array('table' => 'commande', - 'fields' => array('ref'), - 'class' => 'commande/class/commande.class.php', - 'object' => 'Commande'), - 'expedition' => array('table' => 'expedition', - 'fields' => array('ref'), - 'class' => 'expedition/class/expedition.class.php', - 'object' => 'Expedition'), - 'contract' => array('table' => 'contrat', - 'fields' => array('ref'), - 'class' => 'contrat/class/contrat.class.php', - 'object' => 'Contrat'), - 'fichinter' => array('table' => 'fichinter', - 'fields' => array('ref'), - 'class' => 'fichinter/class/fichinter.class.php', - 'object' => 'Fichinter'), - 'ticket' => array('table' => 'ticket', - 'fields' => array('ref'), - 'class' => 'ticket/class/ticket.class.php', - 'object' => 'Ticket'), - 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord', - 'fields' => array('ref'), - 'class' => 'knowledgemanagement/class/knowledgemanagement.class.php', - 'object' => 'KnowledgeRecord'), - 'supplier_proposal' => array('table' => 'supplier_proposal', - 'fields' => array('ref'), - 'class' => 'supplier_proposal/class/supplier_proposal.class.php', - 'object' => 'SupplierProposal'), - 'fournisseur/commande' => array('table' => 'commande_fournisseur', - 'fields' => array('ref', 'ref_supplier'), - 'class' => 'fourn/class/fournisseur.commande.class.php', - 'object' => 'SupplierProposal'), - 'facture' => array('table' => 'facture', - 'fields' => array('ref'), - 'class' => 'compta/facture/class/facture.class.php', - 'object' => 'Facture'), - 'fournisseur/facture' => array('table' => 'facture_fourn', - 'fields' => array('ref', 'ref_client'), - 'class' => 'fourn/class/fournisseur.facture.class.php', - 'object' => 'FactureFournisseur'), - 'produit' => array('table' => 'product', - 'fields' => array('ref'), - 'class' => 'product/class/product.class.php', - 'object' => 'Product'), - 'productlot' => array('table' => 'product_lot', - 'fields' => array('batch'), - 'class' => 'product/stock/class/productlot.class.php', - 'object' => 'Productlot'), - 'projet' => array('table' => 'projet', - 'fields' => array('ref'), - 'class' => 'projet/class/projet.class.php', - 'object' => 'Project'), - 'projet_task' => array('table' => 'projet_task', - 'fields' => array('ref'), - 'class' => 'projet/class/task.class.php', - 'object' => 'Task'), - 'ressource' => array('table' => 'resource', - 'fields' => array('ref'), - 'class' => 'ressource/class/dolressource.class.php', - 'object' => 'Dolresource'), - 'bom' => array('table' => 'bom_bom', - 'fields' => array('ref'), - 'class' => 'bom/class/bom.class.php', - 'object' => 'BOM'), - 'mrp' => array('table' => 'mrp_mo', - 'fields' => array('ref'), - 'class' => 'mrp/class/mo.class.php', - 'object' => 'Mo'), + 'propale' => array('table' => 'propal', + 'fields' => array('ref'), + 'class' => 'comm/propal/class/propal.class.php', + 'object' => 'Propal'), + 'holiday' => array('table' => 'holiday', + 'fields' => array('ref'), + 'class' => 'holiday/class/holiday.class.php', + 'object' => 'Holiday'), + 'expensereport' => array('table' => 'expensereport', + 'fields' => array('ref'), + 'class' => 'expensereport/class/expensereport.class.php', + 'object' => 'ExpenseReport'), + 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition', + 'fields' => array('ref'), + 'class' => 'recruitment/class/recruitmentjobposition.class.php', + 'object' => 'RecruitmentJobPosition'), + 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', + 'fields' => array('ref'), + 'class' => 'recruitment/class/recruitmentcandidature.class.php', + 'object' => ' RecruitmentCandidature'), + 'societe' => array('table' => 'societe', + 'fields' => array('code_client', 'code_fournisseur'), + 'class' => 'societe/class/societe.class.php', + 'object' => 'Societe'), + 'commande' => array('table' => 'commande', + 'fields' => array('ref'), + 'class' => 'commande/class/commande.class.php', + 'object' => 'Commande'), + 'expedition' => array('table' => 'expedition', + 'fields' => array('ref'), + 'class' => 'expedition/class/expedition.class.php', + 'object' => 'Expedition'), + 'contract' => array('table' => 'contrat', + 'fields' => array('ref'), + 'class' => 'contrat/class/contrat.class.php', + 'object' => 'Contrat'), + 'fichinter' => array('table' => 'fichinter', + 'fields' => array('ref'), + 'class' => 'fichinter/class/fichinter.class.php', + 'object' => 'Fichinter'), + 'ticket' => array('table' => 'ticket', + 'fields' => array('ref'), + 'class' => 'ticket/class/ticket.class.php', + 'object' => 'Ticket'), + 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord', + 'fields' => array('ref'), + 'class' => 'knowledgemanagement/class/knowledgemanagement.class.php', + 'object' => 'KnowledgeRecord'), + 'supplier_proposal' => array('table' => 'supplier_proposal', + 'fields' => array('ref'), + 'class' => 'supplier_proposal/class/supplier_proposal.class.php', + 'object' => 'SupplierProposal'), + 'fournisseur/commande' => array('table' => 'commande_fournisseur', + 'fields' => array('ref', 'ref_supplier'), + 'class' => 'fourn/class/fournisseur.commande.class.php', + 'object' => 'SupplierProposal'), + 'facture' => array('table' => 'facture', + 'fields' => array('ref'), + 'class' => 'compta/facture/class/facture.class.php', + 'object' => 'Facture'), + 'fournisseur/facture' => array('table' => 'facture_fourn', + 'fields' => array('ref', 'ref_client'), + 'class' => 'fourn/class/fournisseur.facture.class.php', + 'object' => 'FactureFournisseur'), + 'produit' => array('table' => 'product', + 'fields' => array('ref'), + 'class' => 'product/class/product.class.php', + 'object' => 'Product'), + 'productlot' => array('table' => 'product_lot', + 'fields' => array('batch'), + 'class' => 'product/stock/class/productlot.class.php', + 'object' => 'Productlot'), + 'projet' => array('table' => 'projet', + 'fields' => array('ref'), + 'class' => 'projet/class/projet.class.php', + 'object' => 'Project'), + 'projet_task' => array('table' => 'projet_task', + 'fields' => array('ref'), + 'class' => 'projet/class/task.class.php', + 'object' => 'Task'), + 'ressource' => array('table' => 'resource', + 'fields' => array('ref'), + 'class' => 'ressource/class/dolressource.class.php', + 'object' => 'Dolresource'), + 'bom' => array('table' => 'bom_bom', + 'fields' => array('ref'), + 'class' => 'bom/class/bom.class.php', + 'object' => 'BOM'), + 'mrp' => array('table' => 'mrp_mo', + 'fields' => array('ref'), + 'class' => 'mrp/class/mo.class.php', + 'object' => 'Mo'), ); if (!is_object($hookmanager)) { @@ -2997,43 +3037,43 @@ class EmailCollector extends CommonObject // Set candidature ref if not yet defined /*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status - { - // Get next Ref - $defaultref = ''; - $modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON; + { + // Get next Ref + $defaultref = ''; + $modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON; - // Search template files - $file = ''; $classname = ''; $filefound = 0; $reldir = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); - if (file_exists($file)) { - $filefound = 1; - $classname = $modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); + if (file_exists($file)) { + $filefound = 1; + $classname = $modele; + break; + } + } - if ($filefound) { - if ($savesocid > 0) { - if ($savesocid != $candidaturetocreate->socid) { - $errorforactions++; - setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$candidaturetocreate->socid.') by setting socid in operation with a different value', null, 'errors'); - } - } else { - if ($candidaturetocreate->socid > 0) - { - $thirdpartystatic->fetch($candidaturetocreate->socid); - } - } + if ($filefound) { + if ($savesocid > 0) { + if ($savesocid != $candidaturetocreate->socid) { + $errorforactions++; + setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$candidaturetocreate->socid.') by setting socid in operation with a different value', null, 'errors'); + } + } else { + if ($candidaturetocreate->socid > 0) + { + $thirdpartystatic->fetch($candidaturetocreate->socid); + } + } - $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); - $modModuleToUseForNextValue = new $classname; - $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); - } - $candidaturetocreate->ref = $defaultref; - }*/ + $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); + $modModuleToUseForNextValue = new $classname; + $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); + } + $candidaturetocreate->ref = $defaultref; + }*/ if ($errorforthisaction) { $errorforactions++; @@ -3101,11 +3141,16 @@ class EmailCollector extends CommonObject if (!empty($targetdir) && empty($mode)) { if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG); + $operationslog .= '
Move mail '.((string) $imapemail); + $res = imap_mail_move($connection, $imapemail, $targetdir, 0); if ($res == false) { $errorforemail++; $this->error = imap_last_error(); $this->errors[] = $this->error; + + $operationslog .= '
Error in move '.$this->error; + dol_syslog(imap_last_error()); } } else { @@ -3161,6 +3206,7 @@ class EmailCollector extends CommonObject $output = $langs->trans('NoNewEmailToProcess'); } + // Disconnect if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { $client->disconnect(); } else { diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ca0dd2f04bf..f604a9b9185 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -305,7 +305,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; 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 { $sql .= " WHERE 1 = 1"; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index e7e8cc40b68..445e370d85d 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -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 $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)) { $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users }