Merge branch 'develop' into addLayoutForWebsite

This commit is contained in:
Laurent Destailleur 2024-03-21 16:34:55 +01:00 committed by GitHub
commit 9232c2bda9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
149 changed files with 1685 additions and 1428 deletions

View file

@ -106,7 +106,7 @@ jobs:
ls -l ~/.cache/pre-commit/
- name: Convert Raw Log to Annotations
uses: mdeweerd/logToCheckStyle@2024.3.2
uses: mdeweerd/logToCheckStyle@v2024.3.4
if: ${{ failure() }}
with:
in: ${{ env.RAW_LOG }}

View file

@ -150,7 +150,7 @@ jobs:
for /f "tokens=2 delims==" %%A in ('doskey /m:err') do EXIT /B %%A
- name: Convert Raw Log to Annotations
uses: mdeweerd/logToCheckStyle@2024.3.2
uses: mdeweerd/logToCheckStyle@v2024.3.4
if: ${{ failure() }}
with:
in: ${{ env.PHPUNIT_LOG }}

View file

@ -104,7 +104,7 @@ FIX: #yogosha21416
For users:
----------
NEW: Compatibility with PHP 8.2
NEW: Compatibility with PHP 8.2 (warning must be disabled)
NEW: Module Workstation (used to enhance the module BOM and Manufacturing Order) is now stable
NEW: Add a CLI tool to regenerate all documents
NEW: Add a confirmation popup when deleting extrafields

View file

@ -10,25 +10,20 @@
return [
// # Issue statistics:
// PhanParamSignatureMismatch : 25+ occurrences
// PhanTypeMismatchReturnNullable : 20+ occurrences
// PhanPluginSuspiciousParamPosition : 15+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
// PhanPluginDuplicateExpressionBinaryOp : 10+ occurrences
// PhanTypeArraySuspiciousNull : 10+ occurrences
// PhanTypeMismatchReturn : 10+ occurrences
// PhanTypeMismatchReturn : 8 occurrences
// PhanRedefineFunctionInternal : 6 occurrences
// PhanTypeArraySuspiciousNull : 6 occurrences
// PhanParamTooMany : 4 occurrences
// PhanTypeMismatchPropertyProbablyReal : 2 occurrences
// PhanTypeMismatchReturnNullable : 3 occurrences
// PhanAccessMethodProtected : 1 occurrence
// PhanAccessPropertyStaticAsNonStatic : 1 occurrence
// PhanNoopStringLiteral : 1 occurrence
// PhanPluginAlwaysReturnFunction : 1 occurrence
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'htdocs/adherents/class/adherent.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/adherents/class/adherentstats.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/adherents/stats/geo.php' => ['PhanTypeArraySuspiciousNull'],
'htdocs/adherents/type.php' => ['PhanPluginDuplicateExpressionBinaryOp'],
'htdocs/admin/receiptprinter.php' => ['PhanRedefineFunctionInternal'],
'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'],
@ -36,10 +31,7 @@ return [
'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected'],
'htdocs/categories/viewcat.php' => ['PhanPluginDuplicateExpressionBinaryOp'],
'htdocs/collab/index.php' => ['PhanParamTooMany'],
'htdocs/comm/action/class/actioncomm.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/comm/action/index.php' => ['PhanTypeArraySuspiciousNull'],
'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/comm/propal/class/api_proposals.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp'],
'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanParamTooMany'],
'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition'],
@ -47,24 +39,15 @@ return [
'htdocs/core/class/commonobject.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/class/extrafields.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/class/html.form.class.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/core/class/html.formprojet.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/class/smtps.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/class/stats.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/db/mysqli.class.php' => ['PhanParamSignatureMismatch'],
'htdocs/core/db/pgsql.class.php' => ['PhanParamSignatureMismatch'],
'htdocs/core/db/sqlite3.class.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturnNullable'],
'htdocs/core/get_info.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/core/lib/date.lib.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/lib/files.lib.php' => ['PhanPluginDuplicateExpressionBinaryOp'],
'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanPluginAlwaysReturnFunction', 'PhanRedefineFunctionInternal'],
'htdocs/core/lib/functions2.lib.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/lib/pdf.lib.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanRedefineFunctionInternal'],
'htdocs/core/lib/price.lib.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/core/lib/website.lib.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/modules/DolibarrModules.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/core/modules/movement/doc/pdf_standard.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp'],
'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'],
'htdocs/core/modules/societe/modules_societe.class.php' => ['PhanTypeMismatchReturn'],
'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch'],
'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'],
'htdocs/don/class/don.class.php' => ['PhanParamTooMany'],
@ -76,17 +59,12 @@ return [
'htdocs/mrp/class/mo.class.php' => ['PhanParamSignatureMismatch'],
'htdocs/product/admin/product_tools.php' => ['PhanNoopStringLiteral'],
'htdocs/product/class/product.class.php' => ['PhanTypeMismatchReturn'],
'htdocs/projet/class/project.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/projet/class/projectstats.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/projet/class/task.class.php' => ['PhanTypeMismatchReturnNullable'],
'htdocs/projet/tasks/list.php' => ['PhanTypeArraySuspiciousNull'],
'htdocs/public/payment/paymentok.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/societe/class/companybankaccount.class.php' => ['PhanParamSignatureMismatch'],
'htdocs/stripe/admin/stripe.php' => ['PhanDeprecatedFunction'],
'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/takepos/invoice.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/variants/class/ProductCombination.class.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/website/class/website.class.php' => ['PhanTypeMismatchReturnNullable'],
'internal' => ['PhanUndeclaredConstant'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.

View file

@ -495,7 +495,7 @@ return [
'PhanPossiblyNullTypeMismatchProperty',
'PhanRedefineClass',
'PhanRedefineFunction',
'PhanTypeInvalidLeftOperandOfBitwiseOp',
// 'PhanTypeInvalidLeftOperandOfBitwiseOp',
// 'PhanTypeMismatchDimAssignment',
// 'PhanPluginDescriptionlessCommentOnProtectedMethod',
// 'PhanPluginPrintfIncompatibleArgumentTypeWeak',

View file

@ -31,9 +31,6 @@ CodePaymentTerm
IdPaymentTerm
LabelPaymentTerm
# ticket
TicketAnswered
# website_template
Message
Map
@ -43,6 +40,7 @@ Reservation
ACCOUNTING_ACCOUNT_CUSTOMER
ACCOUNTING_ACCOUNT_CUSTOMER_Desc
ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY
ACCOUNTING_ACCOUNT_EXPENSEREPORT
ACCOUNTING_ACCOUNT_SUPPLIER
ACCOUNTING_ACCOUNT_SUPPLIER_Desc
ACCOUNTING_ACCOUNT_SUSPENSE
@ -3685,8 +3683,3 @@ WebPortalSetupPage
XSubsriptionErrors
YouCanChooseAModelForYouMailContent
YouCanMakeSomeInstructionForEmail
helpWithAi
ExtrafieldLinestringGeo
ExtrafieldMultiPointGeo
ExtrafieldPointGeo
ExtrafieldPolygonGeo

View file

@ -39,6 +39,7 @@ FieldsTitle
FileIntegrityIsOkButFilesWereAdded
FirstUseDate
FollowingLinksArePublic
HelpWithAI
HidePassword
IPP_Device
InstallChoiceRecommanded
@ -1025,15 +1026,10 @@ VideoGeneration
## pass - this list needs to be cleaned up
#####################################################################
#####################################################################
$minimum
AI_KEY_API_
AddService
AnHelpMessage
Analytic
AnalyticLabel
BOOKCAL_MYPARAM10
BOOKCAL_MYPARAM8
BOOKCAL_MYPARAM9
BankId
Bcc
Birthdate
@ -1061,9 +1057,6 @@ Facture
FailedToConnectToSFTPAfterSSHAuthentication
FailedToLogin
First
France
Germany
Greece
GroupCreate
GroupUpdate
INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION
@ -1078,7 +1071,6 @@ InputValueIsNotAnNumber
InterDate
Inventory Code
InvoiceReplace
Italy
ItemID
JobApplications
JobPosition
@ -1092,7 +1084,6 @@ LocalTax1IsUsedExample
LocalTax2IsNotUsedExample
LocalTax2IsUsedExample
Logs
Lot/Série
MAIN_IMAP_USE_PHPIMAPDesc
MYMODULE_CATEGORY_ID_XXX
MYMODULE_MYPARAM1
@ -1138,7 +1129,6 @@ Recruited
Ref. Product
RefNewContract
Societe
Spain
Stable
Suggested
TaskModifieddInDolibarr

View file

@ -328,6 +328,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
// activate
if ($action == $acts[0]) {
$sql = '';
$rowidcol = "rowid";
if ($rowid) {
@ -346,6 +347,7 @@ if ($action == $acts[0]) {
// disable
if ($action == $acts[1]) {
$sql = '';
$rowidcol = "rowid";
if ($rowid) {
@ -364,6 +366,7 @@ if ($action == $acts[1]) {
// favorite
if ($action == 'activate_favorite') {
$sql = '';
$rowidcol = "rowid";
if ($rowid) {
@ -382,6 +385,7 @@ if ($action == 'activate_favorite') {
// disable favorite
if ($action == 'disable_favorite') {
$sql = '';
$rowidcol = "rowid";
if ($rowid) {

View file

@ -52,6 +52,10 @@ $list_account_main = array(
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
);
if (isModEnabled('expensereport')) {
$list_account_main[] = 'ACCOUNTING_ACCOUNT_EXPENSEREPORT';
}
$list_account = array();
$list_account[] = '---Product---';

View file

@ -221,6 +221,7 @@ if ($result) {
$account_supplier = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER', 'NotDefined'); // NotDefined is a reserved word
$account_customer = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER', 'NotDefined'); // NotDefined is a reserved word
$account_employee = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined'); // NotDefined is a reserved word
$account_expensereport = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT', 'NotDefined'); // NotDefined is a reserved word
$account_pay_vat = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT', 'NotDefined'); // NotDefined is a reserved word
$account_pay_donation = getDolGlobalString('DONATION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word
$account_pay_subscription = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word
@ -625,6 +626,9 @@ if (!$error && $action == 'writebookkeeping') {
$accountingaccountpayment = new AccountingAccount($db);
$accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true);
$accountingaccountexpensereport = new AccountingAccount($db);
$accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true);
$accountingaccountsuspense = new AccountingAccount($db);
$accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true);
@ -757,8 +761,8 @@ if (!$error && $action == 'writebookkeeping') {
} elseif ($tabtype[$key] == 'payment_expensereport') {
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['name'];
$bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT');
$bookkeeping->label_compte = $accountingaccountpayment->label;
$bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT');
$bookkeeping->label_compte = $accountingaccountexpensereport->label;
} elseif ($tabtype[$key] == 'payment_salary') {
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['name'];
@ -1013,7 +1017,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
} elseif ($tabtype[$key] == 'payment') {
print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep;
} elseif ($tabtype[$key] == 'payment_expensereport') {
print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep;
print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep;
} elseif ($tabtype[$key] == 'payment_salary') {
print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep;
} else {
@ -1135,7 +1139,8 @@ if (empty($action) || $action == 'view') {
// Button to write into Ledger
if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1'
|| getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1'
|| getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') {
|| getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1'
|| getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSERERPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSERERPORT') == '-1') {
print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
$desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}');
$desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc);
@ -1294,7 +1299,7 @@ if (empty($action) || $action == 'view') {
$account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER');
}
if ($tabtype[$key] == 'payment_expensereport') {
$account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT');
$account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT');
}
if ($tabtype[$key] == 'payment_salary') {
$account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT');

View file

@ -162,7 +162,7 @@ if ($result) {
$num = $db->num_rows($result);
// Variables
$account_salary = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined');
$account_salary = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT', 'NotDefined');
$account_vat = getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT', 'NotDefined');
$i = 0;
@ -247,7 +247,7 @@ if ($action == 'writebookkeeping' && !$error) {
$error = 0;
$accountingaccountexpense = new AccountingAccount($db);
$accountingaccountexpense->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true);
$accountingaccountexpense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true);
foreach ($taber as $key => $val) { // Loop on each expense report
$errorforline = 0;
@ -279,7 +279,7 @@ if ($action == 'writebookkeeping' && !$error) {
$bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['name'];
$bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT');
$bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT');
$bookkeeping->label_compte = $accountingaccountexpense->label;
$bookkeeping->label_operation = $tabuser[$key]['name'];
@ -590,7 +590,7 @@ if (empty($action) || $action == 'view') {
}
// Button to write into Ledger
if (!getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') {
if (!getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1') {
print '<br><div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
$desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}');
$desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc);
@ -602,7 +602,7 @@ if (empty($action) || $action == 'view') {
if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') {
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
}
if (!getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') {
if (!getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} else {
if ($in_bookkeeping == 'notyet') {
@ -726,7 +726,7 @@ if (empty($action) || $action == 'view') {
print "<td>".$expensereportstatic->getNomUrl(1)."</td>";
// Account
print "<td>";
$accountoshow = length_accountg(getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'));
$accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'));
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
print '<span class="error">'.$langs->trans("MainAccountForUsersNotDefined").'</span>';
} else {

View file

@ -560,12 +560,13 @@ class Adherent extends CommonObject
* Return translated label by the nature of a adherent (physical or moral)
*
* @param string $morphy Nature of the adherent (physical or moral)
* @param int $addbadge Add badge (1=Full label, 2=First letters only)
* @param int<0,2> $addbadge Add badge (1=Full label, 2=First letters only)
* @return string Label
*/
public function getmorphylib($morphy = '', $addbadge = 0)
{
global $langs;
$s = '';
// Clean var
if (!$morphy) {
@ -573,7 +574,6 @@ class Adherent extends CommonObject
}
if ($addbadge) {
$s = '';
$labeltoshowm = $langs->trans("Moral");
$labeltoshowp = $langs->trans("Physical");
if ($morphy == 'phy') {

View file

@ -3,6 +3,7 @@
* Copyright (c) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2023 Waël Almoman <info@almoman.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -168,15 +169,15 @@ class AdherentStats extends Stats
/**
* Return count of member by status group by adh type, total and average
*
* @param int $numberYears Number of years to scan (0 = all)
* @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type
* @param int $numberYears Number of years to scan (0 = all)
* @return array<string,array{label:string,members_draft:int,members_pending:0,members_uptodate:int,members_expired:int,members_excluded:int,members_resiliated:int,all?:float|int,total_adhtag:float|int}> Array with total of draft, pending, uptodate, expired, resiliated for each member type
*/
public function countMembersByTypeAndStatus($numberYears = 0)
{
global $user;
$now = dol_now();
$endYear = date('Y');
$endYear = (int) date('Y');
$startYear = $endYear - $numberYears;
$sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label";
@ -224,7 +225,7 @@ class AdherentStats extends Stats
'members_resiliated' => (int) $objp->members_resiliated
);
$totalrow = 0;
foreach ($MembersCountArray[$objp->fk_adherent_type] as $key=>$nb) {
foreach ($MembersCountArray[$objp->fk_adherent_type] as $key => $nb) {
if ($key != 'label') {
$totalrow += $nb;
$totalstatus[$key] += $nb;
@ -244,16 +245,17 @@ class AdherentStats extends Stats
/**
* Return count of member by status group by adh type, total and average
*
* @param int $numberYears Number of years to scan (0 = all)
* @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag
* @param int $numberYears Number of years to scan (0 = all)
* @return array<string,array{label:string,members_draft:int,members_pending:0,members_uptodate:int,members_expired:int,members_excluded:int,members_resiliated:int,all?:float|int,total_adhtag:float|int}> Array with total of draft, pending, uptodate, expired, resiliated for each member tag
*/
public function countMembersByTagAndStatus($numberYears = 0)
{
global $user;
$now = dol_now();
$endYear = date('Y');
$endYear = (int) date('Y');
$startYear = $endYear - $numberYears;
$MembersCountArray = [];
$sql = "SELECT c.rowid as fk_categorie, c.label as label";
$sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft";
@ -282,7 +284,6 @@ class AdherentStats extends Stats
if ($result) {
$num = $this->db->num_rows($result);
$i = 0;
$MembersCountArray = [];
$totalstatus = array(
'label' => 'Total',
'members_draft' => 0,
@ -304,7 +305,7 @@ class AdherentStats extends Stats
'members_resiliated' => (int) $objp->members_resiliated
);
$totalrow = 0;
foreach ($MembersCountArray[$objp->fk_categorie] as $key=>$nb) {
foreach ($MembersCountArray[$objp->fk_categorie] as $key => $nb) {
if ($key != 'label') {
$totalrow += $nb;
$totalstatus[$key] += $nb;

View file

@ -6,6 +6,7 @@
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2021-2023 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -203,6 +204,7 @@ foreach ($object->fields as $key => $val) {
}
}
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
//var_dump($arrayfields);exit;
// Security check

View file

@ -13,6 +13,7 @@
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2019-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020-2022 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.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
@ -2130,6 +2131,11 @@ if ($id > 0) {
$canbemodified = 1;
}
if ($tabname[$id] == "c_product_nature" && in_array($obj->code, array(0, 1))) {
$canbedisabled = 0;
$canbemodified = 0;
$iserasable = 0;
}
// Build Url. The table is id=, the id of line is rowid=
$rowidcol = empty($tabrowid[$id]) ? 'rowid' : $tabrowid[$id];
// If rowidcol not defined

View file

@ -90,31 +90,31 @@ print '</li>';
if (preg_match('/^fr_/i', $langs->getDefaultLang()))
{
print '<li>';
print '<a target="_blank" href="https://www.dolibarr.fr/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("France")).'</a>';
print '<a target="_blank" href="https://www.dolibarr.fr/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryFR")).'</a>';
print '</li>';
}
if (preg_match('/^el_/i', $langs->getDefaultLang()))
{
print '<li>';
print '<a target="_blank" href="https://www.dolibarr.gr/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Greece")).'</a>';
print '<a target="_blank" href="https://www.dolibarr.gr/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryGR")).'</a>';
print '</li>';
}
if (preg_match('/^es_/i', $langs->getDefaultLang()))
{
print '<li>';
print '<a target="_blank" href="https://www.dolibarr.es/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Spain")).'</a>';
print '<a target="_blank" href="https://www.dolibarr.es/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryES")).'</a>';
print '</li>';
}
if (preg_match('/^it_/i', $langs->getDefaultLang()))
{
print '<li>';
print '<a target="_blank" href="https://www.dolibarr.it/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Italy")).'</a>';
print '<a target="_blank" href="https://www.dolibarr.it/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryIT")).'</a>';
print '</li>';
}
if (preg_match('/^de_/i', $langs->getDefaultLang()))
{
print '<li>';
print '<a target="_blank" href="https://www.dolibarr.de/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Germany")).'</a>';
print '<a target="_blank" href="https://www.dolibarr.de/" rel="noopener noreferrer external">'.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryDE")).'</a>';
print '</li>';
}*/
print '<li>';

View file

@ -1548,7 +1548,7 @@ class Asset extends CommonObject
$dir = dol_buildpath($reldir."core/modules/asset/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -875,7 +875,7 @@ class BOM extends CommonObject
$dir = dol_buildpath($reldir."core/modules/bom/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -71,37 +71,6 @@ $formSetup = new FormSetup($db);
// Setup conf BOOKCAL_PUBLIC_INTERFACE_TOPIC
$item = $formSetup->newItem('BOOKCAL_PUBLIC_INTERFACE_TOPIC');
$item->defaultFieldValue = 'MyBigCompany public interface for Bookcal';
/*// Setup conf BOOKCAL_MYPARAM8
$item = $formSetup->newItem('BOOKCAL_MYPARAM8');
$TField = array(
'test01' => $langs->trans('test01'),
'test02' => $langs->trans('test02'),
'test03' => $langs->trans('test03'),
'test04' => $langs->trans('test04'),
'test05' => $langs->trans('test05'),
'test06' => $langs->trans('test06'),
);
$item->setAsMultiSelect($TField);
$item->helpText = $langs->transnoentities('BOOKCAL_MYPARAM8');
// Setup conf BOOKCAL_MYPARAM9
$formSetup->newItem('BOOKCAL_MYPARAM9')->setAsSelect($TField);
// Setup conf BOOKCAL_MYPARAM10
$item = $formSetup->newItem('BOOKCAL_MYPARAM10');
$item->setAsColor();
$item->defaultFieldValue = '#FF0000';
$item->nameText = $item->getNameText().' more html text ';
$item->fieldInputOverride = '';
$item->helpText = $langs->transnoentities('AnHelpMessage');*/
//$item->fieldValue = '';
//$item->fieldAttr = array() ; // fields attribute only for compatible fields like input text
//$item->fieldOverride = false; // set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too
//$item->fieldInputOverride = false; // set this var to override field input
//$item->fieldOutputOverride = false; // set this var to override field output
$setupnotempty = + count($formSetup->items);

View file

@ -975,7 +975,7 @@ class Availabilities extends CommonObject
$dir = dol_buildpath($reldir."core/modules/bookcal/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -964,7 +964,7 @@ class Calendar extends CommonObject
$dir = dol_buildpath($reldir."core/modules/bookcal/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -1393,7 +1393,7 @@ class ActionComm extends CommonObject
*
* @param User $user Object user
* @param int $load_state_board Load indicator array this->nb
* @return WorkboardResponse|int Return integer <0 if KO, WorkboardResponse if OK
* @return WorkboardResponse|int<-1,1> Return integer <0 if KO, WorkboardResponse if OK
*/
public function load_board($user, $load_state_board = 0)
{
@ -1462,7 +1462,7 @@ class ActionComm extends CommonObject
}
$this->db->free($resql);
if (empty($load_state_board)) {
if (empty($load_state_board) && $response instanceof WorkboardResponse) {
return $response;
} else {
return 1;

View file

@ -177,6 +177,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
$result = restrictedArea($user, 'agenda', 0, '', 'myactions');
if ($user->socid && $socid) {

View file

@ -4,6 +4,7 @@
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2022 ATM Consulting <contact@atm-consulting.fr>
* Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -410,6 +411,7 @@ class Proposals extends DolibarrApi
}
$errors = [];
$updateRes = 0;
$this->db->begin();
foreach ($request_data as $TData) {

View file

@ -3615,7 +3615,7 @@ class Propal extends CommonObject
$dir = dol_buildpath($reldir."core/modules/propale/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if (!$mybool) {

View file

@ -416,7 +416,7 @@ class Commande extends CommonOrder
$dir = dol_buildpath($reldir."core/modules/commande/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -227,6 +227,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Security check

View file

@ -231,6 +231,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
if (!$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;
@ -1295,6 +1296,7 @@ if ($resql) {
// Détail commande
if (!empty($arrayfields['rowid']['checked'])) {
print_liste_field_titre($arrayfields['rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', $param, '', $sortfield, $sortorder);
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
}
if (!empty($arrayfields['pr.ref']['checked'])) {
print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);

View file

@ -5,6 +5,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -125,6 +126,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
$permissiontoadd = $user->hasRight('banque', 'modifier');
$permissiontodelete = $user->hasRight('banque', 'configurer');

View file

@ -3,6 +3,7 @@
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -172,6 +173,7 @@ $arrayfields = array(
);
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Security check
$socid = GETPOSTINT("socid");

View file

@ -3524,11 +3524,15 @@ if ($action == 'create') {
setRadioForTypeOfInvoice();
});
function setRadioForTypeOfInvoice() {
console.log("Change radio");
console.log("Change radio for type of invoice");
if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
jQuery("#checkforselects").prop("disabled", true);
jQuery("#checkforselects").prop("checked", false);
jQuery(".checkforselect").prop("disabled", true);
jQuery(".checkforselect").prop("checked", false);
} else {
jQuery("#checkforselects").prop("disabled", false);
jQuery("#checkforselects").prop("checked", true);
jQuery(".checkforselect").prop("disabled", false);
jQuery(".checkforselect").prop("checked", true);
}

View file

@ -4609,7 +4609,7 @@ class Facture extends CommonInvoice
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir.$file;
$mybool = ((bool) include_once $dir.$file) || $mybool;
}
}
@ -4624,7 +4624,7 @@ class Facture extends CommonInvoice
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir.$file;
$mybool = (include_once $dir.$file) || $mybool;
}
}
}

View file

@ -9,6 +9,7 @@
* Copyright (C) 2015-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2023 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -161,6 +162,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
if ($socid > 0) {
$tmpthirdparty = new Societe($db);

View file

@ -293,6 +293,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
if (!$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;

View file

@ -5,6 +5,7 @@
* Copyright (C) 2011-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -423,7 +424,7 @@ class RemiseCheque extends CommonObject
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir.$file;
$mybool = (include_once $dir.$file) || $mybool;
}
}
@ -438,7 +439,7 @@ class RemiseCheque extends CommonObject
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir.$file;
$mybool = (include_once $dir.$file) || $mybool;
}
}
}

View file

@ -4,6 +4,7 @@
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -99,6 +100,7 @@ $arrayfields = array(
'bc.statut' => array('label' => "Status", 'checked' => 1, 'position' => 70)
);
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('chequelist'));

View file

@ -13,6 +13,7 @@
* Copyright (C) 2021 OpenDsi <support@open-dsi.fr>
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
* Copyright (C) 2023 Sylvain Legrand <technique@infras.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -847,7 +848,7 @@ class Paiement extends CommonObject
// Add link to the Direct Debit if invoice refused ('InvoiceRefused') in bank_url
if (!$error && $label == '(InvoiceRefused)') {
$result=$acc->add_url_line(
$result = $acc->add_url_line(
$bank_line_id,
$this->id_prelevement,
DOL_URL_ROOT.'/compta/prelevement/card.php?id=',
@ -1182,7 +1183,7 @@ class Paiement extends CommonObject
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir.$file;
$mybool = (include_once $dir.$file) || $mybool;
}
}
@ -1197,7 +1198,7 @@ class Paiement extends CommonObject
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir.$file;
$mybool = (include_once $dir.$file) || $mybool;
}
}
}
@ -1352,7 +1353,7 @@ class Paiement extends CommonObject
$result .= $linkend;
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$parameters = array('id' => $this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;

View file

@ -9,6 +9,7 @@
* Copyright (C) 2018-2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -110,6 +111,7 @@ $arrayfields = array(
'p.statut' => array('label' => "Status", 'checked' => 1, 'position' => 90, 'enabled' => (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION'))),
);
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('paymentlist'));

View file

@ -7,6 +7,7 @@
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2021-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -114,6 +115,7 @@ if (isModEnabled("bank")) {
}
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('sclist'));

View file

@ -5,6 +5,7 @@
* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -95,6 +96,7 @@ if (isModEnabled("bank")) {
}
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('salestaxeslist'));

View file

@ -12,6 +12,7 @@
* Copyright (C) 2019 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -268,6 +269,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
if (($id > 0 || !empty($ref)) && $action != 'add') {

View file

@ -337,7 +337,7 @@ class Contrat extends CommonObject
$dir = dol_buildpath($reldir."core/modules/contract/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if (!$mybool) {

View file

@ -9,6 +9,7 @@
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019 Nicolas Zabouri <info@inovea-conseil.com>
* Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -194,6 +195,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
if (!$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;

View file

@ -7,6 +7,7 @@
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -139,6 +140,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
$permissiontoread = $user->hasRight('contrat', 'lire');
$permissiontoadd = $user->hasRight('contrat', 'creer');

View file

@ -7269,7 +7269,7 @@ abstract class CommonObject
if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%');
$out = $doleditor->Create(1, '', true, '', '', '', $morecss);
$out = (string) $doleditor->Create(1, '', true, '', '', '', $morecss);
} else {
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
}
@ -7277,7 +7277,7 @@ abstract class CommonObject
if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, isModEnabled('fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%');
$out = $doleditor->Create(1, '', true, '', '', $moreparam, $morecss);
$out = (string) $doleditor->Create(1, '', true, '', '', $moreparam, $morecss);
} else {
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
}

View file

@ -1452,7 +1452,7 @@ class FormMail extends Form
$out = '<tr id="ai_input" class="hidden">';
$out .= '<td>';
//$out .= $form->textwithpicto($langs->trans('helpWithAi'), $langs->trans("YouCanMakeSomeInstructionForEmail"));
//$out .= $form->textwithpicto($langs->trans('HelpWithAI'), $langs->trans("YouCanMakeSomeInstructionForEmail"));
$out .= '</td>';
$out .= '<td>';

View file

@ -3,6 +3,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -686,7 +687,7 @@ class FormProjets extends Form
* @param string $morecss Add more css
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $addcombojs 1=Add a js combo
* @return int|string The HTML select list of element or '' if nothing or -1 if KO
* @return int<-1,-1>|string The HTML select list of element or '' if nothing or -1 if KO
*/
public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0)
{
@ -701,6 +702,7 @@ class FormProjets extends Form
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
$sellist = '';
if ($num > 0) {
$sellist = '<select class="flat oppstatus' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '">';
if ($showempty) {
@ -841,7 +843,7 @@ class FormProjets extends Form
// Use select2 selector
if (!empty($conf->use_javascript_ajax)) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlNameInvoice, array(array('method'=>'getLines', 'url'=>dol_buildpath('/core/ajax/ajaxinvoiceline.php', 1), 'htmlname'=>$htmlNameInvoiceLine)), 0, 0);
$comboenhancement = ajax_combobox($htmlNameInvoice, array(array('method' => 'getLines', 'url' => dol_buildpath('/core/ajax/ajaxinvoiceline.php', 1), 'htmlname' => $htmlNameInvoiceLine)), 0, 0);
$out .= $comboenhancement;
$morecss = 'minwidth200imp maxwidth500';
}
@ -957,9 +959,9 @@ class FormProjets extends Form
$out .= $langs->trans("OppStatus".$code);
// Opportunity percent
$out.= ' / <span title="'.$langs->trans("OpportunityProbability").'"> ';
$out.= price($percent_value, 0, $langs, 1, 0).' %';
$out.= '</span>';
$out .= ' / <span title="'.$langs->trans("OpportunityProbability").'"> ';
$out .= price($percent_value, 0, $langs, 1, 0).' %';
$out .= '</span>';
} else {
$out .= "&nbsp;";
}

View file

@ -1686,6 +1686,8 @@ class SMTPs
}
$content .= "--".$this->_getBoundary('mixed').'--'."\r\n";
} else {
die("Sorry, no content");
}
return $content;

View file

@ -3,6 +3,7 @@
* Copyright (c) 2008-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -75,21 +76,21 @@ abstract class Stats
public $month;
/**
* @param int $year number
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array array of values by month
* @param int $year number
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array<int<0,11>,array{0:int<1,12>,1:int}> Array of nb each month
*/
abstract protected function getNbByMonth($year, $format = 0);
/**
* Return nb of elements by month for several years
*
* @param int $endyear Start year
* @param int $startyear End year
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january
* @return array Array of values
* @param int $endyear Start year
* @param int $startyear End year
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january
* @return array<int<0,11>,array{0:int<1,12>,1:int}> Array of values
*/
public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1)
{
@ -99,7 +100,8 @@ abstract class Stats
return array();
}
$datay = array();
$data = array(); // This is the return value
$datay = array(); // This is a work value
// Search into cache
if (!empty($cachedelay)) {
@ -127,6 +129,7 @@ abstract class Stats
if ($foundintocache) { // Cache file found and is not too old
dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
$data = json_decode(file_get_contents($newpathofdestfile), true);
'@phan-var-force array<int<0,11>,array{0:int<1,12>,1:int}> $data';
} else {
$year = $startyear;
$sm = $startmonth - 1;
@ -138,19 +141,18 @@ abstract class Stats
$year++;
}
$data = array();
for ($i = 0; $i < 12; $i++) {
$data[$i][] = $datay[$endyear][($i + $sm) % 12][0];
$year = $startyear;
while ($year <= $endyear) {
// floor(($i + $sm) / 12)) is 0 if we are after the month start $sm and same year, become 1 when we reach january of next year
$data[$i][] = $datay[$year - (1 - floor(($i + $sm) / 12)) + ($sm == 0 ? 1 : 0)][($i + $sm) % 12][1];
$data[$i][] = $datay[$year - (1 - (int) floor(($i + $sm) / 12)) + ($sm == 0 ? 1 : 0)][($i + $sm) % 12][1];
$year++;
}
}
}
// Save cache file
if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) {
dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
@ -170,9 +172,9 @@ abstract class Stats
}
/**
* @param int $year year number
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array array of values by month
* @param int $year year number
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array<int<0,11>,array{0:int<1,12>,1:int|float}> Array of values by month
*/
abstract protected function getAmountByMonth($year, $format = 0);
@ -187,7 +189,7 @@ abstract class Stats
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january
* @return array Array of values
* @return array<int<0,11>,array<string|int|float>> Array of values
*/
public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1)
{
@ -198,6 +200,7 @@ abstract class Stats
}
$datay = array();
$data = array(); // Return value
// Search into cache
if (!empty($cachedelay)) {
@ -237,7 +240,6 @@ abstract class Stats
$year++;
}
$data = array();
// $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
for ($i = 0; $i < 12; $i++) {
$data[$i][] = isset($datay[$endyear][($i + $sm) % 12]['label']) ? $datay[$endyear][($i + $sm) % 12]['label'] : $datay[$endyear][($i + $sm) % 12][0]; // set label
@ -271,17 +273,17 @@ abstract class Stats
}
/**
* @param int $year year number
* @return array array of values
* @param int $year year number
* @return array<int<0,11>,array{0:int<1,12>,1:int|float}> Array of values
*/
abstract protected function getAverageByMonth($year);
/**
* Return average of entity by month for several years
* Return average of entity by month for several years
*
* @param int $endyear Start year
* @param int $startyear End year
* @return array Array of values
* @param int $endyear Start year
* @param int $startyear End year
* @return array<array<int|float>> Array of values
*/
public function getAverageByMonthWithPrevYear($endyear, $startyear)
{
@ -290,6 +292,7 @@ abstract class Stats
}
$datay = array();
$data = array();
$year = $startyear;
while ($year <= $endyear) {
@ -297,8 +300,6 @@ abstract class Stats
$year++;
}
$data = array();
for ($i = 0; $i < 12; $i++) {
$data[$i][] = $datay[$endyear][$i][0];
$year = $startyear;
@ -312,12 +313,12 @@ abstract class Stats
}
/**
* Return count, and sum of products
* Return count, and sum of products
*
* @param int $year Year
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
* @param int $limit Limit
* @return array Array of values
* @param int $year Year
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
* @param int $limit Limit
* @return array<int<0,11>,array{0:int<1,12>,1:int|float}> Array of values
*/
public function getAllByProductEntry($year, $cachedelay = 0, $limit = 10)
{
@ -325,7 +326,7 @@ abstract class Stats
$data = array();
// Search into cache
// Search in cache
if (!empty($cachedelay)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
@ -352,6 +353,7 @@ abstract class Stats
if ($foundintocache) { // Cache file found and is not too old
dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
$data = json_decode(file_get_contents($newpathofdestfile), true);
'@phan-var-force array<int<0,11>,array{0:int<1,12>,1:int|float}> $data'; // Phan can't decode json_decode's return value
} else {
// This method is defined in parent object only, not into abstract, so we disable phpstan warning
/** @phpstan-ignore-next-line */
@ -465,13 +467,13 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Renvoie le nombre de documents par mois pour une annee donnee
* Return number of documents per month for a given year
* Renvoie le nombre de documents par mois pour une annee donnee
* Return number of documents per month for a given year
*
* @param int $year Year
* @param string $sql SQL
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array Array of nb each month
* @param int $year Year
* @param string $sql SQL
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array<int<0,11>,array{0:int<1,12>,1:int}> Array of nb each month
*/
protected function _getNbByMonth($year, $sql, $format = 0)
{
@ -523,12 +525,12 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Return the amount per month for a given year
* Return the amount per month for a given year
*
* @param int $year Year
* @param string $sql SQL
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array
* @param int $year Year
* @param string $sql SQL
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array<int<0,11>,array{0:int<1,12>,1:int|float}> Array of nb each month
*/
protected function _getAmountByMonth($year, $sql, $format = 0)
{
@ -580,13 +582,12 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Renvoie le montant moyen par mois pour une annee donnee
* Return the amount average par month for a given year
*
* @param int $year Year
* @param string $sql SQL
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array
* @return array<int<0,11>,array{0:int<1,12>,1:int|float}> Array of average each month
*/
protected function _getAverageByMonth($year, $sql, $format = 0)
{
@ -643,7 +644,7 @@ abstract class Stats
*
* @param string $sql SQL
* @param int $limit Limit
* @return array
* @return array<int<0,11>,array{0:int<1,12>,1:int|float}> Array of total of product refs each month
*/
protected function _getAllByProduct($sql, $limit = 10)
{
@ -682,7 +683,7 @@ abstract class Stats
/**
* Returns the summed amounts per year for a given number of past years ending now
* @param string $sql SQL
* @return array
* @return array<int,array{0:int,1:int}> Array of sum of amounts
*/
protected function _getAmountByYear($sql)
{
@ -693,7 +694,6 @@ abstract class Stats
$i = 0;
while ($i < $num) {
$row = $this->db->fetch_row($resql);
$j = (int) $row[0];
$result[] = [
0 => (int) $row[0],
1 => (int) $row[1],

View file

@ -951,7 +951,7 @@ class TimeSpent extends CommonObject
$dir = dol_buildpath($reldir."core/modules/timespent/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -5,6 +5,7 @@
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -326,7 +327,7 @@ interface Database
* Create a table into database
*
* @param string $table Name of table
* @param array $fields Associative table [field name][table of descriptions]
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string}> $fields Associative table [field name][table of descriptions]
* @param string $primary_key Name of the field that will be the primary key
* @param string $type Type of the table
* @param array $unique_keys Associative array Name of fields that will be unique key => value
@ -360,7 +361,7 @@ interface Database
*
* @param string $table Name of table
* @param string $field_name Name of field to add
* @param string $field_desc Associative array of description of the field to insert [parameter name][parameter value]
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Associative array of description of the field to insert [parameter name][parameter value]
* @param string $field_position Optional ex .: "after field stuff"
* @return int Return integer <0 if KO, >0 if OK
*/
@ -384,7 +385,7 @@ interface Database
*
* @param string $table Name of table
* @param string $field_name Name of field to modify
* @param string $field_desc Array with description of field format
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Array with description of field format
* @return int Return integer <0 if KO, >0 if OK
*/
public function DDLUpdateField($table, $field_name, $field_desc);

View file

@ -266,7 +266,7 @@ abstract class DoliDB implements Database
/**
* Return version of database server into an array
*
* @return array Version array
* @return string[] Version array
*/
public function getVersionArray()
{

View file

@ -814,7 +814,7 @@ class DoliDBMysqli extends DoliDB
* Create a table into database
*
* @param string $table Name of table
* @param array $fields Tableau associatif [nom champ][tableau des descriptions]
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
@ -825,69 +825,79 @@ class DoliDBMysqli extends DoliDB
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null)
{
// phpcs:enable
// FIXME: $fulltext_keys parameter is unused
// @TODO: $fulltext_keys parameter is unused
if (empty($type)) {
$type = 'InnoDB';
}
$pk = '';
$sqluq = $sqlk = array();
$sqlk = array();
$sqluq = array();
// cles recherchees dans le tableau des descriptions (fields) : type,value,attribute,null,default,extra
// ex. : $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql = "CREATE TABLE ".$table."(";
// Keys found into the array $fields: type,value,attribute,null,default,extra
// ex. : $fields['rowid'] = array(
// 'type'=>'int' or 'integer',
// 'value'=>'11',
// 'null'=>'not null',
// 'extra'=> 'auto_increment'
// );
$sql = "CREATE TABLE ".$this->sanitize($table)."(";
$i = 0;
$sqlfields = array();
foreach ($fields as $field_name => $field_desc) {
$sqlfields[$i] = $field_name." ";
$sqlfields[$i] .= $field_desc['type'];
if (preg_match("/^[^\s]/i", $field_desc['value'])) {
$sqlfields[$i] .= "(".$field_desc['value'].")";
$sqlfields[$i] = $this->sanitize($field_name)." ";
$sqlfields[$i] .= $this->sanitize($field_desc['type']);
if (isset($field_desc['value']) && $field_desc['value'] !== '') {
$sqlfields[$i] .= "(".$this->sanitize($field_desc['value']).")";
}
if (preg_match("/^[^\s]/i", $field_desc['attribute'])) {
$sqlfields[$i] .= " ".$field_desc['attribute'];
if (isset($field_desc['attribute']) && $field_desc['attribute'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['attribute']);
}
if (preg_match("/^[^\s]/i", $field_desc['default'])) {
if ((preg_match("/null/i", $field_desc['default'])) || (preg_match("/CURRENT_TIMESTAMP/i", $field_desc['default']))) {
$sqlfields[$i] .= " default ".$field_desc['default'];
if (isset($field_desc['default']) && $field_desc['default'] !== '') {
if (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sqlfields[$i] .= " DEFAULT ".((float) $field_desc['default']);
} elseif ($field_desc['default'] == 'null' || $field_desc['default'] == 'CURRENT_TIMESTAMP') {
$sqlfields[$i] .= " DEFAULT ".$this->sanitize($field_desc['default']);
} else {
$sqlfields[$i] .= " default '".$this->escape($field_desc['default'])."'";
$sqlfields[$i] .= " DEFAULT '".$this->escape($field_desc['default'])."'";
}
}
if (preg_match("/^[^\s]/i", $field_desc['null'])) {
$sqlfields[$i] .= " ".$field_desc['null'];
if (isset($field_desc['null']) && $field_desc['null'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['null'], 0, 0, 1);
}
if (preg_match("/^[^\s]/i", $field_desc['extra'])) {
$sqlfields[$i] .= " ".$field_desc['extra'];
if (isset($field_desc['extra']) && $field_desc['extra'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['extra'], 0, 0, 1);
}
if (!empty($primary_key) && $primary_key == $field_name) {
$sqlfields[$i] .= " AUTO_INCREMENT PRIMARY KEY"; // mysql instruction that will be converted by driver late
}
$i++;
}
if ($primary_key != "") {
$pk = "primary key(".$primary_key.")";
}
if (is_array($unique_keys)) {
$i = 0;
foreach ($unique_keys as $key => $value) {
$sqluq[$i] = "UNIQUE KEY '".$key."' ('".$this->escape($value)."')";
$sqluq[$i] = "UNIQUE KEY '".$this->sanitize($key)."' ('".$this->escape($value)."')";
$i++;
}
}
if (is_array($keys)) {
$i = 0;
foreach ($keys as $key => $value) {
$sqlk[$i] = "KEY ".$key." (".$value.")";
$sqlk[$i] = "KEY ".$this->sanitize($key)." (".$value.")";
$i++;
}
}
$sql .= implode(',', $sqlfields);
if ($primary_key != "") {
$sql .= ",".$pk;
}
$sql .= implode(', ', $sqlfields);
if ($unique_keys != "") {
$sql .= ",".implode(',', $sqluq);
}
if (is_array($keys)) {
$sql .= ",".implode(',', $sqlk);
}
$sql .= ") engine=".$type;
$sql .= ")";
$sql .= " engine=".$this->sanitize($type);
if (!$this->query($sql)) {
return -1;
@ -908,7 +918,7 @@ class DoliDBMysqli extends DoliDB
// phpcs:enable
$tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table);
$sql = "DROP TABLE ".$tmptable;
$sql = "DROP TABLE ".$this->sanitize($tmptable);
if (!$this->query($sql)) {
return -1;
@ -928,7 +938,7 @@ class DoliDBMysqli extends DoliDB
public function DDLDescTable($table, $field = "")
{
// phpcs:enable
$sql = "DESC ".$table." ".$field;
$sql = "DESC ".$this->sanitize($table)." ".$this->sanitize($field);
dol_syslog(get_class($this)."::DDLDescTable ".$sql, LOG_DEBUG);
$this->_results = $this->query($sql);
@ -941,7 +951,7 @@ class DoliDBMysqli extends DoliDB
*
* @param string $table Name of table
* @param string $field_name Name of field to add
* @param string $field_desc Associative table with description of field to insert [parameter name][parameter value]
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Associative table with description of field to insert [parameter name][parameter value]
* @param string $field_position Optional e.g.: "after some_field"
* @return int Return integer <0 if KO, >0 if OK
*/
@ -950,30 +960,32 @@ class DoliDBMysqli extends DoliDB
// phpcs:enable
// cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql = "ALTER TABLE ".$table." ADD ".$field_name." ";
$sql .= $field_desc['type'];
if (preg_match("/^[^\s]/i", $field_desc['value'])) {
if (!in_array($field_desc['type'], array('date', 'datetime')) && $field_desc['value']) {
$sql .= "(".$field_desc['value'].")";
$sql = "ALTER TABLE ".$this->sanitize($table)." ADD ".$this->sanitize($field_name)." ";
$sql .= $this->sanitize($field_desc['type']);
if (isset($field_desc['value']) && preg_match("/^[^\s]/i", $field_desc['value'])) {
if (!in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'date', 'datetime')) && $field_desc['value']) {
$sql .= "(".$this->sanitize($field_desc['value']).")";
}
}
if (isset($field_desc['attribute']) && preg_match("/^[^\s]/i", $field_desc['attribute'])) {
$sql .= " ".$field_desc['attribute'];
$sql .= " ".$this->sanitize($field_desc['attribute']);
}
if (isset($field_desc['null']) && preg_match("/^[^\s]/i", $field_desc['null'])) {
$sql .= " ".$field_desc['null'];
}
if (isset($field_desc['default']) && preg_match("/^[^\s]/i", $field_desc['default'])) {
if (preg_match("/null/i", $field_desc['default'])) {
$sql .= " default ".$field_desc['default'];
if (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sql .= " DEFAULT ".((float) $field_desc['default']);
} elseif ($field_desc['default'] == 'null' || $field_desc['default'] == 'CURRENT_TIMESTAMP') {
$sql .= " DEFAULT ".$this->sanitize($field_desc['default']);
} else {
$sql .= " default '".$this->escape($field_desc['default'])."'";
$sql .= " DEFAULT '".$this->escape($field_desc['default'])."'";
}
}
if (isset($field_desc['extra']) && preg_match("/^[^\s]/i", $field_desc['extra'])) {
$sql .= " ".$field_desc['extra'];
$sql .= " ".$this->sanitize($field_desc['extra'], 0, 0, 1);
}
$sql .= " ".$field_position;
$sql .= " ".$this->sanitize($field_position, 0, 0, 1);
dol_syslog(get_class($this)."::DDLAddField ".$sql, LOG_DEBUG);
if ($this->query($sql)) {
@ -988,24 +1000,24 @@ class DoliDBMysqli extends DoliDB
*
* @param string $table Name of table
* @param string $field_name Name of field to modify
* @param string $field_desc Array with description of field format
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Array with description of field format
* @return int Return integer <0 if KO, >0 if OK
*/
public function DDLUpdateField($table, $field_name, $field_desc)
{
// phpcs:enable
$sql = "ALTER TABLE ".$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type'];
$sql = "ALTER TABLE ".$this->sanitize($table);
$sql .= " MODIFY COLUMN ".$this->sanitize($field_name)." ".$this->sanitize($field_desc['type']);
if (in_array($field_desc['type'], array('double', 'tinyint', 'int', 'varchar')) && $field_desc['value']) {
$sql .= "(".$field_desc['value'].")";
$sql .= "(".$this->sanitize($field_desc['value']).")";
}
if ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL') {
if (isset($field_desc['value']) && ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL')) {
// We will try to change format of column to NOT NULL. To be sure the ALTER works, we try to update fields that are NULL
if ($field_desc['type'] == 'varchar' || $field_desc['type'] == 'text') {
$sqlbis = "UPDATE ".$table." SET ".$field_name." = '".$this->escape(isset($field_desc['default']) ? $field_desc['default'] : '')."' WHERE ".$field_name." IS NULL";
$sqlbis = "UPDATE ".$this->sanitize($table)." SET ".$this->sanitize($field_name)." = '".$this->escape(isset($field_desc['default']) ? $field_desc['default'] : '')."' WHERE ".$this->sanitize($field_name)." IS NULL";
$this->query($sqlbis);
} elseif ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
$sqlbis = "UPDATE ".$table." SET ".$field_name." = ".((int) $this->escape(isset($field_desc['default']) ? $field_desc['default'] : 0))." WHERE ".$field_name." IS NULL";
} elseif (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sqlbis = "UPDATE ".$this->sanitize($table)." SET ".$this->sanitize($field_name)." = ".((float) $this->escape(isset($field_desc['default']) ? $field_desc['default'] : 0))." WHERE ".$this->sanitize($field_name)." IS NULL";
$this->query($sqlbis);
}
@ -1013,8 +1025,8 @@ class DoliDBMysqli extends DoliDB
}
if (isset($field_desc['default']) && $field_desc['default'] != '') {
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
$sql .= " DEFAULT ".$this->escape($field_desc['default']);
if (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sql .= " DEFAULT ".((float) $field_desc['default']);
} elseif ($field_desc['type'] != 'text') {
$sql .= " DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
}
@ -1041,7 +1053,7 @@ class DoliDBMysqli extends DoliDB
// phpcs:enable
$tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name);
$sql = "ALTER TABLE ".$table." DROP COLUMN `".$tmp_field_name."`";
$sql = "ALTER TABLE ".$this->sanitize($table)." DROP COLUMN `".$this->sanitize($tmp_field_name)."`";
if ($this->query($sql)) {
return 1;
}

View file

@ -1057,7 +1057,7 @@ class DoliDBPgsql extends DoliDB
* Create a table into database
*
* @param string $table Nom de la table
* @param array $fields Tableau associatif [nom champ][tableau des descriptions]
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
@ -1068,67 +1068,75 @@ class DoliDBPgsql extends DoliDB
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null)
{
// phpcs:enable
// FIXME: $fulltext_keys parameter is unused
// @TODO: $fulltext_keys parameter is unused
$sqlfields = array();
$sqlk = array();
$sqluq = array();
// cles recherchees dans le tableau des descriptions (fields) : type,value,attribute,null,default,extra
// ex. : $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql = "create table ".$table."(";
// Keys found into the array $fields: type,value,attribute,null,default,extra
// ex. : $fields['rowid'] = array(
// 'type'=>'int' or 'integer',
// 'value'=>'11',
// 'null'=>'not null',
// 'extra'=> 'auto_increment'
// );
$sql = "CREATE TABLE ".$this->sanitize($table)."(";
$i = 0;
$sqlfields = array();
foreach ($fields as $field_name => $field_desc) {
$sqlfields[$i] = $field_name." ";
$sqlfields[$i] .= $field_desc['type'];
if (preg_match("/^[^\s]/i", $field_desc['value'])) {
$sqlfields[$i] .= "(".$field_desc['value'].")";
} elseif (preg_match("/^[^\s]/i", $field_desc['attribute'])) {
$sqlfields[$i] .= " ".$field_desc['attribute'];
} elseif (preg_match("/^[^\s]/i", $field_desc['default'])) {
if (preg_match("/null/i", $field_desc['default'])) {
$sqlfields[$i] .= " default ".$field_desc['default'];
$sqlfields[$i] = $this->sanitize($field_name)." ";
$sqlfields[$i] .= $this->sanitize($field_desc['type']);
if (isset($field_desc['value']) && $field_desc['value'] !== '') {
$sqlfields[$i] .= "(".$this->sanitize($field_desc['value']).")";
}
if (isset($field_desc['attribute']) && $field_desc['attribute'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['attribute']);
}
if (isset($field_desc['default']) && $field_desc['default'] !== '') {
if (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sqlfields[$i] .= " DEFAULT ".((float) $field_desc['default']);
} elseif ($field_desc['default'] == 'null' || $field_desc['default'] == 'CURRENT_TIMESTAMP') {
$sqlfields[$i] .= " DEFAULT ".$this->sanitize($field_desc['default']);
} else {
$sqlfields[$i] .= " default '".$this->escape($field_desc['default'])."'";
$sqlfields[$i] .= " DEFAULT '".$this->escape($field_desc['default'])."'";
}
} elseif (preg_match("/^[^\s]/i", $field_desc['null'])) {
$sqlfields[$i] .= " ".$field_desc['null'];
} elseif (preg_match("/^[^\s]/i", $field_desc['extra'])) {
$sqlfields[$i] .= " ".$field_desc['extra'];
}
if (isset($field_desc['null']) && $field_desc['null'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['null'], 0, 0, 1);
}
if (isset($field_desc['extra']) && $field_desc['extra'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['extra'], 0, 0, 1);
}
if (!empty($primary_key) && $primary_key == $field_name) {
$sqlfields[$i] .= " AUTO_INCREMENT PRIMARY KEY"; // mysql instruction that will be converted by driver late
}
$i++;
}
if ($primary_key != "") {
$pk = "primary key(".$primary_key.")";
}
if (is_array($unique_keys)) {
$i = 0;
foreach ($unique_keys as $key => $value) {
$sqluq[$i] = "UNIQUE KEY '".$key."' ('".$this->escape($value)."')";
$sqluq[$i] = "UNIQUE KEY '".$this->sanitize($key)."' ('".$this->escape($value)."')";
$i++;
}
}
if (is_array($keys)) {
$i = 0;
foreach ($keys as $key => $value) {
$sqlk[$i] = "KEY ".$key." (".$value.")";
$sqlk[$i] = "KEY ".$this->sanitize($key)." (".$value.")";
$i++;
}
}
$sql .= implode(',', $sqlfields);
if ($primary_key != "") {
$sql .= ",".$pk;
}
if (is_array($unique_keys)) {
$sql .= implode(', ', $sqlfields);
if ($unique_keys != "") {
$sql .= ",".implode(',', $sqluq);
}
if (is_array($keys)) {
$sql .= ",".implode(',', $sqlk);
}
$sql .= ") type=".$type;
$sql .= ")";
//$sql .= " engine=".$this->sanitize($type);
dol_syslog($sql, LOG_DEBUG);
if (!$this->query($sql)) {
return -1;
} else {
@ -1148,7 +1156,7 @@ class DoliDBPgsql extends DoliDB
// phpcs:enable
$tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table);
$sql = "DROP TABLE ".$tmptable;
$sql = "DROP TABLE ".$this->sanitize($tmptable);
if (!$this->query($sql)) {
return -1;
@ -1157,31 +1165,6 @@ class DoliDBPgsql extends DoliDB
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Create a user to connect to database
*
* @param string $dolibarr_main_db_host Ip server
* @param string $dolibarr_main_db_user Name of user to create
* @param string $dolibarr_main_db_pass Password of user to create
* @param string $dolibarr_main_db_name Database name where user must be granted
* @return int Return integer <0 if KO, >=0 if OK
*/
public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name)
{
// phpcs:enable
// Note: using ' on user does not works with pgsql
$sql = "CREATE USER ".$this->escape($dolibarr_main_db_user)." with password '".$this->escape($dolibarr_main_db_pass)."'";
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
$resql = $this->query($sql);
if (!$resql) {
return -1;
}
return 1;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return a pointer of line with description of a table or field
@ -1219,30 +1202,32 @@ class DoliDBPgsql extends DoliDB
// phpcs:enable
// cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql = "ALTER TABLE ".$table." ADD ".$field_name." ";
$sql .= $field_desc['type'];
if (preg_match("/^[^\s]/i", $field_desc['value'])) {
if (!in_array($field_desc['type'], array('smallint', 'int', 'date', 'datetime')) && $field_desc['value']) {
$sql .= "(".$field_desc['value'].")";
$sql = "ALTER TABLE ".$this->sanitize($table)." ADD ".$this->sanitize($field_name)." ";
$sql .= $this->sanitize($field_desc['type']);
if (isset($field_desc['value']) && preg_match("/^[^\s]/i", $field_desc['value'])) {
if (!in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'date', 'datetime')) && $field_desc['value']) {
$sql .= "(".$this->sanitize($field_desc['value']).")";
}
}
if (preg_match("/^[^\s]/i", $field_desc['attribute'])) {
$sql .= " ".$field_desc['attribute'];
if (isset($field_desc['attribute']) && preg_match("/^[^\s]/i", $field_desc['attribute'])) {
$sql .= " ".$this->sanitize($field_desc['attribute']);
}
if (preg_match("/^[^\s]/i", $field_desc['null'])) {
if (isset($field_desc['null']) && preg_match("/^[^\s]/i", $field_desc['null'])) {
$sql .= " ".$field_desc['null'];
}
if (preg_match("/^[^\s]/i", $field_desc['default'])) {
if (preg_match("/null/i", $field_desc['default'])) {
$sql .= " default ".$field_desc['default'];
if (isset($field_desc['default']) && preg_match("/^[^\s]/i", $field_desc['default'])) {
if (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sql .= " DEFAULT ".((float) $field_desc['default']);
} elseif ($field_desc['default'] == 'null' || $field_desc['default'] == 'CURRENT_TIMESTAMP') {
$sql .= " DEFAULT ".$this->sanitize($field_desc['default']);
} else {
$sql .= " default '".$this->escape($field_desc['default'])."'";
$sql .= " DEFAULT '".$this->escape($field_desc['default'])."'";
}
}
if (preg_match("/^[^\s]/i", $field_desc['extra'])) {
$sql .= " ".$field_desc['extra'];
if (isset($field_desc['extra']) && preg_match("/^[^\s]/i", $field_desc['extra'])) {
$sql .= " ".$this->sanitize($field_desc['extra'], 0, 0, 1);
}
$sql .= " ".$field_position;
$sql .= " ".$this->sanitize($field_position, 0, 0, 1);
dol_syslog($sql, LOG_DEBUG);
if (!$this -> query($sql)) {
@ -1257,36 +1242,36 @@ class DoliDBPgsql extends DoliDB
*
* @param string $table Name of table
* @param string $field_name Name of field to modify
* @param string $field_desc Array with description of field format
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Array with description of field format
* @return int Return integer <0 if KO, >0 if OK
*/
public function DDLUpdateField($table, $field_name, $field_desc)
{
// phpcs:enable
$sql = "ALTER TABLE ".$table;
$sql .= " ALTER COLUMN ".$this->escape($field_name)." TYPE ".$field_desc['type'];
if (preg_match("/^[^\s]/i", $field_desc['value'])) {
$sql = "ALTER TABLE ".$this->sanitize($table);
$sql .= " ALTER COLUMN ".$this->sanitize($field_name)." TYPE ".$this->sanitize($field_desc['type']);
if (isset($field_desc['value']) && preg_match("/^[^\s]/i", $field_desc['value'])) {
if (!in_array($field_desc['type'], array('smallint', 'int', 'date', 'datetime')) && $field_desc['value']) {
$sql .= "(".$field_desc['value'].")";
$sql .= "(".$this->sanitize($field_desc['value']).")";
}
}
if ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL') {
if (isset($field_desc['value']) && ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL')) {
// We will try to change format of column to NOT NULL. To be sure the ALTER works, we try to update fields that are NULL
if ($field_desc['type'] == 'varchar' || $field_desc['type'] == 'text') {
$sqlbis = "UPDATE ".$table." SET ".$this->escape($field_name)." = '".$this->escape(isset($field_desc['default']) ? $field_desc['default'] : '')."' WHERE ".$this->escape($field_name)." IS NULL";
$sqlbis = "UPDATE ".$this->sanitize($table)." SET ".$this->escape($field_name)." = '".$this->escape(isset($field_desc['default']) ? $field_desc['default'] : '')."' WHERE ".$this->escape($field_name)." IS NULL";
$this->query($sqlbis);
} elseif ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
$sqlbis = "UPDATE ".$table." SET ".$this->escape($field_name)." = ".((int) $this->escape(isset($field_desc['default']) ? $field_desc['default'] : 0))." WHERE ".$this->escape($field_name)." IS NULL";
} elseif (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sqlbis = "UPDATE ".$this->sanitize($table)." SET ".$this->escape($field_name)." = ".((float) $this->escape(isset($field_desc['default']) ? $field_desc['default'] : 0))." WHERE ".$this->escape($field_name)." IS NULL";
$this->query($sqlbis);
}
}
if (isset($field_desc['default']) && $field_desc['default'] != '') {
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
$sql .= " DEFAULT ".$this->escape($field_desc['default']);
} elseif ($field_desc['type'] != 'text') {
$sql .= " DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
if (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sql .= ", ALTER COLUMN ".$this->sanitize($field_name)." SET DEFAULT ".((float) $field_desc['default']);
} elseif ($field_desc['type'] != 'text') { // Default not supported on text fields ?
$sql .= ", ALTER COLUMN ".$this->sanitize($field_name)." SET DEFAULT '".$this->escape($field_desc['default'])."'";
}
}
@ -1310,7 +1295,7 @@ class DoliDBPgsql extends DoliDB
// phpcs:enable
$tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name);
$sql = "ALTER TABLE ".$table." DROP COLUMN ".$tmp_field_name;
$sql = "ALTER TABLE ".$this->sanitize($table)." DROP COLUMN ".$this->sanitize($tmp_field_name);
if (!$this->query($sql)) {
$this->error = $this->lasterror();
return -1;
@ -1318,6 +1303,31 @@ class DoliDBPgsql extends DoliDB
return 1;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Create a user to connect to database
*
* @param string $dolibarr_main_db_host Ip server
* @param string $dolibarr_main_db_user Name of user to create
* @param string $dolibarr_main_db_pass Password of user to create
* @param string $dolibarr_main_db_name Database name where user must be granted
* @return int Return integer <0 if KO, >=0 if OK
*/
public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name)
{
// phpcs:enable
// Note: using ' on user does not works with pgsql
$sql = "CREATE USER ".$this->sanitize($dolibarr_main_db_user)." with password '".$this->escape($dolibarr_main_db_pass)."'";
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
$resql = $this->query($sql);
if (!$resql) {
return -1;
}
return 1;
}
/**
* Return charset used to store data in database
*

View file

@ -389,14 +389,14 @@ class DoliDBSqlite3 extends DoliDB
}
/**
* Execute a SQL request and return the resultset
* Execute a SQL request and return the resultset
*
* @param string $query SQL query string
* @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions).
* @param string $query SQL query string
* @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions).
* Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
* @param int $result_mode Result mode (not used with sqlite)
* @return bool|SQLite3Result Resultset of answer
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
* @param int $result_mode Result mode (not used with sqlite)
* @return bool|SQLite3Result|null Resultset of answer
*/
public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0)
{
@ -959,7 +959,7 @@ class DoliDBSqlite3 extends DoliDB
* Create a table into database
*
* @param string $table Nom de la table
* @param array $fields Tableau associatif [nom champ][tableau des descriptions]
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
@ -970,51 +970,62 @@ class DoliDBSqlite3 extends DoliDB
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null)
{
// phpcs:enable
// FIXME: $fulltext_keys parameter is unused
// @TODO: $fulltext_keys parameter is unused
$sqlfields = array();
$sqlk = array();
$sqluq = array();
// cles recherchees dans le tableau des descriptions (fields) : type,value,attribute,null,default,extra
// ex. : $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql = "create table ".$table."(";
// Keys found into the array $fields: type,value,attribute,null,default,extra
// ex. : $fields['rowid'] = array(
// 'type'=>'int' or 'integer',
// 'value'=>'11',
// 'null'=>'not null',
// 'extra'=> 'auto_increment'
// );
$sql = "CREATE TABLE ".$this->sanitize($table)."(";
$i = 0;
$sqlfields = array();
foreach ($fields as $field_name => $field_desc) {
$sqlfields[$i] = $field_name." ";
$sqlfields[$i] .= $field_desc['type'];
if (preg_match("/^[^\s]/i", $field_desc['value'])) {
$sqlfields[$i] .= "(".$field_desc['value'].")";
} elseif (preg_match("/^[^\s]/i", $field_desc['attribute'])) {
$sqlfields[$i] .= " ".$field_desc['attribute'];
} elseif (preg_match("/^[^\s]/i", $field_desc['default'])) {
if (preg_match("/null/i", $field_desc['default'])) {
$sqlfields[$i] .= " default ".$field_desc['default'];
$sqlfields[$i] = $this->sanitize($field_name)." ";
$sqlfields[$i] .= $this->sanitize($field_desc['type']);
if (!is_null($field_desc['value']) && $field_desc['value'] !== '') {
$sqlfields[$i] .= "(".$this->sanitize($field_desc['value']).")";
}
if (!is_null($field_desc['attribute']) && $field_desc['attribute'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['attribute']);
}
if (!is_null($field_desc['default']) && $field_desc['default'] !== '') {
if (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sqlfields[$i] .= " DEFAULT ".((float) $field_desc['default']);
} elseif ($field_desc['default'] == 'null' || $field_desc['default'] == 'CURRENT_TIMESTAMP') {
$sqlfields[$i] .= " DEFAULT ".$this->sanitize($field_desc['default']);
} else {
$sqlfields[$i] .= " default '".$this->escape($field_desc['default'])."'";
$sqlfields[$i] .= " DEFAULT '".$this->escape($field_desc['default'])."'";
}
} elseif (preg_match("/^[^\s]/i", $field_desc['null'])) {
$sqlfields[$i] .= " ".$field_desc['null'];
} elseif (preg_match("/^[^\s]/i", $field_desc['extra'])) {
$sqlfields[$i] .= " ".$field_desc['extra'];
}
if (!is_null($field_desc['null']) && $field_desc['null'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['null'], 0, 0, 1);
}
if (!is_null($field_desc['extra']) && $field_desc['extra'] !== '') {
$sqlfields[$i] .= " ".$this->sanitize($field_desc['extra'], 0, 0, 1);
}
$i++;
}
if ($primary_key != "") {
$pk = "primary key(".$primary_key.")";
$pk = "PRIMARY KEY(".$this->sanitize($primary_key).")";
}
if (is_array($unique_keys)) {
$i = 0;
foreach ($unique_keys as $key => $value) {
$sqluq[$i] = "UNIQUE KEY '".$key."' ('".$this->escape($value)."')";
$sqluq[$i] = "UNIQUE KEY '".$this->sanitize($key)."' ('".$this->escape($value)."')";
$i++;
}
}
if (is_array($keys)) {
$i = 0;
foreach ($keys as $key => $value) {
$sqlk[$i] = "KEY ".$key." (".$value.")";
$sqlk[$i] = "KEY ".$this->sanitize($key)." (".$value.")";
$i++;
}
}
@ -1022,19 +1033,20 @@ class DoliDBSqlite3 extends DoliDB
if ($primary_key != "") {
$sql .= ",".$pk;
}
if (is_array($unique_keys)) {
if ($unique_keys != "") {
$sql .= ",".implode(',', $sqluq);
}
if (is_array($keys)) {
$sql .= ",".implode(',', $sqlk);
}
$sql .= ") type=".$type;
$sql .= ")";
//$sql .= " engine=".$this->sanitize($type);
dol_syslog($sql, LOG_DEBUG);
if (!$this -> query($sql)) {
if (!$this->query($sql)) {
return -1;
} else {
return 1;
}
return 1;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -1082,7 +1094,7 @@ class DoliDBSqlite3 extends DoliDB
*
* @param string $table Table name
* @param string $field_name Field name to add
* @param string $field_desc Associative table with description of field to insert [parameter name][parameter value]
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Associative table with description of field to insert [parameter name][parameter value]
* @param string $field_position Optional e.g.: "after some_field"
* @return int Return integer <0 if KO, >0 if OK
*/
@ -1093,28 +1105,30 @@ class DoliDBSqlite3 extends DoliDB
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql = "ALTER TABLE ".$table." ADD ".$field_name." ";
$sql .= $field_desc['type'];
if (preg_match("/^[^\s]/i", $field_desc['value'])) {
if (isset($field_desc['value']) && preg_match("/^[^\s]/i", $field_desc['value'])) {
if (!in_array($field_desc['type'], array('date', 'datetime'))) {
$sql .= "(".$field_desc['value'].")";
}
}
if (preg_match("/^[^\s]/i", $field_desc['attribute'])) {
$sql .= " ".$field_desc['attribute'];
if (isset($field_desc['attribute']) && preg_match("/^[^\s]/i", $field_desc['attribute'])) {
$sql .= " ".$this->sanitize($field_desc['attribute']);
}
if (preg_match("/^[^\s]/i", $field_desc['null'])) {
$sql .= " ".$field_desc['null'];
if (isset($field_desc['null']) && preg_match("/^[^\s]/i", $field_desc['null'])) {
$sql .= " ".$this->sanitize($field_desc['null'], 0, 0, 1);
}
if (preg_match("/^[^\s]/i", $field_desc['default'])) {
if (preg_match("/null/i", $field_desc['default'])) {
$sql .= " default ".$field_desc['default'];
if (isset($field_desc['default']) && preg_match("/^[^\s]/i", $field_desc['default'])) {
if (in_array($field_desc['type'], array('tinyint', 'smallint', 'int', 'double'))) {
$sql .= " DEFAULT ".((float) $field_desc['default']);
} elseif ($field_desc['default'] == 'null' || $field_desc['default'] == 'CURRENT_TIMESTAMP') {
$sql .= " DEFAULT ".$this->sanitize($field_desc['default']);
} else {
$sql .= " default '".$this->escape($field_desc['default'])."'";
$sql .= " DEFAULT '".$this->escape($field_desc['default'])."'";
}
}
if (preg_match("/^[^\s]/i", $field_desc['extra'])) {
$sql .= " ".$field_desc['extra'];
if (isset($field_desc['extra']) && preg_match("/^[^\s]/i", $field_desc['extra'])) {
$sql .= " ".$this->sanitize($field_desc['extra'], 0, 0, 1);
}
$sql .= " ".$field_position;
$sql .= " ".$this->sanitize($field_position, 0, 0, 1);
dol_syslog(get_class($this)."::DDLAddField ".$sql, LOG_DEBUG);
if (!$this->query($sql)) {
@ -1129,16 +1143,16 @@ class DoliDBSqlite3 extends DoliDB
*
* @param string $table Name of table
* @param string $field_name Name of field to modify
* @param string $field_desc Array with description of field format
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Array with description of field format
* @return int Return integer <0 if KO, >0 if OK
*/
public function DDLUpdateField($table, $field_name, $field_desc)
{
// phpcs:enable
$sql = "ALTER TABLE ".$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type'];
$sql = "ALTER TABLE ".$this->sanitize($table);
$sql .= " MODIFY COLUMN ".$this->sanitize($field_name)." ".$this->sanitize($field_desc['type']);
if ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') {
$sql .= "(".$field_desc['value'].")";
$sql .= "(".$this->sanitize($field_desc['value']).")";
}
dol_syslog(get_class($this)."::DDLUpdateField ".$sql, LOG_DEBUG);
@ -1161,7 +1175,7 @@ class DoliDBSqlite3 extends DoliDB
// phpcs:enable
$tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name);
$sql = "ALTER TABLE ".$table." DROP COLUMN `".$tmp_field_name."`";
$sql = "ALTER TABLE ".$this->sanitize($table)." DROP COLUMN `".$this->sanitize($tmp_field_name)."`";
if (!$this->query($sql)) {
$this->error = $this->lasterror();
return -1;

View file

@ -1005,7 +1005,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
* @param int $timestampEnd Timestamp end UTC
* @param int $lastday Last day is included, 0: no, 1:yes
* @return int Number of days
* @seealso num_public_holiday(), num_open_day()
* @see also num_public_holiday(), num_open_day()
*/
function num_between_day($timestampStart, $timestampEnd, $lastday = 0)
{
@ -1016,6 +1016,8 @@ function num_between_day($timestampStart, $timestampEnd, $lastday = 0)
$bit = 1;
}
$nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit;
} else {
$nbjours = 0;
}
//print ($timestampEnd - $timestampStart) - $lastday;
return $nbjours;

View file

@ -1424,6 +1424,9 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
$maskuser_maskafter = $maskuser_value;
$numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal);
}
} else {
$numFinal = "ErrorBadMode";
dol_syslog("functions2::get_next_value ErrorBadMode '$mode'", LOG_ERR);
}
dol_syslog("functions2::get_next_value return ".$numFinal, LOG_DEBUG);

View file

@ -1288,12 +1288,12 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul
}
$columns = array(
'rowid' => array('type' => 'integer(11)'),
'code' => array('type' => 'varchar(255) NOT NULL'),
'label' => array('type' => 'varchar(255) NOT NULL'),
'position' => array('type' => 'integer(11) NULL'),
'use_default' => array('type' => 'varchar(255) DEFAULT 1'),
'active' => array('type' => 'integer')
'rowid' => array('type' => 'integer', 'value' => 11, 'extra' => 'AUTO_INCREMENT PRIMARY KEY'),
'code' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'),
'label' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'),
'position' => array('type' => 'integer', 'value' => 11, 'null'=>'NULL'),
'use_default' => array('type' => 'varchar', 'value' => 11, 'default'=>'1'),
'active' => array('type' => 'integer', 'value' => 3)
);
@ -1308,14 +1308,16 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul
break;
}
}
// check if tablename exist in Database and create it if not
$query = "SHOW TABLES LIKE '" . MAIN_DB_PREFIX.strtolower($namedic) . "'";
// @FIXME We must use $db->DDLDescTable($table) to know if a table exists.
$query = "SHOW TABLES LIKE '" . $db->escape(MAIN_DB_PREFIX.strtolower($namedic)) . "'";
$checkTable = $db->query($query);
if ($checkTable && $db->num_rows($checkTable) > 0) {
setEventMessages($langs->trans("ErrorTableExist", $namedic), null, 'errors');
return;
} else {
$_results = $db->DDLCreateTable(MAIN_DB_PREFIX.strtolower($namedic), $columns, $primaryKey, "InnoDB");
$_results = $db->DDLCreateTable(MAIN_DB_PREFIX.strtolower($namedic), $columns, $primaryKey, "");
if ($_results < 0) {
dol_print_error($db);
$langs->load("errors");

View file

@ -1018,6 +1018,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$outputlangs->load("dict");
$line = '';
$reg = array();
$marginwithfooter = 0; // Return value
$dims = $pdf->getPageDimensions();
@ -1356,9 +1357,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
if (getDolGlobalString('PDF_USE_GETALIASNBPAGE_FOR_TOTAL')) {
// $pagination = $pdf->getAliasNumPage().' / '.$pdf->getAliasNbPages(); // works with $pdf->Cell
$pagination = $pdf->PageNo().' / '.$pdf->getAliasNbPages(); // seems to not works with all fonts like ru_UK
$pagination = $pdf->PageNo().' / '.$pdf->getAliasNbPages(); // seems to not work with all fonts like ru_UK
} else {
$pagination = $pdf->PageNo().' / '.$pdf->getNumPages(); // seems to always work even with $pdf->Cell. But some users has reported wrong nb (no way to reproduce)
$pagination = $pdf->PageNo().' / '.$pdf->getNumPages(); // seems to always work even with $pdf->Cell. But some users have reported wrong nb (no way to reproduce)
}
$pdf->MultiCell(18, 2, $pagination, 0, 'R', 0);

View file

@ -837,6 +837,8 @@ function getStructuredData($type, $data = array())
}
}'."\n";
$ret .= '</script>'."\n";
} else {
$ret = '';
}
return $ret;
}

View file

@ -806,6 +806,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
} else {
$content = nl2br($content);
}
} else {
$content = '';
}
return $content;
@ -1124,7 +1126,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
*
* @param string $reldir Relative directory where to scan files. Example: '/install/mysql/' or '/module/sql/'
* @param string $onlywithsuffix Only with the defined suffix
* @return int Return integer <=0 if KO, >0 if OK
* @return int<0,1> Return integer <=0 if KO, >0 if OK
*/
protected function _load_tables($reldir, $onlywithsuffix = '')
{
@ -1133,6 +1135,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$error = 0;
$dirfound = 0;
$ok = 1;
if (empty($reldir)) {
return 1;
@ -1140,9 +1143,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$ok = 1;
foreach ($conf->file->dol_document_root as $dirroot) {
if ($ok) {
if ($ok == 1) {
$dirsql = $dirroot.$reldir;
$ok = 0;
@ -1293,7 +1295,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
}
if (!$dirfound) {
dol_syslog("A module ask to load sql files into ".$reldir." but this directory was not found.", LOG_WARNING);
dol_syslog("A module wants to load sql files from ".$reldir." but this directory was not found.", LOG_WARNING);
}
return $ok;
}

View file

@ -243,7 +243,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$object->fetch_thirdparty();
$dir = $conf->facture->dir_output;
$dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/".$objectref;

View file

@ -241,7 +241,7 @@ class modReception extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
}
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_elementdet = cd.rowid';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('reception').')';
if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);

View file

@ -66,7 +66,7 @@ class pdf_standard extends ModelePDFMovement
global $conf, $langs, $mysoc;
// Load traductions files required by page
$langs->loadLangs(array("main", "companies"));
$langs->loadLangs(array("main", "companies", "productbatch"));
$this->db = $db;
$this->name = "stdmouvement";
@ -861,7 +861,7 @@ class pdf_standard extends ModelePDFMovement
//$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxqty, $tab_top + 1);
$pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '', 'C');
$pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Batch"), '', 'C');
}
//Code Inv

View file

@ -255,13 +255,14 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator
* @param DoliDB $db Database handler
* @param Societe $societe Third party object
* @param string $type 'customer' or 'supplier'
* @return int >=0 if OK, <0 if KO
* @return int<-1,1> >=0 if success, -1 if failure
*/
public function get_code($db, $societe, $type = '')
{
// phpcs:enable
global $langs;
return $langs->trans("NotAvailable");
dol_syslog(get_class($this)."::get_code".$langs->trans("NotAvailable"), LOG_ERR);
return -1;
}
}

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -494,7 +495,7 @@ class TraceableDB extends DoliDB
* Create a table into database
*
* @param string $table Name of table
* @param array $fields Tableau associatif [nom champ][tableau des descriptions]
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string}> $fields Associative table [field name][table of descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
@ -533,7 +534,7 @@ class TraceableDB extends DoliDB
*
* @param string $table Name of table
* @param string $field_name Name of field to add
* @param string $field_desc Tableau associatif de description du champ a inserer[nom du parameter][valeur du parameter]
* @param array{type:string,label:string,enabled:int|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Tableau associatif de description du champ a inserer[nom du parameter][valeur du parameter]
* @param string $field_position Optionnel ex.: "after champtruc"
* @return int Return integer <0 if KO, >0 if OK
*/
@ -559,7 +560,7 @@ class TraceableDB extends DoliDB
*
* @param string $table Name of table
* @param string $field_name Name of field to modify
* @param string $field_desc Array with description of field format
* @param array{type:string,label:string,enabled:int|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $field_desc Array with description of field format
* @return int Return integer <0 if KO, >0 if OK
*/
public function DDLUpdateField($table, $field_name, $field_desc)

View file

@ -352,7 +352,7 @@ class Don extends CommonObject
$err++;
} else {
if ($this->amount < $minimum && $minimum > 0) {
$error_string[] = $langs->trans('MinimumAmount', $langs->transnoentitiesnoconv('$minimum'));
$error_string[] = $langs->trans('MinimumAmount', $minimum);
$err++;
}
}

View file

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -98,6 +99,7 @@ $arrayfields = array(
'pd.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 80),
);
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
$optioncss = GETPOST('optioncss', 'alpha');
$moreforfilter = GETPOST('moreforfilter', 'alpha');

View file

@ -969,7 +969,7 @@ class ConferenceOrBoothAttendee extends CommonObject
$dir = dol_buildpath($reldir."core/modules/eventorganization/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -306,7 +306,7 @@ class Expedition extends CommonObject
$dir = dol_buildpath($reldir."core/modules/expedition/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if (!$mybool) {

View file

@ -773,10 +773,6 @@ if ($object->id > 0 || !empty($object->ref)) {
print '</td>'; // Dispatch column
print '<td></td>'; // Warehouse column
/*$sql = "SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
$sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as cfd";
$sql .= " WHERE cfd.fk_commandefourndet = ".(int) $objp->rowid;*/
$sql = "SELECT ed.rowid, ed.qty, ed.fk_entrepot,";
$sql .= " eb.batch, eb.eatby, eb.sellby, cd.fk_product";
$sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";

View file

@ -6,6 +6,7 @@
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2023 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -145,6 +146,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Security check
$expeditionid = GETPOSTINT('id');

View file

@ -1729,7 +1729,7 @@ class ExpenseReport extends CommonObject
$dir = dol_buildpath($reldir."core/modules/expensereport/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -112,6 +112,7 @@ $arrayfields = array(
'pndf.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 70),
);
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('paymentexpensereportlist'));

View file

@ -200,17 +200,17 @@ class Fichinter extends CommonObject
/*
* Signed by sender
*/
CONST STATUS_SIGNED_SENDER = 1;
const STATUS_SIGNED_SENDER = 1;
/*
* Signed by receiver
*/
CONST STATUS_SIGNED_RECEIVER = 2;
const STATUS_SIGNED_RECEIVER = 2;
/*
* Signed by all
*/
CONST STATUS_SIGNED_ALL = 9; // To handle future kind of signature (ex: tripartite contract)
const STATUS_SIGNED_ALL = 9; // To handle future kind of signature (ex: tripartite contract)
/**
* Date delivery
@ -1010,7 +1010,7 @@ class Fichinter extends CommonObject
$dir = dol_buildpath($reldir."core/modules/fichinter/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -9,6 +9,7 @@
* Copyright (C) 2021-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Charlène Benke <charlene@patas-monkey.com>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -149,6 +150,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Security check
$id = GETPOSTINT('id');

View file

@ -1129,7 +1129,7 @@ class CommandeFournisseur extends CommonOrder
$dir = dol_buildpath($reldir."core/modules/supplier_order/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
@ -2252,7 +2252,7 @@ class CommandeFournisseur extends CommonOrder
$this->db->begin();
$sql = "INSERT INTO ".$this->db->prefix()."receptiondet_batch";
$sql .= " (fk_commande, fk_product, qty, fk_entrepot, fk_user, datec, fk_commandefourndet, status, comment, eatby, sellby, batch, fk_reception) VALUES";
$sql .= " (fk_element, fk_product, qty, fk_entrepot, fk_user, datec, fk_elementdet, status, comment, eatby, sellby, batch, fk_reception) VALUES";
$sql .= " ('".$this->id."','".$product."','".$qty."',".($entrepot > 0 ? "'".$entrepot."'" : "null").",'".$user->id."','".$this->db->idate($now)."','".$fk_commandefourndet."', ".$dispatchstatus.", '".$this->db->escape($comment)."', ";
$sql .= ($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ".($batch ? "'".$this->db->escape($batch)."'" : "null").", ".($fk_reception > 0 ? "'".$this->db->escape($fk_reception)."'" : "null");
$sql .= ")";
@ -2497,11 +2497,11 @@ class CommandeFournisseur extends CommonOrder
// List of already dispatched lines
$sql = "SELECT p.ref, p.label,";
$sql .= " e.rowid as warehouse_id, e.ref as entrepot,";
$sql .= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.fk_commandefourndet";
$sql .= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.fk_elementdet";
$sql .= " FROM ".$this->db->prefix()."product as p,";
$sql .= " ".$this->db->prefix()."receptiondet_batch as cfd";
$sql .= " LEFT JOIN ".$this->db->prefix()."entrepot as e ON cfd.fk_entrepot = e.rowid";
$sql .= " WHERE cfd.fk_commande = ".((int) $this->id);
$sql .= " WHERE cfd.fk_element = ".((int) $this->id);
$sql .= " AND cfd.fk_product = p.rowid";
if ($status >= 0) {
$sql .= " AND cfd.status = ".((int) $status);
@ -2521,7 +2521,7 @@ class CommandeFournisseur extends CommonOrder
'productid' => $objp->fk_product,
'warehouseid' => $objp->warehouse_id,
'qty' => $objp->qty,
'orderlineid' => $objp->fk_commandefourndet
'orderlineid' => $objp->fk_elementdet
);
}
@ -3534,7 +3534,7 @@ class CommandeFournisseur extends CommonOrder
$supplierorderdispatch = new CommandeFournisseurDispatch($this->db);
$filter = array('t.fk_commande' => $this->id);
$filter = array('t.fk_element' => $this->id);
if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS')) {
$filter['t.status'] = 1; // Restrict to lines with status validated
}
@ -3670,7 +3670,7 @@ class CommandeFournisseur extends CommonOrder
if ($filtre_statut >= 0) {
$sql .= ' cfd.fk_reception = e.rowid AND';
}
$sql .= ' cfd.fk_commandefourndet = cd.rowid';
$sql .= ' cfd.fk_elementdet = cd.rowid';
$sql .= ' AND cd.fk_commande ='.((int) $this->id);
if (isset($this->fk_product) && !empty($this->fk_product) > 0) {
$sql .= ' AND cd.fk_product = '.((int) $this->fk_product);

View file

@ -3,6 +3,7 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Christophe Battarel <christophe@altairis.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
@ -26,118 +27,28 @@
*/
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php";
require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php";
require_once DOL_DOCUMENT_ROOT."/reception/class/receptionlinebatch.class.php";
/**
* Class to manage table commandefournisseurdispatch
* Class to manage table ReceptionLineBatch.
* Old name was CommandeFournisseurDispatch. This is a transition class.
*/
class CommandeFournisseurDispatch extends CommonObjectLine
class CommandeFournisseurDispatch extends ReceptionLineBatch
{
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var string Error code (or message)
*/
public $error;
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
/**
* @var string ID to identify managed object
*/
public $element = 'commandefournisseurdispatch';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'receptiondet_batch'; //!< Name of table without prefix where object is stored
public $lines = array();
/**
* @var int ID
*/
public $id;
/**
* @var int ID
*/
public $fk_commande;
/**
* @var int ID
*/
public $fk_product;
/**
* @var int ID. Should be named fk_origin_line ?
*/
public $fk_commandefourndet;
public $fk_reception;
public $qty;
public $qty_asked;
public $libelle;
public $label;
public $desc;
public $tva_tx;
public $vat_src_code;
public $ref_supplier;
/**
* @var int ID
*/
public $fk_entrepot;
/**
* @var int User ID
*/
public $fk_user;
public $datec = '';
public $comment;
/**
* @var int Status
*/
public $status;
public $batch;
public $eatby = '';
public $sellby = '';
public $cost_price = 0;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
// List of language codes for status
$this->labelStatus[0] = 'Received';
$this->labelStatus[1] = 'Verified';
$this->labelStatus[2] = 'Denied';
$this->labelStatusShort[0] = 'Received';
$this->labelStatusShort[1] = 'Verified';
$this->labelStatusShort[2] = 'Denied';
}
/**
* Create object into database
@ -148,126 +59,12 @@ class CommandeFournisseurDispatch extends CommonObjectLine
*/
public function create($user, $notrigger = 0)
{
global $conf, $langs, $hookmanager;
$error = 0;
$this->fk_element = $this->fk_commande;
$this->fk_elementdet = $this->fk_commandefourndet;
// Clean parameters
if (isset($this->fk_commande)) {
$this->fk_commande = (int) $this->fk_commande;
}
if (isset($this->fk_product)) {
$this->fk_product = (int) $this->fk_product;
}
if (isset($this->fk_commandefourndet)) {
$this->fk_commandefourndet = (int) $this->fk_commandefourndet;
}
if (isset($this->qty)) {
$this->qty = trim((string) $this->qty);
}
if (isset($this->fk_entrepot)) {
$this->fk_entrepot = (int) $this->fk_entrepot;
}
if (isset($this->fk_user)) {
$this->fk_user = (int) $this->fk_user;
}
if (isset($this->comment)) {
$this->comment = trim($this->comment);
}
if (isset($this->status)) {
$this->status = (int) $this->status;
}
if (isset($this->batch)) {
$this->batch = trim($this->batch);
}
if (empty($this->datec)) {
$this->datec = dol_now();
}
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
$sql .= "fk_commande,";
$sql .= "fk_product,";
$sql .= "fk_commandefourndet,";
$sql .= "qty,";
$sql .= "fk_entrepot,";
$sql .= "fk_user,";
$sql .= "datec,";
$sql .= "comment,";
$sql .= "status,";
$sql .= "batch,";
$sql .= "eatby,";
$sql .= "sellby,";
$sql .= "fk_reception,";
$sql .= "cost_price";
$sql .= ") VALUES (";
$sql .= " ".(!isset($this->fk_commande) ? 'NULL' : "'".$this->db->escape($this->fk_commande)."'").",";
$sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").",";
$sql .= " ".(!isset($this->fk_commandefourndet) ? 'NULL' : "'".$this->db->escape($this->fk_commandefourndet)."'").",";
$sql .= " ".(!isset($this->qty) ? 'NULL' : "'".$this->db->escape($this->qty)."'").",";
$sql .= " ".(!isset($this->fk_entrepot) ? 'NULL' : "'".$this->db->escape($this->fk_entrepot)."'").",";
$sql .= " ".(!isset($this->fk_user) ? 'NULL' : "'".$this->db->escape($this->fk_user)."'").",";
$sql .= " ".(!isset($this->datec) || dol_strlen($this->datec) == 0 ? 'NULL' : "'".$this->db->idate($this->datec)."'").",";
$sql .= " ".(!isset($this->comment) ? 'NULL' : "'".$this->db->escape($this->comment)."'").",";
$sql .= " ".(!isset($this->status) ? 'NULL' : "'".$this->db->escape($this->status)."'").",";
$sql .= " ".(!isset($this->batch) ? 'NULL' : "'".$this->db->escape($this->batch)."'").",";
$sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").",";
$sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").",";
$sql .= " ".(!isset($this->fk_reception) ? 'NULL' : "'".$this->db->escape($this->fk_reception)."'").",";
$sql .= " ".(!isset($this->cost_price) ? '0' : "'".$this->db->escape($this->cost_price)."'");
$sql .= ")";
$this->db->begin();
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
if (!$notrigger) {
// Call triggers
$result = $this->call_trigger('LINERECEPTION_CREATE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
}
// Create extrafields
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
} else {
$this->db->commit();
return $this->id;
}
return parent::create($user, $notrigger);
}
/**
* Load object in memory from the database
*
@ -277,68 +74,14 @@ class CommandeFournisseurDispatch extends CommonObjectLine
*/
public function fetch($id, $ref = '')
{
global $langs;
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.fk_commande,";
$sql .= " t.fk_product,";
$sql .= " t.fk_commandefourndet,";
$sql .= " t.qty,";
$sql .= " t.fk_entrepot,";
$sql .= " t.fk_user,";
$sql .= " t.datec,";
$sql .= " t.comment,";
$sql .= " t.status,";
$sql .= " t.tms,";
$sql .= " t.batch,";
$sql .= " t.eatby,";
$sql .= " t.sellby,";
$sql .= " t.fk_reception";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
if ($ref) {
$sql .= " WHERE t.ref = '".$this->db->escape($ref)."'";
} else {
$sql .= " WHERE t.rowid = ".((int) $id);
}
dol_syslog(get_class($this)."::fetch");
$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->fk_commande = $obj->fk_commande;
$this->fk_product = $obj->fk_product;
$this->fk_commandefourndet = $obj->fk_commandefourndet;
$this->qty = $obj->qty;
$this->fk_entrepot = $obj->fk_entrepot;
$this->fk_user = $obj->fk_user;
$this->datec = $this->db->jdate($obj->datec);
$this->comment = $obj->comment;
$this->status = $obj->status;
$this->tms = $this->db->jdate($obj->tms);
$this->batch = $obj->batch;
$this->eatby = $this->db->jdate($obj->eatby);
$this->sellby = $this->db->jdate($obj->sellby);
$this->fk_reception = $obj->fk_reception;
$this->fetch_optionals();
}
$this->db->free($resql);
return 1;
} else {
$this->error = "Error ".$this->db->lasterror();
return -1;
$ret = parent::fetch($id, $ref);
if ($ret > 0) {
$this->fk_commande = $this->fk_element;
$this->fk_commandefourndet = $this->fk_elementdet;
}
return $ret;
}
/**
* Update object into database
*
@ -348,408 +91,9 @@ class CommandeFournisseurDispatch extends CommonObjectLine
*/
public function update($user, $notrigger = 0)
{
$error = 0;
$this->fk_element = $this->fk_commande;
$this->fk_elementdet = $this->fk_commandefourndet;
// Clean parameters
if (isset($this->fk_commande)) {
$this->fk_commande = (int) $this->fk_commande;
}
if (isset($this->fk_product)) {
$this->fk_product = (int) $this->fk_product;
}
if (isset($this->fk_commandefourndet)) {
$this->fk_commandefourndet = (int) $this->fk_commandefourndet;
}
if (isset($this->qty)) {
$this->qty = trim($this->qty);
}
if (isset($this->fk_entrepot)) {
$this->fk_entrepot = (int) $this->fk_entrepot;
}
if (isset($this->fk_user)) {
$this->fk_user = (int) $this->fk_user;
}
if (isset($this->comment)) {
$this->comment = trim($this->comment);
}
if (isset($this->status)) {
$this->status = (int) $this->status;
}
if (isset($this->batch)) {
$this->batch = trim($this->batch);
}
// Check parameters
// Put here code to add a control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql .= " fk_commande=".(isset($this->fk_commande) ? $this->fk_commande : "null").",";
$sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").",";
$sql .= " fk_commandefourndet=".(isset($this->fk_commandefourndet) ? $this->fk_commandefourndet : "null").",";
$sql .= " qty=".(isset($this->qty) ? $this->qty : "null").",";
$sql .= " fk_entrepot=".(isset($this->fk_entrepot) ? $this->fk_entrepot : "null").",";
$sql .= " fk_user=".(isset($this->fk_user) ? $this->fk_user : "null").",";
$sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql .= " comment=".(isset($this->comment) ? "'".$this->db->escape($this->comment)."'" : "null").",";
$sql .= " status=".(isset($this->status) ? $this->status : "null").",";
$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
$sql .= " batch=".(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").",";
$sql .= " eatby=".(dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').",";
$sql .= " sellby=".(dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null');
$sql .= " WHERE rowid=".((int) $this->id);
$this->db->begin();
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error) {
if (!$error) {
if (empty($this->id) && !empty($this->rowid)) {
$this->id = $this->rowid;
}
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
if (!$notrigger) {
// Call triggers
$result = $this->call_trigger('LINERECEPTION_MODIFY', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
}
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that deletes
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int Return integer <0 if KO, >0 if OK
*/
public function delete($user, $notrigger = 0)
{
$error = 0;
$this->db->begin();
if (!$error) {
if (!$notrigger) {
// Call triggers
$result = $this->call_trigger('LINERECEPTION_DELETE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
}
// Remove extrafields
if (!$error) {
$result = $this->deleteExtraFields();
if ($result < 0) {
$error++;
dol_syslog(get_class($this)."::delete error deleteExtraFields ".$this->error, LOG_ERR);
}
}
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " WHERE rowid=".((int) $this->id);
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
}
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Load an object from its id and create a new one in database
*
* @param User $user User making the clone
* @param int $fromid Id of object to clone
* @return int New id of clone
*/
public function createFromClone(User $user, $fromid)
{
$error = 0;
$object = new CommandeFournisseurDispatch($this->db);
$this->db->begin();
// Load source object
$object->fetch($fromid);
$object->id = 0;
$object->statut = 0;
// Clear fields
// ...
// Create clone
$object->context['createfromclone'] = 'createfromclone';
$result = $object->create($user);
// Other options
if ($result < 0) {
$this->error = $object->error;
$error++;
}
if (!$error) {
}
unset($object->context['createfromclone']);
// End
if (!$error) {
$this->db->commit();
return $object->id;
} else {
$this->db->rollback();
return -1;
}
}
/**
* Return label of the status of object
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto
* @return string Label
*/
public function getLibStatut($mode = 0)
{
return $this->LibStatut($this->status, $mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return label of a status
*
* @param int $status Id status
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto
* @return string Label of status
*/
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;
$langs->load('orders');
if ($mode == 0) {
return $langs->trans($this->labelStatus[$status]);
} elseif ($mode == 1) {
return $langs->trans($this->labelStatusShort[$status]);
} elseif ($mode == 2) {
return $langs->trans($this->labelStatus[$status]);
} elseif ($mode == 3) {
if ($status == 0) {
return img_picto($langs->trans($this->labelStatus[$status]), 'statut0');
} elseif ($status == 1) {
return img_picto($langs->trans($this->labelStatus[$status]), 'statut4');
} elseif ($status == 2) {
return img_picto($langs->trans($this->labelStatus[$status]), 'statut8');
}
} elseif ($mode == 4) {
if ($status == 0) {
return img_picto($langs->trans($this->labelStatus[$status]), 'statut0').' '.$langs->trans($this->labelStatus[$status]);
} elseif ($status == 1) {
return img_picto($langs->trans($this->labelStatus[$status]), 'statut4').' '.$langs->trans($this->labelStatus[$status]);
} elseif ($status == 2) {
return img_picto($langs->trans($this->labelStatus[$status]), 'statut8').' '.$langs->trans($this->labelStatus[$status]);
}
} elseif ($mode == 5) {
if ($status == 0) {
return '<span class="hideonsmartphone">'.$langs->trans($this->labelStatusShort[$status]).' </span>'.img_picto($langs->trans($this->labelStatus[$status]), 'statut0');
} elseif ($status == 1) {
return '<span class="hideonsmartphone">'.$langs->trans($this->labelStatusShort[$status]).' </span>'.img_picto($langs->trans($this->labelStatus[$status]), 'statut4');
} elseif ($status == 2) {
return '<span class="hideonsmartphone">'.$langs->trans($this->labelStatusShort[$status]).' </span>'.img_picto($langs->trans($this->labelStatus[$status]), 'statut8');
}
}
return "";
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
*
* @return int
*/
public function initAsSpecimen()
{
$this->id = 0;
$this->fk_commande = 0;
$this->fk_product = 0;
$this->fk_commandefourndet = 0;
$this->qty = '';
$this->fk_entrepot = 0;
$this->fk_user = 0;
$this->datec = '';
$this->comment = '';
$this->status = 0;
$this->tms = dol_now();
$this->batch = '';
$this->eatby = '';
$this->sellby = '';
return 1;
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset offset limit
* @param string|array $filter filter array
* @param string $filtermode filter mode (AND or OR)
* @return int Return integer <0 if KO, >0 if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.fk_commande,";
$sql .= " t.fk_product,";
$sql .= " t.fk_commandefourndet,";
$sql .= " t.qty,";
$sql .= " t.fk_entrepot,";
$sql .= " t.fk_user,";
$sql .= " t.datec,";
$sql .= " t.comment,";
$sql .= " t.status,";
$sql .= " t.tms,";
$sql .= " t.batch,";
$sql .= " t.eatby,";
$sql .= " t.sellby";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
// Manage filter
if (is_array($filter)) {
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 't.comment') {
$sqlwhere [] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'";
} elseif ($key == 't.datec' || $key == 't.tms' || $key == 't.eatby' || $key == 't.sellby' || $key == 't.batch') {
$sqlwhere [] = $this->db->sanitize($key)." = '".$this->db->escape($value)."'";
} elseif ($key == 'qty') {
$sqlwhere [] = $this->db->sanitize($key)." = ".((float) $value);
} else {
$sqlwhere [] = $this->db->sanitize($key)." = ".((int) $value);
}
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere);
}
$filter = '';
}
// Manage filter
$errormessage = '';
$sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
if ($errormessage) {
$this->errors[] = $errormessage;
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
return -1;
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (!empty($limit)) {
$sql .= $this->db->plimit($limit, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new self($this->db);
$line->id = $obj->rowid;
$line->fk_commande = $obj->fk_commande;
$line->fk_product = $obj->fk_product;
$line->fk_commandefourndet = $obj->fk_commandefourndet;
$line->qty = $obj->qty;
$line->fk_entrepot = $obj->fk_entrepot;
$line->fk_user = $obj->fk_user;
$line->datec = $this->db->jdate($obj->datec);
$line->comment = $obj->comment;
$line->status = $obj->status;
$line->tms = $this->db->jdate($obj->tms);
$line->batch = $obj->batch;
$line->eatby = $this->db->jdate($obj->eatby);
$line->sellby = $this->db->jdate($obj->sellby);
$line->fetch_optionals();
$this->lines[$line->id] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
return -1;
}
return parent::update($user, $notrigger);
}
}

View file

@ -2963,7 +2963,7 @@ class FactureFournisseur extends CommonInvoice
$dir = dol_buildpath($reldir."core/modules/supplier_invoice/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -10,6 +10,7 @@
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
* Copyright (C) 2023 Sylvain Legrand <technique@infras.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -279,9 +280,9 @@ class PaiementFourn extends Paiement
// If we want to closed paid invoices
if ($closepaidinvoices) {
$paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed();
$creditnotes = $invoice->getSumCreditNotesUsed();
//$creditnotes = 0;
$deposits=$invoice->getSumDepositsUsed();
$deposits = $invoice->getSumDepositsUsed();
//$deposits = 0;
$alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
$remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
@ -712,7 +713,7 @@ class PaiementFourn extends Paiement
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$parameters = array('id' => $this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
@ -783,7 +784,7 @@ class PaiementFourn extends Paiement
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir.$file;
$mybool = (include_once $dir.$file) || $mybool;
}
}
@ -798,7 +799,7 @@ class PaiementFourn extends Paiement
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir.$file;
$mybool = (include_once $dir.$file) || $mybool;
}
}
}

View file

@ -669,8 +669,8 @@ if ($id > 0 || !empty($ref)) {
$products_dispatched = array();
$sql = "SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as cfd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet";
$sql .= " WHERE cfd.fk_commande = ".((int) $object->id);
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as l on l.rowid = cfd.fk_elementdet";
$sql .= " WHERE cfd.fk_element = ".((int) $object->id);
$sql .= " GROUP BY l.rowid, cfd.fk_product";
$resql = $db->query($sql);
@ -1172,12 +1172,12 @@ if ($id > 0 || !empty($ref)) {
}
$sql .= " FROM ".MAIN_DB_PREFIX."product as p,";
$sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as cfd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cd ON cd.rowid = cfd.fk_commandefourndet";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cd ON cd.rowid = cfd.fk_elementdet";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
if ($conf->reception->enabled) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid";
}
$sql .= " WHERE cfd.fk_commande = ".((int) $object->id);
$sql .= " WHERE cfd.fk_element = ".((int) $object->id);
$sql .= " AND cfd.fk_product = p.rowid";
$sql .= " ORDER BY cfd.rowid ASC";

View file

@ -10,6 +10,7 @@
* Copyright (C) 2018-2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2019 Nicolas Zabouri <info@inovea-conseil.com>
* Copyright (C) 2021-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -211,6 +212,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
$error = 0;

View file

@ -8,6 +8,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -159,6 +160,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
if ($socid > 0) {
$tmpthirdparty = new Societe($db);

View file

@ -212,6 +212,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
if (!isModEnabled('supplier_invoice')) {
accessforbidden();

View file

@ -12,6 +12,7 @@
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -107,6 +108,7 @@ $arrayfields = array(
'p.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 70),
);
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('paymentsupplierlist'));

View file

@ -232,7 +232,7 @@ class Holiday extends CommonObject
$dir = dol_buildpath($reldir."core/modules/holiday/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -952,7 +952,7 @@ class Evaluation extends CommonObject
$dir = dol_buildpath($reldir."core/modules/hrm/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -922,7 +922,7 @@ class EvaluationLine extends CommonObjectLine
$dir = dol_buildpath($reldir."core/modules/hrm/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -961,7 +961,7 @@ class Job extends CommonObject
$dir = dol_buildpath($reldir."core/modules/hrm/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -1001,7 +1001,7 @@ class Position extends CommonObject
$dir = dol_buildpath($reldir . "core/modules/hrm/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir . $file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -1001,7 +1001,7 @@ class Skill extends CommonObject
$dir = dol_buildpath($reldir."core/modules/hrm/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -889,7 +889,7 @@ class Skilldet extends CommonObjectLine
$dir = dol_buildpath($reldir."core/modules/hrm/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -965,7 +965,7 @@ class SkillRank extends CommonObject
$dir = dol_buildpath($reldir."core/modules/hrm/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

View file

@ -283,3 +283,6 @@ ALTER TABLE llx_societe ADD COLUMN fk_parent integer NULL;
ALTER TABLE llx_expeditiondet ADD COLUMN fk_element integer;
ALTER TABLE llx_expeditiondet ADD COLUMN element_type varchar(50) DEFAULT 'order' NOT NULL;
ALTER TABLE llx_receptiondet_batch CHANGE COLUMN fk_commande fk_element integer;
ALTER TABLE llx_receptiondet_batch CHANGE COLUMN fk_commandefourndet fk_elementdet integer;

View file

@ -1,10 +1,10 @@
--
-- Script to repair some fatal errors due to database corruption
-- when current version is 2.6.0 or higher.
-- when current version is 2.6.0 or higher.
--
-- Replace xxx with your IP Address
-- Replace xxx with your IP Address
-- bind-address = xxx.xxx.xxx.xxx
-- CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
-- CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
@ -65,10 +65,10 @@
-- VMYSQL4.1 INSERT IGNORE INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif) SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author from llx_product_batch as pb, llx_product_stock as ps, llx_entrepot as e WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid;
-- -- a tester VPGSQL9.5 INSERT IGNORE INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif) SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author from llx_product_batch as pb, llx_product_stock as ps, llx_entrepot as e WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid ON CONFLICT DO NOTHING;
-- -- avant 9.5 faire en variant x pour qu'au 2eme passage, le premier doublon soit dans la tabel cible
-- -- INSERT INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif)
-- -- SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author
-- -- INSERT INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif)
-- -- SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author
-- -- from llx_product_batch as pb, llx_product_stock as ps, llx_entrepot as e
-- -- WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid
-- -- WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid
-- -- AND NOT EXISTS (SELECT 1 FROM llx_product_lot as b WHERE b.fk_product=ps.fk_product and pb.batch=b.batch) LIMIT x
@ -145,13 +145,13 @@ update llx_product_batch set batch = '' where batch = 'Non défini';
update llx_stock_mouvement set batch = null where batch = 'Non d&eacute;fini';
update llx_stock_mouvement set batch = null where batch = 'Non défini';
DELETE FROM llx_product_lot WHERE fk_product NOT IN (select rowid from llx_product);
DELETE FROM llx_product_stock WHERE fk_product NOT IN (select rowid from llx_product);
DELETE FROM llx_product_lot WHERE fk_product NOT IN (select rowid from llx_product);
DELETE FROM llx_product_stock WHERE fk_product NOT IN (select rowid from llx_product);
DELETE FROM llx_product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM llx_product_batch as pb);
-- Merge splitted lines into one in table llx_product_batch
-- Merge splitted lines into one in table llx_product_batch
DROP TABLE tmp_llx_product_batch;
DROP TABLE tmp_llx_product_batch2;
CREATE TABLE tmp_llx_product_batch AS select fk_product_stock, eatby, sellby, batch, SUM(qty) as qty, COUNT(rowid) as nb FROM llx_product_batch GROUP BY fk_product_stock, eatby, sellby, batch HAVING COUNT(rowid) > 1;
@ -175,7 +175,7 @@ delete from llx_product_association where fk_product_fils NOT IN (select rowid f
-- Fix: delete category child with no category parent.
drop table tmp_categorie;
create table tmp_categorie as select * from llx_categorie;
create table tmp_categorie as select * from llx_categorie;
-- select * from llx_categorie where fk_parent not in (select rowid from tmp_categorie) and fk_parent is not null and fk_parent <> 0;
delete from llx_categorie where fk_parent not in (select rowid from tmp_categorie) and fk_parent is not null and fk_parent <> 0;
drop table tmp_categorie;
@ -397,7 +397,7 @@ update llx_facturedet set product_type = 1 where product_type = 2;
update llx_propal set fk_statut = 1 where fk_statut = -1;
delete from llx_commande_fournisseur_dispatch where fk_commandefourndet = 0 or fk_commandefourndet IS NULL;
delete from llx_receptiondet_batch where fk_elementdet = 0 or fk_elementdet IS NULL;
delete from llx_menu where menu_handler = 'smartphone';
@ -408,7 +408,7 @@ update llx_expedition set date_valid = NOW() where fk_statut = 1 and date_valid
-- Detect bad consistency between duraction_effective of a task and sum of time of tasks
-- select pt.rowid, pt.duration_effective, SUM(ptt.element_duration) as y from llx_projet_task as pt, llx_element_time as ptt where ptt.fk_element = pt.rowid and ptt.elementtype = 'task' group by pt.rowid, pt.duration_effective having pt.duration_effective <> y;
update llx_projet_task as pt set pt.duration_effective = (select SUM(ptt.element_duration) as y from llx_element_time as ptt where ptt.fk_element = pt.rowid and ptt.elementtype = 'task') where pt.duration_effective <> (select SUM(ptt.element_duration) as y from llx_element_time as ptt where ptt.fk_element = pt.rowid and ptt.elementtype = 'task');
-- Remove duplicate of shipment mode (keep the one with tracking defined)
drop table tmp_c_shipment_mode;
@ -443,9 +443,9 @@ UPDATE llx_expensereport_det SET fk_code_ventilation = 0 WHERE fk_code_ventilati
-- Clean product prices
--delete from llx_product_price where date_price between '2017-04-20 06:51:00' and '2017-04-20 06:51:05';
--delete from llx_product_price where date_price between '2017-04-20 06:51:00' and '2017-04-20 06:51:05';
-- Set product prices into llx_product with last price into llx_product_prices
--update llx_product as p set
--update llx_product as p set
-- p.price = (select pp.price from llx_product_price as pp where pp.price_level = 1 and pp.fk_product = p.rowid order by pp.tms desc limit 1),
-- p.price_ttc = (select pp.price_ttc from llx_product_price as pp where pp.price_level = 1 and pp.fk_product = p.rowid order by pp.tms desc limit 1),
-- p.price_min = (select pp.price_min from llx_product_price as pp where pp.price_level = 1 and pp.fk_product = p.rowid order by pp.tms desc limit 1),
@ -503,7 +503,7 @@ UPDATE llx_chargesociales SET date_creation = tms WHERE date_creation IS NULL;
--ALTER TABLE llx_table modify column columnname datetime DEFAULT CURRENT_TIMESTAMP;
-- Backport a change of value into the hourly rate.
-- Backport a change of value into the hourly rate.
-- update llx_element_time as ptt set ptt.thm = (SELECT thm from llx_user as u where ptt.fk_user = u.rowid) where (ptt.thm is null)
@ -513,14 +513,14 @@ update llx_facturedet set product_type = 1 where product_type = 0 AND fk_product
update llx_facture_fourn_det set product_type = 0 where product_type = 1 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 0);
update llx_facture_fourn_det set product_type = 1 where product_type = 0 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 1);
DELETE FROM llx_mrp_production where qty = 0;
UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS NULL;
-- UPDATE llx_contratdet set label = NULL WHERE label IS NOT NULL;
-- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL;
@ -528,21 +528,21 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS
--Fix bad sign on multicompany column for customer invoice lines
UPDATE llx_facturedet SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and subprice > 0) OR (multicurrency_subprice > 0 and subprice < 0));
UPDATE llx_facturedet SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
UPDATE llx_facturedet SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
UPDATE llx_facturedet SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
UPDATE llx_facturedet SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
UPDATE llx_facturedet SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
--Fix bad sign on multicompany column for customer invoices
UPDATE llx_facture SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
UPDATE llx_facture SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
UPDATE llx_facture SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
UPDATE llx_facture SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
UPDATE llx_facture SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
UPDATE llx_facture SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
--Fix bad sign on multicurrency column for supplier invoice lines
UPDATE llx_facture_fourn_det SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and pu_ht > 0) OR (multicurrency_subprice > 0 and pu_ht < 0));
UPDATE llx_facture_fourn_det SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
UPDATE llx_facture_fourn_det SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and tva > 0) OR (multicurrency_total_tva > 0 and tva < 0));
UPDATE llx_facture_fourn_det SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
UPDATE llx_facture_fourn_det SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and tva > 0) OR (multicurrency_total_tva > 0 and tva < 0));
UPDATE llx_facture_fourn_det SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
--Fix bad sign on multicompany column for customer invoices
UPDATE llx_facture_fourn SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
UPDATE llx_facture_fourn SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
UPDATE llx_facture_fourn SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
UPDATE llx_facture_fourn SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
UPDATE llx_facture_fourn SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
UPDATE llx_facture_fourn SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NULL AND fk_prev_id IS NULL;
@ -558,7 +558,7 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL
--update llx_facture set paye = 1, fk_statut = 2 where rowid in (select rowid from tmp_invoice_deposit_mark_as_available);
-- TODO We should fix multicurrency_amount that are empty into llx_societe_remise_except, but we can't because we don't know what is the rate
-- TODO We should fix multicurrency_amount that are empty into llx_societe_remise_except, but we can't because we don't know what is the rate
-- We may retreive info fro minvoice line by using fk_facture_line or fk_facture_supplier_line
-- select * from llx_societe_remise_except where multicurrency_amount_ht = 0 and amount_ht <> 0;
@ -586,7 +586,7 @@ DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee';
-- Sequence to fix the content of llx_bank.amount_main_currency (value was empty and should not for payment on bank account with a different currency so when amount_main_currency is different than amount)
-- Note: amount is amount in the currency of the bank account
-- Note: pamount is always amount into the main currency
-- Note: pmulticurrencyamount is in the currency of invoice
-- Note: pmulticurrencyamount is in the currency of invoice
-- Note: amount_main_currency must be NULL or amount in main currency of company (we set it when the currency of the bank account differs from main currency)
-- DROP TABLE tmp_bank;
-- CREATE TABLE tmp_bank SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount, b.datec FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment' INNER JOIN llx_paiement as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount;

View file

@ -20,4 +20,4 @@ ALTER TABLE llx_receptiondet_batch ADD INDEX idx_receptiondet_batch_fk_commande
ALTER TABLE llx_receptiondet_batch ADD INDEX idx_receptiondet_batch_fk_reception (fk_reception);
ALTER TABLE llx_receptiondet_batch ADD CONSTRAINT fk_receptiondet_batch_fk_reception FOREIGN KEY (fk_reception) REFERENCES llx_reception (rowid);
ALTER TABLE llx_receptiondet_batch ADD INDEX idx_receptiondet_batch_fk_product (fk_product);
ALTER TABLE llx_receptiondet_batch ADD INDEX idx_receptiondet_batch_fk_commandefourndet (fk_commandefourndet);
ALTER TABLE llx_receptiondet_batch ADD INDEX idx_receptiondet_batch_fk_elementdet (fk_elementdet);

View file

@ -28,8 +28,8 @@ create table llx_receptiondet_batch
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_reception integer DEFAULT NULL, -- ID of parent object
fk_commande integer, -- ID of main source object. TODO should be renamed into fk_element
fk_commandefourndet integer, -- ID of line of main source object. TODO should be renamed into fk_elementdet
fk_element integer, -- ID of main source object. TODO should be renamed into fk_element
fk_elementdet integer, -- ID of line of main source object. TODO should be renamed into fk_elementdet
element_type varchar(50) DEFAULT 'supplier_order' NOT NULL, -- Type of source object ('supplier_order', ...)
fk_product integer,
qty float, -- qty to move

View file

@ -1488,7 +1488,7 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) {
echo '<tr><th>Repair llx_receptiondet_batch.fk_commandefourndet</th></tr>';
echo '<tr><td>Repair in progress. This may take a while.</td></tr>';
$sql_dispatch = 'SELECT * FROM '.MAIN_DB_PREFIX.'receptiondet_batch WHERE COALESCE(fk_commandefourndet, 0) = 0';
$sql_dispatch = 'SELECT * FROM '.MAIN_DB_PREFIX.'receptiondet_batch WHERE COALESCE(fk_elementdet, 0) = 0';
$db->begin();
$resql_dispatch = $db->query($sql_dispatch);
$n_processed_rows = 0;
@ -1529,12 +1529,12 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) {
$qty_for_line = min($remaining_qty, $obj_line->qty);
if ($first_iteration) {
$sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'receptiondet_batch';
$sql_attach .= ' SET fk_commandefourndet = '.((int) $obj_line->rowid).', qty = '.((float) $qty_for_line);
$sql_attach .= ' SET fk_elementdet = '.((int) $obj_line->rowid).', qty = '.((float) $qty_for_line);
$sql_attach .= ' WHERE rowid = '.((int) $obj_dispatch->rowid);
$first_iteration = false;
} else {
$sql_attach_values = array(
(string) ((int) $obj_dispatch->fk_commande),
(string) ((int) $obj_dispatch->fk_element),
(string) ((int) $obj_dispatch->fk_product),
(string) ((int) $obj_line->rowid),
(string) ((float) $qty_for_line),
@ -1551,8 +1551,8 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) {
$sql_attach_values = implode(', ', $sql_attach_values);
$sql_attach = 'INSERT INTO '.MAIN_DB_PREFIX.'receptiondet_batch';
$sql_attach .= ' (fk_commande, fk_product, fk_commandefourndet, qty, fk_entrepot, fk_user, datec, comment, status, tms, batch, eatby, sellby)';
$sql_attach .= " VALUES (".$sql_attach_values.")";
$sql_attach .= ' (fk_element, fk_product, fk_elementdet, qty, fk_entrepot, fk_user, datec, comment, status, tms, batch, eatby, sellby)';
$sql_attach .= " VALUES (".$sql_attach_values.")"; // The string is already sanitized
}
if ($repair_link_dispatch_lines_supplier_order_lines == 'confirmed') {

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
* Copyright (C) 2019-2020 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
@ -143,6 +144,7 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
// Security check
if ($search_type == '0') {

View file

@ -1027,7 +1027,7 @@ class KnowledgeRecord extends CommonObject
$dir = dol_buildpath($reldir."core/modules/knowledgemanagement/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {

Some files were not shown because too many files have changed in this diff Show more