Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2022-09-25 18:35:26 +02:00
commit 24be0f5cde
18 changed files with 219 additions and 151 deletions

View File

@ -811,9 +811,9 @@ class AccountingAccount extends CommonObject
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
if ((($buyer->country_code == $seller->country_code) || empty($buyer->country_code))) { if ((($buyer->country_code == $seller->country_code) || empty($buyer->country_code))) {
// If buyer in same country than seller (if not defined, we assume it is same country) // If buyer in same country than seller (if not defined, we assume it is same country)
if ($type=='customer' && !empty($product->accountancy_code_sell)) { if ($type == 'customer' && !empty($product->accountancy_code_sell)) {
$code_p = $product->accountancy_code_sell; $code_p = $product->accountancy_code_sell;
} elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) {
$code_p = $product->accountancy_code_buy; $code_p = $product->accountancy_code_buy;
} }
$suggestedid = $accountingAccount['dom']; $suggestedid = $accountingAccount['dom'];
@ -821,36 +821,36 @@ class AccountingAccount extends CommonObject
} else { } else {
if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) {
// European intravat sale, but with VAT // European intravat sale, but with VAT
if ($type=='customer' && !empty($product->accountancy_code_sell)) { if ($type == 'customer' && !empty($product->accountancy_code_sell)) {
$code_p = $product->accountancy_code_sell; $code_p = $product->accountancy_code_sell;
} elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) {
$code_p = $product->accountancy_code_buy; $code_p = $product->accountancy_code_buy;
} }
$suggestedid = $accountingAccount['dom']; $suggestedid = $accountingAccount['dom'];
$suggestedaccountingaccountfor = 'eecwithvat'; $suggestedaccountingaccountfor = 'eecwithvat';
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) {
// European intravat sale, without VAT intra community number // European intravat sale, without VAT intra community number
if ($type=='customer' && !empty($product->accountancy_code_sell)) { if ($type == 'customer' && !empty($product->accountancy_code_sell)) {
$code_p = $product->accountancy_code_sell; $code_p = $product->accountancy_code_sell;
} elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) {
$code_p = $product->accountancy_code_buy; $code_p = $product->accountancy_code_buy;
} }
$suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
$suggestedaccountingaccountfor = 'eecwithoutvatnumber'; $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC && !empty($product->accountancy_code_sell_intra)) { } elseif ($isSellerInEEC && $isBuyerInEEC && !empty($product->accountancy_code_sell_intra)) {
// European intravat sale // European intravat sale
if ($type=='customer' && !empty($product->accountancy_code_sell_intra)) { if ($type == 'customer' && !empty($product->accountancy_code_sell_intra)) {
$code_p = $product->accountancy_code_sell_intra; $code_p = $product->accountancy_code_sell_intra;
} elseif ($type=='supplier' && !empty($product->accountancy_code_buy_intra)) { } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy_intra)) {
$code_p = $product->accountancy_code_buy_intra; $code_p = $product->accountancy_code_buy_intra;
} }
$suggestedid = $accountingAccount['intra']; $suggestedid = $accountingAccount['intra'];
$suggestedaccountingaccountfor = 'eec'; $suggestedaccountingaccountfor = 'eec';
} else { } else {
// Foreign sale // Foreign sale
if ($type=='customer' && !empty($product->accountancy_code_sell_export)) { if ($type == 'customer' && !empty($product->accountancy_code_sell_export)) {
$code_p = $product->accountancy_code_sell_export; $code_p = $product->accountancy_code_sell_export;
} elseif ($type=='supplier' && !empty($product->accountancy_code_buy_export)) { } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy_export)) {
$code_p = $product->accountancy_code_buy_export; $code_p = $product->accountancy_code_buy_export;
} }
$suggestedid = $accountingAccount['export']; $suggestedid = $accountingAccount['export'];
@ -870,12 +870,12 @@ class AccountingAccount extends CommonObject
// Manage Deposit // Manage Deposit
if ($factureDet->desc == "(DEPOSIT)" || $facture->type == $facture::TYPE_DEPOSIT) { if ($factureDet->desc == "(DEPOSIT)" || $facture->type == $facture::TYPE_DEPOSIT) {
$accountdeposittoventilated = new self($this->db); $accountdeposittoventilated = new self($this->db);
if ($type=='customer') { if ($type == 'customer') {
$result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); $result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1);
} elseif ($type=='supplier') { } elseif ($type == 'supplier') {
$result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT, 1); $result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT, 1);
} }
if ($result < 0) { if (isset($result) && $result < 0) {
return -1; return -1;
} }

View File

@ -79,7 +79,7 @@ if (GETPOST('addbox')) {
* View * View
*/ */
$help_url = ''; $help_url = 'EN:Module_Double_Entry_Accounting#Setup';
llxHeader('', $langs->trans("AccountancyArea"), $help_url); llxHeader('', $langs->trans("AccountancyArea"), $help_url);

View File

@ -62,7 +62,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'updateform') { } elseif ($action == 'updateform') {
$res1 = 1; $res2 = 1; $res3 = 1; $res1 = 1; $res2 = 1; $res3 = 1; $res4 = 1;
if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) { if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) {
$res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
} }
@ -72,7 +72,10 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) { if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) {
$res3 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", GETPOST("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 'alphanohtml'), 'int', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", GETPOST("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 'alphanohtml'), 'int', 0, '', $conf->entity);
} }
if ($res1 && $res2 && $res3) { if (GETPOSTISSET('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS')) {
$res4 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", GETPOST("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 'alphanohtml'), 'int', 0, '', $conf->entity);
}
if ($res1 && $res2 && $res3 && $res4) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} }
} }
@ -186,6 +189,14 @@ print '<input class="flat right width50" name="MAIN_SECURITY_MAX_IMG_IN_HTML_CON
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</td><td class="right">';
print '</td>';
print '<td class="nowrap">';
print '<input class="flat right width50" name="MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS" type="text" value="'.getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 1000).'"> '.strtolower($langs->trans("Posts"));
print '</td>';
print '</tr>';
/* /*
if (empty($conf->global->MAIN_APPLICATION_TITLE)) { if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
$conf->global->MAIN_APPLICATION_TITLE = ""; $conf->global->MAIN_APPLICATION_TITLE = "";

View File

@ -163,8 +163,8 @@ class AssetDepreciationOptions extends CommonObject
} }
// Unset required option (notnull) if field disabled // Unset required option (notnull) if field disabled
if (!empty($mode_info['enabled_field'])) { if (!empty($field_info['enabled_field'])) {
$info = explode(':', $mode_info['enabled_field']); $info = explode(':', $field_info['enabled_field']);
if ($this->deprecation_options[$info[0]][$info[1]] != $info[2] && isset($this->fields[$field_key]['notnull'])) { if ($this->deprecation_options[$info[0]][$info[1]] != $info[2] && isset($this->fields[$field_key]['notnull'])) {
unset($this->fields[$field_key]['notnull']); unset($this->fields[$field_key]['notnull']);
} }

View File

@ -19,7 +19,7 @@
/** /**
* \file htdocs/bom/bom_card.php * \file htdocs/bom/bom_card.php
* \ingroup bom * \ingroup bom
* \brief Page to create/edit/view BOM * \brief Page to create/edit/view Bill Of Material
*/ */
// Load Dolibarr environment // Load Dolibarr environment
@ -34,17 +34,16 @@ require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('mrp', 'other')); $langs->loadLangs(array('mrp', 'other'));
global $filtertype;
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$lineid = GETPOST('lineid', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomcard'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomcard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$lineid = GETPOST('lineid', 'int');
// PDF // PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -56,6 +55,7 @@ $object = new BOM($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; $diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
@ -86,6 +86,7 @@ if ($object->id > 0) {
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft); $result = restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft);
// Permissions
$permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php $permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php

View File

@ -17,9 +17,9 @@
*/ */
/** /**
* \file bom_note.php * \file htdocs/bom/bom_note.php
* \ingroup bom * \ingroup bom
* \brief Car with notes on BillOfMaterials * \brief Card with notes on BillOfMaterials
*/ */
// Load Dolibarr environment // Load Dolibarr environment
@ -40,9 +40,13 @@ $backtopage = GETPOST('backtopage', 'alpha');
// Initialize technical objects // Initialize technical objects
$object = new BOM($db); $object = new BOM($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id;
// Initialize technical objects for hooks
$hookmanager->initHooks(array('bomnote', 'globalcard')); // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('bomnote', 'globalcard')); // Note that conf->hooks_modules contains array
// Massactions
$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id;
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);

View File

@ -94,6 +94,7 @@ function printDropdownBookmarksList()
$listbtn = '<a class="top-menu-dropdown-link" title="'.dol_escape_htmltag($langs->trans('Bookmarks')).'" href="'.DOL_URL_ROOT.'/bookmarks/list.php">'; $listbtn = '<a class="top-menu-dropdown-link" title="'.dol_escape_htmltag($langs->trans('Bookmarks')).'" href="'.DOL_URL_ROOT.'/bookmarks/list.php">';
$listbtn .= img_picto('', 'edit', 'class="paddingright opacitymedium"').$langs->trans('EditBookmarks').'</a>'; $listbtn .= img_picto('', 'edit', 'class="paddingright opacitymedium"').$langs->trans('EditBookmarks').'</a>';
$bookmarkList = '';
// Menu with list of bookmarks // Menu with list of bookmarks
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
$sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)";

View File

@ -878,7 +878,11 @@ class CMailFile
$keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
$keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
if (isset($supportedoauth2array)) {
$OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : '')); $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
} else {
$OAUTH_SERVICENAME = 'Unknown';
}
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';

View File

@ -758,6 +758,8 @@ class FormSetupItem
$val = GETPOST($this->confKey, 'array'); $val = GETPOST($this->confKey, 'array');
if ($val && is_array($val)) { if ($val && is_array($val)) {
$val_const = implode(',', $val); $val_const = implode(',', $val);
} else {
$val_const = '';
} }
} elseif ($this->type == 'html') { } elseif ($this->type == 'html') {
$val_const = GETPOST($this->confKey, 'restricthtml'); $val_const = GETPOST($this->confKey, 'restricthtml');

View File

@ -625,6 +625,8 @@ class Notify
$mimefilename_list[] = $ref.".pdf"; $mimefilename_list[] = $ref.".pdf";
} }
$labeltouse = !empty($labeltouse) ? $labeltouse : '';
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list, 'outputlangs'=>$outputlangs, 'labeltouse'=>$labeltouse); $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list, 'outputlangs'=>$outputlangs, 'labeltouse'=>$labeltouse);
if (!isset($action)) { if (!isset($action)) {
$action = ''; $action = '';

View File

@ -193,11 +193,12 @@ function dol_ftp_delete($connect_id, $file, $newsection)
* Download a FTP file * Download a FTP file
* *
* @param resource $connect_id Connection handler * @param resource $connect_id Connection handler
* @param string $file File * @param string $localfile The local file path
* @param string $file The remote file path
* @param string $newsection $newsection * @param string $newsection $newsection
* @return result * @return result
*/ */
function dol_ftp_get($connect_id, $file, $newsection) function dol_ftp_get($connect_id, $localfile, $file, $newsection)
{ {
global $conf; global $conf;

View File

@ -332,6 +332,7 @@ class printing_printgcp extends PrintingDriver
} }
$fileprint .= '/'.$file; $fileprint .= '/'.$file;
$mimetype = dol_mimetype($fileprint); $mimetype = dol_mimetype($fileprint);
$printer_id = '';
// select printer uri for module order, propal,... // select printer uri for module order, propal,...
$sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$this->db->escape($module)."' AND driver='printgcp' AND userid=".((int) $user->id); $sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$this->db->escape($module)."' AND driver='printgcp' AND userid=".((int) $user->id);
$result = $this->db->query($sql); $result = $this->db->query($sql);

View File

@ -317,7 +317,7 @@ if ($action == 'download') {
$newsection = $section; $newsection = $section;
$result = dol_ftp_get($connect_id, $file, $newsection); $result = dol_ftp_get($connect_id, $localfile, $file, $newsection);
if ($result) { if ($result) {

View File

@ -657,10 +657,12 @@ if (is_object($db)) {
} }
/** /**
* send email to validator for current leave represented by (id) * send email to validator for current leave represented by (id)
* @param $id validator for current leave represented by (id) *
* @param $cancreate flag for user right * @param int $id validator for current leave represented by (id)
* @param $now date * @param int $cancreate flag for user right
* @param $autoValidation boolean flag on autovalidation * @param int $now date
* @param int $autoValidation boolean flag on autovalidation
*
* @return stdClass * @return stdClass
* @throws Exception * @throws Exception
*/ */

View File

@ -2307,7 +2307,10 @@ MAIN_MAIL_SMTPS_AUTH_TYPE=Authentification method
UsePassword=Use a password UsePassword=Use a password
UseOauth=Use a OAUTH token UseOauth=Use a OAUTH token
Images=Images Images=Images
Posts=Posts
MaxNumberOfImagesInGetPost=Max number of images allowed in a HTML field submitted in a form MaxNumberOfImagesInGetPost=Max number of images allowed in a HTML field submitted in a form
MaxNumberOfPostOnPublicPagesByIP=Max number of posts on public pages with an IP Address
CIDLookupURL=The module brings an URL that can be used by an external tool to get the name of a thirdparty or contact from its phone number. URL to use is:
ScriptIsEmpty=The script is empty ScriptIsEmpty=The script is empty
ShowHideTheNRequests=Show/hide the %s SQL request(s) ShowHideTheNRequests=Show/hide the %s SQL request(s)
DefinedAPathForAntivirusCommandIntoSetup=Define a path for an antivirus program into <b>%s</b> DefinedAPathForAntivirusCommandIntoSetup=Define a path for an antivirus program into <b>%s</b>

View File

@ -232,10 +232,35 @@ if (empty($reshook)) {
} }
if (!$error) { if (!$error) {
$object->db->begin(); $object->type_code = GETPOST("type_code", 'aZ09');
$object->category_code = GETPOST("category_code", 'aZ09');
$object->severity_code = GETPOST("severity_code", 'aZ09');
$object->ip = getUserRemoteIP();
$nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 1000);
// Calculate nb of post for IP
$nb_post_ip = 0;
if ($nb_post_max > 0) { // Calculate only if there is a limit to check
$sql = "SELECT COUNT(ref) as nb_tickets";
$sql .= " FROM ".MAIN_DB_PREFIX."ticket";
$sql .= " WHERE ip = '".$db->escape($object->ip)."'";
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$i++;
$obj = $db->fetch_object($resql);
$nb_post_ip = $obj->nb_tickets;
}
}
}
$object->track_id = generate_random_id(16); $object->track_id = generate_random_id(16);
$object->db->begin();
$object->subject = GETPOST("subject", "restricthtml"); $object->subject = GETPOST("subject", "restricthtml");
$object->message = GETPOST("message", "restricthtml"); $object->message = GETPOST("message", "restricthtml");
$object->origin_email = $origin_email; $object->origin_email = $origin_email;
@ -301,6 +326,14 @@ if (empty($reshook)) {
$object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later $object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later
if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
$error++;
$errors = array($langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
array_push($object->errors, array($langs->trans("AlreadyTooMuchPostOnThisIPAdress")));
$action = 'create_ticket';
}
if (!$error) {
$id = $object->create($user); $id = $object->create($user);
if ($id <= 0) { if ($id <= 0) {
$error++; $error++;
@ -308,12 +341,12 @@ if (empty($reshook)) {
array_push($object->errors, $object->error ? array($object->error) : $object->errors); array_push($object->errors, $object->error ? array($object->error) : $object->errors);
$action = 'create_ticket'; $action = 'create_ticket';
} }
}
if (!$error && $id > 0) { if (!$error && $id > 0) {
if ($usertoassign > 0) { if ($usertoassign > 0) {
$object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0); $object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0);
} }
}
if (!$error) { if (!$error) {
$object->db->commit(); $object->db->commit();
@ -445,6 +478,7 @@ if (empty($reshook)) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
}
} }

View File

@ -82,7 +82,7 @@ if ($action == "send") {
$sendto = $email; $sendto = $email;
$from = $mysoc->email; $from = $mysoc->email;
$mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1); $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1);
if ($mail->error || $mail->errors) { if ($mail->error || !empty($mail->errors)) {
setEventMessages($mail->error, $mail->errors, 'errors'); setEventMessages($mail->error, $mail->errors, 'errors');
} else { } else {
$result = $mail->sendfile(); $result = $mail->sendfile();

View File

@ -467,7 +467,8 @@ class Ticket extends CommonObject
$sql .= "date_read,"; $sql .= "date_read,";
$sql .= "date_close,"; $sql .= "date_close,";
$sql .= "entity,"; $sql .= "entity,";
$sql .= "notify_tiers_at_create"; $sql .= "notify_tiers_at_create,";
$sql .= "ip";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " ".(!isset($this->ref) ? '' : "'".$this->db->escape($this->ref)."'").","; $sql .= " ".(!isset($this->ref) ? '' : "'".$this->db->escape($this->ref)."'").",";
$sql .= " ".(!isset($this->track_id) ? 'NULL' : "'".$this->db->escape($this->track_id)."'").","; $sql .= " ".(!isset($this->track_id) ? 'NULL' : "'".$this->db->escape($this->track_id)."'").",";
@ -492,6 +493,7 @@ class Ticket extends CommonObject
$sql .= " ".(!isset($this->date_close) || dol_strlen($this->date_close) == 0 ? 'NULL' : "'".$this->db->idate($this->date_close)."'").""; $sql .= " ".(!isset($this->date_close) || dol_strlen($this->date_close) == 0 ? 'NULL' : "'".$this->db->idate($this->date_close)."'")."";
$sql .= ", ".((int) $conf->entity); $sql .= ", ".((int) $conf->entity);
$sql .= ", ".(!isset($this->notify_tiers_at_create) ? '1' : "'".$this->db->escape($this->notify_tiers_at_create)."'"); $sql .= ", ".(!isset($this->notify_tiers_at_create) ? '1' : "'".$this->db->escape($this->notify_tiers_at_create)."'");
$sql .= ", ".(!isset($this->ip) ? 'NULL' : "'".$this->db->escape($this->ip)."'");
$sql .= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();