diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 148231a66ca..f227902c745 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -26256,12 +26256,6 @@ parameters: count: 4 path: ../../../htdocs/societe/website.php - - - message: '#^Parameter \#1 \$params of static method Stripe\\Terminal\\Location\:\:all\(\) expects array\|null, string given\.$#' - identifier: argument.type - count: 1 - path: ../../../htdocs/stripe/admin/stripe.php - - message: '#^Call to function is_object\(\) with Facture will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -26448,24 +26442,6 @@ parameters: count: 6 path: ../../../htdocs/supplier_proposal/class/supplier_proposal.class.php - - - message: '#^Parameter \#3 \$remise_percent_ligne of function calcul_price_total expects float, string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/supplier_proposal/class/supplier_proposal.class.php - - - - message: '#^Parameter \#5 \$uselocaltax1_rate of function calcul_price_total expects float, string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/supplier_proposal/class/supplier_proposal.class.php - - - - message: '#^Parameter \#6 \$uselocaltax2_rate of function calcul_price_total expects float, string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/supplier_proposal/class/supplier_proposal.class.php - - message: '#^Property SupplierProposal\:\:\$statut \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -26604,12 +26580,6 @@ parameters: count: 1 path: ../../../htdocs/takepos/admin/terminal.php - - - message: '#^Parameter \#1 \$params of static method Stripe\\Terminal\\Reader\:\:all\(\) expects array\|null, string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/takepos/admin/terminal.php - - message: '#^Right side of && is always true\.$#' identifier: booleanAnd.rightAlwaysTrue @@ -26664,18 +26634,6 @@ parameters: count: 1 path: ../../../htdocs/takepos/index.php - - - message: '#^Variable \$CUSTOMER_DISPLAY_line1 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/takepos/invoice.php - - - - message: '#^Variable \$CUSTOMER_DISPLAY_line2 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/takepos/invoice.php - - message: '#^Variable \$batch might not be defined\.$#' identifier: variable.undefined @@ -26688,30 +26646,12 @@ parameters: count: 1 path: ../../../htdocs/takepos/invoice.php - - - message: '#^Variable \$creditnote might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/takepos/invoice.php - - - - message: '#^Variable \$fk_source might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/takepos/invoice.php - - message: '#^Variable \$footer_ticket might not be defined\.$#' identifier: variable.undefined count: 1 path: ../../../htdocs/takepos/invoice.php - - - message: '#^Variable \$footerorder might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/takepos/invoice.php - - message: '#^Variable \$header_soc might not be defined\.$#' identifier: variable.undefined @@ -26724,42 +26664,12 @@ parameters: count: 1 path: ../../../htdocs/takepos/invoice.php - - - message: '#^Variable \$headerorder might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/takepos/invoice.php - - - - message: '#^Variable \$idoflineadded might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/takepos/invoice.php - - - - message: '#^Variable \$printer might not be defined\.$#' - identifier: variable.undefined - count: 6 - path: ../../../htdocs/takepos/invoice.php - - - - message: '#^Variable \$sectionwithinvoicelink might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/takepos/invoice.php - - message: '#^Variable \$ticket_total might not be defined\.$#' identifier: variable.undefined count: 1 path: ../../../htdocs/takepos/invoice.php - - - message: '#^Variable \$tva_npr might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/takepos/invoice.php - - message: '#^Variable \$warehouseid might not be defined\.$#' identifier: variable.undefined @@ -26784,12 +26694,6 @@ parameters: count: 3 path: ../../../htdocs/takepos/pay.php - - - message: '#^Variable \$stripeacc might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/takepos/pay.php - - message: '#^Variable \$user might not be defined\.$#' identifier: variable.undefined @@ -26814,18 +26718,6 @@ parameters: count: 1 path: ../../../htdocs/takepos/split.php - - - message: '#^Variable \$invoice might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../../htdocs/takepos/split.php - - - - message: '#^Variable \$placeid might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/takepos/split.php - - message: '#^Variable \$fontlist might not be defined\.$#' identifier: variable.undefined diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 6a051e0e047..5d7c8558d06 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,16 +9,16 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 1520+ occurrences + // PhanTypeMismatchArgument : 1470+ occurrences // PhanUndeclaredProperty : 500+ occurrences // PhanTypeMismatchArgumentNullable : 320+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences - // PhanUndeclaredGlobalVariable : 160+ occurrences // PhanTypeMismatchProperty : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 55+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 55+ occurrences + // PhanUndeclaredGlobalVariable : 100+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 35+ occurrences // PhanTypeExpectedObjectPropAccess : 30+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 25+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanPluginUndeclaredVariableIsset : 15+ occurrences @@ -33,8 +33,6 @@ return [ // PhanEmptyFQSENInClasslike : 3 occurrences // PhanInvalidFQSENInClasslike : 3 occurrences // PhanPluginSuspiciousParamPosition : 3 occurrences - // PhanPluginEmptyStatementIf : 2 occurrences - // PhanRedefineFunction : 2 occurrences // PhanTypeMismatchDimAssignment : 2 occurrences // PhanTypeSuspiciousStringExpression : 2 occurrences // PhanAccessMethodProtected : 1 occurrence @@ -43,7 +41,6 @@ return [ // PhanPluginUnknownArrayPropertyType : 1 occurrence // PhanPossiblyUndeclaredVariable : 1 occurrence // PhanTypeExpectedObjectPropAccessButGotNull : 1 occurrence - // PhanUndeclaredVariable : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ @@ -266,7 +263,6 @@ return [ 'htdocs/compta/prelevement/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/compta/prelevement/class/rejetprelevement.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/compta/prelevement/create.php' => ['PhanTypeMismatchArgument'], 'htdocs/compta/prelevement/demandes.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/compta/prelevement/line.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'htdocs/compta/resultat/clientfourn.php' => ['PhanTypeMismatchArgument'], @@ -518,7 +514,6 @@ return [ 'htdocs/expensereport/payment/info.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/expensereport/payment/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/expensereport/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], - 'htdocs/exports/class/export.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/exports/export.php' => ['PhanTypeMismatchArgument'], 'htdocs/externalsite/frames.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/fichinter/agenda.php' => ['PhanTypeMismatchArgument'], @@ -645,28 +640,9 @@ return [ 'htdocs/supplier_proposal/card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/supplier_proposal/class/api_supplier_proposals.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'], 'htdocs/supplier_proposal/class/supplier_proposal.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/takepos/admin/bar.php' => ['PhanTypeMismatchArgument'], - 'htdocs/takepos/admin/terminal.php' => ['PhanTypeMismatchArgument'], - 'htdocs/takepos/ajax/ajax.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/takepos/floors.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/takepos/freezone.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/takepos/index.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgument'], - 'htdocs/takepos/invoice.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/takepos/pay.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/takepos/phone.php' => ['PhanTypeMismatchArgument'], - 'htdocs/takepos/send.php' => ['PhanTypeMismatchArgument'], - 'htdocs/takepos/split.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/theme/eldy/badges.inc.php' => ['PhanRedefineFunction'], - 'htdocs/theme/eldy/btn.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/theme/eldy/dropdown.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/theme/eldy/flags-sprite.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/theme/eldy/main_menu_fa_icons.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/theme/eldy/progress.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/theme/md/badges.inc.php' => ['PhanRedefineFunction'], - 'htdocs/theme/md/btn.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/theme/md/dropdown.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/theme/md/flags-sprite.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/theme/md/progress.inc.php' => ['PhanUndeclaredGlobalVariable'], + 'htdocs/takepos/index.php' => ['PhanPluginUndeclaredVariableIsset'], + 'htdocs/takepos/invoice.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], + 'htdocs/takepos/split.php' => ['PhanPluginUndeclaredVariableIsset'], 'htdocs/ticket/agenda.php' => ['PhanTypeMismatchArgument'], 'htdocs/ticket/card.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/ticket/class/actions_ticket.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index f163ca00544..525e02edd37 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2013-2025 Alexandre Spangaro + * Copyright (C) 2024 Frédéric France * * 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 @@ -24,6 +24,8 @@ // Load Dolibarr environment require '../../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; @@ -83,7 +85,25 @@ if (!$user->hasRight('accounting', 'fiscalyear', 'write')) { // If /* * Actions */ +if ($action == 'setdefault') { + // Set a fiscal year as default + $error = 0; + $defaultFiscalYear = GETPOSTINT('value'); + $defaultFiscalYearLabel = GETPOST('label', 'alpha'); + + if (!empty($defaultFiscalYear)) { + dolibarr_set_const($db, 'ACCOUNTANCY_FISCALYEAR_DEFAULT', $defaultFiscalYear, 'chaine', 0, '', $conf->entity); + } else { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("FiscalYearSetAsDefault", $defaultFiscalYearLabel), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} /* @@ -148,6 +168,7 @@ if ($result) { print ''.$langs->trans("DateEnd").''; print ''.$langs->trans("NumberOfAccountancyEntries").''; print ''.$langs->trans("NumberOfAccountancyMovements").''; + print ''.$langs->trans("Default").''; print ''.$langs->trans("Status").''; print ''; @@ -160,6 +181,7 @@ if ($result) { $fiscalyearstatic->ref = $obj->rowid; $fiscalyearstatic->id = $obj->rowid; + $fiscalyearstatic->label = $obj->label; $fiscalyearstatic->date_start = $obj->date_start; $fiscalyearstatic->date_end = $obj->date_end; $fiscalyearstatic->statut = $obj->status; @@ -174,12 +196,22 @@ if ($result) { print ''.dol_print_date($db->jdate($obj->date_end), 'day').''; print ''.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).''; print ''.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).''; + + // Default + print ''; + if (getDolGlobalString('ACCOUNTANCY_FISCALYEAR_DEFAULT') == (int) $fiscalyearstatic->ref) { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'ref).'&label='.urlencode($fiscalyearstatic->label).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').''; + } + print ''; + print ''.$fiscalyearstatic->LibStatut($obj->status, 5).''; print ''; $i++; } } else { - print ''.$langs->trans("NoRecordFound").''; + print ''.$langs->trans("NoRecordFound").''; } print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index cd2641ff6be..a0921b222b7 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016-2024 Alexandre Spangaro + * Copyright (C) 2016-2025 Alexandre Spangaro * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * @@ -59,8 +59,10 @@ if ($type == 'sub') { } $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default; $show_subgroup = GETPOST('show_subgroup', 'alpha'); -$search_date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_startmonth'), GETPOSTINT('date_startday'), GETPOSTINT('date_startyear')); -$search_date_end = dol_mktime(23, 59, 59, GETPOSTINT('date_endmonth'), GETPOSTINT('date_endday'), GETPOSTINT('date_endyear')); + +$search_date_start = GETPOSTDATE('date_start', 'getpost', 'auto', 'search_date_start_accountancy'); +$search_date_end = GETPOSTDATE('date_end', 'getpostend', 'auto', 'search_date_end_accountancy'); + $search_ledger_code = GETPOST('search_ledger_code', 'array'); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { @@ -96,12 +98,16 @@ $object = new BookKeeping($db); $hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array $formaccounting = new FormAccounting($db); -$formother = new FormOther($db); $form = new Form($db); -if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { - $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; +if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('formfilteraction')) { + $sql = "SELECT date_start, date_end"; + $sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { + $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT'); + } else { + $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; + } $sql .= $db->plimit(1); $res = $db->query($sql); @@ -156,17 +162,17 @@ if (empty($reshook)) { $show_subgroup = ''; $search_date_start = ''; $search_date_end = ''; - $search_date_startyear = ''; - $search_date_startmonth = ''; - $search_date_startday = ''; - $search_date_endyear = ''; - $search_date_endmonth = ''; - $search_date_endday = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; $search_not_reconciled = ''; $search_ledger_code = array(); $filter = array(); + unset($_SESSION['DOLDATE_search_date_start_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_year']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_year']); } // Must be after the remove filter action, before the export. diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 67a6155ef7c..e866ea95980 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2025 Alexandre Spangaro * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2024 Frédéric France @@ -170,9 +170,15 @@ $form = new Form($db); if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOSTINT('page') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { - $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; - $res = $db->query($query); + $sql = "SELECT date_start, date_end"; + $sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { + $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT'); + } else { + $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; + } + $sql .= $db->plimit(1); + $res = $db->query($sql); if ($db->num_rows($res) > 0) { $fiscalYear = $db->fetch_object($res); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 4b4f57cc3b1..59217213de3 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,12 +1,12 @@ - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2024 Alexandre Spangaro - * Copyright (C) 2022 Lionel Vessiller - * Copyright (C) 2016-2017 Laurent Destailleur - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2022 Progiseize - * Copyright (C) 2024 MDW +/* Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2025 Alexandre Spangaro + * Copyright (C) 2022 Lionel Vessiller + * Copyright (C) 2016-2017 Laurent Destailleur + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2022 Progiseize + * Copyright (C) 2024 MDW * * 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 @@ -31,6 +31,7 @@ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfiscalyear.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -65,57 +66,36 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bo $search_mvt_num = GETPOST('search_mvt_num', 'alpha'); $search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); -$search_date_startyear = GETPOSTINT('search_date_startyear'); -$search_date_startmonth = GETPOSTINT('search_date_startmonth'); -$search_date_startday = GETPOSTINT('search_date_startday'); -$search_date_endyear = GETPOSTINT('search_date_endyear'); -$search_date_endmonth = GETPOSTINT('search_date_endmonth'); -$search_date_endday = GETPOSTINT('search_date_endday'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); -$search_doc_date = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear')); -$search_date_creation_startyear = GETPOSTINT('search_date_creation_startyear'); -$search_date_creation_startmonth = GETPOSTINT('search_date_creation_startmonth'); -$search_date_creation_startday = GETPOSTINT('search_date_creation_startday'); -$search_date_creation_endyear = GETPOSTINT('search_date_creation_endyear'); -$search_date_creation_endmonth = GETPOSTINT('search_date_creation_endmonth'); -$search_date_creation_endday = GETPOSTINT('search_date_creation_endday'); -$search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); -$search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear); -$search_date_modification_startyear = GETPOSTINT('search_date_modification_startyear'); -$search_date_modification_startmonth = GETPOSTINT('search_date_modification_startmonth'); -$search_date_modification_startday = GETPOSTINT('search_date_modification_startday'); -$search_date_modification_endyear = GETPOSTINT('search_date_modification_endyear'); -$search_date_modification_endmonth = GETPOSTINT('search_date_modification_endmonth'); -$search_date_modification_endday = GETPOSTINT('search_date_modification_endday'); -$search_date_modification_start = dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear); -$search_date_modification_end = dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear); -$search_date_export_startyear = GETPOSTINT('search_date_export_startyear'); -$search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth'); -$search_date_export_startday = GETPOSTINT('search_date_export_startday'); -$search_date_export_endyear = GETPOSTINT('search_date_export_endyear'); -$search_date_export_endmonth = GETPOSTINT('search_date_export_endmonth'); -$search_date_export_endday = GETPOSTINT('search_date_export_endday'); -$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); -$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); -$search_date_validation_startyear = GETPOSTINT('search_date_validation_startyear'); -$search_date_validation_startmonth = GETPOSTINT('search_date_validation_startmonth'); -$search_date_validation_startday = GETPOSTINT('search_date_validation_startday'); -$search_date_validation_endyear = GETPOSTINT('search_date_validation_endyear'); -$search_date_validation_endmonth = GETPOSTINT('search_date_validation_endmonth'); -$search_date_validation_endday = GETPOSTINT('search_date_validation_endday'); -$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); -$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); + +$search_doc_date = GETPOSTDATE('doc_date', 'getpost'); // deprecated. Can use 'search_date_start/end' + +$search_date_start = GETPOSTDATE('search_date_start', 'getpost', 'auto', 'search_date_start_accountancy'); +$search_date_end = GETPOSTDATE('search_date_end', 'getpostend', 'auto', 'search_date_end_accountancy'); + +$search_date_creation_start = GETPOSTDATE('search_date_creation_start', 'getpost'); +$search_date_creation_end = GETPOSTDATE('search_date_creation_end', 'getpostend'); + +$search_date_modification_start = GETPOSTDATE('search_date_modification_start', 'getpost'); +$search_date_modification_end = GETPOSTDATE('search_date_modification_end', 'getpostend'); + +$search_date_export_start = GETPOSTDATE('search_date_export_start', 'getpost'); +$search_date_export_end = GETPOSTDATE('search_date_export_end', 'getpostend'); + +$search_date_validation_start = GETPOSTDATE('search_date_validation_start', 'getpost'); +$search_date_validation_start = GETPOSTDATE('search_date_validation_end', 'getpostend'); + // Due date start $search_date_due_start_day = GETPOSTINT('search_date_due_start_day'); $search_date_due_start_month = GETPOSTINT('search_date_due_start_month'); $search_date_due_start_year = GETPOSTINT('search_date_due_start_year'); -$search_date_due_start = dol_mktime(0, 0, 0, $search_date_due_start_month, $search_date_due_start_day, $search_date_due_start_year); +$search_date_due_start = GETPOSTDATE('search_date_due_start_', 'getpost'); + // Due date end $search_date_due_end_day = GETPOSTINT('search_date_due_end_day'); $search_date_due_end_month = GETPOSTINT('search_date_due_end_month'); $search_date_due_end_year = GETPOSTINT('search_date_due_end_year'); -$search_date_due_end = dol_mktime(23, 59, 59, $search_date_due_end_month, $search_date_due_end_day, $search_date_due_end_year); +$search_date_due_end = GETPOSTDATE('search_date_due_end_', 'getpostend'); + $search_import_key = GETPOST("search_import_key", 'alpha'); $search_account_category = GETPOSTINT('search_account_category'); @@ -170,14 +150,21 @@ if ($sortfield == "") { $object = new BookKeeping($db); $hookmanager->initHooks(array('bookkeepinglist')); +$formfiscalyear = new FormFiscalYear($db); $formaccounting = new FormAccounting($db); $form = new Form($db); if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'alpha') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { - $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; - $res = $db->query($query); + $sql = "SELECT date_start, date_end"; + $sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { + $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT'); + } else { + $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; + } + $sql .= $db->plimit(1); + $res = $db->query($sql); if ($db->num_rows($res) > 0) { $fiscalYear = $db->fetch_object($res); @@ -278,44 +265,14 @@ if (empty($reshook)) { $search_mvt_label = ''; $search_direction = ''; $search_ledger_code = array(); - $search_date_startyear = ''; - $search_date_startmonth = ''; - $search_date_startday = ''; - $search_date_endyear = ''; - $search_date_endmonth = ''; - $search_date_endday = ''; $search_date_start = ''; $search_date_end = ''; - $search_date_creation_startyear = ''; - $search_date_creation_startmonth = ''; - $search_date_creation_startday = ''; - $search_date_creation_endyear = ''; - $search_date_creation_endmonth = ''; - $search_date_creation_endday = ''; $search_date_creation_start = ''; $search_date_creation_end = ''; - $search_date_modification_startyear = ''; - $search_date_modification_startmonth = ''; - $search_date_modification_startday = ''; - $search_date_modification_endyear = ''; - $search_date_modification_endmonth = ''; - $search_date_modification_endday = ''; $search_date_modification_start = ''; $search_date_modification_end = ''; - $search_date_export_startyear = ''; - $search_date_export_startmonth = ''; - $search_date_export_startday = ''; - $search_date_export_endyear = ''; - $search_date_export_endmonth = ''; - $search_date_export_endday = ''; $search_date_export_start = ''; $search_date_export_end = ''; - $search_date_validation_startyear = ''; - $search_date_validation_startmonth = ''; - $search_date_validation_startday = ''; - $search_date_validation_endyear = ''; - $search_date_validation_endmonth = ''; - $search_date_validation_endday = ''; $search_date_validation_start = ''; $search_date_validation_end = ''; // Due date start @@ -334,6 +291,12 @@ if (empty($reshook)) { $search_not_reconciled = ''; $search_import_key = ''; $toselect = array(); + unset($_SESSION['DOLDATE_search_date_start_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_year']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_year']); } // Must be after the remove filter action, before the export. diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index ba17782a8b0..2ac1ec58814 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Neil Orley * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2020 Florian Henry - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2025 Alexandre Spangaro * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * @@ -63,41 +63,51 @@ if ($type == 'sub') { $context_default = 'bookkeepingbyaccountlist'; } $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default; + +$search_doc_date = GETPOSTDATE('doc_date', 'getpost'); // deprecated. Can use 'search_date_start/end' + $search_date_startyear = GETPOSTINT('search_date_startyear'); $search_date_startmonth = GETPOSTINT('search_date_startmonth'); $search_date_startday = GETPOSTINT('search_date_startday'); +$search_date_start = GETPOSTDATE('search_date_start', 'getpost', 'auto', 'search_date_start_accountancy'); + $search_date_endyear = GETPOSTINT('search_date_endyear'); $search_date_endmonth = GETPOSTINT('search_date_endmonth'); $search_date_endday = GETPOSTINT('search_date_endday'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); -$search_doc_date = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear')); +$search_date_end = GETPOSTDATE('search_date_end', 'getpostend', 'auto', 'search_date_end_accountancy'); + $search_date_export_startyear = GETPOSTINT('search_date_export_startyear'); $search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth'); $search_date_export_startday = GETPOSTINT('search_date_export_startday'); +$search_date_export_start = GETPOSTDATE('search_date_export_start', 'getpost'); + $search_date_export_endyear = GETPOSTINT('search_date_export_endyear'); $search_date_export_endmonth = GETPOSTINT('search_date_export_endmonth'); $search_date_export_endday = GETPOSTINT('search_date_export_endday'); -$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); -$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); +$search_date_export_end = GETPOSTDATE('search_date_export_start', 'getpostend'); + $search_date_validation_startyear = GETPOSTINT('search_date_validation_startyear'); $search_date_validation_startmonth = GETPOSTINT('search_date_validation_startmonth'); $search_date_validation_startday = GETPOSTINT('search_date_validation_startday'); +$search_date_validation_start = GETPOSTDATE('search_date_validation_start', 'getpost'); + $search_date_validation_endyear = GETPOSTINT('search_date_validation_endyear'); $search_date_validation_endmonth = GETPOSTINT('search_date_validation_endmonth'); $search_date_validation_endday = GETPOSTINT('search_date_validation_endday'); -$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); -$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); +$search_date_validation_end = GETPOSTDATE('search_date_validation_end', 'getpostend'); + // Due date start $search_date_due_start_day = GETPOSTINT('search_date_due_start_day'); $search_date_due_start_month = GETPOSTINT('search_date_due_start_month'); $search_date_due_start_year = GETPOSTINT('search_date_due_start_year'); -$search_date_due_start = dol_mktime(0, 0, 0, $search_date_due_start_month, $search_date_due_start_day, $search_date_due_start_year); +$search_date_due_start = GETPOSTDATE('search_date_due_start_', 'getpost'); + // Due date end $search_date_due_end_day = GETPOSTINT('search_date_due_end_day'); $search_date_due_end_month = GETPOSTINT('search_date_due_end_month'); $search_date_due_end_year = GETPOSTINT('search_date_due_end_year'); -$search_date_due_end = dol_mktime(23, 59, 59, $search_date_due_end_month, $search_date_due_end_day, $search_date_due_end_year); +$search_date_due_end = GETPOSTDATE('search_date_due_end_', 'getpostend'); + $search_import_key = GETPOST("search_import_key", 'alpha'); $search_account_category = GETPOSTINT('search_account_category'); @@ -152,8 +162,13 @@ $formaccounting = new FormAccounting($db); $form = new Form($db); if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) { - $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql = "SELECT date_start, date_end"; + $sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { + $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT'); + } else { + $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; + } $sql .= $db->plimit(1); $res = $db->query($sql); @@ -305,6 +320,12 @@ if (empty($reshook)) { $search_not_reconciled = ''; $search_import_key = ''; $toselect = array(); + unset($_SESSION['DOLDATE_search_date_start_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_year']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_year']); } if (!empty($socid)) { diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 10df54ee44d..99a38e9a49e 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -54,6 +54,7 @@ $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'stock'; +$page_y = GETPOST('page_y'); /* @@ -84,7 +85,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { } if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"].($page_y ? '?page_y='.$page_y : '')); exit; } else { dol_print_error($db); @@ -94,7 +95,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"].($page_y ? '?page_y='.$page_y : '')); exit; } else { dol_print_error($db); @@ -220,6 +221,7 @@ print '
'; print '
'; print ''; print ''; +print ''; // Title rule for stock decrease print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table @@ -244,7 +246,7 @@ if (isModEnabled('invoice')) { } } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); + print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_BILL')); } } else { print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")).''; @@ -262,11 +264,11 @@ if (isModEnabled('order')) { if ($disabled) { print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); } else { - print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition'); + print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); } } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); + print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER')); } } else { print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")).''; @@ -283,10 +285,10 @@ print ''.$langs->trans("DeStockOnShipment").''; print ''; if (isModEnabled("shipping")) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); + print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')); } } else { print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).''; @@ -300,7 +302,7 @@ print ''.$langs->trans("DeStockOnShipmentOnClosing").''; print ''; if (isModEnabled("shipping")) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')); @@ -336,11 +338,11 @@ if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($disabled) { print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); } else { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); } } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_BILL')); } } else { print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; @@ -358,11 +360,11 @@ if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($disabled) { print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); } else { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); } } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER')); } } else { print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; @@ -377,10 +379,10 @@ if (isModEnabled("reception")) { print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition'); + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); + print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION')); } print "\n\n"; @@ -392,24 +394,25 @@ if (isModEnabled("reception")) { print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition'); + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); + print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION_CLOSE')); } print "\n\n"; $found++; } else { + // When module Reception is not enabled, option to increase real stocks on manual dispatching into warehouse, after purchase order receipt of goods print ''; print ''; print ''.$langs->trans("ReStockOnDispatchOrder").''; print ''; if (isModEnabled("supplier_order")) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition'); + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')); } } else { print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; @@ -438,7 +441,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER); + print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, getDolGlobalString('STOCK_ALLOW_NEGATIVE_TRANSFER')); } print "\n"; print "\n"; @@ -452,7 +455,7 @@ if (isModEnabled('invoice')) { print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_INVOICE')); } print "\n"; print "\n"; @@ -466,7 +469,7 @@ if (isModEnabled('order')) { print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER')); } print "\n"; print "\n"; @@ -480,7 +483,7 @@ if (isModEnabled("shipping")) { print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT')); } print "\n"; print "\n"; @@ -517,7 +520,7 @@ if ($virtualdiffersfromphysical) { print ajax_constantonoff('STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT", $arrval, $conf->global->STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT); + print $form->selectarray("STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT", $arrval, getDolGlobalString('STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT')); } print "\n"; print "\n"; diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index 21ab35b9828..c04fa592381 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/ai/lib/ai.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formai.class.php"; /** * @var Conf $conf @@ -201,6 +202,7 @@ if ($action == 'confirm_deleteproperty' && GETPOST('confirm') == 'yes') { */ $form = new Form($db); +$formai = new FormAI($db); $help_url = ''; $title = "AiSetup"; diff --git a/htdocs/ai/lib/ai.lib.php b/htdocs/ai/lib/ai.lib.php index 5585549d018..b61b674e81f 100644 --- a/htdocs/ai/lib/ai.lib.php +++ b/htdocs/ai/lib/ai.lib.php @@ -37,11 +37,12 @@ function getListOfAIFeatures() 'textgenerationemail' => array('label' => $langs->trans('TextGeneration').' ('.$langs->trans("EmailContent").')', 'picto'=>'', 'status'=>'dolibarr', 'function' => 'TEXT'), 'textgenerationwebpage' => array('label' => $langs->trans('TextGeneration').' ('.$langs->trans("WebsitePage").')', 'picto'=>'', 'status'=>'dolibarr', 'function' => 'TEXT'), 'textgeneration' => array('label' => $langs->trans('TextGeneration').' ('.$langs->trans("Other").')', 'picto'=>'', 'status'=>'notused', 'function' => 'TEXT'), + 'texttranslation' => array('label' => $langs->trans('TextTranslation'), 'picto'=>'', 'status'=>'dolibarr', 'function' => 'TEXT'), 'imagegeneration' => array('label' => 'ImageGeneration', 'picto'=>'', 'status'=>'notused', 'function' => 'IMAGE'), 'videogeneration' => array('label' => 'VideoGeneration', 'picto'=>'', 'status'=>'notused', 'function' => 'VIDEO'), 'audiogeneration' => array('label' => 'AudioGeneration', 'picto'=>'', 'status'=>'notused', 'function' => 'AUDIO'), - 'transcription' => array('label' => 'Transcription', 'picto'=>'', 'status'=>'notused', 'function' => 'TRANSCRIPT'), - 'translation' => array('label' => 'Translation', 'picto'=>'', 'status'=>'notused', 'function' => 'TRANSLATE') + 'transcription' => array('label' => 'AudioTranscription', 'picto'=>'', 'status'=>'notused', 'function' => 'TRANSCRIPT'), + 'translation' => array('label' => 'AudioTranslation', 'picto'=>'', 'status'=>'notused', 'function' => 'TRANSLATE') ); return $arrayofaifeatures; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dd69f69f2e5..a93bf6b88b8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6926,7 +6926,7 @@ class Form * The name of this function should be selectVat. We keep bad name for compatibility purpose. * * @param string $htmlname Name of HTML select field - * @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing. + * @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (CODE)' for example. Use -1 or '' for no forcing (auto mode). * @param ?Societe $societe_vendeuse Thirdparty seller * @param ?Societe $societe_acheteuse Thirdparty buyer * @param int $idprod Id product. O if unknown of NA. @@ -7055,7 +7055,7 @@ class Form $num = count($arrayofvatrates); if ($num > 0) { - // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') + // Define vat rate to pre-select (if defaulttx not forced and so is -1 or '') if (($defaulttx < 0 || dol_strlen($defaulttx) == 0) && is_object($societe_vendeuse)) { $tmpthirdparty = new Societe($this->db); @@ -7090,12 +7090,13 @@ class Form } } - // Disabled if seller is not subject to VAT + // Disabled is true if the seller is not subject to VAT $disabled = false; $title = ''; - if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") { - // Override/enable VAT for expense report regardless of global setting - needed if expense report used for business expenses instead - // of using supplier invoices (this is a very bad idea !) + if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && empty($societe_vendeuse->tva_assuj)) { + // When we are seller and we do not use VAT, we want to force to disable VAT selection, except if EXPENSEREPORT_OVERRIDE_VAT is set + // EXPENSEREPORT_OVERRIDE_VAT is a strange option that allow to override/enable VAT regardless of sellet vat option - needed for expense report if + // expense report used for business expenses instead of using supplier invoices (but this is a very bad idea !) if (!getDolGlobalString('EXPENSEREPORT_OVERRIDE_VAT')) { $title = ' title="' . dol_escape_htmltag($langs->trans('VATIsNotUsed')) . '"'; $disabled = true; diff --git a/htdocs/core/class/html.formai.class.php b/htdocs/core/class/html.formai.class.php new file mode 100644 index 00000000000..46b5cabe6bd --- /dev/null +++ b/htdocs/core/class/html.formai.class.php @@ -0,0 +1,416 @@ + + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2015-2017 Marcos García + * Copyright (C) 2015-2017 Nicolas ZABOURI + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Anthony Berton + * Copyright (C) 2024 MDW + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/html.formai.class.php + * \ingroup core + * \brief Fichier de la class permettant la generation du formulaire html d'envoi de mail unitaire + */ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + + +/** + * Class permettant la generation du formulaire html d'envoi de mail unitaire + * Usage: $formail = new FormAI($db) + * $formai->proprietes=1 ou chaine ou tableau de valeurs + * $formai->show_form() affiche le formulaire + */ +class FormAI extends Form +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Use case string to a button "Fill with layout" for this use case. Example 'wesitepage', 'emailing', 'email', ... + */ + public $withlayout; + + /** + * @var string 'text' or 'html' to add a button "Fill with AI generation" + */ + public $withaiprompt; + + /** + * @var array + */ + public $substit = array(); + + /** + * @var array> + */ + public $substit_lines = array(); + + /** + * @var array{}|array{models:string,langsmodels?:string,fileinit?:string[],returnurl:string} + */ + public $param = array(); + + /** + * @var int<-1,1> -1 suggests the checkbox 'one email per recipient' not checked, 0 = no suggestion, 1 = suggest and checked + */ + public $withoptiononeemailperrecipient; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + /** + * Return Html code for AI instruction of message and autofill result + * + * @param string $function Function ('textgenerationmail', 'textgenerationwebpage', ...) + * @param string $format Format for output ('', 'html', ...) + * @param string $htmlContent HTML name of WYSIWYG field + * @return string HTML code to ask AI instruction and autofill result + */ + public function getSectionForAIPrompt($function = 'textgeneration', $format = '', $htmlContent = 'message') + { + global $langs; + + $langs->load("other"); + + $htmlContent = preg_replace('/[^a-z0-9_]/', '', $htmlContent); + + $out = '\n"; + + $out .= " + "; + return $out; + } + + /** + * Set ->substit (and ->substit_line) array from object. This is call when suggesting the email template into forms before sending email. + * + * @param CommonObject $object Object to use + * @param Translate $outputlangs Object lang + * @return void + * @see getCommonSubstitutionArray() + */ + public function setSubstitFromObject($object, $outputlangs) + { + global $extrafields; + + $parameters = array(); + $tmparray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($tmparray, $outputlangs, null, $parameters); + + $this->substit = $tmparray; + + // Fill substit_lines with each object lines content + if (is_array($object->lines)) { + foreach ($object->lines as $line) { + $substit_line = array( + '__PRODUCT_REF__' => isset($line->product_ref) ? $line->product_ref : '', + '__PRODUCT_LABEL__' => isset($line->product_label) ? $line->product_label : '', + '__PRODUCT_DESCRIPTION__' => isset($line->product_desc) ? $line->product_desc : '', + '__LABEL__' => isset($line->label) ? $line->label : '', + '__DESCRIPTION__' => isset($line->desc) ? $line->desc : '', + '__DATE_START_YMD__' => dol_print_date($line->date_start, 'day', false, $outputlangs), + '__DATE_END_YMD__' => dol_print_date($line->date_end, 'day', false, $outputlangs), + '__QUANTITY__' => $line->qty, + '__SUBPRICE__' => price($line->subprice), + '__AMOUNT__' => price($line->total_ttc), + '__AMOUNT_EXCL_TAX__' => price($line->total_ht) + ); + + // Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__ + if (!empty($line->fk_product)) { + if (!is_object($extrafields)) { + $extrafields = new ExtraFields($this->db); + } + $product = new Product($this->db); + $product->fetch($line->fk_product); + $product->fetch_optionals(); + + $extrafields->fetch_name_optionals_label($product->table_element, true); + + if (!empty($extrafields->attributes[$product->table_element]['label']) && is_array($extrafields->attributes[$product->table_element]['label']) && count($extrafields->attributes[$product->table_element]['label']) > 0) { + foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) { + $substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = isset($product->array_options['options_'.$key]) ? $product->array_options['options_'.$key] : ''; + } + } + } + + $this->substit_lines[$line->id] = $substit_line; // @phan-suppress-current-line PhanTypeMismatchProperty + } + } + } + + /** + * Get list of substitution keys available for emails. This is used for tooltips help. + * This include the complete_substitutions_array. + * + * @param string $mode 'formai', 'formaiwithlines', 'formaiforlines', 'ai', ... + * @param ?Object $object Object if applicable + * @return array Array of substitution values for emails. + */ + public static function getAvailableSubstitKey($mode = 'formai', $object = null) + { + global $langs; + + $tmparray = array(); + if ($mode == 'formai' || $mode == 'formaiwithlines' || $mode == 'formaiforlines') { + $parameters = array('mode' => $mode); + $tmparray = getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects + complete_substitutions_array($tmparray, $langs, null, $parameters); + + if ($mode == 'formwithlines') { + $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function + } + if ($mode == 'formforlines') { + $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function + } + } + + if ($mode == 'emailing') { + $parameters = array('mode' => $mode); + $tmparray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects + complete_substitutions_array($tmparray, $langs, null, $parameters); + + // For mass emailing, we have different keys specific to the data into tagerts list + $tmparray['__ID__'] = 'IdRecord'; + $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; + $tmparray['__EMAIL__'] = 'EMailRecipient'; + $tmparray['__LASTNAME__'] = 'Lastname'; + $tmparray['__FIRSTNAME__'] = 'Firstname'; + $tmparray['__MAILTOEMAIL__'] = 'TagMailtoEmail'; + $tmparray['__OTHER1__'] = 'Other1'; + $tmparray['__OTHER2__'] = 'Other2'; + $tmparray['__OTHER3__'] = 'Other3'; + $tmparray['__OTHER4__'] = 'Other4'; + $tmparray['__OTHER5__'] = 'Other5'; + $tmparray['__CHECK_READ__'] = $langs->trans('TagCheckMail'); + $tmparray['__UNSUBSCRIBE__'] = $langs->trans('TagUnsubscribe'); + $tmparray['__UNSUBSCRIBE_URL__'] = $langs->trans('TagUnsubscribe').' (URL)'; + + $onlinepaymentenabled = 0; + if (isModEnabled('paypal')) { + $onlinepaymentenabled++; + } + if (isModEnabled('paybox')) { + $onlinepaymentenabled++; + } + if (isModEnabled('stripe')) { + $onlinepaymentenabled++; + } + if ($onlinepaymentenabled && getDolGlobalString('PAYMENT_SECURITY_TOKEN')) { + $tmparray['__SECUREKEYPAYMENT__'] = getDolGlobalString('PAYMENT_SECURITY_TOKEN'); + if (getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) { + if (isModEnabled('member')) { + $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember'; + } + if (isModEnabled('don')) { + $tmparray['__SECUREKEYPAYMENT_DONATION__'] = 'SecureKeyPAYMENTUniquePerDonation'; + } + if (isModEnabled('invoice')) { + $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice'; + } + if (isModEnabled('order')) { + $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder'; + } + if (isModEnabled('contract')) { + $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'SecureKeyPAYMENTUniquePerContractLine'; + } + + //Online payment link + if (isModEnabled('member')) { + $tmparray['__ONLINEPAYMENTLINK_MEMBER__'] = 'OnlinePaymentLinkUniquePerMember'; + } + if (isModEnabled('don')) { + $tmparray['__ONLINEPAYMENTLINK_DONATION__'] = 'OnlinePaymentLinkUniquePerDonation'; + } + if (isModEnabled('invoice')) { + $tmparray['__ONLINEPAYMENTLINK_INVOICE__'] = 'OnlinePaymentLinkUniquePerInvoice'; + } + if (isModEnabled('order')) { + $tmparray['__ONLINEPAYMENTLINK_ORDER__'] = 'OnlinePaymentLinkUniquePerOrder'; + } + if (isModEnabled('contract')) { + $tmparray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = 'OnlinePaymentLinkUniquePerContractLine'; + } + } + } else { + /* No need to show into tooltip help, option is not enabled + $vars['__SECUREKEYPAYMENT__']=''; + $vars['__SECUREKEYPAYMENT_MEMBER__']=''; + $vars['__SECUREKEYPAYMENT_INVOICE__']=''; + $vars['__SECUREKEYPAYMENT_ORDER__']=''; + $vars['__SECUREKEYPAYMENT_CONTRACTLINE__']=''; + */ + } + if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { + $tmparray['__PUBLICLINK_NEWMEMBERFORM__'] = 'BlankSubscriptionForm'; + } + } + + foreach ($tmparray as $key => $val) { + if (empty($val)) { + $tmparray[$key] = $key; + } + } + + return $tmparray; + } +} diff --git a/htdocs/core/class/html.formfiscalyear.class.php b/htdocs/core/class/html.formfiscalyear.class.php new file mode 100644 index 00000000000..9f49aa16f41 --- /dev/null +++ b/htdocs/core/class/html.formfiscalyear.class.php @@ -0,0 +1,112 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/html.formfiscalyear.class.php + * \ingroup Accountancy (Double entries) + * \brief File of class with all html predefined components + */ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + +/** + * Class to manage generation of HTML components for accounting management + */ +class FormFiscalYear extends Form +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + /** + * Return list of fiscal year + * + * @param int $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $useempty Set to 1 if we want an empty value + * @param int $maxlen Max length of text in combo box + * @param int $help Add or not the admin help picto + * @return void|string HTML component with the select + */ + public function selectFiscalYear($selected = 0, $htmlname = 'fiscalyear', $useempty = 0, $maxlen = 0, $help = 1) + { + global $conf, $langs; + + $out = ''; + + $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut as status"; + $sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear as f"; + $sql .= " WHERE f.entity = ".$conf->entity; + $sql .= " ORDER BY f.date_start ASC"; + + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) { + $out .= ''; + //if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + + $out .= ajax_combobox($htmlname, array()); + } else { + $out .= ''.$langs->trans("ErrorNoFiscalyearDefined", $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Fiscalyear")).''; + } + } else { + dol_print_error($this->db); + } + + return $out; + } +} diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index c3904969a64..52d6b586555 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -480,6 +480,9 @@ class FormMail extends Form $form = new Form($this->db); } + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formai.class.php'; + $formai = new FormAI($this->db); + // Load translation files required by the page $langs->loadLangs(array('other', 'mails', 'members')); @@ -1099,6 +1102,8 @@ class FormMail extends Form $showlinktoailabel = $langs->trans("FillMessageWithAIContent"); $formatforouput = ''; $htmlname = 'message'; + $formai->substit = $this->substit; + $formai->substit_lines = $this->substit_lines; // Fill $out include DOL_DOCUMENT_ROOT.'/core/tpl/formlayoutai.tpl.php'; @@ -1486,161 +1491,6 @@ class FormMail extends Form return $out; } - /** - * Return Html code for AI instruction of message and autofill result - * - * @param string $function Function ('textgenerationmail', 'textgenerationwebpage', ...) - * @param string $format Format for output ('', 'html', ...) - * @param string $htmlContent HTML name of WYSIWYG field - * @return string HTML code to ask AI instruction and autofill result - * TODO Move into a file html.formai.class.php - */ - public function getSectionForAIPrompt($function = 'textgeneration', $format = '', $htmlContent = 'message') - { - global $langs; - - $langs->load("other"); - - $htmlContent = preg_replace('/[^a-z0-9_]/', '', $htmlContent); - - $out = '\n"; - - $out .= " - "; - return $out; - } - /** * Return HTML code for selection of email layout * diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4da74eb109c..60715181d98 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1157,17 +1157,18 @@ function GETPOSTFLOAT($paramname, $rounding = '') * Helper function that combines values of a dolibarr DatePicker (such as Form::selectDate) for year, month, day (and * optionally hour, minute, second) fields to return a timestamp. * - * @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate). Example: 'select_datec' - * @param string $hourTime 'getpost' or 'getpostend' to include hour, minute, second values from the HTTP request, - * or 'XX:YY:ZZ' to set hour, minute, second respectively, for example '23:59:59' - * or 'end' means '23:59:59' - * or '' means '00:00:00' (default) - * @param int|string $gm Passed to dol_mktime. If most cases, when used with 'getpost' or 'getpostend', it should be 'tzuserrel'. - * @return int|string Date as a timestamp, '' or false if error + * @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate). Example: 'select_datec' + * @param string $hourTime 'getpost' or 'getpostend' to include hour, minute, second values from the HTTP request, + * or 'XX:YY:ZZ' to set hour, minute, second respectively, for example '23:59:59' + * or 'end' means '23:59:59' + * or '' means '00:00:00' (default) + * @param int|string $gm Passed to dol_mktime. In most cases, when used with 'getpost' or 'getpostend', it should be 'tzuserrel'. Use 'auto' if you need dates related to 'tzserver' (like in accountancy). + * @param string $saverestore Use a string context to save retrieved date so it will be used on next retrieve using same context if not defined. + * @return int|string Date as a timestamp, '' or false if error * * @see dol_mktime() */ -function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') +function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto', $saverestore = '') { $m = array(); if ($hourTime === 'getpost' || $hourTime === 'getpostend') { @@ -1183,13 +1184,30 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') } else { $hour = $minute = $second = 0; } + + if ($saverestore && !GETPOSTISSET($prefix.'day') && !GETPOSTISSET($prefix.'month') && !GETPOSTISSET($prefix.'year')) { + $day = $_SESSION['DOLDATE_'.$saverestore.'_day']; + $month = $_SESSION['DOLDATE_'.$saverestore.'_month']; + $year = $_SESSION['DOLDATE_'.$saverestore.'_year']; + } else { + $month = GETPOSTINT($prefix . 'month'); + $day = GETPOSTINT($prefix . 'day'); + $year = GETPOSTINT($prefix . 'year'); + } + // normalize out of range values $hour = (int) min($hour, 23); $minute = (int) min($minute, 59); $second = (int) min($second, 59); - //print "$hour, $minute, $second, GETPOSTINT($prefix . 'month'), GETPOSTINT($prefix . 'day'), GETPOSTINT($prefix . 'year'), $gm
"; - return dol_mktime($hour, $minute, $second, GETPOSTINT($prefix . 'month'), GETPOSTINT($prefix . 'day'), GETPOSTINT($prefix . 'year'), $gm); + if ($saverestore) { + $_SESSION['DOLDATE_'.$saverestore.'_day'] = $day; + $_SESSION['DOLDATE_'.$saverestore.'_month'] = $month; + $_SESSION['DOLDATE_'.$saverestore.'_year'] = $year; + } + + //print "$hour, $minute, $second, $month, $day, $year, $gm
"; + return dol_mktime($hour, $minute, $second, $month, $day, $year, $gm); } diff --git a/htdocs/core/tpl/formlayoutai.tpl.php b/htdocs/core/tpl/formlayoutai.tpl.php index ba1e1412fb7..31709d692d9 100644 --- a/htdocs/core/tpl/formlayoutai.tpl.php +++ b/htdocs/core/tpl/formlayoutai.tpl.php @@ -21,6 +21,7 @@ * @var Conf $conf * @var ?FormMail $formmail * @var ?FormWebsite $formwebsite + * @var ?FormAI $formai * @var string $htmlname * @var string $showlinktolayout 'emailing', 'email', 'websitepage', ... * @var string $showlinktolayoutlabel '...' @@ -48,6 +49,7 @@ if (empty($htmlname)) { ' @phan-var-force ?FormWebSite $formwebsite @phan-var-force ?FormMail $formmail +@phan-var-force ?FormAI $formai @phan-var-force string $showlinktolayout @phan-var-force string $showlinktolayoutlabel @phan-var-force string $showlinktoai @@ -116,7 +118,7 @@ if ($showlinktolayout) { $out .= ''; } if ($showlinktoai) { - $out .= $formmail->getSectionForAIPrompt($showlinktoai, $formmail->withaiprompt, $htmlname); + $out .= $formai->getSectionForAIPrompt($showlinktoai, $formmail->withaiprompt, $htmlname); } else { $out .= ''; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index d22e57f50d1..5b9c3d99afc 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2656,6 +2656,18 @@ if ($action == 'create') { } } + // To avoid delete order with dispatched lines + if (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')) { + if (empty($object->lines)) { + $object->fetch_lines(); + } + $dispachedLines = $object->getDispachedLines(1); + $nbDispachedLines = count($dispachedLines); + if ($nbDispachedLines > 0) { + $hasreception = 1; + } + } + if (in_array($object->statut, array(3, 4, 5))) { if (isModEnabled("supplier_order") && $usercanreceive) { print ''; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index c8a9a1ef953..a2e56191d1c 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -626,7 +626,7 @@ if ($id > 0 || !empty($ref)) { // Author print ''.$langs->trans("AuthorRequest").''; - print ''.$author->getNomUrl(1, '', 0, 0, 0).''; + print ''.$author->getNomUrl(-1, '', 0, 0, 0).''; print ''; $parameters = array(); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 1af4cfa6c57..6afaaa74d13 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -410,8 +410,8 @@ AccountRemovedFromGroup=Account removed from group SaleLocal=Local sale SaleExport=Export sale SaleEEC=Sale in EEC -SaleEECWithVAT=Sale in EEC with a VAT not null, so we suppose this is NOT an intracommunautary sale and the suggested account is the standard product account. -SaleEECWithoutVATNumber=Sale in EEC with no VAT but the VAT ID of third party is not defined. We fall back on the account for standard sales. You can fix the VAT ID of the third party, or change the product account suggested for binding if needed. +SaleEECWithVAT=Sale is in EEC with a VAT not null, so we suppose this is NOT an intracommunautary sale and the suggested account is the standard product account. +SaleEECWithoutVATNumber=Sale is in EEC with no VAT but the VAT ID of third party is not defined. We fall back on the account for standard sales. You can fix the VAT ID of the third party, or change the product account suggested for binding if needed. AnySale=Any sale ForbiddenTransactionAlreadyExported=Forbidden: The transaction has been validated and/or exported. ForbiddenTransactionAlreadyValidated=Forbidden: The transaction has been validated. diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a1779281e4c..731a835efa0 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2524,10 +2524,13 @@ AiSetup=AI module setup AiCustomPrompt=AI custom prompt AI_CONFIGURATIONS_PROMPT=Custom prompt TextGeneration=Text generation +TextTranslation=Text translation ImageGeneration=Image generation VideoGeneration=Video generation AudioGeneration=Audio generation -AIPromptForFeatures=AI custom prompts for features +AIPromptForFeatures=AI custom prompts or models for features +AudioTranscription=Audio transcription +AudioTranslation=Audio translation EnterAnIP=Enter an IP address ConvertInto=Convert into YouAreHere=You are here diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 723bb8cf0ae..d79ed8a9596 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -283,6 +283,9 @@ ImportDataset_tax_contrib=Social/fiscal taxes ImportDataset_tax_vat=VAT payments ErrorBankAccountNotFound=Error: Bank account not found FiscalPeriod=Accounting period +ErrorNoFiscalyearDefined=Error, no fiscal year defined (See %s - %s - %s) +FiscalYearSetAsDefault=Fiscal year (%s) defined as default +FiscalYearFromTo=Period from %s to %s FiscalYearOpened=Fiscal year opened FiscalYearClosed=Fiscal year closed FiscalYearOpenedShort=Opened diff --git a/htdocs/modulebuilder/template/build/buildzip.php b/htdocs/modulebuilder/template/build/buildzip.php new file mode 100644 index 00000000000..3508bbbec79 --- /dev/null +++ b/htdocs/modulebuilder/template/build/buildzip.php @@ -0,0 +1,316 @@ +#!/usr/bin/env php -d memory_limit=256M + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* + The goal of that php CLI script is to make zip package of your module + as an alternative to web "build zip" or "perl script makepack" +*/ + +// ============================================= configuration + +/** + * list of files & dirs of your module + * + * @var string[] + */ +$listOfModuleContent = [ + 'admin', + 'ajax', + 'backport', + 'class', + 'css', + 'COPYING', + 'core', + 'img', + 'js', + 'langs', + 'lib', + 'sql', + 'tpl', + '*.md', + '*.json', + '*.php', + 'modulebuilder.txt', +]; + +/** + * if you want to exclude some files from your zip + * + * @var string[] + */ +$exclude_list = [ + '/^.git$/', + '/.*js.map/', + '/DEV.md/' +]; + +// ============================================= end of configuration + +/** + * auto detect module name and version from file name + * + * @return (string|string)[] module name and module version + */ +function detectModule() +{ + $name = $version = ""; + $tab = glob("core/modules/mod*.class.php"); + if (count($tab) == 0) { + echo "[fail] Error on auto detect data : there is no mod*.class.php file into core/modules dir\n"; + exit(-1); + } + if (count($tab) == 1) { + $file = $tab[0]; + $pattern = "/.*mod(?.*)\.class\.php/"; + if (preg_match_all($pattern, $file, $matches)) { + $name = strtolower(reset($matches['mod'])); + } + + echo "extract data from $file\n"; + if (!file_exists($file) || $name == "") { + echo "[fail] Error on auto detect data\n"; + exit(-2); + } + } else { + echo "[fail] Error there is more than one mod*.class.php file into core/modules dir\n"; + exit(-3); + } + + //extract version from file + $contents = file_get_contents($file); + $pattern = "/^.*this->version\s*=\s*'(?.*)'\s*;.*\$/m"; + + // search, and store all matching occurrences in $matches + if (preg_match_all($pattern, $contents, $matches)) { + $version = reset($matches['version']); + } + + if (version_compare($version, '0.0.1', '>=') != 1) { + echo "[fail] Error auto extract version fail\n"; + exit(-4); + } + + echo "module name = $name, version = $version\n"; + return [(string) $name, (string) $version]; +} + +/** + * delete recursively a directory + * + * @param string $dir dir path to delete + * + * @return bool true on success or false on failure. + */ +function delTree($dir) +{ + $files = array_diff(scandir($dir), array('.', '..')); + foreach ($files as $file) { + (is_dir("$dir/$file")) ? delTree("$dir/$file") : secureUnlink("$dir/$file"); + } + return rmdir($dir); +} + + +/** + * do a secure delete file/dir with double check + * (don't trust unlink return) + * + * @param string $path full path to delete + * + * @return bool true on success ($path does not exists at the end of process), else exit + */ +function secureUnlink($path) +{ + if (file_exists($path)) { + if (unlink($path)) { + //then check if really deleted + clearstatcache(); + if (file_exists($path)) { // @phpstan-ignore-line + echo "[fail] unlink of $path fail !\n"; + exit(-5); + } + } else { + echo "[fail] unlink of $path fail !\n"; + exit(-6); + } + } + return true; +} + +/** + * create a directory and check if dir exists + * + * @param string $path path to make + * + * @return bool true on success ($path exists at the end of process), else exit + */ +function mkdirAndCheck($path) +{ + if (mkdir($path)) { + clearstatcache(); + if (is_dir($path)) { + return true; + } + } + echo "[fail] Error on $path (mkdir)\n"; + exit(7); +} + +/** + * check if that filename is concerned by exclude filter + * + * @param string $filename file name to check + * + * @return bool true if file is in excluded list + */ +function is_excluded($filename) +{ + global $exclude_list; + $count = 0; + $notused = preg_filter($exclude_list, '1', $filename, -1, $count); + if ($count > 0) { + echo " - exclude $filename\n"; + return true; + } + return false; +} + +/** + * recursive copy files & dirs + * + * @param string $src source dir + * @param string $dst target dir + * + * @return bool true on success or false on failure. + */ +function rcopy($src, $dst) +{ + if (is_dir($src)) { + // Make the destination directory if not exist + mkdirAndCheck($dst); + // open the source directory + $dir = opendir($src); + + // Loop through the files in source directory + while ($file = readdir($dir)) { + if (($file != '.') && ($file != '..')) { + if (is_dir($src . '/' . $file)) { + // Recursively calling custom copy function + // for sub directory + if (!rcopy($src . '/' . $file, $dst . '/' . $file)) { + return false; + } + } else { + if (!is_excluded($file)) { + if (!copy($src . '/' . $file, $dst . '/' . $file)) { + return false; + } + } + } + } + } + closedir($dir); + } elseif (is_file($src)) { + if (!is_excluded($src)) { + if (!copy($src, $dst)) { + return false; + } + } + } + return true; +} + +/** + * build a zip file with only php code and no external depends + * on "zip" exec for example + * + * @param string $folder folder to use as zip root + * @param ZipArchive $zip zip object (ZipArchive) + * @param string $root relative root path into the zip + * + * @return bool true on success or false on failure. + */ +function zipDir($folder, &$zip, $root = "") +{ + foreach (new \DirectoryIterator($folder) as $f) { + if ($f->isDot()) { + continue; + } //skip . .. + $src = $folder . '/' . $f; + $dst = substr($f->getPathname(), strlen($root)); + if ($f->isDir()) { + if ($zip->addEmptyDir($dst)) { + if (zipDir($src, $zip, $root)) { + continue; + } else { + return false; + } + } else { + return false; + } + } + if ($f->isFile()) { + if (! $zip->addFile($src, $dst)) { + return false; + } + } + } + return true; +} + +/** + * main part of script + */ + +list($mod, $version) = detectModule(); +$outzip = sys_get_temp_dir() . "/module_" . $mod . "-" . $version . ".zip"; +if (file_exists($outzip)) { + secureUnlink($outzip); +} + +//copy all sources into system temp directory +$tmpdir = tempnam(sys_get_temp_dir(), $mod . "-module"); +secureUnlink($tmpdir); +mkdirAndCheck($tmpdir); +$dst = $tmpdir . "/" . $mod; +mkdirAndCheck($dst); + +foreach ($listOfModuleContent as $moduleContent) { + foreach (glob($moduleContent) as $entry) { + if (!rcopy($entry, $dst . '/' . $entry)) { + echo "[fail] Error on copy " . $entry . " to " . $dst . "/" . $entry . "\n"; + echo "Please take time to analyze the problem and fix the bug\n"; + exit(-8); + } + } +} + +$z = new ZipArchive(); +$z->open($outzip, ZIPARCHIVE::CREATE); +zipDir($tmpdir, $z, $tmpdir . '/'); +$z->close(); +delTree($tmpdir); +if (file_exists($outzip)) { + echo "[success] module archive is ready : $outzip ...\n"; +} else { + echo "[fail] build zip error\n"; + exit(-9); +} diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 7ffc627d8b0..7ac2a896fe1 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2014 Cedric GROSS * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Ferran Marcet - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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,19 +75,18 @@ class Productbatch extends CommonObject public $fk_product; /** - * * @var int Properties of the lot * ID in table of the details of properties of each lots */ public $lotid; /** - * @var int|string + * @var int|'' * @deprecated */ public $sellby = ''; // dlc /** - * @var int|string + * @var int|'' * @deprecated */ public $eatby = ''; // dmd/dluo @@ -107,9 +106,9 @@ class Productbatch extends CommonObject /** * Create object into database * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, Id of created object if OK */ public function create($user, $notrigger = 0) { @@ -402,13 +401,13 @@ class Productbatch extends CommonObject * Find first detailed record that match either eat-by, sell-by or batch within the warehouse * * @param int $fk_product_stock id product_stock for object - * @param integer $eatby eat-by date for object - deprecated: a search must be done on batch number - * @param integer $sellby sell-by date for object - deprecated: a search must be done on batch number + * @param int|'' $eatby eat-by date for object - deprecated: a search must be done on batch number + * @param int|'' $sellby sell-by date for object - deprecated: a search must be done on batch number * @param string $batch_number batch number for object * @param int $fk_warehouse filter on warehouse (use it if you don't have $fk_product_stock) * @return int Return integer <0 if KO, >0 if OK */ - public function find($fk_product_stock = 0, $eatby = null, $sellby = null, $batch_number = '', $fk_warehouse = 0) + public function find($fk_product_stock = 0, $eatby = '', $sellby = '', $batch_number = '', $fk_warehouse = 0) { $where = array(); @@ -472,7 +471,7 @@ class Productbatch extends CommonObject * * @param DoliDB $dbs database object * @param int $fk_product_stock id product_stock for object - * @param int $with_qty 1 = doesn't return line with 0 quantity + * @param int<0,1> $with_qty 1 = doesn't return line with 0 quantity * @param int $fk_product If set to a product id, get eatby and sellby from table llx_product_lot * @return Productbatch[]|int Return integer <0 if KO, array of batch */ diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 7659c066370..e7fb45d9590 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2015 Laurent Destailleur * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2014 Cedric GROSS - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -201,11 +201,11 @@ class MouvementStock extends CommonObject * @param int $fk_product Id of product * @param int $entrepot_id Id of warehouse * @param float $qty Qty of movement (can be <0 or >0 depending on parameter type) - * @param int $type Direction of movement: + * @param int<0,3> $type Direction of movement: * 0=input (stock increase by a stock transfer), 1=output (stock decrease by a stock transfer), * 2=output (stock decrease), 3=input (stock increase) * Note that qty should be > 0 with 0 or 3, < 0 with 1 or 2. - * @param int $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed. + * @param float $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed. * @param string $label Label of stock movement * @param string $inventorycode Inventory code * @param int|string $datem Force date of movement @@ -785,10 +785,10 @@ class MouvementStock extends CommonObject * @param int $entrepot_id Warehouse id * @param float $qty Quantity * @param int $type Type - * @param int $price Price + * @param float $price Price * @param string $label Label of movement * @param string $inventorycode Inventory code - * @param integer|string $datem Force date of movement + * @param int|'' $datem Force date of movement * @return int Return integer <0 if KO, 0 if OK */ private function _createSubProduct($user, $idProduct, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '') @@ -847,15 +847,15 @@ class MouvementStock extends CommonObject * @param int $fk_product Id product * @param int $entrepot_id Warehouse id * @param float $qty Quantity - * @param int $price Price + * @param float $price Price * @param string $label Label of stock movement - * @param int|string $datem Force date of movement - * @param int|string $eatby eat-by date - * @param int|string $sellby sell-by date + * @param int|'' $datem Force date of movement + * @param int|'' $eatby eat-by date + * @param int|'' $sellby sell-by date * @param string $batch batch number * @param int $id_product_batch Id product_batch * @param string $inventorycode Inventory code - * @param int $donotcleanemptylines Do not clean lines that remains in stock table with qty=0 (because we want to have this done by the caller) + * @param int<0,1> $donotcleanemptylines Do not clean lines that remains in stock table with qty=0 (because we want to have this done by the caller) * @return int Return integer <0 if KO, >0 if OK */ public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0, $inventorycode = '', $donotcleanemptylines = 0) @@ -874,15 +874,15 @@ class MouvementStock extends CommonObject * @param int $fk_product Id product * @param int $entrepot_id Warehouse id * @param float $qty Quantity - * @param int $price Price + * @param float $price Price * @param string $label Label of stock movement - * @param integer|string $eatby eat-by date - * @param integer|string $sellby sell-by date + * @param int|'' $eatby eat-by date + * @param int|'' $sellby sell-by date * @param string $batch batch number - * @param integer|string $datem Force date of movement + * @param int|'' $datem Force date of movement * @param int $id_product_batch Id product_batch * @param string $inventorycode Inventory code - * @param int $donotcleanemptylines Do not clean lines that remains in stock table with qty=0 (because we want to have this done by the caller) + * @param int<0,1> $donotcleanemptylines Do not clean lines that remains in stock table with qty=0 (because we want to have this done by the caller) * @return int Return integer <0 if KO, >0 if OK */ public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0, $inventorycode = '', $donotcleanemptylines = 0) diff --git a/htdocs/takepos/admin/bar.php b/htdocs/takepos/admin/bar.php index 9459557f18c..f49f8b8b2de 100644 --- a/htdocs/takepos/admin/bar.php +++ b/htdocs/takepos/admin/bar.php @@ -3,6 +3,7 @@ * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2022 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -81,7 +82,7 @@ if (GETPOST('action', 'alpha') == 'set') { if (getDolGlobalInt('TAKEPOS_ORDER_NOTES') == 1) { $extrafields = new ExtraFields($db); - $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, 255, 'facturedet', 0, 0, '', '', 0, '', 0, 1); + $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, '255', 'facturedet', 0, 0, '', '', 0, '', '0', '1'); } /* diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 06a8424daac..c430c572d3c 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -269,9 +269,9 @@ if (isModEnabled("bank")) { $stripe = new Stripe($db); $stripeacc = $stripe->getStripeAccount($service); if ($stripeacc) { - $readers = \Stripe\Terminal\Reader::all('', array("location" => getDolGlobalString('STRIPE_LOCATION'), "stripe_account" => $stripeacc)); + $readers = \Stripe\Terminal\Reader::all(null, array("location" => getDolGlobalString('STRIPE_LOCATION'), "stripe_account" => $stripeacc)); } else { - $readers = \Stripe\Terminal\Reader::all('', array("location" => getDolGlobalString('STRIPE_LOCATION'))); + $readers = \Stripe\Terminal\Reader::all(null, array("location" => getDolGlobalString('STRIPE_LOCATION'))); } $reader = array(); @@ -323,7 +323,7 @@ if (isModEnabled('stock')) { print ''; - $disabled = getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal); + $disabled = getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal); print ''; diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index b90d55d2aa6..7855842ae5b 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2004 Andreu Bisquerra * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -111,6 +112,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { $res = array(); if (is_array($prods) && count($prods) > 0) { foreach ($prods as $prod) { + '@phan-var-force Product $prod'; if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { // remove products without stock $prod->load_stock('nobatch,novirtual'); @@ -134,8 +136,8 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { } elseif ($action == 'search' && $search_term != '' && $user->hasRight('takepos', 'run')) { top_httphead('application/json'); - // Search barcode into thirdparties. If found, it means we want to change thirdparties. - $result = $thirdparty->fetch('', '', '', $search_term); + // Search barcode into third parties. If found, it means we want to change third parties. + $result = $thirdparty->fetch(0, '', '', $search_term); if ($result && $thirdparty->id > 0) { $rows = array(); @@ -338,7 +340,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { } // load only one page of products - $sql.= $db->plimit($search_limit, $search_start); + $sql .= $db->plimit($search_limit, $search_start); $resql = $db->query($sql); if ($resql) { @@ -379,7 +381,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { 'price_ttc_formated' => price(price2num(empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency) ); // Add entries to row from hooks - $parameters=array(); + $parameters = array(); $parameters['row'] = $row; $parameters['obj'] = $obj; $reshook = $hookmanager->executeHooks('completeAjaxReturnArray', $parameters); @@ -429,7 +431,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { if ((getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term) > 0) { $object = new Facture($db); $object->fetch($id); - $ret = $printer->sendToPrinter($object, getDolGlobalString('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalString('TAKEPOS_PRINTER_TO_USE'.$term)); + $ret = $printer->sendToPrinter($object, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term)); } } elseif ($action == 'getInvoice' && $user->hasRight('takepos', 'run')) { top_httphead('application/json'); @@ -452,5 +454,5 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { $object = new Facture($db); $printer = new dolReceiptPrinter($db); - $printer->sendToPrinter($object, getDolGlobalString('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalString('TAKEPOS_PRINTER_TO_USE'.$term)); + $printer->sendToPrinter($object, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term)); } diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 540244d87d6..e26369e97a8 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -85,7 +85,7 @@ if ($action == "getTables" && $user->hasRight('takepos', 'run')) { $tmpplace = (int) $row['rowid']; $invoice = new Facture($db); - $result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$tmpplace.')'); + $result = $invoice->fetch(0, '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$tmpplace.')'); if ($result > 0) { $row['occupied'] = "red"; } diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php index b25e42a77ea..245c60be2e3 100644 --- a/htdocs/takepos/freezone.php +++ b/htdocs/takepos/freezone.php @@ -2,6 +2,7 @@ /* Copyright (C) 2018 Andreu Bisquerra * Copyright (C) 2020 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -60,7 +61,7 @@ $langs->loadLangs(array("bills", "cashdesk")); $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'); // $place is id of table for Bar or Restaurant -$invoiceid = GETPOST('invoiceid', 'int'); +$invoiceid = GETPOSTINT('invoiceid'); $idline = GETPOSTINT('idline'); $action = GETPOST('action', 'aZ09'); @@ -74,7 +75,7 @@ $invoice = new Facture($db); if ($invoiceid > 0) { $invoice->fetch($invoiceid); } else { - $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$place.')'); + $invoice->fetch(0, '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$place.')'); } diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index d6c17330525..659a22d10a8 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2018 Andreu Bisquerra * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Thibault FOUCART - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -1363,7 +1363,7 @@ if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) { if (count($maincategories) == 0) { if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) { $tmpcategory = new Categorie($db); - $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID')); + $tmpcategory->fetch(getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID')); setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors'); } else { setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors'); @@ -1577,14 +1577,14 @@ if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) { $count = 0; while ($count < $MAXPRODUCT) { print '
- onclick="MoreProducts('less')" onclick="MoreProducts('more')" > + onclick="MoreProducts('less')" onclick="MoreProducts('more')" > '; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 604fb1dd176..9975c744503 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -3,7 +3,7 @@ * Copyright (C) 2018 Andreu Bisquerra * Copyright (C) 2021 Nicolas ZABOURI * Copyright (C) 2022-2023 Christophe Battarel - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -96,7 +96,7 @@ $takeposterminal = isset($_SESSION["takeposterminal"]) ? $_SESSION["takepostermi * Abort invoice creation with a given error message * * @param string $message Message explaining the error to the user - * @return void + * @return never */ function fail($message) { @@ -106,7 +106,7 @@ function fail($message) -$number = GETPOST('number', 'alpha'); +$number = (float) GETPOST('number', 'alpha'); $idline = GETPOSTINT('idline'); $selectedline = GETPOSTINT('selectedline'); $desc = GETPOST('desc', 'alphanohtml'); @@ -145,7 +145,7 @@ $invoice = new Facture($db); if ($invoiceid > 0) { $ret = $invoice->fetch($invoiceid); } else { - $ret = $invoice->fetch('', '(PROV-POS'.$takeposterminal.'-'.$place.')'); + $ret = $invoice->fetch(0, '(PROV-POS'.$takeposterminal.'-'.$place.')'); } if ($ret > 0) { $placeid = $invoice->id; @@ -157,7 +157,7 @@ $soc = new Societe($db); if ($invoice->socid > 0) { $soc->fetch($invoice->socid); } else { - $soc->fetch(getDolGlobalString($constforcompanyid)); + $soc->fetch(getDolGlobalInt($constforcompanyid)); } // Assign a default project, if relevant @@ -185,6 +185,13 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +$sectionwithinvoicelink = ''; +$CUSTOMER_DISPLAY_line1 = ''; +$CUSTOMER_DISPLAY_line2 = ''; +$headerorder = ''; +$footerorder = ''; +$printer = null; +$idoflineadded = 0; if (empty($reshook)) { // Action to record a payment on a TakePOS invoice if ($action == 'valid' && $user->hasRight('facture', 'creer')) { @@ -227,11 +234,12 @@ if (empty($reshook)) { $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; $sql .= " ORDER BY rowid DESC"; + $fk_source = 0; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); $fk_source = $obj->rowid; - if ($fk_source == null) { + if ((int) $fk_source == 0) { fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); } } else { @@ -342,6 +350,7 @@ if (empty($reshook)) { dol_htmloutput_errors($invoice->error, $invoice->errors, 1); } + $warehouseid = 0; // Update stock for batch products if (!$error && $res >= 0) { if (isModEnabled('stock') && isModEnabled('productbatch') && $allowstockchange) { @@ -392,6 +401,7 @@ if (empty($reshook)) { $db->rollback(); } } + $creditnote = null; if ($action == 'creditnote' && $user->hasRight('facture', 'creer')) { $db->begin(); @@ -535,7 +545,7 @@ if (empty($reshook)) { // Validate invoice with stock change into warehouse getDolGlobalInt($constantforkey) // Label of stock movement will be the same as when we validate invoice "Invoice XXXX validated" $batch_rule = 0; // Module productbatch is disabled here, so no need for a batch_rule. - $res = $creditnote->validate($user, '', getDolGlobalString($constantforkey), 0, $batch_rule); + $res = $creditnote->validate($user, '', getDolGlobalInt($constantforkey), 0, $batch_rule); if ($res < 0) { $error++; dol_htmloutput_errors($creditnote->error, $creditnote->errors, 1); @@ -600,7 +610,7 @@ if (empty($reshook)) { } if (($action == 'history' || $action == 'creditnote') && $user->hasRight('takepos', 'run')) { - if ($action == 'creditnote' && $creditnote->id > 0) { // Test on permission already done + if ($action == 'creditnote' && $creditnote !== null && $creditnote->id > 0) { // Test on permission already done $placeid = $creditnote->id; } else { $placeid = GETPOSTINT('placeid'); @@ -648,6 +658,7 @@ if (empty($reshook)) { } } + $tva_npr = 0; // If we add a line by click on product (invoice exists here because it was created juste before if it didn't exists) if ($action == "addline" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) { $prod = new Product($db); @@ -664,7 +675,7 @@ if (empty($reshook)) { //$price_min = $datapriceofproduct['price_min']; $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type']; $tva_tx = $datapriceofproduct['tva_tx']; - $tva_npr = $datapriceofproduct['tva_npr']; + $tva_npr = (int) $datapriceofproduct['tva_npr']; // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); @@ -727,12 +738,12 @@ if (empty($reshook)) { print ''; $detail = ''; $detail .= ''.$langs->trans("LotSerial").': '.$dbatch->batch; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - //$detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - //$detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); - } + //if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { + //$detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + //} + //if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { + //$detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + //} $detail .= ''; $detail .= ''.$langs->trans("Qty").': '.$dbatch->qty; $detail .= ''; @@ -774,7 +785,6 @@ if (empty($reshook)) { } } - $idoflineadded = 0; $err = 0; // Group if enabled. Skip group if line already sent to the printer if (getDolGlobalString('TAKEPOS_GROUP_SAME_PRODUCT')) { @@ -849,7 +859,7 @@ if (empty($reshook)) { } if (empty($err)) { - $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (empty($parent_line) ? '' : $parent_line), (empty($line['fk_fournprice']) ? 0 : $line['fk_fournprice']), (empty($line['pa_ht']) ? '' : $line['pa_ht']), '', $line['array_options'], 100, '', null, 0); + $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, (float) $line['remise_percent'], '', 0, 0, 0, 0, $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (empty($parent_line) ? '' : $parent_line), (empty($line['fk_fournprice']) ? 0 : $line['fk_fournprice']), (empty($line['pa_ht']) ? '' : $line['pa_ht']), '', $line['array_options'], 100, 0, null, 0); } } @@ -862,7 +872,7 @@ if (empty($reshook)) { $invoice->fetch($placeid); } - // If we add a line by submitting freezone form (invoice exists here because it was created juste before if it didn't exists) + // If we add a line by submitting freezone form (invoice exists here because it was created just before if it didn't exist) if ($action == "freezone" && $user->hasRight('takepos', 'run')) { $customer = new Societe($db); $customer->fetch($invoice->socid); @@ -880,7 +890,7 @@ if (empty($reshook)) { $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - $res = $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $res = $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, 0, getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, 0, 0, '', array(), 100, 0, null, 0); if ($res < 0) { dol_htmloutput_errors($invoice->error, $invoice->errors, 1); } @@ -1170,7 +1180,7 @@ if (empty($reshook)) { $order_receipt_printer1 .= ''; } } - if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0) { + if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0 && $printer !== null) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 1; echo " currency = '.$conf->currency.' - sessioncurrency = '.$sessioncurrency.' -->'."\n"; +$multicurrency = null; if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency != $sessioncurrency) { // Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency - $showothercurrency = 1; include_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php'; $multicurrency = new MultiCurrency($db); $multicurrency->fetch(0, $sessioncurrency); @@ -554,7 +554,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
trans('TotalTTC'); ?>: total_ttc, 1, '', 1, -1, -1, $conf->currency); - if ($showothercurrency) { + if ($multicurrency !== null) { print '   (' . price($invoice->total_ht * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?> @@ -563,7 +563,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
trans('RemainToPay'); ?>: currency); - if ($showothercurrency) { + if ($multicurrency !== null) { print '   (' . price($remaintopay * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?> @@ -572,7 +572,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
trans("Received"); ?>: currency); - if ($showothercurrency) { + if ($multicurrency !== null) { print '   (' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?> @@ -580,7 +580,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
trans("Change"); ?>: currency); - if ($showothercurrency) { + if ($multicurrency !== null) { print '   (' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?> @@ -729,7 +729,7 @@ while ($i < count($arrayOfValidPaymentModes)) { if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && getDolGlobalString('STRIPE_CARD_PRESENT')) { $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; print ''; - if (getDolGlobalString($keyforstripeterminalbank)) { + if (getDolGlobalString((string) $keyforstripeterminalbank)) { // Nothing } else { $langs->loadLangs(array("errors", "admin")); diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php index 81659654315..0a21e58fc89 100644 --- a/htdocs/takepos/phone.php +++ b/htdocs/takepos/phone.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -132,7 +133,7 @@ if ($action == "productinfo" && $user->hasRight('takepos', 'run')) { require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $printer = new dolReceiptPrinter($db); - $printer->initPrinter(getDolGlobalString('TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"])); + $printer->initPrinter(getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"])); if ($printer->getPrintConnector()) { if (!is_null($printer->printer)) { $printer->printer->feed(); diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 9d85490f77d..35385cd8a09 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -2,6 +2,7 @@ /* Copyright (C) 2019 Thibault FOUCART * Copyright (C) 2020 Andreu Bisquerra Gaya * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -77,7 +78,7 @@ if ($action == "send" && $user->hasRight('takepos', 'run')) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $outputlangs = new Translate('', $conf); - $model_id = getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE'); + $model_id = getDolGlobalInt('TAKEPOS_EMAIL_TEMPLATE_INVOICE'); $arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id); $subject = $arraydefaultmessage->topic; diff --git a/htdocs/takepos/split.php b/htdocs/takepos/split.php index 8fadea69c95..c61d9ed3ca9 100644 --- a/htdocs/takepos/split.php +++ b/htdocs/takepos/split.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -65,14 +66,16 @@ if (!$user->hasRight('takepos', 'run')) { if ($action == "split" && $user->hasRight('takepos', 'run')) { $line = GETPOSTINT('line'); $split = GETPOSTINT('split'); - if ($split==1) { // Split line + $invoice = null; + $placeid = 0; + if ($split == 1) { // Split line $invoice = new Facture($db); - $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-SPLIT)'); + $ret = $invoice->fetch(0, '(PROV-POS'.$_SESSION["takeposterminal"].'-SPLIT)'); if ($ret > 0) { $placeid = $invoice->id; } else { $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; - $invoice->socid =getDolGlobalInt($constforcompanyid); + $invoice->socid = getDolGlobalInt($constforcompanyid); $invoice->date = dol_now(); $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; @@ -92,12 +95,12 @@ if ($action == "split" && $user->hasRight('takepos', 'run')) { } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET fk_facture = ".((int) $placeid)." WHERE rowid = ".((int) $line); $db->query($sql); - } elseif ($split==0) { // Unsplit line + } elseif ($split == 0) { // Unsplit line $invoice = new Facture($db); if ($place == "SPLIT") { $place = "0"; } // Avoid move line to the same place (from SPLIT to SPLIT place) - $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); + $ret = $invoice->fetch(0, '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); if ($ret > 0) { $placeid = $invoice->id; } else { @@ -124,11 +127,13 @@ if ($action == "split" && $user->hasRight('takepos', 'run')) { $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set fk_facture=".$placeid." where rowid=".$line; $db->query($sql); } - $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-SPLIT)'); - $invoice->update_price(); + if ($invoice !== null) { + $invoice->fetch(0, '(PROV-POS'.$_SESSION["takeposterminal"].'-SPLIT)'); + $invoice->update_price(); - $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); - $invoice->update_price(); + $invoice->fetch(0, '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); + $invoice->update_price(); + } } diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index 01a3f1d4824..17e9b260a8d 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France */ if (!defined('ISLOADEDBYSTEELSHEET')) { @@ -254,6 +254,8 @@ _createStatusBadgeCss('4b', '', "STATUS4b"); * @param string $commentLabel a comment label * @param string $cssPrefix a css prefix * @return void + * + * @phan-suppress PhanRedefineFunction */ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentLabel = '', $cssPrefix = '') { diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 60c7cf2d04d..1d8091d8a3b 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -1,5 +1,6 @@ + * Copyright (C) 2025 MDW */ if (!defined('ISLOADEDBYSTEELSHEET')) { die('Must be call by steelsheet'); @@ -12,9 +13,21 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { * @var string $colortextlink * @var int $dol_optimize_smallscreen * @var string $textbutaction + * @var int<0,max> $nbtopmenuentries * @var string $right * @var string $left */ + +' +@phan-var-force string $butactionbg +@phan-var-force string $colortextlink +@phan-var-force int<0,1> $dol_optimize_smallscreen +@phan-var-force string $fontlist +@phan-var-force string $left +@phan-var-force int<0,max> $nbtopmenuentries +@phan-var-force string $right +@phan-var-force string $textbutaction +'; ?> /* IDE Hack