@@ -2408,6 +2408,31 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
$fieldValue = '0';
}
}
+
+ // Labels Length
+ $maxlength = '';
+ if (in_array($fieldlist[$field], array('libelle', 'label'))) {
+ switch ($tabname) {
+ case MAIN_DB_PREFIX . 'c_accounting_category':
+ case MAIN_DB_PREFIX . 'c_ecotaxe':
+ case MAIN_DB_PREFIX . 'c_email_senderprofile':
+ case MAIN_DB_PREFIX . 'c_forme_juridique':
+ case MAIN_DB_PREFIX . 'c_holiday_types':
+ case MAIN_DB_PREFIX . 'c_payment_term':
+ case MAIN_DB_PREFIX . 'c_transport_mode':
+ $maxlength = ' maxlength="255"';
+ break;
+ case MAIN_DB_PREFIX . 'c_email_templates':
+ $maxlength = ' maxlength="180"';
+ break;
+ case MAIN_DB_PREFIX . 'c_socialnetworks':
+ $maxlength = ' maxlength="150"';
+ break;
+ default:
+ $maxlength = ' maxlength="128"';
+ }
+ }
+
print '| ';
$transfound = 0;
$transkey = '';
@@ -2426,7 +2451,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
}
}
if (!$transfound) {
- print '';
+ print '';
} else {
print '';
}
diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php
index 8edc61bf255..904d10bff67 100644
--- a/htdocs/admin/eventorganization.php
+++ b/htdocs/admin/eventorganization.php
@@ -41,6 +41,8 @@ $backtopage = GETPOST('backtopage', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index 2d4736cc49d..12e0d0a6d01 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'shipping';
diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php
index 5b73d995b5c..fc63940f0b8 100644
--- a/htdocs/admin/expensereport.php
+++ b/htdocs/admin/expensereport.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'expensereport';
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index ae269492ddf..9eec54b03a7 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -42,6 +42,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'invoice';
diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php
index 91134671692..609a6605d1a 100644
--- a/htdocs/admin/facture_situation.php
+++ b/htdocs/admin/facture_situation.php
@@ -28,24 +28,93 @@
*/
require '../main.inc.php';
+
+// Libraries
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('situationinvoicesetup', 'globalsetup'));
+
+// Access control
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
+$backtopage = GETPOST('backtopage', 'alpha');
+
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'invoice';
+$form = new Form($db);
+$formSetup = new FormSetup($db);
+
+
+// Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style
+$formSetup->newItem('INVOICE_USE_SITUATION')
+ ->setAsYesNo()
+ ->nameText = $langs->trans('UseSituationInvoices');
+
+$item = $formSetup->newItem('INVOICE_USE_SITUATION_CREDIT_NOTE')
+ ->setAsYesNo()
+ ->nameText = $langs->trans('UseSituationInvoicesCreditNote');
+
+//$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY')
+// ->setAsYesNo()
+// ->nameText = $langs->trans('Retainedwarranty');
+
+
+$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY');
+$item->nameText = $langs->trans('AllowedInvoiceForRetainedWarranty');
+
+$arrayAvailableType = array(
+ Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
+ Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
+);
+
+if ($action == 'edit') {
+ $item->fieldInputOverride = $form->selectarray('INVOICE_USE_RETAINED_WARRANTY', $arrayAvailableType, $conf->global->INVOICE_USE_RETAINED_WARRANTY, 1);
+} else {
+ $item->fieldOutputOverride= isset($arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY])?$arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY]:'';
+}
+
+//$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo();
+//$item->nameText = $langs->trans('RetainedwarrantyOnlyForSituation');
+
+$formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION')
+ ->setAsYesNo()
+ ->nameText = $langs->trans('RetainedwarrantyOnlyForSituationFinal');
+
+
+$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT');
+$item->nameText = $langs->trans('RetainedwarrantyDefaultPercent');
+$item->fieldAttr = array(
+ 'type' => 'number',
+ 'step' => '0.01',
+ 'min' => 0,
+ 'max' => 100
+);
+
+
+// Conditions paiements
+$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID');
+$item->nameText = $langs->trans('PaymentConditionsShortRetainedWarranty');
+$form->load_cache_conditions_paiements();
+if (!empty($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID) && isset($form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'])) {
+ $item->fieldOutputOverride = $form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'];
+}
+$item->fieldInputOverride = $form->getSelectConditionsPaiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID', -1, 1);
+
/*
* Actions
@@ -67,7 +136,6 @@ llxHeader(
'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
);
-$form = new Form($db);
$linkback = ''.$langs->trans("BackToModuleList").'';
@@ -84,170 +152,25 @@ print ''.$langs->trans("InvoiceFirstSituationDesc").
* Numbering module
*/
-print '';
print dol_get_fiche_end();
// End of page
llxFooter();
$db->close();
-
-/**
- * Print an update button
- *
- * @return void
- */
-function _updateBtn()
-{
- global $langs;
- print ' ';
- print '';
- print ' ';
-}
-
-/**
- * Print a On/Off button
- *
- * @param string $confkey the conf key
- * @param bool $title Title of conf
- * @param string $desc Description
- *
- * @return void
- */
-function _printOnOff($confkey, $title = false, $desc = '')
-{
- global $langs;
-
- print '';
- print ''.($title ? $title : $langs->trans($confkey));
- if (!empty($desc)) {
- print ' '.$langs->trans($desc).'';
- }
- print ' | ';
- print ' | ';
- print '';
- print ajax_constantonoff($confkey);
- print ' | ';
-}
-
-
-/**
- * Print a form part
- *
- * @param string $confkey the conf key
- * @param bool $title Title of conf
- * @param string $desc Description of
- * @param array $metas html meta
- * @param string $type type of input textarea or input
- * @param bool $help help description
- *
- * @return void
- */
-function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false)
-{
- global $langs, $conf, $db, $inputCount;
-
- $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
- $form = new Form($db);
-
- $defaultMetas = array(
- 'name' => 'value'.$inputCount
- );
-
- if ($type != 'textarea') {
- $defaultMetas['type'] = 'text';
- $defaultMetas['value'] = $conf->global->{$confkey};
- }
-
-
- $metas = array_merge($defaultMetas, $metas);
- $metascompil = '';
- foreach ($metas as $key => $values) {
- $metascompil .= ' '.$key.'="'.$values.'" ';
- }
-
- print '';
- print '';
-
- if (!empty($help)) {
- print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, ''));
- } else {
- print $title ? $title : $langs->trans($confkey);
- }
-
- if (!empty($desc)) {
- print ' '.$langs->trans($desc).'';
- }
-
- print ' | ';
- print ' | ';
- print '';
- print '';
- print '';
- if ($type == 'textarea') {
- print '';
- } elseif ($type == 'input') {
- print '';
- } else {
- // custom
- print $type;
- }
- print ' | ';
-}
diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php
index 4369bb9a2a7..c95f354a189 100644
--- a/htdocs/admin/fichinter.php
+++ b/htdocs/admin/fichinter.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'ficheinter';
diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php
index bfd7e22c461..c1755b17edf 100644
--- a/htdocs/admin/holiday.php
+++ b/htdocs/admin/holiday.php
@@ -39,6 +39,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'contract';
diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php
index 1ad84ce19ac..aea86069f4d 100644
--- a/htdocs/admin/hrm.php
+++ b/htdocs/admin/hrm.php
@@ -50,6 +50,8 @@ $backtopage = GETPOST('backtopage', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 697f8fa2130..e70e6a4cdd7 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -5,6 +5,7 @@
* Copyright (C) 2016 Juanjo Menent
* Copyright (C) 2018 Ferran Marcet
* Copyright (C) 2021 Alexandre Spangaro
+ * Copyright (C) 2021 Anthony Berton
*
* 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
@@ -199,6 +200,20 @@ if ($action == 'update') {
} else {
dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity);
}
+
+ $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BTNACTION'), array()))));
+ if ($val == '') {
+ dolibarr_del_const($db, 'THEME_ELDY_BTNACTION', $conf->entity);
+ } else {
+ dolibarr_set_const($db, 'THEME_ELDY_BTNACTION', $val, 'chaine', 0, '', $conf->entity);
+ }
+
+ $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTBTNACTION'), array()))));
+ if ($val == '') {
+ dolibarr_del_const($db, 'THEME_ELDY_TEXTBTNACTION', $conf->entity);
+ } else {
+ dolibarr_set_const($db, 'THEME_ELDY_TEXTBTNACTION', $val, 'chaine', 0, '', $conf->entity);
+ }
}
if ($mode == 'dashboard') {
diff --git a/htdocs/admin/import.php b/htdocs/admin/import.php
index cd9d7b44074..37168baa3d4 100644
--- a/htdocs/admin/import.php
+++ b/htdocs/admin/import.php
@@ -41,6 +41,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
/*
* Actions
diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php
index 8d93c16741a..c2440bbb885 100644
--- a/htdocs/admin/knowledgemanagement.php
+++ b/htdocs/admin/knowledgemanagement.php
@@ -37,8 +37,9 @@ $langs->loadLangs(array("admin", "knowledgemanagement"));
// Parameters
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
-
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'knowledgemanagement';
diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php
index 54efdc4df19..fac6a3f3d41 100644
--- a/htdocs/admin/mrp.php
+++ b/htdocs/admin/mrp.php
@@ -37,6 +37,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'mrp';
diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php
index 22ce045a7ab..6384c561967 100644
--- a/htdocs/admin/propal.php
+++ b/htdocs/admin/propal.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'propal';
diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php
index 218cc1ef853..26300ece329 100644
--- a/htdocs/admin/reception_setup.php
+++ b/htdocs/admin/reception_setup.php
@@ -36,6 +36,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'reception';
diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php
index 808528cdc0a..0da79845d14 100644
--- a/htdocs/admin/supplier_order.php
+++ b/htdocs/admin/supplier_order.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$type = GETPOST('type', 'alpha');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$action = GETPOST('action', 'aZ09');
$scandir = GETPOST('scan_dir', 'alpha');
diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php
index b31e4c9a433..a41f9fdf80c 100644
--- a/htdocs/admin/supplier_payment.php
+++ b/htdocs/admin/supplier_payment.php
@@ -37,6 +37,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scandir', 'alpha');
$type = 'supplier_payment';
diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php
index 6e3f190aeb6..9bd684afb22 100644
--- a/htdocs/admin/supplier_proposal.php
+++ b/htdocs/admin/supplier_proposal.php
@@ -38,6 +38,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'supplier_proposal';
diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php
index 03fd647dd29..f4e5b4f3fad 100644
--- a/htdocs/admin/ticket.php
+++ b/htdocs/admin/ticket.php
@@ -38,6 +38,8 @@ if (!$user->admin) {
// Parameters
$value = GETPOST('value', 'alpha');
$action = GETPOST('action', 'aZ09');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scandir', 'alpha');
$type = 'ticket';
diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php
index 85ab0f0e9a8..53de8fe2502 100644
--- a/htdocs/admin/user.php
+++ b/htdocs/admin/user.php
@@ -43,9 +43,11 @@ $extrafields = new ExtraFields($db);
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
+
$scandir = GETPOST('scandir', 'alpha');
$type = 'user';
diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php
index 3319ab994a6..709b60068f7 100644
--- a/htdocs/admin/usergroup.php
+++ b/htdocs/admin/usergroup.php
@@ -42,6 +42,8 @@ $extrafields = new ExtraFields($db);
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$type = 'group';
/*
diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php
index e89cbb2fd41..58118827ed4 100644
--- a/htdocs/admin/workstation.php
+++ b/htdocs/admin/workstation.php
@@ -36,6 +36,7 @@ $langs->loadLangs(array("admin", "workstation"));
// Parameters
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
$value = GETPOST('value', 'alpha');
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 748aea4ddb2..7d83a88ce55 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -354,8 +354,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formquestion = array();
if (!empty($conf->bom->enabled)) {
$langs->load("mrp");
- require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
- $formproduct = new FormProduct($db);
$forcecombo = 0;
if ($conf->browser->name == 'ie') {
$forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
@@ -384,8 +382,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formquestion = array();
if (!empty($conf->bom->enabled)) {
$langs->load("mrp");
- require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
- $formproduct = new FormProduct($db);
$forcecombo = 0;
if ($conf->browser->name == 'ie') {
$forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
@@ -415,7 +411,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!empty($conf->bom->enabled)) {
$langs->load("mrp");
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
- $formproduct = new FormProduct($db);
$forcecombo = 0;
if ($conf->browser->name == 'ie') {
$forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php
index 41ed388e044..f03d66bae54 100644
--- a/htdocs/comm/propal/class/api_proposals.class.php
+++ b/htdocs/comm/propal/class/api_proposals.class.php
@@ -1,7 +1,9 @@
- * Copyright (C) 2016 Laurent Destailleur
- * Copyright (C) 2020 Thibault FOUCART
+/* Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2016 Laurent Destailleur
+ * Copyright (C) 2020 Thibault FOUCART
+ * Copyright (C) 2022 ATM Consulting
+ * Copyright (C) 2022 OpenDSI
*
* 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
@@ -274,14 +276,17 @@ class Proposals extends DolibarrApi
/**
* Get lines of a commercial proposal
*
- * @param int $id Id of commercial proposal
+ * @param int $id Id of commercial proposal
+ * @param string $sqlfilters Other criteria to filter answers separated by a comma. d is the alias for proposal lines table, p is the alias for product table. "Syntax example "(p.ref:like:'SO-%') and (d.date_start:<:'20220101')"
*
* @url GET {id}/lines
*
* @return int
*/
- public function getLines($id)
+ public function getLines($id, $sqlfilters = '')
{
+ $filters = "";
+
if (!DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
@@ -294,7 +299,16 @@ class Proposals extends DolibarrApi
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- $this->propal->getLinesArray();
+
+ if (!empty($sqlfilters)) {
+ if (!DolibarrApi::_checkFilters($sqlfilters)) {
+ throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
+ }
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+ $filters = " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+ }
+
+ $this->propal->getLinesArray($filters);
$result = array();
foreach ($this->propal->lines as $line) {
array_push($result, $this->_cleanObjectDatas($line));
@@ -308,7 +322,7 @@ class Proposals extends DolibarrApi
* @param int $id Id of commercial proposal to update
* @param array $request_data Commercial proposal line data
*
- * @url POST {id}/lines
+ * @url POST {id}/line
*
* @return int
*/
@@ -368,6 +382,84 @@ class Proposals extends DolibarrApi
}
}
+ /**
+ * Add lines to given commercial proposal
+ *
+ * @param int $id Id of commercial proposal to update
+ * @param array $request_data Commercial proposal line data
+ *
+ * @url POST {id}/lines
+ *
+ * @return int
+ */
+ public function postLines($id, $request_data = null)
+ {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
+ throw new RestException(401);
+ }
+
+ $result = $this->propal->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'Commercial Proposal not found');
+ }
+
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ $errors = [];
+ $this->db->begin();
+
+ foreach ($request_data as $TData) {
+ if (empty($TData[0])) $TData = array($TData);
+
+ foreach ($TData as $lineData) {
+ $line = (object) $lineData;
+
+ $updateRes = $this->propal->addline(
+ $line->desc,
+ $line->subprice,
+ $line->qty,
+ $line->tva_tx,
+ $line->localtax1_tx,
+ $line->localtax2_tx,
+ $line->fk_product,
+ $line->remise_percent,
+ 'HT',
+ 0,
+ $line->info_bits,
+ $line->product_type,
+ $line->rang,
+ $line->special_code,
+ $line->fk_parent_line,
+ $line->fk_fournprice,
+ $line->pa_ht,
+ $line->label,
+ $line->date_start,
+ $line->date_end,
+ $line->array_options,
+ $line->fk_unit,
+ $line->origin,
+ $line->origin_id,
+ $line->multicurrency_subprice,
+ $line->fk_remise_except
+ );
+
+ if ($updateRes < 0) {
+ $errors['lineLabel'] = $line->label;
+ $errors['msg'] = $this->propal->errors;
+ }
+ }
+ }
+ if (empty($errors)) {
+ $this->db->commit();
+ return count($request_data);
+ } else {
+ $this->db->rollback();
+ throw new RestException(400, implode(", ", $errors));
+ }
+ }
+
/**
* Update a line of given commercial proposal
*
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index fd3bbfe7171..1c532e26147 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1,20 +1,22 @@
- * Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2004-2011 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley
- * Copyright (C) 2005-2013 Regis Houssin
- * Copyright (C) 2006 Andre Cianfarani
- * Copyright (C) 2008 Raphael Bertrand
- * Copyright (C) 2010-2020 Juanjo Menent
- * Copyright (C) 2010-2017 Philippe Grand
- * Copyright (C) 2012-2014 Christophe Battarel
- * Copyright (C) 2012 Cedric Salvador
- * Copyright (C) 2013 Florian Henry
- * Copyright (C) 2014-2015 Marcos García
- * Copyright (C) 2018 Nicolas ZABOURI
- * Copyright (C) 2018-2021 Frédéric France
- * Copyright (C) 2018 Ferran Marcet
+/* Copyright (C) 2002-2004 Rodolphe Quiedeville
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley
+ * Copyright (C) 2005-2013 Regis Houssin
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2008 Raphael Bertrand
+ * Copyright (C) 2010-2020 Juanjo Menent
+ * Copyright (C) 2010-2017 Philippe Grand
+ * Copyright (C) 2012-2014 Christophe Battarel
+ * Copyright (C) 2012 Cedric Salvador
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2014-2015 Marcos García
+ * Copyright (C) 2018 Nicolas ZABOURI
+ * Copyright (C) 2018-2021 Frédéric France
+ * Copyright (C) 2018 Ferran Marcet
+ * Copyright (C) 2022 ATM Consulting
+ * Copyright (C) 2022 OpenDSI
*
* 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
@@ -1714,12 +1716,13 @@ class Propal extends CommonObject
/**
* Load array lines
*
- * @param int $only_product Return only physical products
- * @param int $loadalsotranslation Return translation for products
+ * @param int $only_product Return only physical products
+ * @param int $loadalsotranslation Return translation for products
+ * @param string $filters Filter on other fields
*
- * @return int <0 if KO, >0 if OK
+ * @return int <0 if KO, >0 if OK
*/
- public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
+ public function fetch_lines($only_product = 0, $loadalsotranslation = 0, $filters = '')
{
global $langs, $conf;
// phpcs:enable
@@ -1738,6 +1741,9 @@ class Propal extends CommonObject
if ($only_product) {
$sql .= ' AND p.fk_product_type = 0';
}
+ if ($filters) {
+ $sql .= $filters;
+ }
$sql .= ' ORDER by d.rang';
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
@@ -3689,12 +3695,13 @@ class Propal extends CommonObject
/**
* Retrieve an array of proposal lines
+ * @param string $filters Filter on other fields
*
* @return int >0 if OK, <0 if KO
*/
- public function getLinesArray()
+ public function getLinesArray($filters = '')
{
- return $this->fetch_lines();
+ return $this->fetch_lines(0, 0, $filters);
}
/**
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index c05f0f4530c..3d8e6f8bd98 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -1339,14 +1339,15 @@ if ($resql) {
$labeltoshow = $langs->trans($reg[1]);
} else {
if ($objp->label == '(payment_salary)') {
- $labeltoshow = dol_trunc($langs->trans("SalaryPayment", 40));
+ $labeltoshow = $langs->trans("SalaryPayment");
} else {
$labeltoshow = dol_escape_htmltag($objp->label);
$titletoshow = $objp->label;
}
}
- print '';
- print $labeltoshow; // Already escaped
+
+
+ print ' | ';
// Add info about links after description
$cachebankaccount = array();
@@ -1355,70 +1356,70 @@ if ($resql) {
if ($links[$key]['type'] == 'withdraw') {
$banktransferstatic->id = $links[$key]['url_id'];
$banktransferstatic->ref = $links[$key]['label'];
- print ' '.$banktransferstatic->getNomUrl(0);
+ print $banktransferstatic->getNomUrl(0).' ';
} elseif ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
$paymentstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment
$paymentstatic->date = $db->jdate($objp->do);
- print ' '.$paymentstatic->getNomUrl(2);
+ print $paymentstatic->getNomUrl(2).' ';
} elseif ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment
- print ' '.$paymentsupplierstatic->getNomUrl(2);
+ print $paymentsupplierstatic->getNomUrl(2).' ';
} elseif ($links[$key]['type'] == 'payment_sc') {
$paymentscstatic->id = $links[$key]['url_id'];
$paymentscstatic->ref = $links[$key]['url_id'];
$paymentscstatic->label = $links[$key]['label'];
- print ' '.$paymentscstatic->getNomUrl(2);
+ print $paymentscstatic->getNomUrl(2).' ';
} elseif ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
- print ' '.$paymentvatstatic->getNomUrl(2);
+ print $paymentvatstatic->getNomUrl(2).' ';
} elseif ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
$paymentsalstatic->label = $links[$key]['label'];
- print ' '.$paymentsalstatic->getNomUrl(2);
+ print $paymentsalstatic->getNomUrl(2).' ';
} elseif ($links[$key]['type'] == 'payment_loan') {
print '';
print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
- print '';
+ print ' ';
} elseif ($links[$key]['type'] == 'payment_donation') {
$paymentdonationstatic->id = $links[$key]['url_id'];
$paymentdonationstatic->ref = $links[$key]['url_id'];
- print ' '.$paymentdonationstatic->getNomUrl(2);
+ print $paymentdonationstatic->getNomUrl(2).' ';
} elseif ($links[$key]['type'] == 'payment_expensereport') {
$paymentexpensereportstatic->id = $links[$key]['url_id'];
$paymentexpensereportstatic->ref = $links[$key]['url_id'];
- print ' '.$paymentexpensereportstatic->getNomUrl(2);
+ print $paymentexpensereportstatic->getNomUrl(2).' ';
} elseif ($links[$key]['type'] == 'payment_various') {
$paymentvariousstatic->id = $links[$key]['url_id'];
$paymentvariousstatic->ref = $links[$key]['url_id'];
- print ' '.$paymentvariousstatic->getNomUrl(2);
+ print $paymentvariousstatic->getNomUrl(2).' ';
} elseif ($links[$key]['type'] == 'banktransfert') {
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
if ($objp->amount > 0) {
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id = $banklinestatic->fk_account;
$bankstatic->label = $banklinestatic->bank_account_ref;
- print ' ('.$langs->trans("TransferFrom").' ';
+ print $langs->trans("TransferFrom").' ';
print $bankstatic->getNomUrl(1, 'transactions');
print ' '.$langs->trans("toward").' ';
$bankstatic->id = $objp->bankid;
$bankstatic->label = $objp->bankref;
print $bankstatic->getNomUrl(1, '');
- print ')';
+ print ' - ';
} else {
$bankstatic->id = $objp->bankid;
$bankstatic->label = $objp->bankref;
- print ' ('.$langs->trans("TransferFrom").' ';
+ print $langs->trans("TransferFrom").' ';
print $bankstatic->getNomUrl(1, '');
print ' '.$langs->trans("toward").' ';
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id = $banklinestatic->fk_account;
$bankstatic->label = $banklinestatic->bank_account_ref;
print $bankstatic->getNomUrl(1, 'transactions');
- print ')';
+ print ' - ';
}
//var_dump($links);
} elseif ($links[$key]['type'] == 'company') {
@@ -1430,22 +1431,22 @@ if ($resql) {
// Information is already shown using the payment_salary link. No need of this link.
} else {
// Show link with label $links[$key]['label']
- if (!empty($objp->label) && !empty($links[$key]['label'])) {
- print ' - ';
- }
print '';
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
// Label generique car entre parentheses. On l'affiche en le traduisant
if ($reg[1] == 'paiement') {
$reg[1] = 'Payment';
}
- print ' '.$langs->trans($reg[1]);
+ print $langs->trans($reg[1]);
} else {
- print ' '.$links[$key]['label'];
+ print $links[$key]['label'];
}
- print '';
+ print ''.($labeltoshow ? ' - ' : '');
}
}
+
+ print $labeltoshow; // Already escaped
+
print ' | ';
if (!$i) {
$totalarray['nbfield']++;
@@ -1488,7 +1489,7 @@ if ($resql) {
// Payment type
if (!empty($arrayfields['type']['checked'])) {
- print '';
+ print ' | ';
$labeltype = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $langs->getLabelFromKey($db, $objp->fk_type, 'c_paiement', 'code', 'libelle', '', 1);
if ($labeltype == 'SOLD') {
print ' '; //$langs->trans("InitialBankBalance");
@@ -1514,9 +1515,9 @@ if ($resql) {
print ' | ';
$companylinked_id = 0;
- $userlinked_id = 0;
+ $userlinked_id = 0;
- //payment line type to define user display and user or company linked
+ //payment line type to define user display and user or company linked
foreach ($links as $key => $value) {
if ($links[$key]['type'] == 'payment_sc') {
$type_link = 'payment_sc';
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index a76332197bc..3909d9437b4 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -1354,6 +1354,7 @@ if ($action == 'create') {
$dateexample = $object->date_when;
}
+ // Help of substitution key
$substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
$substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%m').')';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 9b26e38932c..4e2665ceca3 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -610,7 +610,7 @@ if (empty($reshook)) {
// Check parameters
// Check for mandatory fields in thirdparty (defined into setup)
- $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL');
+ $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'ACCOUNTANCY_CODE_CUSTOMER');
foreach ($array_to_check as $key) {
$keymin = strtolower($key);
$i = (int) preg_replace('/[^0-9]/', '', $key);
@@ -638,6 +638,14 @@ if (empty($reshook)) {
setEventMessages($langs->trans("ErrorBadEMail", $object->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors');
}
}
+ if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') {
+ // Check for mandatory
+ if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_INVOICE_MANDATORY) && empty($object->thirdparty->code_compta)) {
+ $langs->load("errors");
+ $error++;
+ setEventMessages($langs->trans("ErrorAccountancyCodeCustomerIsMandatory", $object->thirdparty->name).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors');
+ }
+ }
}
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 63fee0085bb..5344da8d06a 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1622,7 +1622,7 @@ class Facture extends CommonInvoice
if ($rowid) {
$sql .= " WHERE f.rowid=".((int) $rowid);
} else {
- $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid
+ $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Don't use entity if you use rowid
if ($ref) {
$sql .= " AND f.ref='".$this->db->escape($ref)."'";
}
diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php
index f43f4e6ddfa..0ea9b1ba30d 100644
--- a/htdocs/compta/sociales/card.php
+++ b/htdocs/compta/sociales/card.php
@@ -62,6 +62,9 @@ $label = GETPOST('label', 'alpha');
$actioncode = GETPOST('actioncode');
$fk_user = GETPOST('userid', 'int');
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('taxcard', 'globalcard'));
+
// Initialize technical objects
$object = new ChargeSociales($db);
$extrafields = new ExtraFields($db);
@@ -97,7 +100,7 @@ $result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges')
* Actions
*/
-$parameters = array();
+$parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -446,6 +449,8 @@ if ($id > 0) {
$object = new ChargeSociales($db);
$result = $object->fetch($id);
+ $formconfirm = '';
+
if ($result > 0) {
$head = tax_prepare_head($object);
@@ -464,25 +469,36 @@ if ($id > 0) {
$formquestion[] = array('type' => 'text', 'name' => 'amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount), 'morecss' => 'width100');
}
- print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 280);
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 280);
}
if ($action == 'paid') {
$text = $langs->trans('ConfirmPaySocialContribution');
- print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySocialContribution'), $text, "confirm_paid", '', '', 2);
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySocialContribution'), $text, "confirm_paid", '', '', 2);
}
// Confirmation of the removal of the Social Contribution
if ($action == 'delete') {
$text = $langs->trans('ConfirmDeleteSocialContribution');
- print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSocialContribution'), $text, 'confirm_delete', '', '', 2);
+ $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSocialContribution'), $text, 'confirm_delete', '', '', 2);
}
if ($action == 'edit') {
print " | |