Merge branch 'Dolibarr:develop' into develop
This commit is contained in:
commit
7cc62f452b
@ -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">';
|
||||||
|
|||||||
@ -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})
|
|
||||||
.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();
|
init_page(1);
|
||||||
});
|
});
|
||||||
</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>';
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
|
||||||
@ -440,15 +440,15 @@ class EmailCollector extends CommonObject
|
|||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public function fetchLines()
|
public function fetchLines()
|
||||||
{
|
{
|
||||||
$this->lines=array();
|
$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
|
* Fetch all account and load objects into an array
|
||||||
@ -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();
|
||||||
@ -1154,7 +1156,7 @@ class EmailCollector extends CommonObject
|
|||||||
getDolGlobalString('OAUTH_'.$this->oauth_service.'_ID'),
|
getDolGlobalString('OAUTH_'.$this->oauth_service.'_ID'),
|
||||||
getDolGlobalString('OAUTH_'.$this->oauth_service.'_SECRET'),
|
getDolGlobalString('OAUTH_'.$this->oauth_service.'_SECRET'),
|
||||||
getDolGlobalString('OAUTH_'.$this->oauth_service.'_URLAUTHORIZE')
|
getDolGlobalString('OAUTH_'.$this->oauth_service.'_URLAUTHORIZE')
|
||||||
);
|
);
|
||||||
$serviceFactory = new \OAuth\ServiceFactory();
|
$serviceFactory = new \OAuth\ServiceFactory();
|
||||||
$oauthname = explode('-', $OAUTH_SERVICENAME);
|
$oauthname = explode('-', $OAUTH_SERVICENAME);
|
||||||
// ex service is Google-Emails we need only the first part Google
|
// 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']));
|
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']));
|
||||||
@ -1296,12 +1308,12 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
/* seems not used */
|
/* seems not used */
|
||||||
/*
|
/*
|
||||||
if ($rule['type'] == 'notinsubject') {
|
if ($rule['type'] == 'notinsubject') {
|
||||||
array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue']));
|
array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue']));
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'notinbody') {
|
if ($rule['type'] == 'notinbody') {
|
||||||
array_push($criteria, array($not."BODY NOT" => $rule['rulevalue']));
|
array_push($criteria, array($not."BODY NOT" => $rule['rulevalue']));
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ($rule['type'] == 'seen') {
|
if ($rule['type'] == 'seen') {
|
||||||
array_push($criteria, array($not."SEEN"));
|
array_push($criteria, array($not."SEEN"));
|
||||||
@ -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'];
|
||||||
@ -1417,12 +1439,12 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
/* seems not used */
|
/* seems not used */
|
||||||
/*
|
/*
|
||||||
if ($rule['type'] == 'notinsubject') {
|
if ($rule['type'] == 'notinsubject') {
|
||||||
$search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
|
$search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'notinbody') {
|
if ($rule['type'] == 'notinbody') {
|
||||||
$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
|
$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ($rule['type'] == 'seen') {
|
if ($rule['type'] == 'seen') {
|
||||||
$search .= ($search ? ' ' : '').$not.'SEEN';
|
$search .= ($search ? ' ' : '').$not.'SEEN';
|
||||||
@ -1538,19 +1560,19 @@ class EmailCollector extends CommonObject
|
|||||||
if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) {
|
if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) {
|
||||||
// Loop to get part html and plain
|
// Loop to get part html and plain
|
||||||
/*
|
/*
|
||||||
0 multipart/mixed
|
0 multipart/mixed
|
||||||
1 multipart/alternative
|
1 multipart/alternative
|
||||||
1.1 text/plain
|
1.1 text/plain
|
||||||
1.2 text/html
|
1.2 text/html
|
||||||
2 message/rfc822
|
2 message/rfc822
|
||||||
2 multipart/mixed
|
2 multipart/mixed
|
||||||
2.1 multipart/alternative
|
2.1 multipart/alternative
|
||||||
2.1.1 text/plain
|
2.1.1 text/plain
|
||||||
2.1.2 text/html
|
2.1.2 text/html
|
||||||
2.2 message/rfc822
|
2.2 message/rfc822
|
||||||
2.2 multipart/alternative
|
2.2 multipart/alternative
|
||||||
2.2.1 text/plain
|
2.2.1 text/plain
|
||||||
2.2.2 text/html
|
2.2.2 text/html
|
||||||
*/
|
*/
|
||||||
dol_syslog("Start of loop on email", LOG_INFO, 1);
|
dol_syslog("Start of loop on email", LOG_INFO, 1);
|
||||||
|
|
||||||
@ -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);
|
||||||
@ -1738,45 +1769,45 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
// Parse IMAP email structure
|
// Parse IMAP email structure
|
||||||
/*
|
/*
|
||||||
$structure = imap_fetchstructure($connection, $imapemail, 0);
|
$structure = imap_fetchstructure($connection, $imapemail, 0);
|
||||||
|
|
||||||
$partplain = $parthtml = -1;
|
$partplain = $parthtml = -1;
|
||||||
$encodingplain = $encodinghtml = '';
|
$encodingplain = $encodinghtml = '';
|
||||||
|
|
||||||
$result = createPartArray($structure, '');
|
$result = createPartArray($structure, '');
|
||||||
|
|
||||||
foreach($result as $part)
|
foreach($result as $part)
|
||||||
{
|
{
|
||||||
// $part['part_object']->type seems 0 for content
|
// $part['part_object']->type seems 0 for content
|
||||||
// $part['part_object']->type seems 5 for attachment
|
// $part['part_object']->type seems 5 for attachment
|
||||||
if (empty($part['part_object'])) continue;
|
if (empty($part['part_object'])) continue;
|
||||||
if ($part['part_object']->subtype == 'HTML')
|
if ($part['part_object']->subtype == 'HTML')
|
||||||
{
|
{
|
||||||
$parthtml=$part['part_number'];
|
$parthtml=$part['part_number'];
|
||||||
if ($part['part_object']->encoding == 4)
|
if ($part['part_object']->encoding == 4)
|
||||||
{
|
{
|
||||||
$encodinghtml = 'aaa';
|
$encodinghtml = 'aaa';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($part['part_object']->subtype == 'PLAIN')
|
if ($part['part_object']->subtype == 'PLAIN')
|
||||||
{
|
{
|
||||||
$partplain=$part['part_number'];
|
$partplain=$part['part_number'];
|
||||||
if ($part['part_object']->encoding == 4)
|
if ($part['part_object']->encoding == 4)
|
||||||
{
|
{
|
||||||
$encodingplain = 'rr';
|
$encodingplain = 'rr';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//var_dump($result);
|
//var_dump($result);
|
||||||
//var_dump($partplain);
|
//var_dump($partplain);
|
||||||
//var_dump($parthtml);
|
//var_dump($parthtml);
|
||||||
|
|
||||||
//var_dump($structure);
|
//var_dump($structure);
|
||||||
//var_dump($parthtml);
|
//var_dump($parthtml);
|
||||||
//var_dump($partplain);
|
//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($messagetext);
|
||||||
//var_dump($structure->parts[0]->parts);
|
//var_dump($structure->parts[0]->parts);
|
||||||
@ -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;
|
||||||
|
|
||||||
@ -1918,11 +1958,11 @@ class EmailCollector extends CommonObject
|
|||||||
$objectemail = new Adherent($this->db);
|
$objectemail = new Adherent($this->db);
|
||||||
}
|
}
|
||||||
/*if ($reg[1] == 'leav') { // Leave / Holiday
|
/*if ($reg[1] == 'leav') { // Leave / Holiday
|
||||||
$objectemail = new Holiday($db);
|
$objectemail = new Holiday($db);
|
||||||
}
|
}
|
||||||
if ($reg[1] == 'exp') { // ExpenseReport
|
if ($reg[1] == 'exp') { // ExpenseReport
|
||||||
$objectemail = new ExpenseReport($db);
|
$objectemail = new ExpenseReport($db);
|
||||||
}*/
|
}*/
|
||||||
} elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) {
|
} elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) {
|
||||||
// This is an external reference, we check if we have it in our database
|
// This is an external reference, we check if we have it in our database
|
||||||
if (!is_object($objectemail)) {
|
if (!is_object($objectemail)) {
|
||||||
@ -2081,34 +2121,34 @@ class EmailCollector extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if ($replyto) {
|
if ($replyto) {
|
||||||
if (empty($contactid)) { // Try to find contact using email
|
if (empty($contactid)) { // Try to find contact using email
|
||||||
$result = $contactstatic->fetch(0, null, '', $replyto);
|
$result = $contactstatic->fetch(0, null, '', $replyto);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
dol_syslog("We found a contact with the email ".$replyto);
|
dol_syslog("We found a contact with the email ".$replyto);
|
||||||
$contactid = $contactstatic->id;
|
$contactid = $contactstatic->id;
|
||||||
$contactfoundby = 'email of contact ('.$replyto.')';
|
$contactfoundby = 'email of contact ('.$replyto.')';
|
||||||
if (empty($thirdpartyid) && $contactstatic->socid > 0) {
|
if (empty($thirdpartyid) && $contactstatic->socid > 0) {
|
||||||
$result = $thirdpartystatic->fetch($contactstatic->socid);
|
$result = $thirdpartystatic->fetch($contactstatic->socid);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$thirdpartyid = $thirdpartystatic->id;
|
$thirdpartyid = $thirdpartystatic->id;
|
||||||
$thirdpartyfoundby = 'email of contact ('.$replyto.')';
|
$thirdpartyfoundby = 'email of contact ('.$replyto.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($thirdpartyid)) { // Try to find thirdparty using email
|
if (empty($thirdpartyid)) { // Try to find thirdparty using email
|
||||||
$result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto);
|
$result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
dol_syslog("We found a thirdparty with the email ".$replyto);
|
dol_syslog("We found a thirdparty with the email ".$replyto);
|
||||||
$thirdpartyid = $thirdpartystatic->id;;
|
$thirdpartyid = $thirdpartystatic->id;;
|
||||||
$thirdpartyfoundby = 'email ('.$replyto.')';
|
$thirdpartyfoundby = 'email ('.$replyto.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Do operations (extract variables and creating data)
|
// 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
|
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';
|
$this->errors[] = 'User Not allowed to add documents';
|
||||||
}
|
}
|
||||||
$arrayobject = array(
|
$arrayobject = array(
|
||||||
'propale' => array('table' => 'propal',
|
'propale' => array('table' => 'propal',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'comm/propal/class/propal.class.php',
|
'class' => 'comm/propal/class/propal.class.php',
|
||||||
'object' => 'Propal'),
|
'object' => 'Propal'),
|
||||||
'holiday' => array('table' => 'holiday',
|
'holiday' => array('table' => 'holiday',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'holiday/class/holiday.class.php',
|
'class' => 'holiday/class/holiday.class.php',
|
||||||
'object' => 'Holiday'),
|
'object' => 'Holiday'),
|
||||||
'expensereport' => array('table' => 'expensereport',
|
'expensereport' => array('table' => 'expensereport',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'expensereport/class/expensereport.class.php',
|
'class' => 'expensereport/class/expensereport.class.php',
|
||||||
'object' => 'ExpenseReport'),
|
'object' => 'ExpenseReport'),
|
||||||
'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition',
|
'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'recruitment/class/recruitmentjobposition.class.php',
|
'class' => 'recruitment/class/recruitmentjobposition.class.php',
|
||||||
'object' => 'RecruitmentJobPosition'),
|
'object' => 'RecruitmentJobPosition'),
|
||||||
'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature',
|
'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'recruitment/class/recruitmentcandidature.class.php',
|
'class' => 'recruitment/class/recruitmentcandidature.class.php',
|
||||||
'object' => ' RecruitmentCandidature'),
|
'object' => ' RecruitmentCandidature'),
|
||||||
'societe' => array('table' => 'societe',
|
'societe' => array('table' => 'societe',
|
||||||
'fields' => array('code_client', 'code_fournisseur'),
|
'fields' => array('code_client', 'code_fournisseur'),
|
||||||
'class' => 'societe/class/societe.class.php',
|
'class' => 'societe/class/societe.class.php',
|
||||||
'object' => 'Societe'),
|
'object' => 'Societe'),
|
||||||
'commande' => array('table' => 'commande',
|
'commande' => array('table' => 'commande',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'commande/class/commande.class.php',
|
'class' => 'commande/class/commande.class.php',
|
||||||
'object' => 'Commande'),
|
'object' => 'Commande'),
|
||||||
'expedition' => array('table' => 'expedition',
|
'expedition' => array('table' => 'expedition',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'expedition/class/expedition.class.php',
|
'class' => 'expedition/class/expedition.class.php',
|
||||||
'object' => 'Expedition'),
|
'object' => 'Expedition'),
|
||||||
'contract' => array('table' => 'contrat',
|
'contract' => array('table' => 'contrat',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'contrat/class/contrat.class.php',
|
'class' => 'contrat/class/contrat.class.php',
|
||||||
'object' => 'Contrat'),
|
'object' => 'Contrat'),
|
||||||
'fichinter' => array('table' => 'fichinter',
|
'fichinter' => array('table' => 'fichinter',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'fichinter/class/fichinter.class.php',
|
'class' => 'fichinter/class/fichinter.class.php',
|
||||||
'object' => 'Fichinter'),
|
'object' => 'Fichinter'),
|
||||||
'ticket' => array('table' => 'ticket',
|
'ticket' => array('table' => 'ticket',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'ticket/class/ticket.class.php',
|
'class' => 'ticket/class/ticket.class.php',
|
||||||
'object' => 'Ticket'),
|
'object' => 'Ticket'),
|
||||||
'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord',
|
'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'knowledgemanagement/class/knowledgemanagement.class.php',
|
'class' => 'knowledgemanagement/class/knowledgemanagement.class.php',
|
||||||
'object' => 'KnowledgeRecord'),
|
'object' => 'KnowledgeRecord'),
|
||||||
'supplier_proposal' => array('table' => 'supplier_proposal',
|
'supplier_proposal' => array('table' => 'supplier_proposal',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'supplier_proposal/class/supplier_proposal.class.php',
|
'class' => 'supplier_proposal/class/supplier_proposal.class.php',
|
||||||
'object' => 'SupplierProposal'),
|
'object' => 'SupplierProposal'),
|
||||||
'fournisseur/commande' => array('table' => 'commande_fournisseur',
|
'fournisseur/commande' => array('table' => 'commande_fournisseur',
|
||||||
'fields' => array('ref', 'ref_supplier'),
|
'fields' => array('ref', 'ref_supplier'),
|
||||||
'class' => 'fourn/class/fournisseur.commande.class.php',
|
'class' => 'fourn/class/fournisseur.commande.class.php',
|
||||||
'object' => 'SupplierProposal'),
|
'object' => 'SupplierProposal'),
|
||||||
'facture' => array('table' => 'facture',
|
'facture' => array('table' => 'facture',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'compta/facture/class/facture.class.php',
|
'class' => 'compta/facture/class/facture.class.php',
|
||||||
'object' => 'Facture'),
|
'object' => 'Facture'),
|
||||||
'fournisseur/facture' => array('table' => 'facture_fourn',
|
'fournisseur/facture' => array('table' => 'facture_fourn',
|
||||||
'fields' => array('ref', 'ref_client'),
|
'fields' => array('ref', 'ref_client'),
|
||||||
'class' => 'fourn/class/fournisseur.facture.class.php',
|
'class' => 'fourn/class/fournisseur.facture.class.php',
|
||||||
'object' => 'FactureFournisseur'),
|
'object' => 'FactureFournisseur'),
|
||||||
'produit' => array('table' => 'product',
|
'produit' => array('table' => 'product',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'product/class/product.class.php',
|
'class' => 'product/class/product.class.php',
|
||||||
'object' => 'Product'),
|
'object' => 'Product'),
|
||||||
'productlot' => array('table' => 'product_lot',
|
'productlot' => array('table' => 'product_lot',
|
||||||
'fields' => array('batch'),
|
'fields' => array('batch'),
|
||||||
'class' => 'product/stock/class/productlot.class.php',
|
'class' => 'product/stock/class/productlot.class.php',
|
||||||
'object' => 'Productlot'),
|
'object' => 'Productlot'),
|
||||||
'projet' => array('table' => 'projet',
|
'projet' => array('table' => 'projet',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'projet/class/projet.class.php',
|
'class' => 'projet/class/projet.class.php',
|
||||||
'object' => 'Project'),
|
'object' => 'Project'),
|
||||||
'projet_task' => array('table' => 'projet_task',
|
'projet_task' => array('table' => 'projet_task',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'projet/class/task.class.php',
|
'class' => 'projet/class/task.class.php',
|
||||||
'object' => 'Task'),
|
'object' => 'Task'),
|
||||||
'ressource' => array('table' => 'resource',
|
'ressource' => array('table' => 'resource',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'ressource/class/dolressource.class.php',
|
'class' => 'ressource/class/dolressource.class.php',
|
||||||
'object' => 'Dolresource'),
|
'object' => 'Dolresource'),
|
||||||
'bom' => array('table' => 'bom_bom',
|
'bom' => array('table' => 'bom_bom',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'bom/class/bom.class.php',
|
'class' => 'bom/class/bom.class.php',
|
||||||
'object' => 'BOM'),
|
'object' => 'BOM'),
|
||||||
'mrp' => array('table' => 'mrp_mo',
|
'mrp' => array('table' => 'mrp_mo',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'mrp/class/mo.class.php',
|
'class' => 'mrp/class/mo.class.php',
|
||||||
'object' => 'Mo'),
|
'object' => 'Mo'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!is_object($hookmanager)) {
|
if (!is_object($hookmanager)) {
|
||||||
@ -2997,43 +3037,43 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
// Set candidature ref if not yet defined
|
// Set candidature ref if not yet defined
|
||||||
/*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status
|
/*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status
|
||||||
{
|
{
|
||||||
// Get next Ref
|
// Get next Ref
|
||||||
$defaultref = '';
|
$defaultref = '';
|
||||||
$modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON;
|
$modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON;
|
||||||
|
|
||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0; $reldir = '';
|
$file = ''; $classname = ''; $filefound = 0; $reldir = '';
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
$file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0);
|
$file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0);
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = $modele;
|
$classname = $modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound) {
|
if ($filefound) {
|
||||||
if ($savesocid > 0) {
|
if ($savesocid > 0) {
|
||||||
if ($savesocid != $candidaturetocreate->socid) {
|
if ($savesocid != $candidaturetocreate->socid) {
|
||||||
$errorforactions++;
|
$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');
|
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 {
|
} else {
|
||||||
if ($candidaturetocreate->socid > 0)
|
if ($candidaturetocreate->socid > 0)
|
||||||
{
|
{
|
||||||
$thirdpartystatic->fetch($candidaturetocreate->socid);
|
$thirdpartystatic->fetch($candidaturetocreate->socid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php');
|
$result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php');
|
||||||
$modModuleToUseForNextValue = new $classname;
|
$modModuleToUseForNextValue = new $classname;
|
||||||
$defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate);
|
$defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate);
|
||||||
}
|
}
|
||||||
$candidaturetocreate->ref = $defaultref;
|
$candidaturetocreate->ref = $defaultref;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ($errorforthisaction) {
|
if ($errorforthisaction) {
|
||||||
$errorforactions++;
|
$errorforactions++;
|
||||||
@ -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 {
|
||||||
|
|||||||
@ -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";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user