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

This commit is contained in:
Laurent Destailleur 2023-04-18 20:38:55 +02:00
commit 272a0030b7
20 changed files with 377 additions and 94 deletions

View File

@ -511,7 +511,7 @@ if (empty($reshook)) {
if ($result > 0) {
$lineid = $result;
if (!empty($createbills_onebythird)) //increment rang to keep order
$TFactThirdNbLines[$rcp->socid]++;
$TFactThirdNbLines[$cmd->socid]++;
} else {
$lineid = 0;
$error++;

View File

@ -459,7 +459,7 @@ class Translate
// Enable caching of lang file in memory (not by default)
$usecachekey = '';
// Using a memcached server
if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) {
if (isModEnabled('memcached') && !empty($conf->global->MEMCACHED_SERVER)) {
$usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars
} elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) {
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)

View File

@ -129,6 +129,17 @@ interface Database
public function DDLListTables($database, $table = '');
// phpcs:enable
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List tables into a database with table type
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
*/
public function DDLListTablesFull($database, $table = '');
// phpcs:enable
/**
* Return last request executed with query()
*

View File

@ -716,6 +716,38 @@ class DoliDBMysqli extends DoliDB
return $listtables;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List tables into a database
*
* @param string $database Name of database
* @param string $table Nmae of table filter ('xxx%')
* @return array List of tables in an array
*/
public function DDLListTablesFull($database, $table = '')
{
// phpcs:enable
$listtables = array();
$like = '';
if ($table) {
$tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table);
$like = "LIKE '".$this->escape($tmptable)."'";
}
$tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database);
$sql = "SHOW FULL TABLES FROM `".$tmpdatabase."` ".$like.";";
$result = $this->query($sql);
if ($result) {
while ($row = $this->fetch_row($result)) {
$listtables[] = $row;
}
}
return $listtables;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List information of columns into a table.

View File

@ -977,6 +977,34 @@ class DoliDBPgsql extends DoliDB
return $listtables;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List tables into a database
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
*/
public function DDLListTablesFull($database, $table = '')
{
// phpcs:enable
$listtables = array();
$escapedlike = '';
if ($table) {
$tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table);
$escapedlike = " AND table_name LIKE '".$this->escape($tmptable)."'";
}
$result = pg_query($this->db, "SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'public'".$escapedlike." ORDER BY table_name");
if ($result) {
while ($row = $this->fetch_row($result)) {
$listtables[] = $row;
}
}
return $listtables;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List information of columns into a table.

View File

@ -896,6 +896,38 @@ class DoliDBSqlite3 extends DoliDB
return $listtables;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List tables into a database with table type
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
*/
public function DDLListTablesFull($database, $table = '')
{
// phpcs:enable
$listtables = array();
$like = '';
if ($table) {
$tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table);
$like = "LIKE '".$this->escape($tmptable)."'";
}
$tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database);
$sql = "SHOW FULL TABLES FROM ".$tmpdatabase." ".$like.";";
//print $sql;
$result = $this->query($sql);
if ($result) {
while ($row = $this->fetch_row($result)) {
$listtables[] = $row;
}
}
return $listtables;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List information of columns into a table.

View File

@ -20,6 +20,7 @@
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
* Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.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
@ -633,7 +634,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
}
}
if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
if (!empty($_GET['action']) && (preg_match('/^create|^add_price|^make/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
if (!empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
// Now search in setup to overwrite default values
if (!empty($user->default_values)) { // $user->default_values defined from menu 'Setup - Default values'
if (isset($user->default_values[$relativepathstring]['createform'])) {

View File

@ -742,3 +742,108 @@ function writePermsInAsciiDoc($file, $destfile)
}
return 1;
}
/**
* Add Object in ModuleApi File
* @param string $file path of file
* @param array $objects array of objects in the module
* @param string $modulename name of module
* @return int 1 if OK, -1 if KO
*/
function addObjectsToApiFile($file, $objects, $modulename)
{
if (!file_exists($file)) {
return -1;
}
$content = file($file);
$includeClass = "dol_include_once('/mymodule/class/myobject.class.php');";
$props = "public \$myobject;";
$varcomented = "@var MyObject \$myobject {@type MyObject}";
$constructObj = "\$this->myobject = new MyObject(\$this->db);";
// add properties and declare them in consturctor
foreach ($content as $lineNumber => &$lineContent) {
if (strpos($lineContent, $varcomented) !== false) {
$lineContent = '';
foreach ($objects as $object) {
$lineContent .= "\t * @var ".$object." \$".strtolower($object)." {@type ".$object."}". PHP_EOL;
}
//var_dump($lineContent);exit;
}
if (strpos($lineContent, $props) !== false) {
$lineContent = '';
foreach ($objects as $object) {
$lineContent .= "\tpublic \$".strtolower($object).";". PHP_EOL;
}
}
if (strpos($lineContent, $constructObj) !== false) {
$lineContent = '';
foreach ($objects as $object) {
$lineContent .= "\t\t\$this->".strtolower($object)." = new ".$object."(\$this->db);". PHP_EOL;
}
}
if (strpos($lineContent, $includeClass) !== false) {
$lineContent = '';
foreach ($objects as $object) {
$lineContent .= "dol_include_once('/".strtolower($modulename)."/class/".strtolower($object).".class.php');". PHP_EOL;
}
}
}
$allContent = implode("", $content);
file_put_contents($file, $allContent);
//add methods for each object
$allContent = getFromFile($file, '/*begin methods CRUD*/', '/*end methods CRUD*/');
foreach ($objects as $object) {
$contentReplaced =str_replace(["myobject","MyObject"], [strtolower($object),$object], $allContent);
dolReplaceInFile($file, array('/*end methods CRUD*/' => '/*CRUD FOR '.strtoupper($object).'*/'."\n".$contentReplaced."\n\t".'/*END CRUD FOR '.strtoupper($object).'*/'."\n\t".'/*end methods CRUD*/'));
}
dolReplaceInFile($file, array($allContent => '','MyModule' => ucfirst($modulename)));
return 1;
}
/**
* Remove Object variables and methods from API_Module File
* @param string $file file api module
* @param string $objectname name of object whant to remove
* @param string $modulename name of module
* @return int 1 if OK, -1 if KO
*/
function removeObjectFromApiFile($file, $objectname, $modulename)
{
$begin = '/*CRUD FOR '.strtoupper($objectname).'*/';
$end = '/*END CRUD FOR '.strtoupper($objectname).'*/';
$includeClass = "dol_include_once('/".strtolower($modulename)."/class/".strtolower($objectname).".class.php');";
$varcomentedDel = "\t * @var ".$objectname." \$".strtolower($objectname)." {@type ".$objectname."}";
$propsDel = "\tpublic \$".strtolower($objectname).";";
$constructObjDel = "\t\t\$this->".strtolower($objectname)." = new ".$objectname."(\$this->db);";
if (!file_exists($file)) {
return -1;
}
$content = file($file);
// for delete property and the initialization from the construct
foreach ($content as $lineNumber => &$lineContent) {
if (strpos($lineContent, $includeClass) !== false) {
$lineContent = '';
}
if (strpos($lineContent, $varcomentedDel) !== false) {
$lineContent = '';
}
if (strpos($lineContent, $propsDel) !== false) {
$lineContent = '';
}
if (strpos($lineContent, $constructObjDel) !== false) {
$lineContent = '';
}
}
$allContent = implode("", $content);
file_put_contents($file, $allContent);
// for delete methods of object
$allContent = getFromFile($file, $begin, $end);
$check = dolReplaceInFile($file, array($allContent => ''));
if ($check) {
dolReplaceInFile($file, array($begin => '', $end => ''));
}
return 1;
}

View File

@ -205,6 +205,18 @@ class TraceableDB extends DoliDB
return $this->db->DDLListTables($database, $table);
}
/**
* List tables into a database with table info
*
* @param string $database Name of database
* @param string $table Nmae of table filter ('xxx%')
* @return array List of tables in an array
*/
public function DDLListTablesFull($database, $table = '')
{
return $this->db->DDLListTablesFull($database, $table);
}
/**
* Return last request executed with query()
*

View File

@ -8,9 +8,10 @@
* Copyright (C) 2012-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Ion Agorria <ion@agorria.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.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
@ -1047,7 +1048,7 @@ if (empty($reshook)) {
$action = '';
} elseif ($methodecommande <= 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("OrderMode")), null, 'errors');
$action = 'makeorder';
$action = 'createorder';
}
}
@ -2438,7 +2439,7 @@ if ($action == 'create') {
*/
if ($user->socid == 0 && $action != 'delete') {
if ($action != 'makeorder' && $action != 'presend' && $action != 'editline') {
if ($action != 'createorder' && $action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">';
$parameters = array();
@ -2569,7 +2570,7 @@ if ($action == 'create') {
if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) {
if ($usercanorder) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=makeorder#makeorder">'.$langs->trans("MakeOrder").'</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=createorder#makeorder">'.$langs->trans("MakeOrder").'</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("MakeOrder").'</a></div>';
}
@ -2637,7 +2638,7 @@ if ($action == 'create') {
print "</div>";
}
if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'makeorder') {
if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'createorder') {
// Set status to ordered (action=commande)
print '<!-- form to record supplier order -->'."\n";
print '<form name="commande" id="makeorder" action="card.php?id='.$object->id.'&amp;action=commande" method="POST">';
@ -2678,7 +2679,7 @@ if ($action == 'create') {
$action = 'presend';
}
if ($action != 'makeorder' && $action != 'presend' ) {
if ($action != 'createorder' && $action != 'presend' ) {
print '<div class="fichecenter"><div class="fichehalfleft">';
// Generated documents

View File

@ -547,3 +547,11 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23208, '', 0, 'Nor-Oriental');
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23209, '', 0, 'Zuliana');
-- Turkiye (Turkey) Regions (id country=221)
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22101, '', 0, 'Marmara');
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22102, '', 0, 'İç Anadolu');
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22103, '', 0, 'Ege');
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22104, '', 0, 'Akdeniz');
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22105, '', 0, 'Güneydoğu');
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22106, '', 0, 'Karadeniz');
INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22107, '', 0, 'Doğu Anadolu');

View File

@ -1951,3 +1951,88 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc
insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) values (12301, '45', '', 0, '宮崎', '宮崎県', 1);
insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) values (12301, '46', '', 0, '鹿児島', '鹿児島県', 1);
insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) values (12301, '47', '', 0, '沖縄', '沖縄県', 1);
-- Turkiye (Turkey) (id country=221)
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-01',22104,'Adana');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-02',22107,'Adıyaman');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-03',22103,'Afyon');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-04',22107,'Ağrı');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-05',22106,'Amasya');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-06',22102,'Ankara');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-07',22104,'Antalya');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-08',22106,'Artvin');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-09',22103,'Aydın');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-10',22101,'Balıkesir');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-11',22101,'Bilecik');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-12',22107,'Bingöl');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-13',22107,'Bitlis');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-14',22106,'Bolu');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-15',22104,'Burdur');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-16',22101,'Bursa');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-17',22101,'Çanakkale');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-18',22102,'Çankırı');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-19',22106,'Çorum');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-20',22104,'Denizli');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-21',22105,'Diyarbakır');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-22',22101,'Edirne');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-23',22107,'Elazığ');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-24',22107,'Erzincan');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-25',22107,'Erzurum');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-26',22102,'Eskişehir');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-27',22105,'Gaziantep');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-28',22106,'Giresun');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-29',22106,'Gümüşhane');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-30',22107,'Hakkari');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-31',22104,'Hatay');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-32',22104,'Isparta');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-33',22104,'İçel');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-34',22101,'İstanbul');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-35',22103,'İzmir');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-36',22107,'Kars');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-37',22106,'Kastamonu');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-38',22102,'Kayseri');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-39',22101,'Kırklareli');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-40',22102,'Kırşehir');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-41',22101,'Kocaeli');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-42',22102,'Konya');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-43',22103,'Kütahya');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-44',22107,'Malatya');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-45',22103,'Manisa');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-46',22104,'Kahramanmaraş');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-47',22105,'Mardin');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-48',22103,'Muğla');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-49',22107,'Muş');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-50',22102,'Nevşehir');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-51',22102,'Niğde');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-52',22106,'Ordu');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-53',22106,'Rize');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-54',22101,'Sakarya');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-55',22106,'Samsun');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-56',22105,'Siirt');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-57',22106,'Sinop');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-58',22102,'Sivas');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-59',22101,'Tekirdağ');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-60',22106,'Tokat');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-61',22106,'Trabzon');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-62',22107,'Tunceli');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-63',22105,'Şanlıurfa');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-63',22103,'Uşak');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-65',22107,'Van');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-66',22102,'Yozgat');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-67',22106,'Zonguldak');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-68',22102,'Aksaray');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-69',22106,'Bayburt');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-70',22102,'Karaman');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-71',22102,'Kırıkkale');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-72',22105,'Batman');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-73',22105,'Şırnak');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-74',22106,'Bartın');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-75',22107,'Ardahan');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-76',22107,'Iğdır');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-77',22101,'Yalova');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-78',22106,'Karabük');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-79',22105,'Kilis');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-80',22104,'Osmaniye');
INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-81',22106,'Düzce');

View File

@ -154,7 +154,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TWD'
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'THB', '[3647]', 1, 'Thailand Baht');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TTD', '[84,84,36]', 1, 'Trinidad and Tobago Dollar');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TND', NULL, 1, 'Tunisia Dinar');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TRY', '[8356]', 1, 'Turkey Lira');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TRY', '[8378]', 1, 'Turkey Lira');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TVD', '[36]', 1, 'Tuvalu Dollar');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'UAH', '[8372]', 1, 'Ukraine Hryvna');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'AED', NULL, 1, 'United Arab Emirates Dirham');

View File

@ -34,3 +34,7 @@ insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active)
insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1541, 154, 1.5, 'percent', 'Revenue stamp mexico', 1);
insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1542, 154, 3, 'percent', 'Revenue stamp mexico', 1);
-- Turkiye (Turkey) (id country=221) --
insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (22101,221,0.00948,'percent','Mukavelenameler Damga Vergisi',1);
insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (22102,221,0.00189,'percent','Kira mukavelenameleri Damga Vergisi',1);

View File

@ -403,3 +403,9 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (23
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2335,61, '0','0','No VAT',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2336,61, '10','0','VAT 10%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2337,61, '18','0','VAT 18%',1);
-- Turkiye (Turkey) (id country=221)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (22101,221, '0','0','No VAT',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (22102,221, '1','0','VAT 1%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (22103,221, '8','0','VAT 8%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (22104,221, '18','0','VAT 18%',1);

View File

@ -1244,7 +1244,7 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) {
if ($db->type == "mysql" || $db->type == "mysqli") {
$force_utf8_on_tables = GETPOST('force_utf8_on_tables', 'alpha');
$listoftables = $db->DDLListTables($db->database_name);
$listoftables = $db->DDLListTablesFull($db->database_name);
// Disable foreign key checking for avoid errors
if ($force_utf8_on_tables == 'confirmed') {
@ -1255,14 +1255,18 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) {
foreach ($listoftables as $table) {
// do not convert llx_const if mysql encrypt/decrypt is used
if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) {
if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table[0])) {
continue;
}
if ($table[1] == 'VIEW') {
print '<tr><td colspan="2">'.$table[0].' is a '.$table[1].' (Skipped)</td></tr>';
continue;
}
print '<tr><td colspan="2">';
print $table;
$sql1 = "ALTER TABLE ".$table." ROW_FORMAT=dynamic";
$sql2 = "ALTER TABLE ".$table." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci";
print $table[0];
$sql1 = "ALTER TABLE ".$table[0]." ROW_FORMAT=dynamic";
$sql2 = "ALTER TABLE ".$table[0]." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci";
print '<!-- '.$sql1.' -->';
print '<!-- '.$sql2.' -->';
if ($force_utf8_on_tables == 'confirmed') {
@ -1297,7 +1301,7 @@ if ($ok && GETPOST('force_utf8mb4_on_tables', 'alpha')) {
if ($db->type == "mysql" || $db->type == "mysqli") {
$force_utf8mb4_on_tables = GETPOST('force_utf8mb4_on_tables', 'alpha');
$listoftables = $db->DDLListTables($db->database_name);
$listoftables = $db->DDLListTablesFull($db->database_name);
// Disable foreign key checking for avoid errors
if ($force_utf8mb4_on_tables == 'confirmed') {
@ -1308,14 +1312,18 @@ if ($ok && GETPOST('force_utf8mb4_on_tables', 'alpha')) {
foreach ($listoftables as $table) {
// do not convert llx_const if mysql encrypt/decrypt is used
if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) {
if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table[0])) {
continue;
}
if ($table[1] == 'VIEW') {
print '<tr><td colspan="2">'.$table[0].' is a '.$table[1].' (Skipped)</td></tr>';
continue;
}
print '<tr><td colspan="2">';
print $table;
$sql1 = "ALTER TABLE ".$table." ROW_FORMAT=dynamic";
$sql2 = "ALTER TABLE ".$table." CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
print $table[0];
$sql1 = "ALTER TABLE ".$table[0]." ROW_FORMAT=dynamic";
$sql2 = "ALTER TABLE ".$table[0]." CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
print '<!-- '.$sql1.' -->';
print '<!-- '.$sql2.' -->';
if ($force_utf8mb4_on_tables == 'confirmed') {

View File

@ -471,72 +471,10 @@ if ($dirins && in_array($action, array('initapi', 'initphpunit', 'initpagecontac
);
if (count($objects) > 1) {
$file = $destfile;
$content = file($file);
$props = "public \$myobject;";
$varcomented = "@var MyObject \$myobject {@type MyObject}";
$constructObj = "\$this->myobject = new MyObject(\$this->db);";
// add properties and declare them in consturctor
foreach ($content as $lineNumber => &$lineContent) {
if (strpos($lineContent, $varcomented) !== false) {
$lineContent = '';
foreach ($objects as $object) {
$lineContent .= "\t * @var ".$object." \$".strtolower($object)." {@type ".$object."}". PHP_EOL;
}
//var_dump($lineContent);exit;
}
if (strpos($lineContent, $props) !== false) {
$lineContent = '';
foreach ($objects as $object) {
$lineContent .= "\tpublic \$".strtolower($object).";". PHP_EOL;
}
}
if (strpos($lineContent, $constructObj) !== false) {
$lineContent = '';
foreach ($objects as $object) {
$lineContent .= "\t\t\$this->".strtolower($object)."= new ".$object."(\$this->db);". PHP_EOL;
}
}
}
$allContent = implode("", $content);
file_put_contents($destfile, $allContent);
}
if (count($objects) > 1) {
$search = "/*begin methods CRUD*/";
// Open the file and read line by line
$handle = fopen($destfile, "r");
$i = 1;
$lines = array();
$props = " public \$myobject; ";
while (($line = fgets($handle)) !== false) {
//search line begin
if (strpos($line, $search) !== false) {
$start_line = $i;
// Copy lines until the end on array
while (($line = fgets($handle)) !== false) {
if (strpos($line, "/*end methods CRUD*/") !== false) {
$end_line = $i;
break;
}
$lines[] = $line;
$i++;
}
break;
}
$i++;
}
$allContent = implode("", $lines);
foreach ($objects as $object) {
$contentReplaced = str_replace(["myobject","MyObject"], [strtolower($object),$object], $allContent);
dolReplaceInFile($destfile, array('/*end methods CRUD*/' => '/*CRUD FOR '.strtoupper($object).'*/'."\n".$contentReplaced."\n\t".'/*END CRUD FOR '.strtoupper($object).'*/'."\n\t".'/*end methods CRUD*/'));
}
dolReplaceInFile($destfile, array($allContent => ''));
fclose($handle);
addObjectsToApiFile($destfile, $objects, $modulename);
} else {
dolReplaceInFile($destfile, $arrayreplacement);
dolReplaceInFile($destfile, array('/*begin methods CRUD*/' => '/*begin methods CRUD*/'."\n\t".'/*CRUD FOR '.strtoupper($objectname).'*/', '/*end methods CRUD*/' => '/*END CRUD FOR '.strtoupper($objectname).'*/'."\n\t".'/*end methods CRUD*/'));
}
if ($varnametoupdate) {
@ -938,17 +876,25 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
$relativefilename = dol_sanitizePathName(GETPOST('file', 'restricthtml'));
// Get list of existing objects
$objects = dolGetListOfObjectClasses($destdir);
// Now we delete the file
if ($relativefilename) {
$dirnametodelete = dirname($relativefilename);
$filetodelete = $dirins.'/'.$relativefilename;
$dirtodelete = $dirins.'/'.$dirnametodelete;
$result = dol_delete_file($filetodelete);
//check when we want delete api_file
if (strpos($relativefilename, 'api') !== false) {
$removeFile = removeObjectFromApiFile($file_api, $objectname, $module);
$var = getFromFile($file_api, '/*begin methods CRUD*/', '/*end methods CRUD*/');
if (str_word_count($var) == 0) {
$result = dol_delete_file($filetodelete);
}
if ($removeFile) {
setEventMessages($langs->trans("ApiObjectDeleted"), null);
}
} else {
$result = dol_delete_file($filetodelete);
}
if (!$result) {
setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors');
} else {

View File

@ -66,6 +66,7 @@ class Productcustomerprice extends CommonObject
public $price_min;
public $price_min_ttc;
public $price_base_type;
public $default_vat_code;
public $tva_tx;
public $recuperableonly;
public $localtax1_type;
@ -78,6 +79,9 @@ class Productcustomerprice extends CommonObject
*/
public $fk_user;
/**
* @var PriceByCustomerLine[]
*/
public $lines = array();

View File

@ -12,7 +12,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2018-2021 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org>
*
* This program is free software; you can redistribute it and/or modify
@ -2453,7 +2453,7 @@ class User extends CommonObject
//print $password.'-'.$this->id.'-'.$dolibarr_main_instance_unique_id;
$url = $urlwithroot.'/user/passwordforgotten.php?action=validatenewpassword';
$url .= '&username='.urlencode($this->login)."&passworduidhash=".urlencode(dol_hash($password.'-'.$this->id.'-'.$dolibarr_main_instance_unique_id));
if (!empty($conf->multicompany->enabled)) {
if (isModEnabled('multicompany')) {
$url .= '&entity='.(!empty($this->entity) ? $this->entity : 1);
}

View File

@ -82,7 +82,7 @@ class ProductTest extends PHPUnit\Framework\TestCase
{
global $conf,$user,$langs,$db;
if (!isModEnabled('produit')) {
if (!isModEnabled('product')) {
print __METHOD__." Module Product must be enabled.\n"; die(1);
}