Merge branch 'develop' into new-ai-model-setup-for-feature

This commit is contained in:
Lucas Marcouiller 2025-02-19 14:49:18 +01:00 committed by GitHub
commit 4e26febdd8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 1348 additions and 571 deletions

View file

@ -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

View file

@ -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'],

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
/* Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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 '<td>'.$langs->trans("DateEnd").'</td>';
print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
print '<td class="center">'.$langs->trans("Default").'</td>';
print '<td class="right">'.$langs->trans("Status").'</td>';
print '</tr>';
@ -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 '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
// Default
print '<td class="center">';
if (getDolGlobalString('ACCOUNTANCY_FISCALYEAR_DEFAULT') == (int) $fiscalyearstatic->ref) {
print img_picto($langs->trans("Default"), 'on');
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdefault&token='.newToken().'&value='.urlencode($fiscalyearstatic->ref).'&label='.urlencode($fiscalyearstatic->label).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').'</a>';
}
print '</td>';
print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->status, 5).'</td>';
print '</tr>';
$i++;
}
} else {
print '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
print '<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
print '</table>';
print '</div>';

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2016-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
@ -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.

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
@ -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);

View file

@ -1,12 +1,12 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inoveasya.solutions>
* Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Progiseize <a.bisotti@progiseiea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Progiseize <a.bisotti@progiseiea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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.

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2020 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
@ -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)) {

View file

@ -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 '<br>';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="warehouse">';
print '<input type="hidden" name="page_y" value="">';
// Title rule for stock decrease
print '<div class="div-table-responsive-no-min">'; // 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 '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
@ -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 '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")).'</span>';
@ -283,10 +285,10 @@ print '<td>'.$langs->trans("DeStockOnShipment").'</td>';
print '<td class="right">';
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 '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).'</span>';
@ -300,7 +302,7 @@ print '<td>'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
print '<td class="right">';
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 '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
@ -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 '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
@ -377,10 +379,10 @@ if (isModEnabled("reception")) {
print '<td class="right">';
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 "</td>\n</tr>\n";
@ -392,24 +394,25 @@ if (isModEnabled("reception")) {
print '<td class="right">';
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 "</td>\n</tr>\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 '<!-- STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER -->';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
print '<td class="right">';
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 '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
@ -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 "</td>\n";
print "</tr>\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 "</td>\n";
print "</tr>\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 "</td>\n";
print "</tr>\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 "</td>\n";
print "</tr>\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 "</td>\n";
print "</tr>\n";

View file

@ -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";

View file

@ -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;

View file

@ -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;

View file

@ -0,0 +1,416 @@
<?php
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015-2017 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2017 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Anthony Berton <anthony.berton@bb2a.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file 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<string,string>
*/
public $substit = array();
/**
* @var array<int,array<string,string>>
*/
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 = '<div id="ai_input'.$htmlContent.'" class="ai_input'.$htmlContent.' hidden paddingtop paddingbottom">';
$out .= '<input type="text" class="quatrevingtpercent" id="ai_instructions'.$htmlContent.'" name="instruction" placeholder="'.$langs->trans("EnterYourAIPromptHere").'..." />';
$out .= '<input id="generate_button'.$htmlContent.'" type="button" class="button smallpaddingimp" value="'.$langs->trans('Generate').'"/>';
$out .= '<div id="ai_status_message'.$htmlContent.'" class="fieldrequired hideobject marginrightonly margintoponly">';
$out .= '<i class="fa fa-spinner fa-spin fa-2x fa-fw valignmiddle marginrightonly"></i>'.$langs->trans("AIProcessingPleaseWait", getDolGlobalString('AI_API_SERVICE', 'chatgpt'));
$out .= '</div>';
if ($function == 'imagegeneration') {
$out .= '<div id="ai_image_result" class="margintoponly"></div>'; // Div for displaying the generated image
}
$out .= "</div>\n";
$out .= "<script type='text/javascript'>
$(document).ready(function() {
// for keydown
$('#ai_instructions".$htmlContent."').keydown(function(event) {
if (event.keyCode === 13) {
event.preventDefault();
$('#generate_button".$htmlContent."').click();
}
});
$('#generate_button".$htmlContent."').click(function() {
console.log('We click on generate_button".$htmlContent." ai button, so we make an ajax on url /ai/ajax/generate_content.php');
var instructions = $('#ai_instructions".$htmlContent."').val();
var timeoutfinished = 0;
var apicallfinished = 0;
$('#ai_status_message".$htmlContent."').show();
$('.icon-container .loader').show();
setTimeout(function() {
timeoutfinished = 1;
if (apicallfinished) {
$('#ai_status_message".$htmlContent."').hide();
}
}, 2000);
if ('".$function."' === 'imagegeneration') {
// Handle image generation request
$.ajax({
url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
'format': '".dol_escape_js($format)."', /* the format for output */
'function': '".dol_escape_js($function)."', /* the AI feature to call */
'instructions': instructions, /* the prompt string */
}),
success: function(response) {
console.log('Received image URL: '+response);
// make substitutions
let substit = ". json_encode($this->substit).";
for (let key in substit) {
if (substit.hasOwnProperty(key)) {
// Replace the placeholder with its corresponding value
response = response.replace(key, substit[key]);
}
}
// Assuming response is the URL of the generated image
var imageUrl = response;
$('#ai_image_result').html('<img src=\"' + imageUrl + '\" alt=\"Generated Image\" />');
// Clear the input field
$('#ai_instructions').val('');
apicallfinished = 1;
if (timeoutfinished) {
$('#ai_status_message').hide();
}
},
error: function(xhr, status, error) {
alert(error);
console.error('error ajax', status, error);
$('#ai_status_message').hide();
}
});
} else {
// set editor in readonly
if (CKEDITOR.instances.".$htmlContent.") {
CKEDITOR.instances.".$htmlContent.".setReadOnly(1);
}
$.ajax({
url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
'format': '".dol_escape_js($format)."', /* the format for output */
'function': '".dol_escape_js($function)."', /* the AI feature to call */
'instructions': instructions, /* the prompt string */
}),
success: function(response) {
console.log('Add response into field \'#".$htmlContent."\': '+response);
jQuery('#".$htmlContent."').val(response); // If #htmlcontent is a input name or textarea
jQuery('#".$htmlContent."').html(response); // If #htmlContent is a div
//jQuery('#".$htmlContent."preview').val(response);
if (CKEDITOR.instances) {
var editorInstance = CKEDITOR.instances.".$htmlContent.";
if (editorInstance) {
editorInstance.setReadOnly(0);
editorInstance.setData(response);
}
//var editorInstancepreview = CKEDITOR.instances.".$htmlContent."preview;
//if (editorInstancepreview) {
// editorInstancepreview.setData(response);
//}
}
// remove readonly
$('#ai_instructions".$htmlContent."').val('');
apicallfinished = 1;
if (timeoutfinished) {
$('#ai_status_message".$htmlContent."').hide();
}
},
error: function(xhr, status, error) {
alert(error);
console.error('error ajax', status, error);
$('#ai_status_message".$htmlContent."').hide();
}
});
}
});
});
</script>
";
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<string,string> 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;
}
}

View file

@ -0,0 +1,112 @@
<?php
/* Copyright (C) 2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file 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 .= '<select class="flat minwidth200" id="'.$htmlname.'" name="'.$htmlname.'">';
$i = 0;
if ($useempty) {
$out .= '<option value="0">&nbsp;</option>';
}
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$titletoshowhtml = ($maxlen ? dol_trunc($obj->label, $maxlen) : $obj->label).' <span class="opacitymedium">('.$obj->date_start . " - " . $obj->date_end.')</span>';
$titletoshow = ($maxlen ? dol_trunc($obj->label, $maxlen) : $obj->label).' <span class="opacitymedium">('.$langs->transnoentitiesnoconv("FiscalYearFromTo", $obj->date_start, $obj->date_end).')</span>';
$out .= '<option value="'.$obj->rowid.'"';
if ($obj->rowid == $selected) {
$out .= ' selected';
}
//$out .= ' data-html="'.dol_escape_htmltag(dol_string_onlythesehtmltags($titletoshowhtml, 1, 0, 0, 0, array('span'))).'"';
$out .= ' data-html="'.dolPrintHTMLForAttribute($titletoshowhtml).'"';
$out .= '>';
$out .= dol_escape_htmltag($titletoshow);
$out .= '</option>';
$i++;
}
$out .= '</select>';
//if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
$out .= ajax_combobox($htmlname, array());
} else {
$out .= '<span class="opacitymedium">'.$langs->trans("ErrorNoFiscalyearDefined", $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Fiscalyear")).'</span>';
}
} else {
dol_print_error($this->db);
}
return $out;
}
}

View file

@ -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 = '<div id="ai_input'.$htmlContent.'" class="ai_input'.$htmlContent.' hidden paddingtop paddingbottom">';
$out .= '<input type="text" class="quatrevingtpercent" id="ai_instructions'.$htmlContent.'" name="instruction" placeholder="'.$langs->trans("EnterYourAIPromptHere").'..." />';
$out .= '<input id="generate_button'.$htmlContent.'" type="button" class="button smallpaddingimp" value="'.$langs->trans('Generate').'"/>';
$out .= '<div id="ai_status_message'.$htmlContent.'" class="fieldrequired hideobject marginrightonly margintoponly">';
$out .= '<i class="fa fa-spinner fa-spin fa-2x fa-fw valignmiddle marginrightonly"></i>'.$langs->trans("AIProcessingPleaseWait", getDolGlobalString('AI_API_SERVICE', 'chatgpt'));
$out .= '</div>';
if ($function == 'imagegeneration') {
$out .= '<div id="ai_image_result" class="margintoponly"></div>'; // Div for displaying the generated image
}
$out .= "</div>\n";
$out .= "<script type='text/javascript'>
$(document).ready(function() {
// for keydown
$('#ai_instructions".$htmlContent."').keydown(function(event) {
if (event.keyCode === 13) {
event.preventDefault();
$('#generate_button".$htmlContent."').click();
}
});
$('#generate_button".$htmlContent."').click(function() {
console.log('We click on generate_button".$htmlContent." ai button, so we make an ajax on url /ai/ajax/generate_content.php');
var instructions = $('#ai_instructions".$htmlContent."').val();
var timeoutfinished = 0;
var apicallfinished = 0;
$('#ai_status_message".$htmlContent."').show();
$('.icon-container .loader').show();
setTimeout(function() {
timeoutfinished = 1;
if (apicallfinished) {
$('#ai_status_message".$htmlContent."').hide();
}
}, 2000);
if ('".$function."' === 'imagegeneration') {
// Handle image generation request
$.ajax({
url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
'format': '".dol_escape_js($format)."', /* the format for output */
'function': '".dol_escape_js($function)."', /* the AI feature to call */
'instructions': instructions, /* the prompt string */
}),
success: function(response) {
console.log('Received image URL: '+response);
// make substitutions
let substit = ". json_encode($this->substit).";
for (let key in substit) {
if (substit.hasOwnProperty(key)) {
// Replace the placeholder with its corresponding value
response = response.replace(key, substit[key]);
}
}
// Assuming response is the URL of the generated image
var imageUrl = response;
$('#ai_image_result').html('<img src=\"' + imageUrl + '\" alt=\"Generated Image\" />');
// Clear the input field
$('#ai_instructions').val('');
apicallfinished = 1;
if (timeoutfinished) {
$('#ai_status_message').hide();
}
},
error: function(xhr, status, error) {
alert(error);
console.error('error ajax', status, error);
$('#ai_status_message').hide();
}
});
} else {
// set editor in readonly
if (CKEDITOR.instances.".$htmlContent.") {
CKEDITOR.instances.".$htmlContent.".setReadOnly(1);
}
$.ajax({
url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
'format': '".dol_escape_js($format)."', /* the format for output */
'function': '".dol_escape_js($function)."', /* the AI feature to call */
'instructions': instructions, /* the prompt string */
}),
success: function(response) {
console.log('Add response into field \'#".$htmlContent."\': '+response);
jQuery('#".$htmlContent."').val(response); // If #htmlcontent is a input name or textarea
jQuery('#".$htmlContent."').html(response); // If #htmlContent is a div
//jQuery('#".$htmlContent."preview').val(response);
if (CKEDITOR.instances) {
var editorInstance = CKEDITOR.instances.".$htmlContent.";
if (editorInstance) {
editorInstance.setReadOnly(0);
editorInstance.setData(response);
}
//var editorInstancepreview = CKEDITOR.instances.".$htmlContent."preview;
//if (editorInstancepreview) {
// editorInstancepreview.setData(response);
//}
}
// remove readonly
$('#ai_instructions".$htmlContent."').val('');
apicallfinished = 1;
if (timeoutfinished) {
$('#ai_status_message".$htmlContent."').hide();
}
},
error: function(xhr, status, error) {
alert(error);
console.error('error ajax', status, error);
$('#ai_status_message".$htmlContent."').hide();
}
});
}
});
});
</script>
";
return $out;
}
/**
* Return HTML code for selection of email layout
*

View file

@ -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<br>";
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<br>";
return dol_mktime($hour, $minute, $second, $month, $day, $year, $gm);
}

View file

@ -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 .= '<!-- No link to the layout feature, $formmail->withlayout must be set to a string use case, module WYSIWYG must be enabled and MAIN_EMAIL_USE_LAYOUT must be set -->';
}
if ($showlinktoai) {
$out .= $formmail->getSectionForAIPrompt($showlinktoai, $formmail->withaiprompt, $htmlname);
$out .= $formai->getSectionForAIPrompt($showlinktoai, $formmail->withaiprompt, $htmlname);
} else {
$out .= '<!-- No link to the AI feature, $formmail->withaiprompt must be set to the ai feature and module ai must be enabled -->';
}

View file

@ -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 '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id.'">'.$labelofbutton.'</a></div>';

View file

@ -626,7 +626,7 @@ if ($id > 0 || !empty($ref)) {
// Author
print '<tr><td class="titlefield">'.$langs->trans("AuthorRequest").'</td>';
print '<td>'.$author->getNomUrl(1, '', 0, 0, 0).'</td>';
print '<td>'.$author->getNomUrl(-1, '', 0, 0, 0).'</td>';
print '</tr>';
$parameters = array();

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,316 @@
#!/usr/bin/env php -d memory_limit=256M
<?php
/**
* buildzip.php
*
* Copyright (c) 2023-2025 Eric Seigne <eric.seigne@cap-rel.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 <https://www.gnu.org/licenses/>.
*/
/*
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(?<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*'(?<version>.*)'\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);
}

View file

@ -3,7 +3,7 @@
* Copyright (C) 2013-2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -75,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
*/

View file

@ -3,7 +3,7 @@
* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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)

View file

@ -3,6 +3,7 @@
* Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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');
}
/*

View file

@ -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 '</td></tr>';
$disabled = getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal);
$disabled = getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal);
print '<tr class="oddeven"><td>';

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2004 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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));
}

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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";
}

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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.')');
}

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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 '<div class="wrapper2 arrow" id="prodiv'.$count.'" '; ?>
<?php if ($count == ($MAXPRODUCT - 2)) {
?> onclick="MoreProducts('less')" <?php
}
if ($count == ($MAXPRODUCT - 1)) {
?> onclick="MoreProducts('more')" <?php
} else {
echo 'onclick="ClickProduct('.$count.')"';
} ?>>
<?php if ($count == ($MAXPRODUCT - 2)) {
?> onclick="MoreProducts('less')" <?php
}
if ($count == ($MAXPRODUCT - 1)) {
?> onclick="MoreProducts('more')" <?php
} else {
echo 'onclick="ClickProduct('.$count.')"';
} ?>>
<?php
if ($count == ($MAXPRODUCT - 2)) {
//echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';

View file

@ -3,7 +3,7 @@
* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2021 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2022-2023 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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 '<td class="left">';
$detail = '';
$detail .= '<span class="opacitymedium">'.$langs->trans("LotSerial").':</span> '.$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 .= '</td><td>';
$detail .= '<span class="opacitymedium">'.$langs->trans("Qty").':</span> '.$dbatch->qty;
$detail .= '</td><td>';
@ -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 .= '</td></tr>';
}
}
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 "<script>";
@ -1234,7 +1244,7 @@ if (empty($reshook)) {
$order_receipt_printer3 .= '</td></tr>';
}
}
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 = 3;
echo "<script>";
@ -1247,7 +1257,6 @@ if (empty($reshook)) {
$invoice->fetch($placeid); //Reload object after set lines as printed
}
$sectionwithinvoicelink = '';
if (($action == "valid" || $action == "history" || $action == 'creditnote') && $user->hasRight('takepos', 'run')) {
$sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n";
$sectionwithinvoicelink .= '<span style="font-size:120%;" class="center">';
@ -1543,9 +1552,9 @@ $( document ).ready(function() {
$("#shoppingcart").html('');
<?php if (getDolGlobalInt('TAKEPOS_CHOOSE_CONTACT') == 0) { ?>
$("#customerandsales").append('<a class="valignmiddle tdoverflowmax100 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js(dol_escape_htmltag($s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js($s); ?></a>');
$("#customerandsales").append('<a class="valignmiddle tdoverflowmax100 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js(dol_escape_htmltag((string) $s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js((string) $s); ?></a>');
<?php } else { ?>
$("#customerandsales").append('<a class="valignmiddle tdoverflowmax300 minwidth100" id="contact" onclick="Contact();" title="<?php print dol_escape_js(dol_escape_htmltag($s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js($s); ?></a>');
$("#customerandsales").append('<a class="valignmiddle tdoverflowmax300 minwidth100" id="contact" onclick="Contact();" title="<?php print dol_escape_js(dol_escape_htmltag((string) $s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js((string) $s); ?></a>');
<?php } ?>
<?php
@ -1556,7 +1565,7 @@ $( document ).ready(function() {
$sql .= " AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%'";
} else {
// If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined
$sql .= " AND pos_source = '".$db->escape($_SESSION["takeposterminal"])."'";
$sql .= " AND pos_source = '".$db->escape((string) $_SESSION["takeposterminal"])."'";
$sql .= " AND module_source = 'takepos'";
}
@ -1598,7 +1607,7 @@ $( document ).ready(function() {
if (isModEnabled('stock')) {
if (getDolGlobalString($constantforkey) != "1") {
$constantforkey = 'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
$idwarehouse = getDolGlobalString($constantforkey);
$idwarehouse = getDolGlobalInt($constantforkey);
if ($idwarehouse > 0) {
$s = '<span class="small">';
$warehouse = new Entrepot($db);
@ -1637,7 +1646,7 @@ $( document ).ready(function() {
$langs->load("members");
$s .= $langs->trans("Member").': ';
$adh = new Adherent($db);
$result = $adh->fetch('', '', $invoice->socid);
$result = $adh->fetch(0, '', $invoice->socid);
if ($result > 0) {
$adh->ref = $adh->getFullName($langs);
if (empty($adh->statut) || $adh->statut == Adherent::STATUS_EXCLUDED) {

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2021-2022 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -94,6 +94,7 @@ $usestripeterminals = 0;
$keyforstripeterminalbank = '';
$stripe = null;
$servicestatus = 0;
$stripeacc = null;
if (isModEnabled('stripe')) {
$service = 'StripeTest';
@ -184,7 +185,7 @@ if ($invoiceid > 0) {
<script>
<?php
if ($usestripeterminals && $invoice->type != $invoice::TYPE_CREDIT_NOTE) {
if (!getDolGlobalString($keyforstripeterminalbank)) { ?>
if (!getDolGlobalString((string) $keyforstripeterminalbank) || $stripeacc === null) { ?>
const config = {
simulated: <?php if (empty($servicestatus) && getDolGlobalString('STRIPE_TERMINAL_SIMULATED')) { ?> true <?php } else { ?> false <?php } ?>
<?php if (getDolGlobalString('STRIPE_LOCATION')) { ?>, location: '<?php echo dol_escape_js(getDolGlobalString('STRIPE_LOCATION')); ?>'<?php } ?>
@ -215,7 +216,7 @@ if ($usestripeterminals && $invoice->type != $invoice::TYPE_CREDIT_NOTE) {
}
});
<?php } else { ?>
terminal.connectReader(<?php echo json_encode($stripe->getSelectedReader(getDolGlobalString($keyforstripeterminalbank), $stripeacc, $servicestatus)); ?>).then(function(connectResult) {
terminal.connectReader(<?php echo json_encode($stripe->getSelectedReader(getDolGlobalString((string) $keyforstripeterminalbank), $stripeacc, $servicestatus)); ?>).then(function(connectResult) {
if (connectResult.error) {
document.getElementById("card-present-alert").innerHTML = '<div class="error clearboth">'+connectResult.error.message+'</div>';
console.log('Failed to connect: ', connectResult.error);
@ -233,8 +234,8 @@ if ($usestripeterminals && $invoice->type != $invoice::TYPE_CREDIT_NOTE) {
</script>
<?php
// Define list of possible payments
$arrayOfValidPaymentModes = array();
// Define list of possible payments
$arrayOfValidPaymentModes = array();
$arrayOfValidBankAccount = array();
$sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement";
@ -538,12 +539,11 @@ if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
</script>
<?php
$showothercurrency = 0;
$sessioncurrency = $_SESSION["takeposcustomercurrency"] ?? '';
print '<!-- conf->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 !
<div class="paymentbordline paymentbordlinetotal center">
<span class="takepospay colorwhite"><?php echo $langs->trans('TotalTTC'); ?>: <span id="totaldisplay" class="colorwhite"><?php
echo price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency);
if ($showothercurrency) {
if ($multicurrency !== null) {
print ' &nbsp; <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' . price($invoice->total_ht * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')</span>';
}
?></span></span>
@ -563,7 +563,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
<div class="paymentbordline paymentbordlineremain center">
<span class="takepospay colorwhite"><?php echo $langs->trans('RemainToPay'); ?>: <span id="remaintopaydisplay" class="colorwhite"><?php
echo price($remaintopay, 1, '', 1, -1, -1, $conf->currency);
if ($showothercurrency) {
if ($multicurrency !== null) {
print ' &nbsp; <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' . price($remaintopay * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')</span>';
}
?></span></span>
@ -572,7 +572,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
<div class="paymentbordline paymentbordlinereceived center">
<span class="takepospay colorwhite"><?php echo $langs->trans("Received"); ?>: <span class="change1 colorred"><?php
echo price(0, 1, '', 1, -1, -1, $conf->currency);
if ($showothercurrency) {
if ($multicurrency !== null) {
print ' &nbsp; <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')</span>';
}
?></span><input type="hidden" id="change1" class="change1" value="0"></span>
@ -580,7 +580,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
<div class="paymentbordline paymentbordlinechange center">
<span class="takepospay colorwhite"><?php echo $langs->trans("Change"); ?>: <span class="change2 colorwhite"><?php
echo price(0, 1, '', 1, -1, -1, $conf->currency);
if ($showothercurrency) {
if ($multicurrency !== null) {
print ' &nbsp; <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')</span>';
}
?></span><input type="hidden" id="change2" class="change2" value="0"></span>
@ -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 '<span id="StripeTerminal"></span>';
if (getDolGlobalString($keyforstripeterminalbank)) {
if (getDolGlobalString((string) $keyforstripeterminalbank)) {
// Nothing
} else {
$langs->loadLangs(array("errors", "admin"));

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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();

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2020 Andreu Bisquerra Gaya <jove@bisquerra.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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;

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2021 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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();
}
}

View file

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*/
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 = '')
{

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*/
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 <style type="text/css"> */

View file

@ -1,8 +1,28 @@
<?php
/* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*/
if (!defined('ISLOADEDBYSTEELSHEET')) {
die('Must be call by steelsheet');
}
include_once DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php";
/**
* @var string $colorbackhmenu1
* @var string $colorbacklinepair1
* @var string $colortextbackhmenu
* @var string $colortextlink
* @var int<0,1> $disableimages
* @var string $left
* @var string $right
*/
'
@phan-var-force string $colorbackhmenu1
@phan-var-force string $colorbacklinepair1
@phan-var-force string $colortextbackhmenu
@phan-var-force string $colortextlink
@phan-var-force int<0,1> $disableimages
@phan-var-force string $left
@phan-var-force string $right
';
?>
/* IDE Hack <style type="text/css"> */

View file

@ -1,7 +1,7 @@
<?php
/*
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,6 +27,9 @@ if (!defined('ISLOADEDBYSTEELSHEET')) {
/**
* @var string $path
*/
'
@phan-var-force string $path
';
?>
/* IDE Hack <style type="text/css"> */

View file

@ -1,7 +1,7 @@
<?php
/*
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,6 +24,22 @@
if (!defined('ISLOADEDBYSTEELSHEET')) {
die('Must be call by stylesheet');
}
/**
* @var string $badgeDanger
* @var string $badgeSuccess
* @var string $badgeWarning
* @var string $colorblind_deuteranopes_badgeDanger
* @var string $colorblind_deuteranopes_badgeSuccess
* @var string $topMenuFontSize
*/
'
@phan-var-force string $badgeDanger
@phan-var-force string $badgeSuccess
@phan-var-force string $badgeWarning
@phan-var-force string $colorblind_deuteranopes_badgeDanger
@phan-var-force string $colorblind_deuteranopes_badgeSuccess
@phan-var-force string $topMenuFontSize
';
?>
/* IDE Hack <style type="text/css"> */

View file

@ -1,7 +1,24 @@
<?php
/* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*/
if (!defined('ISLOADEDBYSTEELSHEET')) {
die('Must be call by steelsheet');
} ?>
}
/**
* @var string $badgeDanger
* @var string $badgeSuccess
* @var string $badgeWarning
* @var string $colorblind_deuteranopes_badgeDanger
* @var string $colorblind_deuteranopes_badgeSuccess
*/
'
@phan-var-force string $badgeDanger
@phan-var-force string $badgeSuccess
@phan-var-force string $badgeWarning
@phan-var-force string $colorblind_deuteranopes_badgeDanger
@phan-var-force string $colorblind_deuteranopes_badgeSuccess
'
?>
/* IDE Hack <style type="text/css"> */

View file

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
*/
if (!defined('ISLOADEDBYSTEELSHEET')) {
@ -257,6 +257,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 = '')
{

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*/
if (!defined('ISLOADEDBYSTEELSHEET')) {
die('Must be call by steelsheet');
@ -12,6 +13,16 @@ if (!defined('ISLOADEDBYSTEELSHEET')) {
* @var string $butactionbg
* @var string $textbutaction
*/
'
@phan-var-force string $butactionbg
@phan-var-force string $colortextlink
@phan-var-force int $dol_optimize_smallscreen
@phan-var-force string $fontlist
@phan-var-force string $left
@phan-var-force int $nbtopmenuentries
@phan-var-force string $right
@phan-var-force string $textbutaction
';
?>
/* IDE Hack <style type="text/css"> */

View file

@ -1,4 +1,6 @@
<?php
/* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*/
if (!defined('ISLOADEDBYSTEELSHEET')) {
die('Must be call by steelsheet');
}
@ -6,6 +8,25 @@ if (!defined('ISLOADEDBYSTEELSHEET')) {
// When no photo, we show the login name, so we need an offset to output picto at a fixed position.
$atoploginusername = empty($user->photo) ? 52 : 0;
/**
* @var string $colorbackhmenu1
* @var string $colorbacklinepair1
* @var string $colortextbackhmenu
* @var string $colortextlink
* @var int<0,1> $disableimages
* @var string $left
* @var string $right
*/
'
@phan-var-force string $colorbackhmenu1
@phan-var-force string $colorbacklinepair1
@phan-var-force string $colortextbackhmenu
@phan-var-force string $colortextlink
@phan-var-force int<0,1> $disableimages
@phan-var-force string $left
@phan-var-force string $right
';
?>
/* IDE Hack <style type="text/css"> */

View file

@ -1,7 +1,16 @@
<?php
/* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*/
if (!defined('ISLOADEDBYSTEELSHEET')) {
die('Must be call by steelsheet');
} ?>
}
/**
* @var string $path
*/
'
@phan-var-force string $path
';
?>
/* IDE Hack <style type="text/css"> */

View file

@ -1,6 +1,15 @@
<?php
/* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*/
if (!defined('ISLOADEDBYSTEELSHEET')) {
die('Must be call by steelsheet');
}
/**
* @var string $path
*/
'
@phan-var-force string $path
';
include dol_buildpath($path.'/theme/eldy/progress.inc.php', 0); // actually md use same style as eldy theme

View file

@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -118,8 +118,8 @@ $filters = [];
if (($search_status != '' && $search_status >= 0)) {
$filters[] = "statut = ".((int) $search_status);
}
if (($search_employee != '' && $search_employee >= 0)) {
$filters[] = "employee = ".((int) $search_employee);
if ($search_employee == 1) {
$filters[] = "employee = 1";
}
$sqlfilter = '';
if (!empty($filters)) {