Merge branch 'develop' into addInputInEmailing

This commit is contained in:
lamrani abdelwadoud 2024-01-18 14:35:23 +01:00 committed by GitHub
commit 5213eedfa8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
80 changed files with 1808 additions and 467 deletions

View file

@ -48,12 +48,16 @@ Reports are processed around once a month.
ONLY vulnerabilities discovered, when the following setup on test platform is used, are "valid":
* The version to analyze must be the last version available in the "develop" branch or in the last stable "vX.Y" released version. Reports on vulnerabilities already fixed (so already reported) in the develop branch will not be validated.
* The version to analyze must be the last version available in the "develop" branch. Reports on vulnerabilities already fixed (so already reported) in the develop branch will not be validated.
* $dolibarr_main_prod must be set to 1 in conf.php
* $dolibarr_nocsrfcheck must be kept to the value 0 in conf.php (this is the default value)
* $dolibarr_main_force_https must be set to something else than 0.
* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3 in the backoffice menu Home - Setup - Other (this protection should be set to 3 soon by default). CSRF attacks are accepted but
double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3.
* Some constant must be set in the backoffice menu Home - Setup - Other
- MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3
- MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1
- MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1
- MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1
CSRF attacks and HTML injections are accepted but double check this setup that is experimental setup that already fix a lot of case and soon enabled by default.
* ONLY security reports on modules provided by default and with the "stable" status are valid (troubles in "experimental", "development" or external modules are not valid vulnerabilities).
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
* The web server setup must be done so that only the documents directory is in write mode. The root directory called htdocs must be read-only.
@ -87,12 +91,10 @@ Scope is the web application (backoffice) and the APIs.
* Logout and other instances of low-severity Cross-Site Request Forgery
* Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated
* Reports on features on modules flagged as "deprecated", "experimental" or "development" if the module needs to be enabled for that (this is not the case on production).
* Software or libraries versions or private IP disclosure when logged-in user is admin
* Stack traces or path disclosure when logged-in user is admin
* Software or libraries versions, private IP disclosure, Stack traces or path disclosure when logged-in user is admin.
* Any vulnerabilities due to a configuration different than the one defined in chapter "Scope for qualified vulnerabilities".
* Vulnerabilities affecting outdated browsers or platforms, or vulnerabilities inside browsers themself.
* Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the recommended fail2ban rules were not installed.
* SSL/TLS best practices
* Denial of Service attacks
* Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC)
* Physical or social engineering attempts or issues that require physical access to a victim’s computer/device

View file

@ -11,10 +11,22 @@
# ```shell
# echo > dev/tools/codespell/codespell-lines-ignore.txt
# ```
# and then execute this script
# and then execute this script.
#
# author: https://github.com/mdeweerd
#
# :warning:
#
# This script only works properly if codespell is install for your CLI.
# As the configuration is in pyproject.toml, you also need tomli.
#
# ```shell
# python -m pip install codespell tomli
# # or
# pip install codespell tomli
# ```
codespell_ignore_file=dev/tools/codespell/codespell-lines-ignore.txt
if [ -z "${0##*.sh}" ] ; then
# Suppose running from inside script

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2014-2024 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@netlogic.fr>
*
* 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
@ -109,7 +109,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
$object->date_start = $date_start;
$object->date_end = $date_end;
$object->label = GETPOST('label', 'alpha');
$object->status = GETPOST('status', 'int');
$object->status = GETPOSTINT('status');
$object->datec = dol_now();
if (empty($object->date_start) && empty($object->date_end)) {
@ -152,7 +152,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
$object->date_start = GETPOST("fiscalyear") ? $date_start : '';
$object->date_end = GETPOST("fiscalyearend") ? $date_end : '';
$object->label = GETPOST('label', 'alpha');
$object->status = GETPOST('status', 'int');
$object->status = GETPOSTINT('status');
$result = $object->update($user);

View file

@ -663,7 +663,7 @@ if ($action == 'create') {
if (!empty($object->linesmvt[0])) {
$tmpline = $object->linesmvt[0];
if (!empty($tmpline->numero_compte)) {
$line = new BookKeepingLine();
$line = new BookKeepingLine($db);
$object->linesmvt[] = $line;
}
}

View file

@ -1087,7 +1087,7 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print "</tr>\n";
$line = new BookKeepingLine();
$line = new BookKeepingLine($db);
// Loop on record
// --------------------------------------------------------------------

View file

@ -1037,7 +1037,7 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print "</tr>\n";
$line = new BookKeepingLine();
$line = new BookKeepingLine($db);
// Loop on record
// --------------------------------------------------------------------

View file

@ -26,6 +26,7 @@
// Class
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
@ -986,7 +987,7 @@ class BookKeeping extends CommonObject
$i = 0;
while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) {
$line = new BookKeepingLine();
$line = new BookKeepingLine($this->db);
$line->id = $obj->rowid;
@ -1140,7 +1141,7 @@ class BookKeeping extends CommonObject
$i = 0;
while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) {
$line = new BookKeepingLine();
$line = new BookKeepingLine($this->db);
$line->id = $obj->rowid;
@ -1275,7 +1276,7 @@ class BookKeeping extends CommonObject
$i = 0;
while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) {
$line = new BookKeepingLine();
$line = new BookKeepingLine($this->db);
$line->numero_compte = $obj->numero_compte;
//$line->label_compte = $obj->label_compte;
@ -1881,7 +1882,7 @@ class BookKeeping extends CommonObject
$result = $this->db->query($sql);
if ($result) {
while ($obj = $this->db->fetch_object($result)) {
$line = new BookKeepingLine();
$line = new BookKeepingLine($this->db);
$line->id = $obj->rowid;
@ -1951,7 +1952,7 @@ class BookKeeping extends CommonObject
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new BookKeepingLine();
$line = new BookKeepingLine($this->db);
$line->id = $obj->rowid;
@ -2976,7 +2977,7 @@ class BookKeeping extends CommonObject
/**
* Class BookKeepingLine
*/
class BookKeepingLine
class BookKeepingLine extends CommonObjectLine
{
/**
* @var int ID

View file

@ -323,7 +323,7 @@ if (empty($reshook)) {
}
$object->birth = $birthdate;
$object->default_lang = GETPOST('default_lang', 'alpha');
$object->typeid = GETPOST("typeid", 'int');
$object->typeid = GETPOSTINT("typeid");
//$object->note = trim(GETPOST("comment", "restricthtml"));
$object->morphy = GETPOST("morphy", 'alpha');
@ -1118,7 +1118,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Birth Date
print "<tr><td>".$langs->trans("DateOfBirth")."</td><td>\n";
print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print img_picto('', 'object_calendar', 'class="pictofixedwidth"').$form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print "</td></tr>\n";
// Public profil
@ -1364,13 +1364,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Birth Date
print "<tr><td>".$langs->trans("DateOfBirth")."</td><td>\n";
print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print img_picto('', 'object_calendar', 'class="pictofixedwidth"').$form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print "</td></tr>\n";
// Default language
if (getDolGlobalInt('MAIN_MULTILANGS')) {
print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3">'."\n";
print img_picto('', 'language').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1);
print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1);
print '</td>';
print '</tr>';
}

View file

@ -80,6 +80,10 @@ $socid = GETPOST('socid', 'int');
$search_filter = GETPOST("search_filter", 'alpha');
$search_status = GETPOST("search_status", 'intcomma'); // statut
$search_datec_start = dol_mktime(0, 0, 0, GETPOST('search_datec_start_month', 'int'), GETPOST('search_datec_start_day', 'int'), GETPOST('search_datec_start_year', 'int'));
$search_datec_end = dol_mktime(23, 59, 59, GETPOST('search_datec_end_month', 'int'), GETPOST('search_datec_end_day', 'int'), GETPOST('search_datec_end_year', 'int'));
$search_datem_start = dol_mktime(0, 0, 0, GETPOST('search_datem_start_month', 'int'), GETPOST('search_datem_start_day', 'int'), GETPOST('search_datem_start_year', 'int'));
$search_datem_end = dol_mktime(23, 59, 59, GETPOST('search_datem_end_month', 'int'), GETPOST('search_datem_end_day', 'int'), GETPOST('search_datem_end_year', 'int'));
$filter = GETPOST("filter", 'alpha');
if ($filter) {
@ -258,6 +262,10 @@ if (empty($reshook)) {
$catid = "";
$search_all = "";
$toselect = array();
$search_datec_start = '';
$search_datec_end = '';
$search_datem_start = '';
$search_datem_end = '';
$search_array_options = array();
}
@ -513,6 +521,18 @@ if ($search_country) {
if ($search_import_key) {
$sql .= natural_search("d.import_key", $search_import_key);
}
if ($search_datec_start) {
$sql .= " AND d.datec >= '".$db->idate($search_datec_start)."'";
}
if ($search_datec_end) {
$sql .= " AND d.datec <= '".$db->idate($search_datec_end)."'";
}
if ($search_datem_start) {
$sql .= " AND d.tms >= '".$db->idate($search_datem_start)."'";
}
if ($search_datem_end) {
$sql .= " AND d.tms <= '".$db->idate($search_datem_end)."'";
}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
@ -659,6 +679,12 @@ if ($search_import_key != '') {
if ($search_type > 0) {
$param .= "&search_type=".urlencode($search_type);
}
if ($search_datec_start) {
$param .= '&search_datec_start_day='.dol_print_date($search_datec_start, '%d').'&search_datec_start_month='.dol_print_date($search_datec_start, '%m').'&search_datec_start_year='.dol_print_date($search_datec_start, '%Y');
}
if ($search_datem_end) {
$param .= '&search_datem_end_day='.dol_print_date($search_datem_end, '%d').'&search_datem_end_month='.dol_print_date($search_datem_end, '%m').'&search_datem_end_year='.dol_print_date($search_datem_end, '%Y');
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -914,6 +940,12 @@ print $hookmanager->resPrint;
// Date creation
if (!empty($arrayfields['d.datec']['checked'])) {
print '<td class="liste_titre">';
print '<div class="nowrapfordate">';
print $form->selectDate($search_datec_start ? $search_datec_start : -1, 'search_datec_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrapfordate">';
print $form->selectDate($search_datec_end ? $search_datec_end : -1, 'search_datec_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
print '</td>';
}
@ -926,6 +958,12 @@ if (!empty($arrayfields['d.birth']['checked'])) {
// Date modification
if (!empty($arrayfields['d.tms']['checked'])) {
print '<td class="liste_titre">';
print '<div class="nowrapfordate">';
print $form->selectDate($search_datem_start ? $search_datem_start : -1, 'search_datem_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrapfordate">';
print $form->selectDate($search_datem_end ? $search_datem_end : -1, 'search_datem_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
print '</td>';
}

14
htdocs/ai/README.md Normal file
View file

@ -0,0 +1,14 @@
# AI FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
## Features
Provides an api key for chatchpt for use it in other modules
### Main code
GPLv3 or (at your option) any later version. See file COPYING for more information.
### Documentation
All texts and readmes are licensed under GFDL.

239
htdocs/ai/admin/setup.php Normal file
View file

@ -0,0 +1,239 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Alice Adminson <aadminson@example.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 ai/admin/setup.php
* \ingroup ai
* \brief Ai setup page.
*/
// Load Dolibarr environment
require '../../main.inc.php';
global $langs, $user;
// Libraries
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
require_once '../lib/ai.lib.php';
// Access control
if (!$user->admin) {
accessforbidden();
}
// Parameters
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
$error = 0;
$setupnotempty = 0;
// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
$useFormSetup = 1;
if (!class_exists('FormSetup')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
}
$formSetup = new FormSetup($db);
// Setup conf AI_PUBLIC_INTERFACE_TOPIC
$item = $formSetup->newItem('AI_KEY_API_CHATGPT');
$item->defaultFieldValue = '';
// Save API Key
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$apiKey = GETPOST('api_key', 'alpha');
// Validate and clean $apiKey here
dolibarr_set_const($db, 'MAIN_AI_CHATGPT_API_KEY', $apiKey, 'chaine', 0, '', $conf->entity);
}
// Retrieve existing API Key
$apiKey = dolibarr_get_const($db, 'MAIN_AI_CHATGPT_API_KEY');
$setupnotempty =+ count($formSetup->items);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
/*
* Actions
*/
// For retrocompatibility Dolibarr < 15.0
if (versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'update' && !empty($user->admin)) {
$formSetup->saveConfFromPost();
}
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') {
$maskconst = GETPOST('maskconst', 'aZ09');
$maskvalue = GETPOST('maskvalue', 'alpha');
if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'specimen') {
$modele = GETPOST('module', 'alpha');
$tmpobjectkey = GETPOST('object');
$tmpobject = new $tmpobjectkey($db);
$tmpobject->initAsSpecimen();
// Search template files
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/ai/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
if (file_exists($file)) {
$filefound = 1;
$classname = "pdf_".$modele."_".strtolower($tmpobjectkey);
break;
}
}
if ($filefound) {
require_once $file;
$module = new $classname($db);
if ($module->write_file($tmpobject, $langs) > 0) {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bookcal-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
return;
} else {
setEventMessages($module->error, null, 'errors');
dol_syslog($module->error, LOG_ERR);
}
} else {
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
} elseif ($action == 'setmod') {
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
$constforval = 'Ai_'.strtoupper($tmpobjectkey)."_ADDON";
dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
}
} elseif ($action == 'set') {
// Activate a model
$ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') {
$ret = delDocumentModel($value, $type);
if ($ret > 0) {
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
$constforval = 'Ai_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
if (getDolGlobalString($constforval) == "$value") {
dolibarr_del_const($db, $constforval, $conf->entity);
}
}
}
} elseif ($action == 'setdoc') {
// Set or unset default model
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
$constforval = 'Ai_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
// The constant that was read before the new set
// We therefore requires a variable to have a coherent view
$conf->global->$constforval = $value;
}
// We disable/enable the document template (into llx_document_model table)
$ret = delDocumentModel($value, $type);
if ($ret > 0) {
$ret = addDocumentModel($value, $type, $label, $scandir);
}
}
} elseif ($action == 'unsetdoc') {
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
$constforval = 'Ai_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
dolibarr_del_const($db, $constforval, $conf->entity);
}
}
/*
* View
*/
$form = new Form($db);
$help_url = '';
$page_name = "AiSetup";
llxHeader('', $langs->trans($page_name), $help_url);
// Subheader
$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
// Configuration header
$head = aiAdminPrepareHead();
print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "fa-microchip");
// Setup page goes here
//echo '<span class="opacitymedium">'.$langs->trans("AiSetupPage").'</span><br><br>';
if ($action == 'edit') {
print $formSetup->generateOutput(true);
print '<br>';
} elseif (!empty($formSetup->items)) {
print $formSetup->generateOutput();
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
print '</div>';
} else {
print '<br>'.$langs->trans("NothingToSetup");
}
if (empty($setupnotempty)) {
print '<br>'.$langs->trans("NothingToSetup");
}
// Page end
print dol_get_fiche_end();
llxFooter();
$db->close();

View file

@ -0,0 +1,90 @@
<?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
*
* 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/>.
* or see https://www.gnu.org/
*/
/**
* Class for AI
*/
class Ai
{
/**
* @var DoliDB $db Database object
*/
protected $db;
/**
* @var string $apiEndpoint
*/
private $apiEndpoint;
/**
* @var string $apiKey
*/
private $apiKey;
/**
* Constructor
*
* @param string $apiEndpoint Endpoint of api
* @param boolean $apiKey key of api
*/
public function __construct($apiEndpoint, $apiKey)
{
$this->apiEndpoint = $apiEndpoint;
$this->apiKey = $apiKey;
}
/**
* Generate response of instructions
* @param string $instructions instruction for generate content
* @return mixed $response
*/
public function generateContent($instructions)
{
try {
$ch = curl_init($this->apiEndpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['prompt' => $instructions]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $this->apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception('cURL error: ' . curl_error($ch));
}
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
throw new Exception('API request failed with status code ' . $statusCode);
}
return $response;
} catch (Exception $e) {
error_log($e->getMessage());
return null;
} finally {
curl_close($ch);
}
}
}

63
htdocs/ai/lib/ai.lib.php Normal file
View file

@ -0,0 +1,63 @@
<?php
/* Copyright (C) 2022 Alice Adminson <aadminson@example.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 ai/lib/ai.lib.php
* \ingroup ai
* \brief Library files with common functions for Ai
*/
/**
* Prepare admin pages header
*
* @return array
*/
function aiAdminPrepareHead()
{
global $langs, $conf;
$langs->load("agenda");
$h = 0;
$head = array();
$head[$h][0] = dol_buildpath("/ai/admin/setup.php", 1);
$head[$h][1] = $langs->trans("Settings");
$head[$h][2] = 'settings';
$h++;
/*
$head[$h][0] = dol_buildpath("/ai/admin/myobject_extrafields.php", 1);
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'myobject_extrafields';
$h++;
*/
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
//$this->tabs = array(
// 'entity:+tabname:Title:@ai:/ai/mypage.php?id=__ID__'
//); // to add new tab
//$this->tabs = array(
// 'entity:-tabname:Title:@ai:/ai/mypage.php?id=__ID__'
//); // to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'ai@ai');
complete_head_from_modules($conf, $langs, null, $head, $h, 'ai@ai', 'remove');
return $head;
}

View file

@ -0,0 +1,70 @@
<?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
*
* 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/>.
* or see https://www.gnu.org/
*/
/**
* \file htdocs/ai/lib/generate_content.lib.php
* \brief Library of ai script
*/
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/ai/class/ai.class.php';
//get data from AJAX
$rawData = file_get_contents('php://input');
$jsonData = json_decode($rawData, true);
if (is_null($jsonData)) {
dol_print_error('data with format JSON valide.');
}
$token = GETPOST('token');
if ($token !== currentToken()) { // Remplacez 'newToken' par le nom de votre variable de session contenant le token
dol_print_error('CSRF token validation failed.');
exit;
}
$chatGPT = new Ai('API_ENDPOINT', 'API_KEY');
$instructions = dol_string_nohtmltag($jsonData['instructions'], 1, 'UTF-8');
$generatedContent = $chatGPT->generateContent($instructions);
if ($generatedContent) {
print $generatedContent;
} else {
dol_print_error('error!!');
}

View file

@ -63,7 +63,9 @@ class Setup extends DolibarrApi
*
* @return array [List of ordering methods]
*
* @throws RestException 400
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 401 Access denied
* @throws RestException 503 Error retrieving list of ordering methods
*/
public function getOrderingMethods($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -81,7 +83,7 @@ class Setup extends DolibarrApi
$errormessage = '';
$sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
if ($errormessage) {
throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
}
@ -106,7 +108,7 @@ class Setup extends DolibarrApi
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(400, $this->db->lasterror());
throw new RestException(503, $this->db->lasterror());
}
return $list;
@ -125,7 +127,9 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/ordering_origins
*
* @throws RestException 400
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 401 Access denied
* @throws RestException 503 Error retrieving list of ordering origins
*/
public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -168,7 +172,7 @@ class Setup extends DolibarrApi
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(400, $this->db->lasterror());
throw new RestException(503, $this->db->lasterror());
}
return $list;
@ -188,7 +192,9 @@ class Setup extends DolibarrApi
*
* @return array [List of payment types]
*
* @throws RestException 400
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 401 Access denied
* @throws RestException 503 Error retrieving list of payment types
*/
public function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -232,7 +238,7 @@ class Setup extends DolibarrApi
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(400, $this->db->lasterror());
throw new RestException(503, $this->db->lasterror());
}
return $list;
@ -253,7 +259,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/regions
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error retrieving list of regions
*/
public function getListOfRegions($sortfield = "code_region", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $filter = '', $sqlfilters = '')
{
@ -316,7 +323,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/regions/{id}
*
* @throws RestException
* @throws RestException 404 Region not found
* @throws RestException 503 Error retrieving region
*/
public function getRegionByID($id)
{
@ -331,7 +339,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/regions/byCode/{code}
*
* @throws RestException
* @throws RestException 404 Region not found
* @throws RestException 503 Error when retrieving region
*/
public function getRegionByCode($code)
{
@ -357,7 +366,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/states
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error retrieving list of states
*/
public function getListOfStates($sortfield = "code_departement", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $filter = '', $sqlfilters = '')
{
@ -422,7 +432,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/states/{id}
*
* @throws RestException
* @throws RestException 404 State not found
* @throws RestException 503 Error retrieving state
*/
public function getStateByID($id)
{
@ -437,7 +448,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/states/byCode/{code}
*
* @throws RestException
* @throws RestException 404 State not found
* @throws RestException 503 Error retrieving state
*/
public function getStateByCode($code)
{
@ -463,7 +475,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/countries
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error retrieving list of countries
*/
public function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '')
{
@ -527,7 +540,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/countries/{id}
*
* @throws RestException
* @throws RestException 404 Country not found
* @throws RestException 503 Error retrieving country
*/
public function getCountryByID($id, $lang = '')
{
@ -543,7 +557,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/countries/byCode/{code}
*
* @throws RestException
* @throws RestException 404 Country not found
* @throws RestException 503 Error retrieving country
*/
public function getCountryByCode($code, $lang = '')
{
@ -559,7 +574,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/countries/byISO/{iso}
*
* @throws RestException
* @throws RestException 404 Country not found
* @throws RestException 503 Error retrieving country
*/
public function getCountryByISO($iso, $lang = '')
{
@ -654,7 +670,9 @@ class Setup extends DolibarrApi
*
* @return array [List of availability]
*
* @throws RestException 400
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 401 Access denied
* @throws RestException 503 Error when retrieving list of availabilities
*/
public function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -697,7 +715,7 @@ class Setup extends DolibarrApi
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(400, $this->db->lasterror());
throw new RestException(503, $this->db->lasterror());
}
return $list;
@ -766,7 +784,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/event_types
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of events types
*/
public function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '')
{
@ -832,7 +851,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/expensereport_types
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of expense report types
*/
public function getListOfExpenseReportsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '')
{
@ -897,7 +917,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/contact_types
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of contacts types
*/
public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang = '', $sqlfilters = '')
{
@ -965,7 +986,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/civilities
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of civilities
*/
public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $lang = '', $sqlfilters = '')
{
@ -1029,7 +1051,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/currencies
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of currencies
*/
public function getListOfCurrencies($multicurrency = 0, $sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -1098,7 +1121,8 @@ class Setup extends DolibarrApi
*
* @url GET extrafields
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of extra fields
*/
public function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '')
{
@ -1175,7 +1199,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/towns
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of towns
*/
public function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '')
{
@ -1240,7 +1265,8 @@ class Setup extends DolibarrApi
*
* @return array List of payment terms
*
* @throws RestException 400
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of payments terms
*/
public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -1284,7 +1310,7 @@ class Setup extends DolibarrApi
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(400, $this->db->lasterror());
throw new RestException(503, $this->db->lasterror());
}
return $list;
@ -1303,7 +1329,8 @@ class Setup extends DolibarrApi
*
* @return array List of shipping methods
*
* @throws RestException 400
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of shipping modes
*/
public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
@ -1345,7 +1372,7 @@ class Setup extends DolibarrApi
$list[] = $method;
}
} else {
throw new RestException(400, $this->db->lasterror());
throw new RestException(503, $this->db->lasterror());
}
return $list;
@ -1364,7 +1391,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/units
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of measuring units
*/
public function getListOfMeasuringUnits($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -1423,7 +1451,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/legal_form
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of legal form
*/
public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters = '')
{
@ -1484,7 +1513,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/staff
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of staff
*/
public function getListOfStaff($sortfield = "id", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -1542,7 +1572,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/socialnetworks
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of social networks
*/
public function getListOfsocialNetworks($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
@ -1608,7 +1639,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/ticket_categories
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of tickets categories
*/
public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
@ -1670,7 +1702,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/ticket_severities
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of tickets severities
*/
public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
@ -1732,7 +1765,8 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/ticket_types
*
* @throws RestException
* @throws RestException 400 Bad value for sqlfilters
* @throws RestException 503 Error when retrieving list of tickets types
*/
public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
@ -1795,7 +1829,7 @@ class Setup extends DolibarrApi
*
* @url GET dictionary/incoterms
*
* @throws RestException
* @throws RestException 503 Error when retrieving list of incoterms types
*/
public function getListOfIncoterms($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
@ -1905,7 +1939,7 @@ class Setup extends DolibarrApi
*
* @url GET /establishments
*
* @throws RestException
* @throws RestException 503 Error when retrieving list of establishments
*/
public function getEstablishments()
{
@ -1943,7 +1977,8 @@ class Setup extends DolibarrApi
*
* @url GET establishments/{id}
*
* @throws RestException
* @throws RestException 404 Establishment not found
* @throws RestException 503 Error when retrieving establishment
*/
public function getEtablishmentByID($id)
{
@ -1969,8 +2004,8 @@ class Setup extends DolibarrApi
*
* @url GET conf/{constantname}
*
* @throws RestException 400 Error Bad or unknown value for constantname
* @throws RestException 403 Forbidden
* @throws RestException 404 Error Bad or unknown value for constantname
*/
public function getConf($constantname)
{
@ -1982,7 +2017,7 @@ class Setup extends DolibarrApi
}
if (!preg_match('/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) {
throw new RestException(404, 'Error Bad or unknown value for constantname');
throw new RestException(400, 'Error Bad or unknown value for constantname');
}
if (isASecretKey($constantname)) {
throw new RestException(403, 'Forbidden. This parameter can not be read with APIs');
@ -2002,7 +2037,6 @@ class Setup extends DolibarrApi
* @throws RestException 403 Forbidden
* @throws RestException 404 Signature file not found
* @throws RestException 500 Technical error
* @throws RestException 503 Forbidden
*/
public function getCheckIntegrity($target)
{

View file

@ -411,19 +411,19 @@ Luracast\Restler\Defaults::$returnResponse = $usecompression;
// Call API (we suppose we found it).
// The handle will use the file api/temp/routes.php to get data to run the API. If the file exists and the entry for API is not found, it will return 404.
$result = $api->r->handle();
$responsedata = $api->r->handle();
if (Luracast\Restler\Defaults::$returnResponse) {
// We try to compress the data received data
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress') && defined('BROTLI_TEXT')) {
header('Content-Encoding: br');
$result = brotli_compress($result, 11, constant('BROTLI_TEXT'));
$result = brotli_compress($responsedata, 11, constant('BROTLI_TEXT'));
} elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) {
header('Content-Encoding: bz');
$result = bzcompress($result, 9);
$result = bzcompress($responsedata, 9);
} elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) {
header('Content-Encoding: gzip');
$result = gzencode($result, 9);
$result = gzencode($responsedata, 9);
} else {
header('Content-Encoding: text/html');
print "No compression method found. Try to disable compression by adding API_DISABLE_COMPRESSION=1";
@ -434,4 +434,20 @@ if (Luracast\Restler\Defaults::$returnResponse) {
echo $result;
}
// Call API termination method
$apiMethodInfo = &$api->r->apiMethodInfo;
$terminateCall = '_terminate_' . $apiMethodInfo->methodName . '_' . $api->r->responseFormat->getExtension();
if (method_exists($apiMethodInfo->className, $terminateCall)) {
// Now flush output buffers so that response data is sent to the client even if we still have action to do in a termination method.
ob_end_flush();
// If you're using PHP-FPM, this function will allow you to send the response and then continue processing
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
}
// Call a termination method. Warning: This method can do I/O, sync but must not make ouput.
call_user_func(array(Luracast\Restler\Scope::get($apiMethodInfo->className), $terminateCall), $responsedata);
}
//session_destroy();

View file

@ -61,7 +61,9 @@ class Boms extends DolibarrApi
* @return Object Object with cleaned properties
*
* @url GET {id}
* @throws RestException
*
* @throws RestException 401 Access denied
* @throws RestException 404 BOM not found
*/
public function get($id)
{
@ -95,7 +97,9 @@ class Boms extends DolibarrApi
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
* @return array Array of order objects
*
* @throws RestException
* @throws RestException 400 Bad sqlfilters
* @throws RestException 401 Access denied
* @throws RestException 503 Error retrieving list of boms
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '')
{
@ -176,6 +180,9 @@ class Boms extends DolibarrApi
*
* @param array $request_data Request datas
* @return int ID of bom
*
* @throws RestException 401 Access denied
* @throws RestException 500 Error retrieving list of boms
*/
public function post($request_data = null)
{
@ -210,6 +217,10 @@ class Boms extends DolibarrApi
* @param array $request_data Datas
*
* @return int
*
* @throws RestException 401 Access denied
* @throws RestException 404 BOM not found
* @throws RestException 500 Error updating bom
*/
public function put($id, $request_data = null)
{
@ -253,6 +264,10 @@ class Boms extends DolibarrApi
*
* @param int $id BOM ID
* @return array
*
* @throws RestException 401 Access denied
* @throws RestException 404 BOM not found
* @throws RestException 500 Error deleting bom
*/
public function delete($id)
{
@ -288,6 +303,9 @@ class Boms extends DolibarrApi
* @url GET {id}/lines
*
* @return array
*
* @throws RestException 401 Access denied
* @throws RestException 404 BOM not found
*/
public function getLines($id)
{
@ -320,6 +338,10 @@ class Boms extends DolibarrApi
* @url POST {id}/lines
*
* @return int
*
* @throws RestException 401 Access denied
* @throws RestException 404 BOM not found
* @throws RestException 500 Error adding bom line
*/
public function postLine($id, $request_data = null)
{
@ -353,7 +375,7 @@ class Boms extends DolibarrApi
if ($updateRes > 0) {
return $updateRes;
} else {
throw new RestException(400, $this->bom->error);
throw new RestException(500, $this->bom->error);
}
}
@ -367,6 +389,9 @@ class Boms extends DolibarrApi
* @url PUT {id}/lines/{lineid}
*
* @return object|bool
*
* @throws RestException 401 Access denied
* @throws RestException 404 BOM not found
*/
public function putLine($id, $lineid, $request_data = null)
{
@ -415,9 +440,9 @@ class Boms extends DolibarrApi
*
* @return int
*
* @throws RestException 401
* @throws RestException 404
* @throws RestException 500
* @throws RestException 401 Access denied
* @throws RestException 404 BOM not found
* @throws RestException 500 Error deleting bom line
*/
public function deleteLine($id, $lineid)
{
@ -450,7 +475,7 @@ class Boms extends DolibarrApi
if ($updateRes > 0) {
return $this->get($id);
} else {
throw new RestException(405, $this->bom->error);
throw new RestException(500, $this->bom->error);
}
}

View file

@ -22,62 +22,14 @@
* \brief Tab of events on Calendar
*/
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
//if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--;
$j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
dol_include_once('/bookcal/class/calendar.class.php');
dol_include_once('/bookcal/lib/bookcal_calendar.lib.php');
require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php';
require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_calendar.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bookcal@bookcal", "other"));

View file

@ -220,6 +220,11 @@ class Categorie extends CommonObject
*/
public $color;
/**
* @var int Position
*/
public $position;
/**
* @var int Visible
*/
@ -352,7 +357,7 @@ class Categorie extends CommonObject
$type = $this->MAP_ID[$type];
}
$sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext";
$sql = "SELECT rowid, fk_parent, entity, label, description, color, position, fk_soc, visible, type, ref_ext";
$sql .= ", date_creation, tms, fk_user_creat, fk_user_modif";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie";
if ($id) {
@ -378,6 +383,7 @@ class Categorie extends CommonObject
$this->label = $res['label'];
$this->description = $res['description'];
$this->color = $res['color'];
$this->position = $res['position'];
$this->socid = (int) $res['fk_soc'];
$this->visible = (int) $res['visible'];
$this->type = (int) $res['type'];
@ -440,6 +446,7 @@ class Categorie extends CommonObject
$this->label = trim($this->label);
$this->description = trim($this->description);
$this->color = trim($this->color);
$this->position = trim($this->position);
$this->import_key = trim($this->import_key);
$this->ref_ext = trim($this->ref_ext);
if (empty($this->visible)) {
@ -461,6 +468,7 @@ class Categorie extends CommonObject
$sql .= " label,";
$sql .= " description,";
$sql .= " color,";
$sql .= " position,";
if (getDolGlobalString('CATEGORY_ASSIGNED_TO_A_CUSTOMER')) {
$sql .= "fk_soc,";
}
@ -476,6 +484,7 @@ class Categorie extends CommonObject
$sql .= "'".$this->db->escape($this->label)."', ";
$sql .= "'".$this->db->escape($this->description)."', ";
$sql .= "'".$this->db->escape($this->color)."', ";
$sql .= (int) $this->position.",";
if (getDolGlobalString('CATEGORY_ASSIGNED_TO_A_CUSTOMER')) {
$sql .= ($this->socid > 0 ? $this->socid : 'null').", ";
}
@ -566,6 +575,7 @@ class Categorie extends CommonObject
$sql .= " description = '".$this->db->escape($this->description)."',";
$sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',";
$sql .= " color = '".$this->db->escape($this->color)."'";
$sql .= ", position = ".(int) $this->position;
if (getDolGlobalString('CATEGORY_ASSIGNED_TO_A_CUSTOMER')) {
$sql .= ", fk_soc = ".($this->socid > 0 ? $this->socid : 'null');
}
@ -1028,6 +1038,7 @@ class Categorie extends CommonObject
$categories[$i]['label'] = $category_static->label;
$categories[$i]['description'] = $category_static->description;
$categories[$i]['color'] = $category_static->color;
$categories[$i]['position'] = $category_static->position;
$categories[$i]['socid'] = $category_static->socid;
$categories[$i]['ref_ext'] = $category_static->ref_ext;
$categories[$i]['visible'] = $category_static->visible;
@ -1163,7 +1174,7 @@ class Categorie extends CommonObject
$current_lang = $langs->getDefaultLang();
// Init $this->cats array
$sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates
$sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.position, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates
if (getDolGlobalInt('MAIN_MULTILANGS')) {
$sql .= ", t.label as label_trans, t.description as description_trans";
}
@ -1185,6 +1196,7 @@ class Categorie extends CommonObject
$this->cats[$obj->rowid]['label'] = !empty($obj->label_trans) ? $obj->label_trans : $obj->label;
$this->cats[$obj->rowid]['description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description;
$this->cats[$obj->rowid]['color'] = $obj->color;
$this->cats[$obj->rowid]['position'] = $obj->position;
$this->cats[$obj->rowid]['visible'] = $obj->visible;
$this->cats[$obj->rowid]['ref_ext'] = $obj->ref_ext;
$this->cats[$obj->rowid]['picto'] = 'category';

View file

@ -45,6 +45,7 @@ $socid = (int) GETPOST('socid', 'int');
$label = (string) GETPOST('label', 'alphanohtml');
$description = (string) GETPOST('description', 'restricthtml');
$color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('color', 'alphanohtml'));
$position = (int) GETPOST('position', 'int');
$visible = (int) GETPOST('visible', 'int');
$parent = (int) GETPOST('parent', 'int');
@ -80,7 +81,7 @@ $error = 0;
/*
* Actions
*/
$parameters = array('id' => $id, 'ref' => $ref, 'cancel'=> $cancel, 'backtopage' => $backtopage, 'socid' => $socid, 'label' => $label, 'description' => $description, 'color' => $color, 'visible' => $visible, 'parent' => $parent);
$parameters = array('id' => $id, 'ref' => $ref, 'cancel'=> $cancel, 'backtopage' => $backtopage, 'socid' => $socid, 'label' => $label, 'description' => $description, 'color' => $color, 'position' => $position, 'visible' => $visible, 'parent' => $parent);
// Note that $action and $object may be modified by some hooks
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
if ($reshook < 0) {
@ -105,6 +106,7 @@ if (empty($reshook)) {
$object->label = $label;
$object->description = dol_htmlcleanlastbr($description);
$object->color = $color;
$object->position = $position;
$object->socid = ($socid > 0 ? $socid : 0);
$object->visible = $visible;
$object->fk_parent = $parent != -1 ? $parent : 0;
@ -186,6 +188,12 @@ print '<td>';
print $formother->selectColor($object->color, 'color');
print '</td></tr>';
// Position
print '<tr><td>';
print $langs->trans("Position").'</td>';
print '<td><input type="text" size="25" id="position" name ="position" value="'.$object->position.'" />';
print '</tr>';
// Parent category
print '<tr><td>'.$langs->trans("In").'</td><td>';
print img_picto('', 'category', 'class="pictofixedwidth"');

View file

@ -301,6 +301,12 @@ print $langs->trans("Color").'</td><td>';
print $formother->showColor($object->color);
print '</td></tr>';
// Position
print '<tr><td class="titlefield notopnoleft">';
print $langs->trans("Position").'</td><td>';
print $object->position;
print '</td></tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';

View file

@ -215,12 +215,12 @@ if (isModEnabled('accounting')) {
$calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPING"'.($modecompta == 'BOOKKEEPING' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
$calcmode .= '<br>';
}
$calcmode .= '<input type="radio" name="modecompta" id="modecompta1" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta1"> '.$langs->trans("CalcModeDebt");
$calcmode .= '<input type="radio" name="modecompta" id="modecompta1" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta1"> '.$langs->trans("CalcModePayment");
if (isModEnabled('accounting')) {
$calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
}
$calcmode .= '</label>';
$calcmode .= '<br><input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeEngagement");
$calcmode .= '<br><input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeDebt");
if (isModEnabled('accounting')) {
$calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
}

View file

@ -189,12 +189,12 @@ if (isModEnabled('accounting')) {
$calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPING"'.($modecompta == 'BOOKKEEPING' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
$calcmode .= '<br>';
}
$calcmode .= '<input type="radio" name="modecompta" id="modecompta1" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta1"> '.$langs->trans("CalcModeDebt");
$calcmode .= '<input type="radio" name="modecompta" id="modecompta1" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta1"> '.$langs->trans("CalcModePayment");
if (isModEnabled('accounting')) {
$calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
}
$calcmode .= '</label>';
$calcmode .= '<br><input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeEngagement");
$calcmode .= '<br><input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeDebt");
if (isModEnabled('accounting')) {
$calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
}

View file

@ -215,7 +215,7 @@ if ($modecompta == "CREANCES-DETTES") {
//$exportlink=$langs->trans("NotYetAvailable");
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("AnnualByAccountInputOutputMode");
$calcmode = $langs->trans("CalcModeEngagement");
$calcmode = $langs->trans("CalcModePayment");
$calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month") > 0 ? '&month='.GETPOST("month") : '').'&modecompta=CREANCES-DETTES">', '</a>').')';
if (isModEnabled('accounting')) {
$calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=BOOKKEEPING">', '</a>').')';

View file

@ -265,7 +265,7 @@ if ($modecompta == "CREANCES-DETTES") {
$builddate = dol_now();
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByVatRate");
$calcmode = $langs->trans("CalcModeEngagement");
$calcmode = $langs->trans("CalcModePayment");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description .= $langs->trans("RulesCAIn");

View file

@ -250,7 +250,7 @@ if ($modecompta == "CREANCES-DETTES") {
$builddate = dol_now();
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByProductsAndServices");
$calcmode = $langs->trans("CalcModeEngagement");
$calcmode = $langs->trans("CalcModePayment");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description = $langs->trans("RulesCAIn");

View file

@ -205,7 +205,7 @@ if ($modecompta == "CREANCES-DETTES") {
//$exportlink=$langs->trans("NotYetAvailable");
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByUserAuthorOfInvoice");
$calcmode = $langs->trans("CalcModeEngagement");
$calcmode = $langs->trans("CalcModePayment");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description = $langs->trans("RulesCAIn");
$description .= $langs->trans("DepositsAreIncluded");

View file

@ -239,7 +239,7 @@ if ($modecompta == "CREANCES-DETTES") {
//$exportlink=$langs->trans("NotYetAvailable");
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByThirdParties");
$calcmode = $langs->trans("CalcModeEngagement");
$calcmode = $langs->trans("CalcModePayment");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description = $langs->trans("RulesCAIn");
$description .= $langs->trans("DepositsAreIncluded");

View file

@ -188,7 +188,7 @@ if ($modecompta == "RECETTES-DEPENSES" || $modecompta == "BOOKKEEINGCOLLECTED")
$calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPINGCOLLECTED"'.($modecompta == 'BOOKKEEPINGCOLLECTED' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
$calcmode .= '<br>';
}*/
$calcmode .= '<input type="radio" name="modecompta" id="modecompta2" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeEngagement");
$calcmode .= '<input type="radio" name="modecompta" id="modecompta2" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModePayment");
if (isModEnabled('accounting')) {
$calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
}

View file

@ -180,7 +180,7 @@ if ($modecompta == "RECETTES-DEPENSES" || $modecompta == "BOOKKEEPINGCOLLECTED")
$calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPINGCOLLECTED"'.($modecompta == 'BOOKKEEPINGCOLLECTED' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
$calcmode .= '<br>';
}*/
$calcmode .= '<input type="radio" name="modecompta" id="modecompta2" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeEngagement");
$calcmode .= '<input type="radio" name="modecompta" id="modecompta2" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModePayment");
if (isModEnabled('accounting')) {
$calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
}
@ -190,7 +190,7 @@ if ($modecompta == "RECETTES-DEPENSES" || $modecompta == "BOOKKEEPINGCOLLECTED")
$calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPING"'.($modecompta == 'BOOKKEEPING' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
$calcmode .= '<br>';
}
$calcmode .= '<input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeEngagement");
$calcmode .= '<input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModePayment");
if (isModEnabled('accounting')) {
$calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
}

View file

@ -234,7 +234,7 @@ if ($modecompta == "CREANCES-DETTES") {
$builddate = dol_now();
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByProductsAndServices");
$calcmode = $langs->trans("CalcModeEngagement");
$calcmode = $langs->trans("CalcModePayment");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description = $langs->trans("RulesPurchaseTurnoverIn");

View file

@ -212,7 +212,7 @@ if ($modecompta == "CREANCES-DETTES") {
//$exportlink=$langs->trans("NotYetAvailable");
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByThirdParties");
$calcmode = $langs->trans("CalcModeEngagement");
$calcmode = $langs->trans("CalcModePayment");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description = $langs->trans("RulesPurchaseTurnoverIn");
//$exportlink=$langs->trans("NotYetAvailable");

View file

@ -47,6 +47,8 @@ if ($action == 'update' && is_array($arrayofparameters) && !empty($user->admin))
} else {
$val_const = GETPOST($key, 'int');
}
} else if ($val['type'] == 'html') {
$val_const = GETPOST($key, 'restricthtml');
} else {
$val_const = GETPOST($key, 'alpha');
}

View file

@ -70,7 +70,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
$roworder = GETPOST('roworder', 'alpha', 3);
$table_element_line = GETPOST('table_element_line', 'aZ09', 3);
$fk_element = GETPOST('fk_element', 'aZ09', 3);
$element_id = GETPOST('element_id', 'int', 3);
$element_id = GETPOSTINT('element_id', 3);
dol_syslog("AjaxRow roworder=".$roworder." table_element_line=".$table_element_line." fk_element=".$fk_element." element_id=".$element_id, LOG_DEBUG);

View file

@ -1182,7 +1182,7 @@ abstract class CommonInvoice extends CommonObject
$this->fetch_thirdparty();
dol_syslog("--- Process payment request amount=".$amount." thirdparty_id=" . $this->thirdparty->id . ", thirdparty_name=" . $this->thirdparty->name . " ban id=" . $bac->id, LOG_DEBUG);
dol_syslog("makeStripeSepaRequest Process payment request amount=".$amount." thirdparty_id=" . $this->thirdparty->id . ", thirdparty_name=" . $this->thirdparty->name . " ban id=" . $bac->id, LOG_DEBUG);
//$alreadypayed = $this->getSommePaiement();
//$amount_credit_notes_included = $this->getSumCreditNotesUsed();
@ -1201,7 +1201,7 @@ abstract class CommonInvoice extends CommonObject
if (!($fk_bank_account > 0)) {
$error++;
$errorforinvoice++;
dol_syslog("Error no bank account defined for Stripe payments", LOG_ERR);
dol_syslog("makeStripeSepaRequest Error no bank account defined for Stripe payments", LOG_ERR);
$this->errors[] = "Error bank account for Stripe payments not defined into Stripe module";
}
@ -1217,7 +1217,7 @@ abstract class CommonInvoice extends CommonObject
if ($nbinvoices <= 0) {
$error++;
$errorforinvoice++;
dol_syslog("Error on BonPrelevement creation", LOG_ERR);
dol_syslog("makeStripeSepaRequest Error on BonPrelevement creation", LOG_ERR);
$this->errors[] = "Error on BonPrelevement creation";
}
/*
@ -1237,7 +1237,7 @@ abstract class CommonInvoice extends CommonObject
} else {
$error++;
$errorforinvoice++;
dol_syslog("Error Line already part of a bank payment order", LOG_ERR);
dol_syslog("makeStripeSepaRequest Error Line already part of a bank payment order", LOG_ERR);
$this->errors[] = "The line is already included into a bank payment order. Delete the bank payment order first.";
}
}
@ -1253,7 +1253,7 @@ abstract class CommonInvoice extends CommonObject
}
//var_dump($companypaymentmode);
dol_syslog("We will try to pay with companypaymentmodeid=" . $companypaymentmode->id . " stripe_card_ref=" . $companypaymentmode->stripe_card_ref . " mode=" . $companypaymentmode->status, LOG_DEBUG);
dol_syslog("makeStripeSepaRequest We will try to pay with companypaymentmodeid=" . $companypaymentmode->id . " stripe_card_ref=" . $companypaymentmode->stripe_card_ref . " mode=" . $companypaymentmode->status, LOG_DEBUG);
$thirdparty = new Societe($this->db);
$resultthirdparty = $thirdparty->fetch($this->socid);
@ -1614,7 +1614,7 @@ abstract class CommonInvoice extends CommonObject
}
} else {
$this->error = "Status of invoice does not allow this";
dol_syslog(get_class($this)."::makeStripeSepaRequest ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id");
dol_syslog(get_class($this)."::makeStripeSepaRequest ".$this->error." ".$this->status." ,".$this->paye.", ".$this->mode_reglement_id, LOG_WARNING);
return -3;
}
}

View file

@ -1120,9 +1120,10 @@ class ExtraFields
} else {
$checked = ' value="1" ';
}
$out = '<input type="checkbox" class="flat valignmiddle'.($morecss ? ' '.$morecss : '').' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam ? $moreparam : '').'>';
$out = '<input type="hidden" name="'.$keyprefix.$key.$keysuffix.'_boolean" value="1">'; // A hidden field ending with "_boolean" that is always set to 1.
$out .= '<input type="checkbox" class="flat valignmiddle'.($morecss ? ' '.$morecss : '').' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam ? $moreparam : '').'>';
} else {
$out .= $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1);
$out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1);
}
} elseif ($type == 'price') {
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
@ -2352,7 +2353,9 @@ class ExtraFields
$value_key = GETPOST($keysuffix."options_".$key.$keyprefix);
}
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) {
if (!GETPOST($keysuffix."options_".$key.$keyprefix)) {
// We test on a hidden field named "..._multiselect" that is always set to 1 if param is in form so
// when nothing is provided we can make a difference between noparam in the form and param was set to nothing.
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix.'_multiselect')) {
continue; // Value was not provided, we should not set it.
}
$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix);
@ -2360,7 +2363,7 @@ class ExtraFields
$value_arr = (array) $value_arr;
$value_key = implode(',', $value_arr);
} elseif (in_array($key_type, array('price', 'double', 'int'))) {
if (!GETPOST($keysuffix."options_".$key.$keyprefix)) {
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) {
continue; // Value was not provided, we should not set it.
}
$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix);
@ -2370,14 +2373,16 @@ class ExtraFields
$value_key = $value_arr;
}
} elseif (in_array($key_type, array('boolean'))) {
if (!GETPOST($keysuffix."options_".$key.$keyprefix)) {
// We test on a hidden field named "..._boolean" that is always set to 1 if param is in form so
// when nothing is provided we can make a difference between noparam in the form and param was set to nothing.
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."_boolean")) {
$value_key = '';
} else {
$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix);
$value_key = $value_arr;
}
} elseif (in_array($key_type, array('html'))) {
if (!GETPOST($keysuffix."options_".$key.$keyprefix)) {
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) {
continue; // Value was not provided, we should not set it.
}
$value_key = dol_htmlcleanlastbr(GETPOST($keysuffix."options_".$key.$keyprefix, 'restricthtml'));

View file

@ -6526,14 +6526,31 @@ class Form
}
if (getDolGlobalString('SERVICE_ARE_ECOMMERCE_200238EC')) { // If option to have vat for end customer for services is on
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
// If SERVICE_ARE_ECOMMERCE_200238EC=1 combo list vat rate of purchaser and seller countries
// If SERVICE_ARE_ECOMMERCE_200238EC=2 combo list only the vat rate of the purchaser country
$selectVatComboMode = getDolGlobalString('SERVICE_ARE_ECOMMERCE_200238EC');
if (isInEEC($societe_vendeuse) && isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()) {
// We also add the buyer country code
if (is_numeric($type)) {
if ($type == 1) { // We know product is a service
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
switch ($selectVatComboMode) {
case '1':
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
break;
case '2':
$code_country = "'" . $societe_acheteuse->country_code . "'";
break;
}
}
} elseif (!$idprod) { // We don't know type of product
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
switch ($selectVatComboMode) {
case '1':
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
break;
case '2':
$code_country = "'" . $societe_acheteuse->country_code . "'";
break;
}
} else {
$prodstatic = new Product($this->db);
$prodstatic->fetch($idprod);
@ -6546,6 +6563,7 @@ class Form
// Now we load the list of VAT
$this->load_cache_vatrates($code_country); // If no vat defined, return -1 with message into this->error
// Keep only the VAT qualified for $type_vat
$arrayofvatrates = array();
foreach ($this->cache_vatrates as $cachevalue) {
@ -8512,10 +8530,6 @@ class Form
$out .= ajax_combobox($idname, array(), 0, 0, 'resolve', (((int) $show_empty) < 0 ? (string) $show_empty : '-1'), $morecss);
}
return $out;
}
@ -8778,10 +8792,16 @@ class Form
}
$useenhancedmultiselect = 0;
if (!empty($conf->use_javascript_ajax) && getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT') || defined('REQUIRE_JQUERY_MULTISELECT')) {
$useenhancedmultiselect = 1;
if (!empty($conf->use_javascript_ajax) && (getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT') || defined('REQUIRE_JQUERY_MULTISELECT'))) {
if ($addjscombo) {
$useenhancedmultiselect = 1; // Use the js multiselect in one line. Possible only if $addjscombo not 0.
}
}
// We need a hidden field because when using the multiselect, if we unselect all, there is no
// variable submitted at all, so no way to make a difference between variable not submited and variable
// submited to nothing.
$out .= '<input type="hidden" name="'.$htmlname.'_multiselect" value="1">';
// Output select component
$out .= '<select id="' . $htmlname . '" class="multiselect' . ($useenhancedmultiselect ? ' multiselectononeline' : '') . ($morecss ? ' ' . $morecss : '') . '" multiple name="' . $htmlname . '[]"' . ($moreattrib ? ' ' . $moreattrib : '') . ($width ? ' style="width: ' . (preg_match('/%/', $width) ? $width : $width . 'px') . '"' : '') . '>' . "\n";
if (is_array($array) && !empty($array)) {
@ -9054,11 +9074,11 @@ class Form
/**
* Show linked object block.
*
* @param CommonObject $object Object we want to show links to
* @param string $morehtmlright More html to show on right of title
* @param array $compatibleImportElementsList Array of compatibles elements object for "import from" action
* @param string $title Title
* @return int Return integer <0 if KO, >=0 if OK
* @param CommonObject $object Object we want to show links to
* @param string $morehtmlright More html to show on right of title
* @param array $compatibleImportElementsList Array of compatibles elements object for "import from" action
* @param string $title Title
* @return int Return integer <0 if KO, >=0 if OK
*/
public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = array(), $title = 'RelatedObjects')
{

View file

@ -1200,12 +1200,14 @@ class FormMail extends Form
/**
* get html For WithCCC
* This information is show when MAIN_EMAIL_USECCC is set.
*
* @return string html
*/
public function getHtmlForWithCcc()
{
global $conf, $langs, $form;
global $langs, $form;
$out = '<tr><td>';
$out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out .= '</td><td>';
@ -1261,9 +1263,15 @@ class FormMail extends Form
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO') && !empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') {
$showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO');
}
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROJECT_TO') && !empty($this->param['models']) && $this->param['models'] == 'project') {
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROJECT_TO') && !empty($this->param['models']) && $this->param['models'] == 'project') { // don't know why there is not '_send' at end of this models name.
$showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROJECT_TO');
}
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_SHIPMENT_TO') && !empty($this->param['models']) && $this->param['models'] == 'shipping_send') {
$showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_SHIPMENT_TO');
}
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_RECEPTION_TO') && !empty($this->param['models']) && $this->param['models'] == 'reception_send') {
$showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_RECEPTION_TO');
}
if ($showinfobcc) {
$out .= ' + '.$showinfobcc;
}
@ -1278,7 +1286,8 @@ class FormMail extends Form
*/
public function getHtmlForWithErrorsTo()
{
global $conf, $langs;
global $langs;
//if (! $this->errorstomail) $this->errorstomail=$this->frommail;
$errorstomail = getDolGlobalString('MAIN_MAIL_ERRORS_TO', (!empty($this->errorstomail) ? $this->errorstomail : ''));
if ($this->witherrorstoreadonly) {
@ -1301,7 +1310,8 @@ class FormMail extends Form
*/
public function getHtmlForDeliveryreceipt()
{
global $conf, $langs;
global $langs;
$out = '<tr><td><label for="deliveryreceipt">'.$langs->trans("DeliveryReceipt").'</label></td><td>';
if (!empty($this->withdeliveryreceiptreadonly)) {
@ -1339,7 +1349,7 @@ class FormMail extends Form
*/
public function getHtmlForTopic($arraydefaultmessage, $helpforsubstitution)
{
global $conf, $langs, $form;
global $langs, $form;
$defaulttopic = GETPOST('subject', 'restricthtml');
@ -1376,18 +1386,49 @@ class FormMail extends Form
{
global $langs, $form;
$baseUrl = dol_buildpath('/', 1);
$out = '<tr>';
$out .= '<td>';
$out .= $form->textwithpicto($langs->trans('helpWithAi'), $langs->trans("YouCanMakeSomeInstructionForEmail"));
$out .= '</td>';
$out .= '<td>';
$out .= '<input type="text" class="quatrevingtpercent" id="instruction" name="instruction" placeholder="message with AI"/>';
$out .= '<input type="submit" class="button smallpaddingimp" name="generate_email_content" value="'.$langs->trans('Generate').'" />';
$out .= '<input type="hidden" id="csrf_token" name="token" value="'.newToken().'">';
$out .= '<input type="text" class="quatrevingtpercent" id="ai_instructions" name="instruction" placeholder="message with AI"/>';
$out .= '<button id="generate_button" type="button" class="button smallpaddingimp">'.$langs->trans('Generate').'</button>';
$out .= "</td></tr>\n";
$out .= "<script type='text/javascript'>
$(document).ready(function() {
$('#generate_button').click(function() {
var instructions = $('#ai_instructions').val();
var token = $('#csrf_token').val();
$.ajax({
url: '".$baseUrl."ai/lib/generate_content.lib.php',
method: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify({
'token': token,
'instructions': instructions,
}),
success: function(response) {
console.log(response);
},
error: function(xhr, status, error) {
console.error('error ajax', status, error);
}
});
});
});
</script>
";
return $out;
}
/**
* Return templates of email with type = $type_template or type = 'all'.
* This search into table c_email_templates. Used by the get_form function.

View file

@ -887,6 +887,11 @@ class FormSetupItem
$selected = (empty($this->fieldValue) ? '' : $this->fieldValue);
$out.= $this->form->select_produits($selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1);
}
} elseif ($this->type == 'selectBankAccount') {
if (isModEnabled("bank")) {
$selected = (empty($this->fieldValue) ? '' : $this->fieldValue);
$out.= $this->form->select_comptes($selected, $this->confKey, 0, '', 0, '', 0, '', 1);
}
} else {
$out.= $this->generateInputFieldText();
}
@ -1175,6 +1180,16 @@ class FormSetupItem
} elseif ($resprod < 0) {
$this->setErrors($product->errors);
}
} elseif ($this->type == 'selectBankAccount') {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$bankaccount = new Account($this->db);
$resbank = $bankaccount->fetch($this->fieldValue);
if ($resbank > 0) {
$out.= $bankaccount->label;
} elseif ($resbank < 0) {
$this->setErrors($bankaccount->errors);
}
} else {
$out.= $this->fieldValue;
}
@ -1427,4 +1442,15 @@ class FormSetupItem
$this->type = 'selectUser';
return $this;
}
/**
* Set type of input as a simple title. No data to store
*
* @return self
*/
public function setAsSelectBankAccount()
{
$this->type = 'selectBankAccount';
return $this;
}
}

View file

@ -937,7 +937,7 @@ class FormTicket
$arraycodenotparent[] = "";
$stringtoprint = '<span class="supportemailfield bold">'.$langs->trans("GroupOfTicket").'</span> ';
$stringtoprint .= '<select id ="'.$htmlname.'" class="minwidth500" child_id="0">';
$stringtoprint .= '<select id="'.$htmlname.'" class="minwidth500" child_id="0">';
$stringtoprint .= '<option value="">&nbsp;</option>';
$sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
@ -997,7 +997,7 @@ class FormTicket
$levelid = 1; // The first combobox
while ($levelid <= $use_multilevel) { // Loop to take the child of the combo
$tabscript = array();
$stringtoprint .= '<select id ="'.$htmlname.'_child_'.$levelid.'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.'">';
$stringtoprint .= '<select id="'.$htmlname.'_child_'.$levelid.'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.'">';
$stringtoprint .= '<option value="">&nbsp;</option>';
$sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";

View file

@ -3,6 +3,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2021 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2006-2021 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
*
* 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
@ -44,12 +45,12 @@ class Ldap
public $errors = array();
/**
* Tableau des serveurs (IP addresses ou nom d'hotes)
* @var array Servers (IP addresses or hostnames)
*/
public $server = array();
/**
* Current connected server
* @var string Current connected server
*/
public $connectedServer;
@ -59,51 +60,62 @@ class Ldap
public $serverPort;
/**
* Base DN (e.g. "dc=foo,dc=com")
* @var string Base DN (e.g. "dc=foo,dc=com")
*/
public $dn;
/**
* type de serveur, actuellement OpenLdap et Active Directory
* @var string Server type: OpenLDAP or Active Directory
*/
public $serverType;
/**
* Version du protocole ldap
* @var string LDAP protocol version
*/
public $ldapProtocolVersion;
/**
* Server DN
* @var string Server DN
*/
public $domain;
/**
* @var string Server FQDN
*/
public $domainFQDN;
/**
* @var int bind
* @var bool LDAP bind
*/
public $bind;
/**
* User administrateur Ldap
* @var string LDAP administrator user
* Active Directory does not allow anonymous connections
*/
public $searchUser;
/**
* Administraot Password
* @var string LDAP administrator password
* Active Directory does not allow anonymous connections
*/
public $searchPassword;
/**
* Users DN
* @var string Users DN
*/
public $people;
/**
* Groups DN
* @var string Groups DN
*/
public $groups;
/**
* @var string|null Error code provided by the LDAP server
* @var int|null Error code provided by the LDAP server
*/
public $ldapErrorCode;
/**
* @var string|null Error text message
*/
@ -113,10 +125,12 @@ class Ldap
* @var string
*/
public $filter;
/**
* @var string
*/
public $filtergroup;
/**
* @var string
*/
@ -168,56 +182,91 @@ class Ldap
public $badpwdtime;
/**
* @var string ladpUserDN
* @var string LDAP user DN
*/
public $ldapUserDN;
//Fetch user
/**
* @var string Fetched username
*/
public $name;
/**
* @var string Fetched user first name
*/
public $firstname;
/**
* @var string Fetched user login
*/
public $login;
/**
* @var string Fetched user phone number
*/
public $phone;
/**
* @var string Fetched user fax number
*/
public $fax;
/**
* @var string Fetched user email
*/
public $mail;
/**
* @var string Fetched user mobile number
*/
public $mobile;
/**
* @var array UserAccountControl Flags
*/
public $uacf;
/**
* @var int Password last set time
*/
public $pwdlastset;
public $ldapcharset = 'UTF-8'; // LDAP should be UTF-8 encoded
/**
* @var string LDAP charset.
* LDAP should be UTF-8 encoded
*/
public $ldapcharset = 'UTF-8';
/**
* The internal LDAP connection handle
* @var bool|resource The internal LDAP connection handle
*/
public $connection;
/**
* Result of any connections etc.
* @var bool|resource Result of any connections or search.
*/
public $result;
/**
* No Ldap synchronization
* @var int No LDAP synchronization
*/
const SYNCHRO_NONE = 0;
/**
* Dolibarr to Ldap synchronization
* @var int Dolibarr to LDAP synchronization
*/
const SYNCHRO_DOLIBARR_TO_LDAP = 1;
/**
* Ldap to Dolibarr synchronization
* @var int LDAP to Dolibarr synchronization
*/
const SYNCHRO_LDAP_TO_DOLIBARR = 2;
/**
* Constructor
*/
public function __construct()
{
global $conf;
// Server
if (getDolGlobalString('LDAP_SERVER_HOST')) {
@ -260,17 +309,16 @@ class Ldap
* Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType, this->searchUser, this->searchPassword
* After return, this->connection and $this->bind are defined
*
* @return int Return integer <0 if KO, 1 if bind anonymous, 2 if bind auth
* @return int if KO: <0 || if bind anonymous: 1 || if bind auth: 2
*/
public function connect_bind()
{
// phpcs:enable
global $conf;
global $dolibarr_main_auth_ldap_debug;
$connected = 0;
$this->bind = 0;
$this->error = 0;
$this->bind = false;
$this->error = '';
$this->connectedServer = '';
$ldapdebug = ((empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false") ? false : true);
@ -290,7 +338,7 @@ class Ldap
if (!function_exists("ldap_connect")) {
$this->error = 'LDAPFunctionsNotAvailableOnPHP';
dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
$return = -1;
return -1;
}
if (empty($this->error)) {
@ -303,9 +351,9 @@ class Ldap
continue;
}
if ($this->serverPing($host, $this->serverPort) === true) {
if ($this->serverPing($host, $this->serverPort)) {
if ($ldapdebug) {
dol_syslog(get_class($this)."::connect_bind serverPing true, we try ldap_connect to ".$host);
dol_syslog(get_class($this)."::connect_bind serverPing true, we try ldap_connect to ".$host, LOG_DEBUG);
}
$this->connection = ldap_connect($host, $this->serverPort);
} else {
@ -313,10 +361,13 @@ class Ldap
// With host = ldaps://server, the serverPing to ssl://server sometimes fails, even if the ldap_connect succeed, so
// we test this case and continue in such a case even if serverPing fails.
if ($ldapdebug) {
dol_syslog(get_class($this)."::connect_bind serverPing false, we try ldap_connect to ".$host);
dol_syslog(get_class($this)."::connect_bind serverPing false, we try ldap_connect to ".$host, LOG_DEBUG);
}
$this->connection = ldap_connect($host, $this->serverPort);
} else {
if ($ldapdebug) {
dol_syslog(get_class($this)."::connect_bind serverPing false, no ldap_connect ".$host, LOG_DEBUG);
}
continue;
}
}
@ -344,8 +395,7 @@ class Ldap
// Execute the ldap_set_option here (after connect and before bind)
$this->setVersion();
ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); // no limit here. should return true.
$this->setSizeLimit();
if ($this->serverType == "activedirectory") {
$result = $this->setReferrals();
@ -396,15 +446,13 @@ class Ldap
}
if ($connected) {
$return = $connected;
dol_syslog(get_class($this)."::connect_bind return=".$return, LOG_DEBUG);
dol_syslog(get_class($this)."::connect_bind ".$connected, LOG_DEBUG);
return $connected;
} else {
$this->error = 'Failed to connect to LDAP'.($this->error ? ': '.$this->error : '');
$return = -1;
dol_syslog(get_class($this)."::connect_bind return=".$return.' - '.$this->error, LOG_WARNING);
dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
return -1;
}
return $return;
}
/**
@ -481,50 +529,57 @@ class Ldap
/**
* Verification de la version du serveur ldap.
* Verify LDAP server version
*
* @return string version
* @return int version
*/
public function getVersion()
{
$version = 0;
$version = @ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version);
@ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version);
return $version;
}
/**
* Change ldap protocol version to use.
* Set LDAP protocol version.
* LDAP_OPT_PROTOCOL_VERSION is a constant equal to 3
*
* @return boolean version
* @return boolean if set LDAP option OK: true, if KO: false
*/
public function setVersion()
{
// LDAP_OPT_PROTOCOL_VERSION est une constante qui vaut 17
$ldapsetversion = ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion);
return $ldapsetversion;
return ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion);
}
/**
* changement du referrals.
* Set LDAP size limit.
*
* @return boolean referrals
* @return boolean if set LDAP option OK: true, if KO: false
*/
public function setSizeLimit()
{
return ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0);
}
/**
* Set LDAP referrals.
* LDAP_OPT_REFERRALS is a constant equal to ?
*
* @return boolean if set LDAP option OK: true, if KO: false
*/
public function setReferrals()
{
// LDAP_OPT_REFERRALS est une constante qui vaut ?
$ldapreferrals = ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
return $ldapreferrals;
return ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
}
/**
* Add a LDAP entry
* Ldap object connect and bind must have been done
* Add an LDAP entry
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param User $user Object user that create
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function add($dn, $info, $user)
{
@ -566,13 +621,13 @@ class Ldap
}
/**
* Modify a LDAP entry
* Ldap object connect and bind must have been done
* Modify an LDAP entry
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param User $user Object user that modify
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function modify($dn, $info, $user)
{
@ -622,15 +677,15 @@ class Ldap
}
/**
* Rename a LDAP entry
* Ldap object connect and bind must have been done
* Rename an LDAP entry
* LDAP object connect and bind must have been done
*
* @param string $dn Old DN entry key (uid=qqq,ou=xxx,dc=aaa,dc=bbb) (before update)
* @param string $newrdn New RDN entry key (uid=qqq)
* @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb)
* @param User $user Object user that modify
* @param bool $deleteoldrdn If true the old RDN value(s) is removed, else the old RDN value(s) is retained as non-distinguished values of the entry.
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true)
{
@ -665,8 +720,8 @@ class Ldap
}
/**
* Modify a LDAP entry (to use if dn != olddn)
* Ldap object connect and bind must have been done
* Modify an LDAP entry (to use if dn != olddn)
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
@ -674,7 +729,7 @@ class Ldap
* @param string $olddn Old DN entry key (before update)
* @param string $newrdn New RDN entry key (uid=qqq) (for ldap_rename)
* @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb) (for ldap_rename)
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function update($dn, $info, $user, $olddn, $newrdn = '', $newparent = '')
{
@ -720,11 +775,11 @@ class Ldap
/**
* Delete a LDAP entry
* Ldap object connect and bind must have been done
* Delete an LDAP entry
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function delete($dn)
{
@ -753,7 +808,7 @@ class Ldap
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Build a LDAP message
* Build an LDAP message
*
* @param string $dn DN entry key
* @param array $info Attributes array
@ -790,29 +845,32 @@ class Ldap
}
/**
* Dump a LDAP message to ldapinput.in file
* Dump an LDAP message to ldapinput.in file
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function dump($dn, $info)
{
global $conf;
$ldapDirTemp = $conf->ldap->dir_temp;
// Create content
$content = $this->dump_content($dn, $info);
//Create file
$result = dol_mkdir($conf->ldap->dir_temp);
$outputfile = $conf->ldap->dir_temp.'/ldapinput.in';
$fp = fopen($outputfile, "w");
if ($fp) {
fputs($fp, $content);
fclose($fp);
dolChmod($outputfile);
return 1;
//Create directory & file
$result = dol_mkdir($ldapDirTemp);
if ($result != 0) {
$outputfile = $ldapDirTemp.'/ldapinput.in';
$fp = fopen($outputfile, "w");
if ($fp) {
fputs($fp, $content);
fclose($fp);
dolChmod($outputfile);
return 1;
} else {
return -1;
}
} else {
return -1;
}
@ -821,10 +879,10 @@ class Ldap
/**
* Ping a server before ldap_connect for avoid waiting
*
* @param string $host Server host or address
* @param int $port Server port (default 389)
* @param int $timeout Timeout in second (default 1s)
* @return boolean true or false
* @param string $host Server host or address
* @param int $port Server port (default 389)
* @param int $timeout Timeout in second (default 1s)
* @return boolean true or false
*/
public function serverPing($host, $port = 389, $timeout = 1)
{
@ -865,13 +923,13 @@ class Ldap
// Attribute methods -----------------------------------------------------
/**
* Add a LDAP attribute in entry
* Ldap object connect and bind must have been done
* Add an LDAP attribute in entry
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param User $user Object user that create
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function addAttribute($dn, $info, $user)
{
@ -911,13 +969,13 @@ class Ldap
}
/**
* Update a LDAP attribute in entry
* Ldap object connect and bind must have been done
* Update an LDAP attribute in entry
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param User $user Object user that create
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function updateAttribute($dn, $info, $user)
{
@ -957,13 +1015,13 @@ class Ldap
}
/**
* Delete a LDAP attribute in entry
* Ldap object connect and bind must have been done
* Delete an LDAP attribute in entry
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param User $user Object user that create
* @return int Return integer <0 if KO, >0 if OK
* @return int if KO: <0 || if OK: >0
*/
public function deleteAttribute($dn, $info, $user)
{
@ -1007,7 +1065,7 @@ class Ldap
*
* @param string $dn DN entry key
* @param string $filter Filter
* @return int|array Return integer <0 or false if KO, array if OK
* @return int|array if KO: <=0 || if OK: array
*/
public function getAttribute($dn, $filter)
{
@ -1046,9 +1104,9 @@ class Ldap
/**
* Returns an array containing values for an attribute and for first record matching filterrecord
*
* @param string $filterrecord Record
* @param string $attribute Attributes
* @return array|boolean
* @param string $filterrecord Record
* @param string $attribute Attributes
* @return array|boolean
*/
public function getAttributeValues($filterrecord, $attribute)
{
@ -1082,16 +1140,16 @@ class Ldap
}
/**
* Returns an array containing a details or list of LDAP record(s).
* ldapsearch -LLLx -hlocalhost -Dcn=admin,dc=parinux,dc=org -w password -b "ou=adherents,ou=people,dc=parinux,dc=org" userPassword
* Returns an array containing a details or list of LDAP record(s).
* ldapsearch -LLLx -hlocalhost -Dcn=admin,dc=parinux,dc=org -w password -b "ou=adherents,ou=people,dc=parinux,dc=org" userPassword
*
* @param string $search Value of field to search, '*' for all. Not used if $activefilter is set.
* @param string $userDn DN (Ex: ou=adherents,ou=people,dc=parinux,dc=org)
* @param string $useridentifier Name of key field (Ex: uid).
* @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword)
* @param array $attributeArray Array of fields required. Note this array must also contain field $useridentifier (Ex: sn,userPassword)
* @param int $activefilter '1' or 'user'=use field this->filter as filter instead of parameter $search, 'group'=use field this->filtergroup as filter, 'member'=use field this->filtermember as filter
* @param array $attributeAsArray Array of fields wanted as an array not a string
* @return array|int Array of [id_record][ldap_field]=value
* @return array|int if KO: <0 || if OK: array of [id_record][ldap_field]=value
*/
public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array())
{
@ -1179,7 +1237,7 @@ class Ldap
}
/**
* Converts a little-endian hex-number to one, that 'hexdec' can convert
* Converts a little-endian hex-number to one, that 'hexdec' can convert
* Required by Active Directory
*
* @param string $hex Hex value
@ -1196,11 +1254,11 @@ class Ldap
/**
* Recupere le SID de l'utilisateur
* Gets LDAP user SID.
* Required by Active Directory
*
* @param string $ldapUser Login de l'utilisateur
* @return string Sid
* @param string $ldapUser User login
* @return int|string if SID OK: SID string, if KO: -1
*/
public function getObjectSid($ldapUser)
{
@ -1241,13 +1299,13 @@ class Ldap
return $SIDText;
} else {
$this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
return '?';
return -1;
}
}
/**
* Returns the textual SID
* Indispensable pour Active Directory
* Required by Active Directory
*
* @param string $binsid Binary SID
* @return string Textual SID
@ -1267,15 +1325,17 @@ class Ldap
/**
* Fonction de recherche avec filtre
* this->connection doit etre defini donc la methode bind ou bindauth doit avoir deja ete appelee
* Ne pas utiliser pour recherche d'une liste donnee de proprietes
* car conflict majuscule-minuscule. A n'utiliser que pour les pages
* 'Fiche LDAP' qui affiche champ lisibles par default.
* Search method with filter
* this->connection must be defined. The bind or bindauth methods must already have been called.
* Do not use for search of a given properties list because of upper-lower case conflict.
* Only use for pages.
* 'Fiche LDAP' shows readable fields by default.
* @see bind
* @see bindauth
*
* @param string $checkDn DN de recherche (Ex: ou=users,cn=my-domain,cn=com)
* @param string $filter Search filter (ex: (sn=nom_personne) )
* @return array|int Array with answers (key lowercased - value)
* @param string $checkDn Search DN (Ex: ou=users,cn=my-domain,cn=com)
* @param string $filter Search filter (ex: (sn=name_person) )
* @return array|int Array with answers (lowercase key - value)
*/
public function search($checkDn, $filter)
{
@ -1303,12 +1363,12 @@ class Ldap
/**
* Load all attribute of a LDAP user
* Load all attributes of an LDAP user
*
* @param User|string $user Not used.
* @param string $filter Filter for search. Must start with &.
* Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com)
* @return int >0 if OK, <0 if KO
* @param User|string $user Not used.
* @param string $filter Filter for search. Must start with &.
* Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com)
* @return int if KO: <0 || if OK: > 0
*/
public function fetch($user, $filter)
{
@ -1363,14 +1423,14 @@ class Ldap
$this->uacf = $this->parseUACF($this->convToOutputCharset($result[0]["useraccountcontrol"][0], $this->ldapcharset));
if (isset($result[0]["pwdlastset"][0])) { // If expiration on password exists
$this->pwdlastset = ($result[0]["pwdlastset"][0] != 0) ? $this->convert_time($this->convToOutputCharset($result[0]["pwdlastset"][0], $this->ldapcharset)) : 0;
$this->pwdlastset = ($result[0]["pwdlastset"][0] != 0) ? $this->convertTime($this->convToOutputCharset($result[0]["pwdlastset"][0], $this->ldapcharset)) : 0;
} else {
$this->pwdlastset = -1;
}
if (!$this->name && !$this->login) {
$this->pwdlastset = -1;
}
$this->badpwdtime = $this->convert_time($this->convToOutputCharset($result[0]["badpasswordtime"][0], $this->ldapcharset));
$this->badpwdtime = $this->convertTime($this->convToOutputCharset($result[0]["badpasswordtime"][0], $this->ldapcharset));
// FQDN domain
$domain = str_replace('dc=', '', $this->domain);
@ -1390,7 +1450,7 @@ class Ldap
// helper methods
/**
* Returns the correct user identifier to use, based on the ldap server type
* Returns the correct user identifier to use, based on the LDAP server type
*
* @return string Login
*/
@ -1404,7 +1464,7 @@ class Ldap
}
/**
* UserAccountControl Flgs to more human understandable form...
* UserAccountControl Flags to more human understandable form...
*
* @param string $uacf UACF
* @return array
@ -1482,16 +1542,14 @@ class Ldap
return $retval;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Convertit le temps ActiveDirectory en Unix timestamp
* Converts ActiveDirectory time to Unix timestamp
*
* @param string $value AD time to convert
* @return integer Unix timestamp
*/
public function convert_time($value)
public function convertTime($value)
{
// phpcs:enable
$dateLargeInt = $value; // nano secondes depuis 1601 !!!!
$secsAfterADEpoch = $dateLargeInt / (10000000); // secondes depuis le 1 jan 1601
$ADToUnixConvertor = ((1970 - 1601) * 365.242190) * 86400; // UNIX start date - AD start date * jours * secondes
@ -1503,9 +1561,9 @@ class Ldap
/**
* Convert a string into output/memory charset
*
* @param string $str String to convert
* @param string $str String to convert
* @param string $pagecodefrom Page code of src string
* @return string Converted string
* @return string Converted string
*/
private function convToOutputCharset($str, $pagecodefrom = 'UTF-8')
{
@ -1522,9 +1580,9 @@ class Ldap
/**
* Convert a string from output/memory charset
*
* @param string $str String to convert
* @param string $str String to convert
* @param string $pagecodeto Page code for result string
* @return string Converted string
* @return string Converted string
*/
public function convFromOutputCharset($str, $pagecodeto = 'UTF-8')
{
@ -1547,7 +1605,6 @@ class Ldap
*/
public function getNextGroupGid($keygroup = 'LDAP_KEY_GROUPS')
{
global $conf;
if (empty($keygroup)) {
$keygroup = 'LDAP_KEY_GROUPS';

View file

@ -1339,17 +1339,17 @@ jQuery(document).ready(function() {
});
<?php
if (!getDolGlobalString('MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined('DISABLE_SELECT2_FOCUS_PROTECTION')) {
?>
/*
* Hacky fix for a bug in select2 with jQuery 3.6.0's new nested-focus "protection"
* Hacky fix for a bug in select2 with jQuery 3.6.4's new nested-focus "protection"
* This fix needs to click a second time when clicking into a combo with ajax (see Test4d and Test5a in test_forms.php
* see: https://github.com/select2/select2/issues/5993
* see: https://github.com/jquery/jquery/issues/4382
*
* TODO: Recheck with the select2 GH issue and remove once this is fixed on their side
*/
<?php
if (!getDolGlobalString('MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined('DISABLE_SELECT2_FOCUS_PROTECTION')) {
?>
$(document).on('select2:open', (e) => {
console.log("Execute the focus (click on combo or use space when on component");
const target = $(e.target);

View file

@ -6724,7 +6724,7 @@ function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournpric
$found = 1;
}
} else {
// TODO Read default product vat according to product and another countrycode.
// TODO Read default product vat according to product and an other countrycode.
// Vat for couple anothercountrycode/product is data that is not managed and store yet, so we will fallback on next rule.
}
}
@ -11878,6 +11878,9 @@ function getElementProperties($element_type)
$module = 'societe';
$subelement = 'contact';
$table_element = 'socpeople';
} elseif ($element_type == 'inventory') {
$module = 'product';
$classpath = 'product/inventory/class';
} elseif ($element_type == 'stock') {
$classpath = 'product/stock/class';
$classfile = 'entrepot';

View file

@ -30,10 +30,10 @@ insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, left
-- Sub-Menus
-- Home - Dashboard
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'MyDashboard', 0, '', '', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'MyDashboard', 0, '', '', '', 2, 0, __ENTITY__, '<span class="fas fa-chart-bar fa-fw paddingright pictofixedwidth"></span>');
-- Home - Setup
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$user->admin' , __HANDLER__, 'left', 100__+MAX_llx_menu__, 'home', 'setup', 1__+MAX_llx_menu__, '/admin/index.php?mainmenu=home&amp;leftmenu=setup', 'Setup', 0, 'admin', '', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', '$user->admin' , __HANDLER__, 'left', 100__+MAX_llx_menu__, 'home', 'setup', 1__+MAX_llx_menu__, '/admin/index.php?mainmenu=home&amp;leftmenu=setup', 'Setup', 0, 'admin', '', '', 2, 1, __ENTITY__, '<span class="fas fa-tools fa-fw paddingright pictofixedwidth" style=""></span>');
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 101__+MAX_llx_menu__, 'home', '' , 100__+MAX_llx_menu__, '/admin/company.php?mainmenu=home&amp;leftmenu=setup', 'MenuCompanySetup', 1, 'admin', '', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 102__+MAX_llx_menu__, 'home', '' , 100__+MAX_llx_menu__, '/admin/ihm.php?mainmenu=home&amp;leftmenu=setup', 'GUISetup', 1, 'admin', '', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 114__+MAX_llx_menu__, 'home', '' , 100__+MAX_llx_menu__, '/admin/translation.php?mainmenu=home&amp;leftmenu=setup', 'Translation', 1, 'admin', '', '', 2, 4, __ENTITY__);
@ -52,7 +52,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 112__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/const.php?mainmenu=home&amp;leftmenu=setup', 'OtherSetup', 1, 'admin', '', '', 2, 14, __ENTITY__);
-- Home - Admin tools
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$user->admin', __HANDLER__, 'left', 300__+MAX_llx_menu__, 'home', 'admintools', 1__+MAX_llx_menu__, '/admin/tools/index.php?mainmenu=home&amp;leftmenu=admintools', 'AdminTools', 0, 'admin', '', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', '$user->admin', __HANDLER__, 'left', 300__+MAX_llx_menu__, 'home', 'admintools', 1__+MAX_llx_menu__, '/admin/tools/index.php?mainmenu=home&amp;leftmenu=admintools', 'AdminTools', 0, 'admin', '', '', 2, 2, __ENTITY__, '<span class="fas fa-server fa-fw paddingright pictofixedwidth"></span>');
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 201__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/system/dolibarr.php?mainmenu=home&amp;leftmenu=admintools', 'InfoDolibarr', 1, 'admin', '', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 202__+MAX_llx_menu__, 'home', '', 201__+MAX_llx_menu__, '/admin/system/modules.php?mainmenu=home&amp;leftmenu=admintools', 'Modules', 2, 'admin', '', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 203__+MAX_llx_menu__, 'home', '', 201__+MAX_llx_menu__, '/admin/triggers.php?mainmenu=home&amp;leftmenu=admintools', 'Triggers', 2, 'admin', '', '', 2, 3, __ENTITY__);
@ -75,7 +75,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 320__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/product/admin/product_tools.php?mainmenu=home&amp;leftmenu=admintools', 'ProductVatMassChange', 1, 'products', '', '', 2, 15, __ENTITY__);
-- Home - Menu users and groups
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?mainmenu=home&amp;leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?mainmenu=home&amp;leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 4, __ENTITY__, '<span class="fas fa-user infobox-adherent fa-fw paddingright pictofixedwidth"></span>');
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/list.php?mainmenu=home&amp;leftmenu=users', 'Users', 1, 'users', '$user->hasRight("user","user","lire") || $user->admin', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?mainmenu=home&amp;leftmenu=users&amp;action=create', 'NewUser', 2, 'users', '($user->hasRight("user","user","creer") || $user->admin) && !(isModEnabled("multicompany") && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__);
@ -87,7 +87,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 408__+MAX_llx_menu__, 'home', '', 407__+MAX_llx_menu__, '/user/group/card.php?mainmenu=home&amp;leftmenu=users&amp;action=create', 'NewGroup', 2, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->hasRight("user","user","creer")) || $user->admin) && !(isModEnabled("multicompany") && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__);
-- Third parties
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?mainmenu=companies&amp;leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->hasRight("societe","lire")', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?mainmenu=companies&amp;leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->hasRight("societe","lire")', '', 2, 0, __ENTITY__, '<span class="fas fa-building fa-fw pictofixedwidth" style="color: #6c6aa8;"></span>');
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&amp;action=create', 'MenuNewThirdParty', 1, 'companies', '$user->hasRight("societe","creer")', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 502__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&amp;leftmenu=thirdparties', 'List', 1, 'companies', '$user->hasRight("societe","lire")', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&amp;type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->hasRight("societe","lire") && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__);
@ -98,7 +98,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 510__+MAX_llx_menu__, 'companies', '', 509__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&amp;leftmenu=customers&amp;action=create&amp;type=c', 'MenuNewCustomer', 2, 'companies', '$user->hasRight("societe","creer")', '', 2, 0, __ENTITY__);
-- Third parties - Contacts
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 600__+MAX_llx_menu__, 'companies', 'contacts', 2__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&amp;leftmenu=contacts', 'ContactsAddresses', 0, 'companies', '$user->hasRight("societe","lire")', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 600__+MAX_llx_menu__, 'companies', 'contacts', 2__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&amp;leftmenu=contacts', 'ContactsAddresses', 0, 'companies', '$user->hasRight("societe","lire")', '', 2, 1, __ENTITY__, '<span class="fas fa-address-book fa-fw paddingright pictofixedwidth" style="color: #6c6aa8;"></span>');
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 601__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/card.php?mainmenu=companies&amp;leftmenu=contacts&amp;action=create', 'NewContactAddress', 1, 'companies', '$user->hasRight("societe","creer")', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 602__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&amp;leftmenu=contacts', 'List', 1, 'companies', '$user->hasRight("societe","lire")', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 604__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&amp;leftmenu=contacts&amp;type=p', 'ThirdPartyProspects', 2, 'companies', '$user->hasRight("societe","contact","lire")', '', 2, 1, __ENTITY__);

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
*
* 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
@ -651,11 +652,11 @@ class ExportExcel2007 extends ModeleExports
/**
* Set a value cell and merging it by giving a starting cell and a length
*
* @param string $val Cell value
* @param string $startCell Starting cell
* @param int $length Length
* @param int $offset Starting offset
* @return string Coordinate or -1 if KO
* @param string $val Cell value
* @param string $startCell Starting cell
* @param int $length Length
* @param int $offset Starting offset
* @return int|string Coordinate or if KO: -1
*/
public function setMergeCellValueByLength($val, $startCell, $length, $offset = 0)
{

View file

@ -0,0 +1,570 @@
<?php
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019-2022 Frédéric France <frederic.france@netlogic.fr>
*
* 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/>.
*/
/**
* \defgroup ai Module Ai
* \brief Ai module descriptor.
*
* \file htdocs/ai/core/modules/modAi.class.php
* \ingroup ai
* \brief Description and activation file for module Ai
*/
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
* Description and activation class for module Ai
*/
class modAi extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
global $langs, $conf;
$this->db = $db;
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 4560;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'ai';
// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
// It is used to group modules by family in module setup page
$this->family = "mailings";
// Module position in the family on 2 digits ('01', '10', '20', ...)
$this->module_position = '50';
// Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
// Module label (no space allowed), used if translation string 'ModuleAiName' not found (Ai is name of module).
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleAiDesc' not found (Ai is name of module).
$this->description = "AiDescription";
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "AiDescription";
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = 'development';
// Key used in llx_const table to save module status enabled/disabled (where BOOKCAL is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
// To use a supported fa-xxx css style of font awesome, use this->picto='xxx'
$this->picto = 'fa-microchip"';
// Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
$this->module_parts = array(
// Set this to 1 if module has its own trigger directory (core/triggers)
'triggers' => 0,
// Set this to 1 if module has its own login method file (core/login)
'login' => 0,
// Set this to 1 if module has its own substitution function file (core/substitutions)
'substitutions' => 0,
// Set this to 1 if module has its own menus handler directory (core/menus)
'menus' => 0,
// Set this to 1 if module overwrite template dir (core/tpl)
'tpl' => 0,
// Set this to 1 if module has its own barcode directory (core/modules/barcode)
'barcode' => 0,
// Set this to 1 if module has its own models directory (core/modules/xxx)
'models' => 0,
// Set this to 1 if module has its own printing directory (core/modules/printing)
'printing' => 0,
// Set this to 1 if module has its own theme directory (theme)
'theme' => 0,
// Set this to relative path of css file if module has its own css file
'css' => array(
// '/ai/css/ai.css.php',
),
// Set this to relative path of js file if module must load a js on all pages
'js' => array(
// '/ai/js/ai.js.php',
),
// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
'hooks' => array(
// 'data' => array(
// 'hookcontext1',
// 'hookcontext2',
// ),
// 'entity' => '0',
),
// Set this to 1 if features of module are opened to external users
'moduleforexternal' => 0,
);
// Data directories to create when module is enabled.
// Example: this->dirs = array("/ai/temp","/ai/subdir");
$this->dirs = array("/ai/temp");
// Config pages. Put here list of php page, stored into ai/admin directory, to use to setup module.
$this->config_page_url = array("setup.php@ai");
// Dependencies
// A condition to hide module
$this->hidden = false;
// List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))
$this->depends = array();
$this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
// The language file dedicated to your module
$this->langfiles = array("ai");
// Prerequisites
$this->phpmin = array(7, 0); // Minimum version of PHP required by module
// Messages at activation
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','MX'='textmx'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','MX'='textmx'...)
//$this->automatic_activation = array('FR'=>'AiWasAutomaticallyActivatedBecauseOfYourCountryChoice');
//$this->always_enabled = true; // If true, can't be disabled
// Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(1 => array('BOOKCAL_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
// 2 => array('BOOKCAL_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
// );
$this->const = array();
// Some keys to add into the overwriting translation tables
/*$this->overwrite_translation = array(
'en_US:ParentCompany'=>'Parent company or reseller',
'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
)*/
if (!isset($conf->ai) || !isset($conf->ai->enabled)) {
$conf->ai = new stdClass();
$conf->ai->enabled = 0;
}
// Array to add new pages in new tabs
$this->tabs = array();
// Example:
// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@ai:$user->rights->ai->read:/ai/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@ai:$user->rights->othermodule->read:/ai/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
//
// Where objecttype can be
// 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
// 'contact' to add a tab in contact view
// 'contract' to add a tab in contract view
// 'group' to add a tab in group view
// 'intervention' to add a tab in intervention view
// 'invoice' to add a tab in customer invoice view
// 'invoice_supplier' to add a tab in supplier invoice view
// 'member' to add a tab in foundation member view
// 'opensurveypoll' to add a tab in opensurvey poll view
// 'order' to add a tab in customer order view
// 'order_supplier' to add a tab in supplier order view
// 'payment' to add a tab in payment view
// 'payment_supplier' to add a tab in supplier payment view
// 'product' to add a tab in product view
// 'propal' to add a tab in propal view
// 'project' to add a tab in project view
// 'stock' to add a tab in stock view
// 'thirdparty' to add a tab in third party view
// 'user' to add a tab in user view
// Dictionaries
$this->dictionaries = array();
/* Example:
$this->dictionaries=array(
'langs'=>'ai@ai',
// List of tables we want to see into dictonnary editor
'tabname'=>array("table1", "table2", "table3"),
// Label of tables
'tablib'=>array("Table1", "Table2", "Table3"),
// Request to select fields
'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),
// Sort order
'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"),
// List of fields (result of select to show dictionary)
'tabfield'=>array("code,label", "code,label", "code,label"),
// List of fields (list of fields to edit a record)
'tabfieldvalue'=>array("code,label", "code,label", "code,label"),
// List of fields (list of fields for insert)
'tabfieldinsert'=>array("code,label", "code,label", "code,label"),
// Name of columns with primary key (try to always name it 'rowid')
'tabrowid'=>array("rowid", "rowid", "rowid"),
// Condition to show each dictionary
'tabcond'=>array($conf->ai->enabled, $conf->ai->enabled, $conf->ai->enabled)
// Help tooltip for each fields of the dictionary
'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp')))
);
*/
// Boxes/Widgets
// Add here list of php file(s) stored in ai/core/boxes that contains a class to show a widget.
$this->boxes = array(
// 0 => array(
// 'file' => 'aiwidget1.php@ai',
// 'note' => 'Widget provided by Ai',
// 'enabledbydefaulton' => 'Home',
// ),
// ...
);
// Cronjobs (List of cron jobs entries to add when module is enabled)
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
$this->cronjobs = array(
// 0 => array(
// 'label' => 'MyJob label',
// 'jobtype' => 'method',
// 'class' => '/ai/class/availabilities.class.php',
// 'objectname' => 'Availabilities',
// 'method' => 'doScheduledJob',
// 'parameters' => '',
// 'comment' => 'Comment',
// 'frequency' => 2,
// 'unitfrequency' => 3600,
// 'status' => 0,
// 'test' => '$conf->ai->enabled',
// 'priority' => 50,
// ),
);
// Example: $this->cronjobs=array(
// 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->ai->enabled', 'priority'=>50),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->ai->enabled', 'priority'=>50)
// );
// Permissions provided by this module
$this->rights = array();
$r = 0;
// Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */
$this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 1);
$this->rights[$r][1] = 'Read objects of Ai';
$this->rights[$r][4] = 'availabilities';
$this->rights[$r][5] = 'read';
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 2);
$this->rights[$r][1] = 'Create/Update objects of Ai';
$this->rights[$r][4] = 'availabilities';
$this->rights[$r][5] = 'write';
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 3);
$this->rights[$r][1] = 'Delete objects of Ai';
$this->rights[$r][4] = 'availabilities';
$this->rights[$r][5] = 'delete';
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 1);
$this->rights[$r][1] = 'Read Calendar object of Ai';
$this->rights[$r][4] = 'calendar';
$this->rights[$r][5] = 'read';
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 2);
$this->rights[$r][1] = 'Create/Update Calendar object of Ai';
$this->rights[$r][4] = 'calendar';
$this->rights[$r][5] = 'write';
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 3);
$this->rights[$r][1] = 'Delete Calendar object of Ai';
$this->rights[$r][4] = 'calendar';
$this->rights[$r][5] = 'delete';
$r++;
/* END MODULEBUILDER PERMISSIONS */
// Main menu entries to add
$this->menu = array();
$r = 0;
// Add here entries to declare new menus
/* BEGIN MODULEBUILDER TOPMENU */
/*$this->menu[$r++] = array(
'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'top', // This is a Top menu entry
'titre'=>'ModuleAiName',
'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth valignmiddle"'),
'mainmenu'=>'ai',
'leftmenu'=>'',
'url'=>'/ai/aiindex.php',
'langs'=>'ai', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000 + $r,
'enabled'=>'$conf->ai->enabled', // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled.
'perms'=>'$user->rights->ai->availabilities->read', // Use 'perms'=>'$user->rights->ai->availabilities->read' if you want your menu with a permission rules
'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
);*/
/* END MODULEBUILDER TOPMENU */
/* BEGIN MODULEBUILDER LEFTMENU CALENDAR */
$this->menu[$r++] = array(
'fk_menu'=>'fk_mainmenu=agenda',
'type'=>'left',
'titre'=> 'MenuBookcalIndex',
'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'),
'mainmenu'=>'agenda',
'leftmenu'=> 'ai',
'url'=> '/ai/aiindex.php',
'langs'=> 'ai',
'position'=> 1100+$r,
'enabled'=> '1',
'perms'=> '$user->rights->ai->read',
'user'=> 0
);
$this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=ai',
// This is a Left menu entry
'type'=>'left',
'titre'=>'Calendar',
'mainmenu'=>'agenda',
'leftmenu'=>'ai_list',
'url'=>'/ai/list.php',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'ai',
'position'=>1100+$r,
// Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'$conf->ai->enabled',
// Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules
'perms'=>'$user->rights->ai->read',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2,
);
$this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=ai_list',
// This is a Left menu entry
'type'=>'left',
'titre'=>'NewKey',
'mainmenu'=>'agenda',
'leftmenu'=>'ai_new_key',
'url'=>'/ai/ai_card.php?action=create',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'ai',
'position'=>1100+$r,
// Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'$conf->ai->enabled',
// Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules
'perms'=>'$user->rights->ai->read',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2
);
/* END MODULEBUILDER LEFTMENU CALENDAR */
/* BEGIN MODULEBUILDER LEFTMENU AVAILABILITIES
$this->menu[$r++]=array(
'fk_menu'=>'fk_mainmenu=ai', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
'titre'=>'Availabilities',
'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'),
'mainmenu'=>'ai',
'leftmenu'=>'availabilities',
'url'=>'/ai/aiindex.php',
'langs'=>'ai@ai', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r,
'enabled'=>'$conf->ai->enabled', // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled.
'perms'=>'$user->rights->ai->availabilities->read', // Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
);
$this->menu[$r++]=array(
'fk_menu'=>'fk_mainmenu=ai,fk_leftmenu=availabilities', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
'titre'=>'List_Availabilities',
'mainmenu'=>'ai',
'leftmenu'=>'ai_availabilities_list',
'url'=>'/ai/availabilities_list.php',
'langs'=>'ai@ai', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r,
'enabled'=>'$conf->ai->enabled', // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->ai->availabilities->read', // Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
);
$this->menu[$r++]=array(
'fk_menu'=>'fk_mainmenu=ai,fk_leftmenu=availabilities', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
'titre'=>'New_Availabilities',
'mainmenu'=>'ai',
'leftmenu'=>'ai_availabilities_new',
'url'=>'/ai/availabilities_card.php?action=create',
'langs'=>'ai@ai', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r,
'enabled'=>'$conf->ai->enabled', // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->ai->availabilities->write', // Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
);
*/
/* END MODULEBUILDER LEFTMENU AVAILABILITIES */
// Exports profiles provided by this module
$r = 1;
/* BEGIN MODULEBUILDER EXPORT AVAILABILITIES */
/*
$langs->load("agenda");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='AvailabilitiesLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='availabilities@ai';
// Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
$keyforclass = 'Availabilities'; $keyforclassfile='/ai/class/availabilities.class.php'; $keyforelement='availabilities@ai';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
//$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
//unset($this->export_fields_array[$r]['t.fieldtoremove']);
//$keyforclass = 'AvailabilitiesLine'; $keyforclassfile='/ai/class/availabilities.class.php'; $keyforelement='availabilitiesline@ai'; $keyforalias='tl';
//include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='availabilities'; $keyforaliasextra='extra'; $keyforelement='availabilities@ai';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$keyforselect='availabilitiesline'; $keyforaliasextra='extraline'; $keyforelement='availabilitiesline@ai';
//include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r] = array('availabilitiesline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
//$this->export_special_array[$r] = array('t.field'=>'...');
//$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
//$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'availabilities as t';
//$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'availabilities_line as tl ON tl.fk_availabilities = t.rowid';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('availabilities').')';
$r++; */
/* END MODULEBUILDER EXPORT AVAILABILITIES */
// Imports profiles provided by this module
$r = 1;
/* BEGIN MODULEBUILDER IMPORT AVAILABILITIES */
/*
$langs->load("agenda");
$this->import_code[$r]=$this->rights_class.'_'.$r;
$this->import_label[$r]='AvailabilitiesLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->import_icon[$r]='availabilities@ai';
$this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX.'ai_availabilities', 'extra' => MAIN_DB_PREFIX.'ai_availabilities_extrafields');
$this->import_tables_creator_array[$r] = array('t' => 'fk_user_author'); // Fields to store import user id
$import_sample = array();
$keyforclass = 'Availabilities'; $keyforclassfile='/ai/class/availabilities.class.php'; $keyforelement='availabilities@ai';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinimport.inc.php';
$import_extrafield_sample = array();
$keyforselect='availabilities'; $keyforaliasextra='extra'; $keyforelement='availabilities@ai';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'ai_availabilities');
$this->import_regex_array[$r] = array();
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('t.ref' => 'Ref');
$this->import_convertvalue_array[$r] = array(
't.ref' => array(
'rule'=>'getrefifauto',
'class'=>(empty($conf->global->BOOKCAL_AVAILABILITIES_ADDON) ? 'mod_availabilities_standard' : $conf->global->BOOKCAL_AVAILABILITIES_ADDON),
'path'=>"/core/modules/commande/".(empty($conf->global->BOOKCAL_AVAILABILITIES_ADDON) ? 'mod_availabilities_standard' : $conf->global->BOOKCAL_AVAILABILITIES_ADDON).'.php'
'classobject'=>'Availabilities',
'pathobject'=>'/ai/class/availabilities.class.php',
),
't.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
't.fk_user_valid' => array('rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user'),
't.fk_mode_reglement' => array('rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment'),
);
$r++; */
/* END MODULEBUILDER IMPORT AVAILABILITIES */
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function init($options = '')
{
global $conf, $langs;
// $result = $this->_load_tables('/install/mysql/', 'ai');
// if ($result < 0) {
// return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
// }
// Create extrafields during init
//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
//$extrafields = new ExtraFields($this->db);
//$result1=$extrafields->addExtraField('ai_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled');
//$result2=$extrafields->addExtraField('ai_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled');
//$result3=$extrafields->addExtraField('ai_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled');
//$result4=$extrafields->addExtraField('ai_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled');
//$result5=$extrafields->addExtraField('ai_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled');
// Permissions
$this->remove($options);
$sql = array();
// Document templates
$moduledir = dol_sanitizeFileName('ai');
$myTmpObjects = array();
$myTmpObjects['Availabilities'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
// foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// if ($myTmpObjectKey == 'Availabilities') {
// continue;
// }
// if ($myTmpObjectArray['includerefgeneration']) {
// $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_availabilitiess.odt';
// $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir;
// $dest = $dirodt.'/template_availabilitiess.odt';
// if (file_exists($src) && !file_exists($dest)) {
// require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// dol_mkdir($dirodt);
// $result = dol_copy($src, $dest, 0, 0);
// if ($result < 0) {
// $langs->load("errors");
// $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
// return 0;
// }
// }
// $sql = array_merge($sql, array(
// "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
// "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")",
// "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
// "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")"
// ));
// }
// }
return $this->_init($sql, $options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function remove($options = '')
{
$sql = array();
return $this->_remove($sql, $options);
}
}

View file

@ -6,6 +6,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
*
* 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
@ -503,7 +504,7 @@ class modFacture extends DolibarrModules
's.code_compta_fournisseur'=>'SupplierAccountancyCode',
's.tva_intra'=>'VATIntra',
't.libelle'=>"ThirdPartyType", // 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus",
'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',
'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', 'f.fk_facture_source'=>'SourceInvoiceId',
'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT",
'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',
'none.rest'=>'Rest',
@ -546,7 +547,7 @@ class modFacture extends DolibarrModules
's.rowid'=>'Numeric', 's.nom'=>'Text', 'ps.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
't.libelle'=>"Text", // 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text",
'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.fk_mode_reglement'=>'Numeric',
'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.fk_facture_source'=>'Numeric', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.fk_mode_reglement'=>'Numeric',
'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text',
'none.rest'=>"NumericCompute",
'f.note_private'=>"Text", 'f.note_public'=>"Text",
@ -630,7 +631,7 @@ class modFacture extends DolibarrModules
's.phone'=>'Phone',
's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',
'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', 'f.fk_facture_source'=>'SourceInvoiceId',
'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT",
'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',
'none.rest'=>'Rest',
@ -655,7 +656,7 @@ class modFacture extends DolibarrModules
$this->export_TypeFields_array[$r] = array(
's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.fk_facture_source'=>'Numeric', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text',
'none.rest'=>'NumericCompute',
'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',

View file

@ -63,7 +63,7 @@ class modStockTransfer extends DolibarrModules
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "Advanced management of stock transfer orders with generation of stock transfer sheets";
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = 'dolibarr';
$this->version = 'experimental';
// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';

View file

@ -1602,7 +1602,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
),
'border-left' => true, // add left line separator
);
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$this->cols['unit']['status'] = true;
}

View file

@ -138,32 +138,32 @@ if ($action == 'presend') {
}
if ($object->element == 'salary' && getDolGlobalString('INVOICE_EMAIL_SENDER')) {
$formmail->frommail = getDolGlobalString('SINVOICE_EMAIL_SENDER');
$formmail->fromname = (getDolGlobalString('INVOICE_EMAIL_SENDER_NAME') ? $conf->global->INVOICE_EMAIL_SENDER_NAME : '');
$formmail->fromname = getDolGlobalString('INVOICE_EMAIL_SENDER_NAME', '');
$formmail->fromtype = 'special';
}
if ($object->element === 'facture' && getDolGlobalString('INVOICE_EMAIL_SENDER')) {
$formmail->frommail = getDolGlobalString('INVOICE_EMAIL_SENDER');
$formmail->fromname = (getDolGlobalString('INVOICE_EMAIL_SENDER_NAME') ? $conf->global->INVOICE_EMAIL_SENDER_NAME : '');
$formmail->fromname = getDolGlobalString('INVOICE_EMAIL_SENDER_NAME', '');
$formmail->fromtype = 'special';
}
if ($object->element === 'shipping' && getDolGlobalString('SHIPPING_EMAIL_SENDER')) {
$formmail->frommail = getDolGlobalString('SHIPPING_EMAIL_SENDER');
$formmail->fromname = (getDolGlobalString('SHIPPING_EMAIL_SENDER_NAME') ? $conf->global->SHIPPING_EMAIL_SENDER_NAME : '');
$formmail->fromname = getDolGlobalString('SHIPPING_EMAIL_SENDER_NAME', '');
$formmail->fromtype = 'special';
}
if ($object->element === 'commande' && getDolGlobalString('COMMANDE_EMAIL_SENDER')) {
$formmail->frommail = getDolGlobalString('COMMANDE_EMAIL_SENDER');
$formmail->fromname = (getDolGlobalString('COMMANDE_EMAIL_SENDER_NAME') ? $conf->global->COMMANDE_EMAIL_SENDER_NAME : '');
$formmail->fromname = getDolGlobalString('COMMANDE_EMAIL_SENDER_NAME', '');
$formmail->fromtype = 'special';
}
if ($object->element === 'order_supplier' && getDolGlobalString('ORDER_SUPPLIER_EMAIL_SENDER')) {
$formmail->frommail = getDolGlobalString('ORDER_SUPPLIER_EMAIL_SENDER');
$formmail->fromname = (getDolGlobalString('ORDER_SUPPLIER_EMAIL_SENDER_NAME') ? $conf->global->ORDER_SUPPLIER_EMAIL_SENDER_NAME : '');
$formmail->fromname = getDolGlobalString('ORDER_SUPPLIER_EMAIL_SENDER_NAME', '');
$formmail->fromtype = 'special';
}
if ($object->element === 'recruitmentcandidature') {
$formmail->frommail = (getDolGlobalString('RECRUITMENT_EMAIL_SENDER') ? $conf->global->RECRUITMENT_EMAIL_SENDER : $recruitermail);
$formmail->fromname = (getDolGlobalString('RECRUITMENT_EMAIL_SENDER_NAME') ? $conf->global->RECRUITMENT_EMAIL_SENDER_NAME : (!empty($recruitername) ? $recruitername : ''));
$formmail->frommail = getDolGlobalString('RECRUITMENT_EMAIL_SENDER', (!empty($recruitermail) ? $recruitermail : ''));
$formmail->fromname = getDolGlobalString('RECRUITMENT_EMAIL_SENDER_NAME', (!empty($recruitername) ? $recruitername : ''));
$formmail->fromtype = 'special';
}

View file

@ -874,6 +874,7 @@ if (empty($reshook)) {
}
$triggersendname = 'SHIPPING_SENTBYMAIL';
$paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO';
$mode = 'emailfromshipment';
$trackid = 'shi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';

View file

@ -2337,10 +2337,13 @@ class ExpenseReport extends CommonObject
*/
public function periode_existe($fuser, $date_debut, $date_fin)
{
global $conf;
// phpcs:enable
$sql = "SELECT rowid, date_debut, date_fin";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " WHERE fk_user_author = ".((int) $fuser->id);
$sql .= " WHERE entity = ".((int) $conf->entity); // not shared, only for the current entity
$sql .= " AND fk_user_author = ".((int) $fuser->id);
dol_syslog(get_class($this)."::periode_existe sql=".$sql);
$result = $this->db->query($sql);

View file

@ -1020,7 +1020,6 @@ if ($resql) {
exit;
}
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-supplier-order page-list');
$param = '';

View file

@ -203,3 +203,5 @@ ALTER TABLE llx_expensereport DROP INDEX idx_expensereport_fk_refuse, ADD INDEX
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (1,'66','Société publique locale');
ALTER TABLE llx_prelevement_lignes ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE llx_bom_bomline ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

View file

@ -159,6 +159,8 @@ ALTER TABLE llx_user_extrafields ADD UNIQUE INDEX uk_user_extrafields (fk_object
ALTER TABLE llx_usergroup_extrafields DROP INDEX idx_usergroup_extrafields;
ALTER TABLE llx_usergroup_extrafields ADD UNIQUE INDEX uk_usergroup_extrafields (fk_object);
ALTER TABLE llx_website ADD COLUMN name_template varchar(255) NULL;
UPDATE llx_categorie SET date_creation = tms, tms = tms WHERE date_creation IS NULL AND tms IS NOT NULL;
ALTER TABLE llx_product_price ADD COLUMN price_label varchar(255) AFTER fk_user_author;
@ -204,4 +206,3 @@ ALTER TABLE llx_c_tva ADD COLUMN type_vat smallint NOT NULL DEFAULT 0 AFTER fk_p
ALTER TABLE llx_categorie ADD COLUMN position integer DEFAULT 0 AFTER color;
ALTER TABLE llx_product DROP COLUMN onportal;

View file

@ -19,6 +19,7 @@ CREATE TABLE llx_bom_bomline(
fk_bom integer NOT NULL,
fk_product integer NOT NULL,
fk_bom_child integer NULL,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
description text,
import_key varchar(14),
qty double(24,8) NOT NULL,

View file

@ -41,5 +41,6 @@ CREATE TABLE llx_website
pageviews_month BIGINT UNSIGNED DEFAULT 0, -- increased by 1 at each page access, saved into pageviews_previous_month when on different month than lastaccess
pageviews_total BIGINT UNSIGNED DEFAULT 0, -- increased by 1 at each page access, no reset
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
import_key varchar(14) -- import key
import_key varchar(14), -- import key
name_template varchar(255) NULL --name of template imported
) ENGINE=innodb;

View file

@ -0,0 +1 @@
AI_KEY_API_CHATGPT= Key for IA api

View file

@ -354,6 +354,7 @@ HelpAbandonOther=This amount has been abandoned since it was an error (wrong cus
IdSocialContribution=Social/fiscal tax payment id
PaymentId=Payment id
PaymentRef=Payment ref.
SourceInvoiceId=Source invoice id
InvoiceId=Invoice id
InvoiceRef=Invoice ref.
InvoiceDateCreation=Invoice creation date

View file

@ -103,3 +103,4 @@ WebsitePagesCategoriesArea=Page-Container Categories
KnowledgemanagementsCategoriesArea=KM article Categories
UseOrOperatorForCategories=Use 'OR' operator for categories
AddObjectIntoCategory=Assign to the category
Position=Position

View file

@ -162,6 +162,7 @@ CalcModeVATDebt=Mode <b>%sVAT on commitment accounting%s</b>.
CalcModeVATEngagement=Mode <b>%sVAT on incomes-expenses%s</b>.
CalcModeDebt=Analysis of known recorded documents
CalcModeEngagement=Analysis of known recorded payments
CalcModePayment=Analysis of known recorded payments
CalcModeBookkeeping=Analysis of data journalized in Bookkeeping Ledger table.
CalcModeNoBookKeeping=Even if they are not yet accounted in Ledger
CalcModeLT1= Mode <b>%sRE on customer invoices - suppliers invoices%s</b>

View file

@ -0,0 +1 @@
AI_KEY_API_CHATGPT= Clé pour l'api IA

View file

@ -537,7 +537,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt(
// Array of action code where CSRFCHECK with token will be forced (so token must be provided on url request)
$sensitiveget = false;
if ((GETPOSTISSET('massaction') || GETPOST('action', 'aZ09')) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') >= 3) {
// All GET actions (except the listed exception) and mass actions are processed as sensitive.
// All GET actions (except the listed exception that are post actions) and mass actions are processed as sensitive.
if (GETPOSTISSET('massaction') || !in_array(GETPOST('action', 'aZ09'), array('create', 'createsite', 'createcard', 'edit', 'editvalidator', 'file_manager', 'presend', 'presend_addmessage', 'preview', 'specimen'))) { // We exclude some action that are legitimate
$sensitiveget = true;
}

View file

@ -204,7 +204,7 @@ if (empty($reshook)) {
$moline->fk_default_workstation = $tmpproduct->fk_default_workstation;
}
$moline->disable_stock_change = ($tmpproduct->type == Product::TYPE_SERVICE ? 1 : 0);
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$moline->fk_unit = $tmpproduct->fk_unit;
}
}
@ -840,7 +840,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Qty
print '<td class="right">'.$langs->trans("Qty").'</td>';
// Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="right">' . $langs->trans("Unit") . '</td>';
}
// Cost price
@ -911,7 +911,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</td>';
// Qty
print '<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td></td>';
}
// Cost price
@ -1029,7 +1029,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<input class="width40" name="qty_lineProduce" value="'. $line->qty.'">';
print '</td>';
// Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="right nowraponall">';
print measuringUnitString($line->fk_unit, '', '', 1);
print '</td>';
@ -1107,7 +1107,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print price2num($line->qty, 'MS');
print '</td>';
// Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="right nowraponall">';
print measuringUnitString($line->fk_unit, '', '', 1);
print '</td>';
@ -1323,7 +1323,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="right"><input type="text" class="width50 right" id="qtytoconsume-' . $line->id . '-' . $i . '" name="qty-' . $line->id . '-' . $i . '" value="' . $preselected . '" ' . $disable . '></td>';
// Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td></td>';
}
@ -1449,7 +1449,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Qty
print '<td class="right">'.$langs->trans("Qty").'</td>';
/// Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="right">'.$langs->trans("Unit").'</td>';
}
// Cost price
@ -1502,7 +1502,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Qty
print '<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
//Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td></td>';
}
// Cost price
@ -1569,7 +1569,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Qty
print '<td class="right">'.$line->qty.'</td>';
// Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="right">'.measuringUnitString($line->fk_unit, '', '', 1).'</td>';
}
// Cost price
@ -1668,7 +1668,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Qty
print '<td></td>';
// Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td></td>';
}
// Cost price
@ -1721,7 +1721,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Qty
print '<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.'-'.$i.'" name="qtytoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>';
//Unit
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="right"></td>';
}
// Cost

View file

@ -27,33 +27,9 @@
*/
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--;
$j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require '../../main.inc.php';
global $conf, $langs, $user;
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
@ -94,7 +70,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
$textobject = $langs->transnoentitiesnoconv("Inventory");
llxHeader('', $langs->trans("InventorySetup"), $help_url);
llxHeader('', $langs->trans("InventorySetup"));
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';

View file

@ -27,34 +27,7 @@
*/
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--;
$j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
@ -94,7 +67,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
$textobject = $langs->transnoentitiesnoconv("StockMovement");
llxHeader('', $langs->trans("StockSetup"), $help_url);
llxHeader('', $langs->trans("StockSetup"));
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';

View file

@ -477,14 +477,13 @@ class Productbatch extends CommonObject
}
if (getDolGlobalString('SHIPPING_DISPLAY_STOCK_ENTRY_DATE')) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock AS ps ON (ps.rowid = fk_product_stock)';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'stock_mouvement AS sm ON (sm.batch = t.batch AND ps.fk_entrepot=sm.fk_entrepot)';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'stock_mouvement AS sm ON (sm.batch = t.batch AND ps.fk_entrepot=sm.fk_entrepot AND sm.type_mouvement IN (0,3))';
}
$sql .= " WHERE fk_product_stock=".((int) $fk_product_stock);
if ($with_qty) {
$sql .= " AND t.qty <> 0";
}
if (getDolGlobalString('SHIPPING_DISPLAY_STOCK_ENTRY_DATE')) {
$sql .= ' AND sm.type_mouvement IN (0,3)';
$sql .= ' GROUP BY t.rowid, t.tms, t.fk_product_stock,t.sellby,t.eatby , t.batch,t.qty,t.import_key';
if ($fk_product > 0) {
$sql .= ', pl.rowid, pl.eatby, pl.sellby';

View file

@ -773,7 +773,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print getTitleFieldOfList($langs->trans('WarehouseSource'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone ');
print getTitleFieldOfList($langs->trans('WarehouseTarget'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone ');
print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone ');
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print getTitleFieldOfList($langs->trans('Unit'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone ');
}
print getTitleFieldOfList($langs->trans('AverageUnitPricePMPShort'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone ');
@ -846,7 +846,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="center">'.$line->qty.'</td>';
}
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="linecoluseunit nowrap left">';
$label = $productstatic->getLabelOfUnit('short');
if ($label !== '') {
@ -968,7 +968,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ? 'value="'.$qty.'"' : '').'></td>';
// PMP
print '<td></td>';
if ($conf->global->PRODUCT_USE_UNITS) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
// Unité
print '<td></td>';
}

View file

@ -173,6 +173,9 @@ if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a ded
}
$arrayfields['author'] = array('label' => $langs->trans("By"), 'checked' => 1);
$arrayfields['t.note'] = array('label' => $langs->trans("Note"), 'checked' => 1);
if (!getDolGlobalInt('PROJECT_HIDE_TASKS') && getDolGlobalInt('PROJECT_BILL_TIME_SPENT') && !$projectstatic->usage_bill_time ) {
$projectstatic->usage_bill_time=1;
}
if (isModEnabled('service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
$arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1);
}
@ -2282,7 +2285,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$userstatic->lastname = $task_time->lastname;
$userstatic->firstname = $task_time->firstname;
$userstatic->photo = $task_time->photo;
$userstatic->statut = $task_time->user_status;
$userstatic->status = $task_time->user_status;
print $userstatic->getNomUrl(-1);
}
print '</td>';
@ -2564,7 +2567,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$userstatic->lastname = $task_time->lastname;
$userstatic->firstname = $task_time->firstname;
$userstatic->photo = $task_time->photo;
$userstatic->statut = $task_time->user_status;
$userstatic->status = $task_time->user_status;
print $userstatic->getNomUrl(-1);
}
print '</td>';
@ -2720,7 +2723,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$userstatic->lastname = $task_time->lastname;
$userstatic->firstname = $task_time->firstname;
$userstatic->photo = $task_time->photo;
$userstatic->statut = $task_time->user_status;
$userstatic->status = $task_time->user_status;
print $userstatic->getNomUrl(-1);
}
print '</td>';

View file

@ -565,6 +565,18 @@ if ($ispaymentok) {
if ($paymentmethod == 'stripe') {
$accountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
}
//Get bank account for a specific paymentmedthod
$parameters = [
'paymentmethod' => $paymentmethod,
];
$reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action);
if ($reshook >= 0) {
if (isset($hookmanager->resArray['bankaccountid'])) {
dol_syslog('accountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment');
$accountid = $hookmanager->resArray['bankaccountid'];
}
}
if ($accountid < 0) {
$error++;
$errmsg = 'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
@ -903,6 +915,17 @@ if ($ispaymentok) {
$bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
}
//Get bank account for a specific paymentmedthod
$parameters = [
'paymentmethod' => $paymentmethod,
];
$reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action);
if ($reshook >= 0) {
if (isset($hookmanager->resArray['bankaccountid'])) {
dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment');
$bankaccountid = $hookmanager->resArray['bankaccountid'];
}
}
if ($bankaccountid > 0) {
$label = '(CustomerInvoicePayment)';
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
@ -1020,6 +1043,17 @@ if ($ispaymentok) {
$bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
}
//Get bank account for a specific paymentmedthod
$parameters = [
'paymentmethod' => $paymentmethod,
];
$reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action);
if ($reshook >= 0) {
if (isset($hookmanager->resArray['bankaccountid'])) {
dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment');
$bankaccountid = $hookmanager->resArray['bankaccountid'];
}
}
if ($bankaccountid > 0) {
$label = '(CustomerInvoicePayment)';
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
@ -1146,6 +1180,17 @@ if ($ispaymentok) {
$bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
}
//Get bank account for a specific paymentmedthod
$parameters = [
'paymentmethod' => $paymentmethod,
];
$reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action);
if ($reshook >= 0) {
if (isset($hookmanager->resArray['bankaccountid'])) {
dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment');
$bankaccountid = $hookmanager->resArray['bankaccountid'];
}
}
if ($bankaccountid > 0) {
$label = '(DonationPayment)';
$result = $paiement->addPaymentToBank($user, 'payment_donation', $label, $bankaccountid, '', '');
@ -1265,6 +1310,17 @@ if ($ispaymentok) {
$bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
}
//Get bank account for a specific paymentmedthod
$parameters = [
'paymentmethod' => $paymentmethod,
];
$reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action);
if ($reshook >= 0) {
if (isset($hookmanager->resArray['bankaccountid'])) {
dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment');
$bankaccountid = $hookmanager->resArray['bankaccountid'];
}
}
if ($bankaccountid > 0) {
$label = '(CustomerInvoicePayment)';
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
@ -1484,6 +1540,17 @@ if ($ispaymentok) {
$bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
}
//Get bank account for a specific paymentmedthod
$parameters = [
'paymentmethod' => $paymentmethod,
];
$reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action);
if ($reshook >= 0) {
if (isset($hookmanager->resArray['bankaccountid'])) {
dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment');
$bankaccountid = $hookmanager->resArray['bankaccountid'];
}
}
if ($bankaccountid > 0) {
$label = '(CustomerInvoicePayment)';
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
@ -1684,6 +1751,17 @@ if ($ispaymentok) {
$bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
}
//Get bank account for a specific paymentmedthod
$parameters = [
'paymentmethod' => $paymentmethod,
];
$reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action);
if ($reshook >= 0) {
if (isset($hookmanager->resArray['bankaccountid'])) {
dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment');
$bankaccountid = $hookmanager->resArray['bankaccountid'];
}
}
if ($bankaccountid > 0) {
$label = '(CustomerInvoicePayment)';
if ($object->type == Facture::TYPE_CREDIT_NOTE) {

View file

@ -733,6 +733,7 @@ if (empty($reshook)) {
$triggersendname = 'RECEPTION_SENTBYMAIL';
$paramname = 'id';
$mode = 'emailfromreception';
$autocopy = 'MAIN_MAIL_AUTOCOPY_RECEPTION_TO';
$trackid = 'rec'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}

View file

@ -22,35 +22,9 @@
*/
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--;
$j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require '../../main.inc.php';
global $langs, $user;
global $conf, $langs, $user;
// Libraries
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";

View file

@ -52,4 +52,4 @@ if (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha')) {
\Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']);
\Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version
\Stripe\Stripe::setApiVersion(!getDolGlobalString('STRIPE_FORCE_VERSION') ? "2022-11-15" : $conf->global->STRIPE_FORCE_VERSION); // force version API
\Stripe\Stripe::setApiVersion(getDolGlobalString('STRIPE_FORCE_VERSION', "2022-11-15")); // force version API

View file

@ -228,7 +228,7 @@ class SupplierProposal extends CommonObject
* @param int $socid Id third party
* @param int $supplier_proposalid Id supplier_proposal
*/
public function __construct($db, $socid = "", $supplier_proposalid = 0)
public function __construct($db, $socid = 0, $supplier_proposalid = 0)
{
global $conf, $langs;
@ -397,7 +397,7 @@ class SupplierProposal extends CommonObject
*
* @see add_product()
*/
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_options = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0)
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_options = [], $ref_supplier = '', $fk_unit = 0, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0)
{
global $mysoc, $conf, $langs;
@ -661,7 +661,7 @@ class SupplierProposal extends CommonObject
* @param double $txlocaltax1 Local tax 1 rate
* @param double $txlocaltax2 Local tax 2 rate
* @param string $desc Description
* @param double $price_base_type HT or TTC
* @param string $price_base_type HT or TTC
* @param int $info_bits Miscellaneous information
* @param int $special_code Special code (also used by externals modules!)
* @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines).
@ -676,7 +676,7 @@ class SupplierProposal extends CommonObject
* @param double $pu_ht_devise Unit price in currency
* @return int 0 if OK, <0 if KO
*/
public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_options = 0, $ref_supplier = '', $fk_unit = '', $pu_ht_devise = 0)
public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_options = [], $ref_supplier = '', $fk_unit = 0, $pu_ht_devise = 0)
{
global $conf, $user, $langs, $mysoc;

View file

@ -79,7 +79,15 @@ $manifest->short_name = $manifest->name;
$manifest->theme_color = getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR', getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40'));
if (!preg_match('/#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/', $manifest->theme_color)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$manifest->theme_color = '#'.colorArrayToHex(colorStringToArray($manifest->theme_color));
}
$manifest->background_color = getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR', "#ffffff");
if (!preg_match('/#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/', $manifest->background_color)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$manifest->background_color = '#'.colorArrayToHex(colorStringToArray($manifest->background_color));
}
$manifest->display = getDolGlobalString('MAIN_MANIFEST_DISPLAY', "minimal-ui");
$manifest->splash_pages = null;
$manifest->icons = array();

View file

@ -77,7 +77,15 @@ if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
$manifest->short_name = $manifest->name;
$manifest->theme_color = getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR', getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40'));
if (!preg_match('/#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/', $manifest->theme_color)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$manifest->theme_color = '#'.colorArrayToHex(colorStringToArray($manifest->theme_color));
}
$manifest->background_color = getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR', "#ffffff");
if (!preg_match('/#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/', $manifest->background_color)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$manifest->background_color = '#'.colorArrayToHex(colorStringToArray($manifest->background_color));
}
$manifest->display = getDolGlobalString('MAIN_MANIFEST_DISPLAY', "minimal-ui");
$manifest->splash_pages = null;
$manifest->icons = array();

View file

@ -2328,7 +2328,7 @@ class User extends CommonObject
* @param int $nosyncmember Do not synchronize linked member
* @param int $passwordalreadycrypted 0=Value is cleartext password, 1=Value is encrypted value.
* @param int $flagdelsessionsbefore 1=Save also the current date to ask to invalidate all other session before this date.
* @return string If OK return clear password, 0 if no change (warning, you may retrieve 1 instead of 0 even if password was same), < 0 if error
* @return int|string If OK return clear password, 0 if no change (warning, you may retrieve 1 instead of 0 even if password was same), < 0 if error
*/
public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $passwordalreadycrypted = 0, $flagdelsessionsbefore = 1)
{

View file

@ -175,8 +175,8 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
$sanit_features[$explode[0]] = $explode[1];
$tmp = new ProductCombination2ValuePair($db);
$tmp->fk_prod_attr = $explode[0];
$tmp->fk_prod_attr_val = $explode[1];
$tmp->fk_prod_attr = (int) $explode[0];
$tmp->fk_prod_attr_val = (int) $explode[1];
$productCombination2ValuePairs1[] = $tmp;
}

View file

@ -223,7 +223,7 @@ class Target extends CommonObject
public function create(User $user, $notrigger = 0)
{
$resultcreate = $this->createCommon($user, $notrigger);
$this->ref = $this->id;
$this->ref = (string) $this->id;
if ($resultcreate <= 0) {
return $resultcreate;
@ -341,7 +341,7 @@ class Target extends CommonObject
{
$result = $this->fetchCommon($id, $ref);
if (empty($this->ref)) {
$this->ref = $this->id;
$this->ref = (string) $this->id;
}
return $result;

View file

@ -1,9 +1,9 @@
parameters:
tmpDir: ./.github/tmp
parallel:
jobSize: 20
jobSize: 8
processTimeout: 600.0
maximumNumberOfProcesses: 8
maximumNumberOfProcesses: 20
minimumNumberOfJobsPerProcess: 2
buffer: 134217728 # 128 MB
customRulesetUsed: true