@@ -77,8 +77,8 @@ $listoffset = GETPOST('listoffset');
$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries
$active = 1;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
@@ -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/dolistore/css/dolistore.css b/htdocs/admin/dolistore/css/dolistore.css
index fb4dc2d5bb1..3d8f163caf2 100644
--- a/htdocs/admin/dolistore/css/dolistore.css
+++ b/htdocs/admin/dolistore/css/dolistore.css
@@ -1,6 +1,5 @@
div.divsearchfield {
- float: left;
margin: 4px 12px 4px 2px;
padding-left: 2px;
}
diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php
index 06309a2706e..904d10bff67 100644
--- a/htdocs/admin/eventorganization.php
+++ b/htdocs/admin/eventorganization.php
@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/eventorganization.lib.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Translations
-$langs->loadLangs(array("admin", "eventorganization"));
+$langs->loadLangs(array("admin", "eventorganization", "categories"));
// Parameters
$action = GETPOST('action', 'aZ09');
@@ -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';
@@ -54,11 +56,11 @@ $arrayofparameters = array(
'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
- 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
- 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
- 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1),
+ //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
+ //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1),
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1),
+ 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1),
);
$error = 0;
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/mails_templates.php b/htdocs/admin/mails_templates.php
index 033220d4a15..6ad1cdc6974 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -80,8 +80,8 @@ $actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"')
$listoffset = GETPOST('listoffset', 'alpha');
$listlimit = GETPOST('listlimit', 'alpha') > 0 ?GETPOST('listlimit', 'alpha') : 1000;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index f720e411717..29d2335a0f9 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -535,11 +535,11 @@ if ($mode == 'common' || $mode == 'commonkanban') {
//$moreforfilter .= ''.$moreinfo.' '.$moreinfo2.'
';
- $moreforfilter .= '';
- $moreforfilter .= '
';
+ $moreforfilter .= '
';
+ $moreforfilter .= '
';
$moreforfilter .= img_picto($langs->trans("Filter"), 'filter', 'class="paddingright opacityhigh hideonsmartphone"').' ';
$moreforfilter .= '
';
- $moreforfilter .= '
';
+ $moreforfilter .= '
';
$moreforfilter .= $form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), $langs->trans('Origin'), 0, 0, '', 0, 0, 0, '', 'maxwidth250', 1);
$moreforfilter .= '
';
if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) {
@@ -553,16 +553,16 @@ if ($mode == 'common' || $mode == 'commonkanban') {
if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
$array_version['development'] = $langs->trans("Development");
}
- $moreforfilter .= '
';
+ $moreforfilter .= '
';
$moreforfilter .= $form->selectarray('search_version', $array_version, $search_version, $langs->trans('Version'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1);
$moreforfilter .= '
';
}
- $moreforfilter .= '
';
+ $moreforfilter .= '
';
$moreforfilter .= $form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, $langs->trans('Status'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1);
$moreforfilter .= '
';
$moreforfilter .= ' ';
- $moreforfilter .= '
';
- $moreforfilter .= '
';
+ $moreforfilter .= '
';
+ $moreforfilter .= '
';
if ($search_keyword || ($search_nature && $search_nature != '-1') || ($search_version && $search_version != '-1') || ($search_status && $search_status != '-1')) {
$moreforfilter .= ' ';
$moreforfilter .= '
';
@@ -1139,7 +1139,7 @@ if ($mode == 'deploy') {
}
if ($allowfromweb == 1) {
- print $langs->trans("UnpackPackageInModulesRoot", $dirins).'
';
+ print '
'.$langs->trans("UnpackPackageInModulesRoot", $dirins).' ';
print '
';
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/oauth.php b/htdocs/admin/oauth.php
index 9bf5be2c294..a0d82d1d6bd 100644
--- a/htdocs/admin/oauth.php
+++ b/htdocs/admin/oauth.php
@@ -27,6 +27,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php';
+// $supportedoauth2array is defined into oauth.lib.php
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
@@ -96,10 +97,12 @@ print '
';
$i = 0;
-// $list is defined into oauth.lib.php
+// $list is defined into oauth.lib.php to the list of supporter OAuth providers.
foreach ($list as $key) {
$supported = 0;
- if (in_array($key[0], array_keys($supportedoauth2array))) {
+ $keyforsupportedoauth2array = $key[0];
+
+ if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) {
$supported = 1;
}
if (!$supported) {
@@ -110,20 +113,23 @@ foreach ($list as $key) {
print '';
// Api Name
- $label = $langs->trans($key[0]);
- print ''.$label.' ';
+ $label = $langs->trans($keyforsupportedoauth2array);
print '';
- if (!empty($key[3])) {
- print $langs->trans($key[3]);
+ print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
+ print $label;
+ print ' ';
+ print '';
+ if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforapp'])) {
+ print $langs->trans($supportedoauth2array[$keyforsupportedoauth2array]['urlforapp']);
}
print ' ';
print ' ';
if ($supported) {
- $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php';
+ $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php';
print '';
print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").' ';
- print ' ';
+ print ' ';
print ' ';
} else {
print '';
diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php
index 8697b400a2b..73a9139f856 100644
--- a/htdocs/admin/oauthlogintokens.php
+++ b/htdocs/admin/oauthlogintokens.php
@@ -25,17 +25,13 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // This define $list
+require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // This define $list and $supportedoauth2array
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
use OAuth\Common\Storage\DoliStorage;
// Load translation files required by the page
$langs->loadLangs(array('admin', 'printing', 'oauth'));
-if (!$user->admin) {
- accessforbidden();
-}
-
$action = GETPOST('action', 'aZ09');
$mode = GETPOST('mode', 'alpha');
$value = GETPOST('value', 'alpha');
@@ -50,6 +46,10 @@ if (!$mode) {
$mode = 'setup';
}
+if (!$user->admin) {
+ accessforbidden();
+}
+
/*
* Action
@@ -122,7 +122,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai
$form = new Form($db);
-llxHeader('', $langs->trans("PrintingSetup"));
+llxHeader('', $langs->trans("TokenManager"));
$linkback = ''.$langs->trans("BackToModuleList").' ';
print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup');
@@ -140,7 +140,9 @@ if ($mode == 'setup' && $user->admin) {
foreach ($list as $key) {
$supported = 0;
- if (in_array($key[0], array_keys($supportedoauth2array))) {
+ $keyforsupportedoauth2array = $key[0];
+
+ if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) {
$supported = 1;
}
if (!$supported) {
@@ -148,34 +150,44 @@ if ($mode == 'setup' && $user->admin) {
}
- $OAUTH_SERVICENAME = 'Unknown';
- if ($key[0] == 'OAUTH_GITHUB_NAME') {
- $OAUTH_SERVICENAME = 'GitHub';
+ $OAUTH_SERVICENAME = empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'];
+
+ // Define $shortscope, $urltorenew, $urltodelete, $urltocheckperms
+ // TODO Use array $supportedoauth2array
+ if ($keyforsupportedoauth2array == 'OAUTH_GITHUB_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect.
$shortscope = 'user,public_repo';
$urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/';
- } elseif ($key[0] == 'OAUTH_GOOGLE_NAME') {
- $OAUTH_SERVICENAME = 'Google';
+ } elseif ($keyforsupportedoauth2array == 'OAUTH_GOOGLE_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
- // We pass this param list in to 'state' because we need it before and after the redirect.
- $shortscope = 'userinfo_email,userinfo_profile,cloud_print';
- if (!empty($conf->global->OAUTH_GSUITE)) {
+ // List of scopes for Google are here: https://developers.google.com/identity/protocols/oauth2/scopes
+ // We pass this key list into the param 'state' because we need it before and after the redirect.
+ $shortscope = 'userinfo_email,userinfo_profile';
+ $shortscope .= ',openid,email,profile'; // For openid connect
+ if (!empty($conf->printing->enabled)) {
+ $shortscope .= ',cloud_print';
+ }
+ if (!empty($conf->global->OAUTH_GOOGLE_GSUITE)) {
$shortscope .= ',admin_directory_user';
}
- //$scope.=',gmail_full';
- $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ if (!empty($conf->global->OAUTH_GOOGLE_GMAIL)) {
+ $shortscope.=',gmail_full';
+ }
+
+ $oauthstateanticsrf = bin2hex(random_bytes(128/8));
+ $_SESSION['oauthstateanticsrf'] = $shortscope.'-'.$oauthstateanticsrf;
+
+ $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://security.google.com/settings/security/permissions';
- } elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME') {
- $OAUTH_SERVICENAME = 'StripeTest';
+ } elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_TEST_NAME') {
$urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
- } elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME') {
- $OAUTH_SERVICENAME = 'StripeLive';
+ } elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_LIVE_NAME') {
$urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
@@ -230,11 +242,14 @@ if ($mode == 'setup' && $user->admin) {
print ' ';
print ' ';
- print '';
+ print '
';
print '
'."\n";
print '';
- print ''.$langs->trans($key[0]).' ';
+ print '';
+ print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
+ print $langs->trans($keyforsupportedoauth2array);
+ print ' ';
print ' ';
print ' ';
print " \n";
@@ -244,7 +259,7 @@ if ($mode == 'setup' && $user->admin) {
//var_dump($key);
print $langs->trans("OAuthIDSecret").'';
print '';
- print $langs->trans("SeePreviousTab");
+ print ''.$langs->trans("SeePreviousTab").' ';
print ' ';
print '';
print ' ';
@@ -259,7 +274,7 @@ if ($mode == 'setup' && $user->admin) {
if (is_object($tokenobj)) {
print $langs->trans("HasAccessToken");
} else {
- print $langs->trans("NoAccessToken");
+ print ''.$langs->trans("NoAccessToken").' ';
}
print '';
print '';
@@ -346,7 +361,7 @@ if ($mode == 'setup' && $user->admin) {
if ($mode == 'test' && $user->admin) {
print $langs->trans('PrintTestDesc'.$driver)." \n";
- print '';
+ print '
';
print '
';
if (!empty($driver)) {
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
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/system/modules.php b/htdocs/admin/system/modules.php
index a56ed8c1da3..9e60ff46bd7 100644
--- a/htdocs/admin/system/modules.php
+++ b/htdocs/admin/system/modules.php
@@ -40,8 +40,8 @@ $search_id = GETPOST("search_id", 'alpha');
$search_version = GETPOST("search_version", 'alpha');
$search_permission = GETPOST("search_permission", 'alpha');
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
if (!$sortfield) {
$sortfield = "id";
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/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index d6700cedf04..5f9dc97ba44 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -400,8 +400,6 @@ print '';
print '';
print '
';
-print '
';
-print '
';
@@ -538,6 +536,8 @@ if (!empty($_SESSION["commandbackuptorun"])) {
print "
\n";
+print '
';
+print '
';
print "
\n";
diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php
index 0b9272c2418..36be1f273ff 100644
--- a/htdocs/admin/tools/export_files.php
+++ b/htdocs/admin/tools/export_files.php
@@ -137,7 +137,7 @@ $dirtocompress = basename($fulldirtocompress);
if ($compression == 'zip') {
$file .= '.zip';
- $excludefiles = '/(\.back|\.old|\.log|[\/\\\]temp[\/\\\]|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i';
+ $excludefiles = '/(\.back|\.old|\.log|\.pdf_preview-.*\.png|[\/\\\]temp[\/\\\]|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i';
//var_dump($fulldirtocompress);
//var_dump($outputdir."/".$file);exit;
@@ -173,7 +173,7 @@ if ($compression == 'zip') {
// We also exclude '/temp/' dir and 'documents/admin/documents'
// We make escapement here and call executeCLI without escapement because we don't want to have the '*.log' escaped.
- $cmd = "tar -cf ".escapeshellcmd($outputdir."/".$file)." --exclude-vcs --exclude-caches-all --exclude='temp' --exclude='*.log' --exclude='documents/admin/documents' -C '".escapeshellcmd(dol_sanitizePathName($dirtoswitch))."' '".escapeshellcmd(dol_sanitizeFileName($dirtocompress))."'";
+ $cmd = "tar -cf ".escapeshellcmd($outputdir."/".$file)." --exclude-vcs --exclude-caches-all --exclude='temp' --exclude='*.log' --exclude='*.pdf_preview-*.png' --exclude='documents/admin/documents' -C '".escapeshellcmd(dol_sanitizePathName($dirtoswitch))."' '".escapeshellcmd(dol_sanitizeFileName($dirtocompress))."'";
$result = $utils->executeCLI($cmd, $outputfile, 0, null, 1);
diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php
index 10a38fb59a1..cc9aaa356bc 100644
--- a/htdocs/admin/tools/listsessions.php
+++ b/htdocs/admin/tools/listsessions.php
@@ -47,8 +47,8 @@ if ($user->socid > 0) {
}
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php
index 12b2eec700d..93f62337746 100644
--- a/htdocs/admin/translation.php
+++ b/htdocs/admin/translation.php
@@ -47,8 +47,8 @@ $transvalue = GETPOST('transvalue', 'restricthtml');
$mode = GETPOST('mode', 'aZ09') ? GETPOST('mode', 'aZ09') : 'searchkey';
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
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/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php
index 3cd8d3e0774..28dbef6887e 100644
--- a/htdocs/api/class/api_documents.class.php
+++ b/htdocs/api/class/api_documents.class.php
@@ -624,6 +624,9 @@ class Documents extends DolibarrApi
} elseif ($modulepart == 'expensereport') {
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$object = new ExpenseReport($this->db);
+ } elseif ($modulepart == 'fichinter') {
+ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
+ $object = new Fichinter($this->db);
} elseif ($modulepart == 'adherent' || $modulepart == 'member') {
$modulepart = 'adherent';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php
index 0b3dbe3971c..5282a43dacc 100644
--- a/htdocs/api/class/api_login.class.php
+++ b/htdocs/api/class/api_login.class.php
@@ -137,7 +137,11 @@ class Login
if (empty($tmpuser->api_key) || $reset) {
$tmpuser->getrights();
if (empty($tmpuser->rights->user->self->creer)) {
- throw new RestException(403, 'User need write permission on itself to reset its API token');
+ if (empty($tmpuser->api_key)) {
+ throw new RestException(403, 'No API token set for this user and user need write permission on itself to reset its API token');
+ } else {
+ throw new RestException(403, 'User need write permission on itself to reset its API token');
+ }
}
// Generate token for user
diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php
index f4e17f42556..15a29c0e18b 100644
--- a/htdocs/api/class/api_setup.class.php
+++ b/htdocs/api/class/api_setup.class.php
@@ -4,7 +4,7 @@
* Copyright (C) 2017 Regis Houssin
* Copyright (C) 2017 Neil Orley
* Copyright (C) 2018-2021 Frédéric France
- * Copyright (C) 2018-2021 Thibault FOUCART
+ * Copyright (C) 2018-2022 Thibault FOUCART
*
*
* This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@ use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/cstate.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
-
+require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
/**
* API class for dictionaries
@@ -1721,6 +1721,66 @@ class Setup extends DolibarrApi
return $this->_cleanObjectDatas($mysoc);
}
+ /**
+ * Get the list of establishments.
+ *
+ * @return array List of establishments
+ *
+ * @url GET /establishments
+ *
+ * @throws RestException
+ */
+ public function getEstablishments()
+ {
+ $list = array();
+
+ $limit = 0;
+
+ $sql = "SELECT e.rowid, e.rowid as ref, e.label, e.address, e.zip, e.town, e.status";
+ $sql .= " FROM ".MAIN_DB_PREFIX."establishment as e";
+ $sql .= " WHERE e.entity IN (".getEntity('establishment').')';
+ // if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
+ // if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
+ // Add sql filters
+
+ $result = $this->db->query($sql);
+
+ if ($result) {
+ $num = $this->db->num_rows($result);
+ $min = min($num, ($limit <= 0 ? $num : $limit));
+ for ($i = 0; $i < $min; $i++) {
+ $list[] = $this->db->fetch_object($result);
+ }
+ } else {
+ throw new RestException(503, 'Error when retrieving list of establishments : '.$this->db->lasterror());
+ }
+
+ return $list;
+ }
+
+ /**
+ * Get establishment by ID.
+ *
+ * @param int $id ID of establishment
+ * @return array Array of cleaned object properties
+ *
+ * @url GET establishments/{id}
+ *
+ * @throws RestException
+ */
+ public function getEtablishmentByID($id)
+ {
+ $establishment = new Establishment($this->db);
+
+ $result = $establishment->fetch($id);
+ if ($result < 0) {
+ throw new RestException(503, 'Error when retrieving state : '.$establishment->error);
+ } elseif ($result == 0) {
+ throw new RestException(404, 'Establishment not found');
+ }
+
+ return $this->_cleanObjectDatas($establishment);
+ }
/**
* Get value of a setup variables
diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php
index 75b3030eac9..be8643e3f20 100644
--- a/htdocs/asset/class/asset_type.class.php
+++ b/htdocs/asset/class/asset_type.class.php
@@ -359,11 +359,7 @@ class AssetType extends CommonObject
if (!array_key_exists($obj->rowid, $ret)) {
if ($mode < 2) {
$assetstatic = new Asset($this->db);
- if ($mode == 1) {
- $assetstatic->fetch($obj->rowid, '', '', '', false, false);
- } else {
- $assetstatic->fetch($obj->rowid);
- }
+ $assetstatic->fetch($obj->rowid);
$ret[$obj->rowid] = $assetstatic;
} else {
$ret[$obj->rowid] = $obj->rowid;
diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php
index b4ee3a0a175..9d46e9ae0b6 100644
--- a/htdocs/asset/document.php
+++ b/htdocs/asset/document.php
@@ -42,8 +42,8 @@ $confirm = GETPOST('confirm', 'alpha');
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index 0bef6b25609..cd802c1c4fd 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -47,8 +47,8 @@ $backtopage = GETPOST('backtopage', 'alpha');
$type = GETPOST('type', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php
index 841086399c9..2b9c6f57bbd 100644
--- a/htdocs/bom/bom_agenda.php
+++ b/htdocs/bom/bom_agenda.php
@@ -52,8 +52,8 @@ if (GETPOST('actioncode', 'array')) {
$search_agenda_label = GETPOST('search_agenda_label');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
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/bom/bom_document.php b/htdocs/bom/bom_document.php
index c36ac32bb59..64f3cdbfac1 100644
--- a/htdocs/bom/bom_document.php
+++ b/htdocs/bom/bom_document.php
@@ -47,8 +47,8 @@ $ref = GETPOST('ref', 'alpha');
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index 656b3169eef..0520c76dde2 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -790,7 +790,7 @@ class BOM extends CommonObject
$label .= ''.$langs->trans('Label').': '.$this->label;
}
if (!empty($this->fk_product) && $this->fk_product > 0) {
- include_once DOL_DOCUMENT_ROO.'/product/class/product.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($db);
$resultFetch = $product->fetch($this->fk_product);
if ($resultFetch > 0) {
diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php
index edd9bd69ef4..805ba304c1d 100644
--- a/htdocs/bom/lib/bom.lib.php
+++ b/htdocs/bom/lib/bom.lib.php
@@ -56,7 +56,7 @@ function bomAdminPrepareHead()
//); // to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'bom@mrp');
- complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom@mrp', 'remove');
+ complete_head_from_modules($conf, $langs, null, $head, $h, 'bom@mrp', 'remove');
return $head;
}
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 63f18d2c046..52b93acdabb 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -937,7 +937,7 @@ if ($action == 'create') {
$("#selectcomplete").change(function() {
if ($("#selectcomplete").val() == 100)
{
- if ($("#doneby").val() <= 0) $("#doneby").val(\''.$user->id.'\');
+ if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).'\');
}
if ($("#selectcomplete").val() == 0)
{
@@ -992,7 +992,8 @@ if ($action == 'create') {
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
print ''.$langs->trans("Type").' ';
$default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ? 'AC_RDV' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT);
- $formactions->select_type_actions(GETPOSTISSET("actioncode") ? GETPOST("actioncode", 'aZ09') : ($object->type_code ? $object->type_code : $default), "actioncode", "systemauto", 0, -1);
+ print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"');
+ print $formactions->select_type_actions(GETPOSTISSET("actioncode") ? GETPOST("actioncode", 'aZ09') : ($object->type_code ? $object->type_code : $default), "actioncode", "systemauto", 0, -1, 0, 1); // TODO Replace 0 with -2 in onlyautoornot
print ' ';
}
@@ -1000,7 +1001,7 @@ if ($action == 'create') {
print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Label").' ';
// Full day
- print ''.$langs->trans("EventOnFullDay").' ';
+ print ''.$langs->trans("EventOnFullDay").' ';
$datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep));
if (GETPOST('datep', 'int', 1)) {
@@ -1311,7 +1312,7 @@ if ($action == 'create') {
print '';
- if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) {
+ if (getDolGlobalString('AGENDA_REMINDER_EMAIL') || getDolGlobalString('AGENDA_REMINDER_BROWSER')) {
//checkbox create reminder
print ' ';
print ' ';
@@ -1336,10 +1337,11 @@ if ($action == 'create') {
print ' ';
//Mail Model
- print ''.$langs->trans("EMailTemplates").' ';
- print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1, 1);
- print ' ';
-
+ if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
+ print ''.$langs->trans("EMailTemplates").' ';
+ print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1, 1);
+ print ' ';
+ }
print '';
print '';
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index e2adf06425f..9ab13962bfa 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -123,16 +123,17 @@ class ActionComm extends CommonObject
*/
public $label;
+ /**
+ * @var string Agenda event label
+ * @deprecated Use $label
+ */
+ public $libelle;
+
/**
* @var integer Date creation record (datec)
*/
public $datec;
- /**
- * @var integer Date end record (datef)
- */
- public $datef;
-
/**
* @var integer Duration (duree)
*/
@@ -172,6 +173,21 @@ class ActionComm extends CommonObject
*/
public $datep;
+ /**
+ * @var integer Date action end (datef)
+ */
+ public $datef;
+
+ /**
+ * @var integer This is date start action (datep) but modified to not be outside calendar view.
+ */
+ public $date_start_in_calendar;
+
+ /**
+ * @var integer This is date end action (datef) but modified to not be outside calendar view.
+ */
+ public $date_end_in_calendar;
+
/**
* @var integer Date action end (datep2)
*/
@@ -188,6 +204,11 @@ class ActionComm extends CommonObject
*/
public $fulldayevent = 0;
+ /**
+ * @var int 1=???
+ */
+ public $ponctuel;
+
/**
* @var integer Percentage
*/
@@ -219,8 +240,7 @@ class ActionComm extends CommonObject
public $userownerid;
/**
- * @var int Id of user done (deprecated)
- * @deprecated
+ * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set.
*/
public $userdoneid;
@@ -239,20 +259,6 @@ class ActionComm extends CommonObject
*/
public $reminders = array();
- /**
- * @var User Object user of owner
- * @deprecated
- * @see $userownerid
- */
- public $usertodo;
-
- /**
- * @var User Object user that did action
- * @deprecated
- * @see $userdoneid
- */
- public $userdone;
-
/**
* @var int thirdparty id linked to action
*/
@@ -827,18 +833,17 @@ class ActionComm extends CommonObject
$this->usermodid = $obj->fk_user_mod;
if (!is_object($this->author)) {
- $this->author = new stdClass(); // To avoid warning
+ $this->author = new User($this->db); // To avoid warning
}
$this->author->id = $obj->fk_user_author; // deprecated
$this->author->firstname = $obj->firstname; // deprecated
$this->author->lastname = $obj->lastname; // deprecated
if (!is_object($this->usermod)) {
- $this->usermod = new stdClass(); // To avoid warning
+ $this->usermod = new User($this->db); // To avoid warning
}
$this->usermod->id = $obj->fk_user_mod; // deprecated
$this->userownerid = $obj->fk_user_action;
- $this->userdoneid = $obj->fk_user_done;
$this->priority = $obj->priority;
$this->fulldayevent = $obj->fulldayevent;
$this->location = $obj->location;
@@ -1130,18 +1135,18 @@ class ActionComm extends CommonObject
$sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null');
$sql .= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'".$this->db->escape($this->durationp)."'" : "null"); // deprecated
$sql .= ", note = '".$this->db->escape($this->note_private)."'";
- $sql .= ", fk_project =".($this->fk_project > 0 ? $this->fk_project : "null");
- $sql .= ", fk_soc =".($socid > 0 ? $socid : "null");
- $sql .= ", fk_contact =".($contactid > 0 ? $contactid : "null");
+ $sql .= ", fk_project =".($this->fk_project > 0 ? ((int) $this->fk_project) : "null");
+ $sql .= ", fk_soc =".($socid > 0 ? ((int) $socid) : "null");
+ $sql .= ", fk_contact =".($contactid > 0 ? ((int) $contactid) : "null");
$sql .= ", priority = '".$this->db->escape($this->priority)."'";
$sql .= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'";
$sql .= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'" : "null");
$sql .= ", transparency = '".$this->db->escape($this->transparency)."'";
- $sql .= ", fk_user_mod = ".$user->id;
- $sql .= ", fk_user_action = ".($userownerid > 0 ? "'".$this->db->escape($userownerid)."'" : "null");
- $sql .= ", fk_user_done = ".($userdoneid > 0 ? "'".$this->db->escape($userdoneid)."'" : "null");
+ $sql .= ", fk_user_mod = ".((int) $user->id);
+ $sql .= ", fk_user_action = ".($userownerid > 0 ? ((int) $userownerid) : "null");
+ $sql .= ", fk_user_done = ".($userdoneid > 0 ? ((int) $userdoneid) : "null");
if (!empty($this->fk_element)) {
- $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null");
+ $sql .= ", fk_element=".($this->fk_element ? ((int) $this->fk_element) : "null");
}
if (!empty($this->elementtype)) {
$sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null");
@@ -1439,9 +1444,9 @@ class ActionComm extends CommonObject
/**
- * Return label of status
+ * Return the label of the status
*
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto
* @param int $hidenastatus 1=Show nothing if status is "Not applicable"
* @return string String with status
*/
@@ -1628,36 +1633,34 @@ class ActionComm extends CommonObject
}
if ($withpicto == 2) {
- $libelle = $label;
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
- $libelle = $labeltype;
+ $label = $labeltype;
}
- $libelleshort = '';
+ $labelshort = '';
} else {
- $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : ''));
- if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) {
- $libelle = $labeltype;
+ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($label)) {
+ $label = $labeltype;
}
if ($maxlength < 0) {
- $libelleshort = $this->ref;
+ $labelshort = $this->ref;
} else {
- $libelleshort = dol_trunc($libelle, $maxlength);
+ $labelshort = dol_trunc($label, $maxlength);
}
}
if ($withpicto) {
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { // Add code into ()
if ($labeltype) {
- $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')');
+ $label .= (preg_match('/'.preg_quote($labeltype, '/').'/', $label) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')');
}
}
}
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$label), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
- $result .= $libelleshort;
+ $result .= $labelshort;
$result .= $linkend;
global $action;
diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php
index aa693d2e41f..ff242430b0a 100644
--- a/htdocs/comm/action/class/actioncommreminder.class.php
+++ b/htdocs/comm/action/class/actioncommreminder.class.php
@@ -205,9 +205,9 @@ class ActionCommReminder extends CommonObject
}
/**
- * Retourne le libelle du status d'un user (actif, inactif)
+ * Return label of the status of a reminder
*
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public function getLibStatut($mode = 0)
diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php
index a248482ee9d..32c2345a657 100644
--- a/htdocs/comm/action/class/cactioncomm.class.php
+++ b/htdocs/comm/action/class/cactioncomm.class.php
@@ -145,7 +145,7 @@ class CActionComm
* @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter)
* @param string $idorcode 'id' or 'code' or 'all'
* @param string $excludetype Type to exclude ('system' or 'systemauto')
- * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line per calendar (Default, Auto, BoothConf, ...)
+ * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1 or -2=Keep details and add a combined line per calendar (Default, Auto, BoothConf, ...)
* @param string $morefilter Add more SQL filter
* @param int $shortlabel 1=Get short label instead of long label
* @return mixed Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode.
@@ -241,7 +241,7 @@ class CActionComm
$transcode = $langs->trans($keyfortrans);
}
$label = (($transcode != $keyfortrans) ? $transcode : $langs->trans($obj->label));
- if ($onlyautoornot == -1 && !empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
+ if (($onlyautoornot == -1 || $onlyautoornot == -2) && !empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
if ($typecalendar == 'system') {
$label = ' '.$label;
$repid[-99] = $langs->trans("ActionAC_MANUAL");
diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index 35e00006c6f..59c101c390d 100644
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -64,8 +64,8 @@ if ($id > 0) {
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index bdbbe74697d..d3538c6a2c9 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -61,8 +61,8 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
$newparam = '';
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
@@ -107,10 +107,10 @@ $year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y");
$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m");
$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d");
-$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
-$status = GETPOST("search_status", 'aZ09') ?GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo'
-$type = GETPOST("search_type", 'aZ09') ?GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09');
-$maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
+$pid = GETPOST("search_projectid", "int", 3) ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
+$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo'
+$type = GETPOSTISSET("search_type", 'aZ09') ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09');
+$maxprint = GETPOSTISSET("maxprint") ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW;
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
@@ -570,7 +570,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
$s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n";
$s .= 'var frm=jQuery("#searchFormList");'."\n";
$s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n";
- $s .= 'console.log(newurl);'."\n";
+ $s .= 'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'."\n";
$s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n";
$s .= '});'."\n";
}
@@ -837,7 +837,7 @@ if ($resql) {
$event->fk_project = $obj->fk_project;
- $event->thirdparty_id = $obj->fk_soc;
+ $event->socid = $obj->fk_soc;
$event->contact_id = $obj->fk_contact;
// Defined date_start_in_calendar and date_end_in_calendar property
@@ -848,10 +848,6 @@ if ($resql) {
} else {
$event->date_end_in_calendar = $event->datep;
}
- // Define ponctual property
- if ($event->date_start_in_calendar == $event->date_end_in_calendar) {
- $event->ponctuel = 1;
- }
// Check values
if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
@@ -945,7 +941,6 @@ if ($showbirthday) {
$event->date_start_in_calendar = $db->jdate($event->datep);
$event->date_end_in_calendar = $db->jdate($event->datef);
- $event->ponctuel = 0;
// Add an entry in eventarray for each day
$daycursor = $event->datep;
@@ -1288,12 +1283,6 @@ if (count($listofextcals)) {
$event->date_end_in_calendar = $event->datep;
}
- // Define ponctual property
- if ($event->date_start_in_calendar == $event->date_end_in_calendar) {
- $event->ponctuel = 1;
- //print 'x'.$datestart.'-'.$dateend;exit;
- }
-
// Add event into $eventarray if date range are ok.
if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
//print 'x'.$datestart.'-'.$dateend;exit;
@@ -1393,7 +1382,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month
print '';
print '';
- print '
';
+ print '';
print ' ';
// Column title of weeks numbers
echo ' # ';
@@ -1482,7 +1471,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month
print '';
print ' ';
- print ' ';
+ print ' ';
print ' ';
} elseif ($mode == 'show_week') {
// View by week
@@ -1502,7 +1491,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month
print '';
print '';
- print '
';
+ print '';
print ' ';
$i = 0;
while ($i < 7) {
@@ -1544,10 +1533,9 @@ if (empty($mode) || $mode == 'show_month') { // View by month
print '';
echo ' ';
- echo ' ';
+ echo ' ';
echo ' ';
-} else // View by day
-{
+} else { // View by day
$newparam = $param; // newparam is for birthday links
$newparam = preg_replace('/mode=show_month&?/i', '', $newparam);
$newparam = preg_replace('/mode=show_week&?/i', '', $newparam);
@@ -1965,7 +1953,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
if ($event->type_code != 'ICALEVENT') {
$savlabel = $event->label ? $event->label : $event->libelle;
$event->label = $titletoshow;
- $event->libelle = $titletoshow;
+ $event->libelle = $titletoshow; // deprecatd
// Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
$titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
$titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0);
@@ -1997,7 +1985,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
print ' ('.dol_trunc($event->icalname, $maxnbofchar).')';
}
- $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
+ $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
$contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
// If action related to company / contact
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 62308649834..de961b5517e 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -110,8 +110,8 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
}
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
// If $page is not defined, or '' or -1 or if we click on clear filters
diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php
index 5095d5ac65c..eee8baa2b20 100644
--- a/htdocs/comm/action/pertype.php
+++ b/htdocs/comm/action/pertype.php
@@ -57,8 +57,8 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
$filtert = $user->id;
}
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
@@ -683,10 +683,6 @@ if ($resql) {
$event->date_end_in_calendar = $datep;
}
}
- // Define ponctual property
- if ($event->date_start_in_calendar == $event->date_end_in_calendar) {
- $event->ponctuel = 1;
- }
// Check values
if ($event->date_end_in_calendar < $firstdaytoshow ||
@@ -1236,9 +1232,9 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
$color2 = '222222';
}
print '';
- print '';
+ print ' ';
print $string1;
- print ' ';
+ print ' ';
print $string2;
print ' ';
print '
';
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index cc3e63e1610..957ccd6e361 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -58,8 +58,8 @@ $showbirthday = 0;
$filtert = $user->id;
}*/
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
@@ -711,10 +711,6 @@ if ($resql) {
$event->date_end_in_calendar = $datep;
}
}
- // Define ponctual property
- if ($event->date_start_in_calendar == $event->date_end_in_calendar) {
- $event->ponctuel = 1;
- }
// Check values
if ($event->date_end_in_calendar < $firstdaytoshow ||
@@ -1441,7 +1437,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
}
print 'class="';
print ($style1 ? $style1.' ' : '');
- print 'onclickopenref'.($title2 ? ' classfortooltip' : '').($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>';
+ print 'onclickopenref center'.($title2 ? ' classfortooltip' : '').($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>';
print $string1;
print '';
+ print 'onclickopenref center'.($title2 ? ' classfortooltip' : '').($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids2 ? $ids2 : 'none').'"'.($title2 ? ' title="'.$title2.'"' : '').'>';
print $string2;
print ' ';
print '
';
diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php
index c48877681c2..9b3f9a27140 100644
--- a/htdocs/comm/action/rapport/index.php
+++ b/htdocs/comm/action/rapport/index.php
@@ -40,8 +40,8 @@ $year = GETPOST('year', 'int');
$optioncss = GETPOST('optioncss', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
// If $page is not defined, or '' or -1 or if we click on clear filters
@@ -163,7 +163,7 @@ if ($resql) {
// Button to build doc
print '';
- print 'month).'&year='.((int) $obj->year).'">'.img_picto($langs->trans('BuildDoc'), 'filenew').' ';
+ print 'month).'&year='.((int) $obj->year).'">'.img_picto($langs->trans('BuildDoc'), 'filenew').' ';
print ' ';
$name = "actions-".$obj->month."-".$obj->year.".pdf";
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 2fe683f4f8e..90d3ed128f7 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -93,8 +93,8 @@ $action = GETPOST('action', 'aZ09');
$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php
index 57a88bef157..62f57c008ba 100644
--- a/htdocs/comm/contact.php
+++ b/htdocs/comm/contact.php
@@ -157,10 +157,10 @@ if ($resql) {
print '';
print ''.img_object($langs->trans("ShowContact"), "contact");
print ' '.$obj->name.' ';
- print "$obj->firstname ";
+ print ''.dol_escape_htmltag($obj->firstname).' ';
print 'rowid.'">'.img_object($langs->trans("ShowCompany"), "company").' ';
- print "rowid."\">$obj->name \n";
+ print 'rowid.'">'.$obj->name." \n";
print ''.dol_print_phone($obj->email, $obj->cidp, $obj->rowid, 'AC_EMAIL').' ';
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index bfa458eca45..79faf4b2cd2 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -171,6 +171,7 @@ if (empty($reshook)) {
dol_print_error($db);
}
+ $thirdpartystatic = new Societe($db);
// Loop on each email and send it
$i = 0;
@@ -200,6 +201,15 @@ if (empty($reshook)) {
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$substitutionarray['__ID__'] = $obj->source_id;
+ if ($obj->source_type == "thirdparty") {
+ $result = $thirdpartystatic->fetch($obj->source_id);
+
+ if ($result > 0) {
+ $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client;
+ } else {
+ $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = '';
+ }
+ }
$substitutionarray['__EMAIL__'] = $obj->email;
$substitutionarray['__LASTNAME__'] = $obj->lastname;
$substitutionarray['__FIRSTNAME__'] = $obj->firstname;
@@ -483,9 +493,9 @@ if (empty($reshook)) {
if ($action == 'add') {
$mesgs = array();
- $object->email_from = (string) GETPOST("from", "none"); // Must allow 'name '
- $object->email_replyto = (string) GETPOST("replyto", "none"); // Must allow 'name '
- $object->email_errorsto = (string) GETPOST("errorsto", "none"); // Must allow 'name '
+ $object->email_from = (string) GETPOST("from", 'alphawithlgt'); // Must allow 'name '
+ $object->email_replyto = (string) GETPOST("replyto", 'alphawithlgt'); // Must allow 'name '
+ $object->email_errorsto = (string) GETPOST("errorsto", 'alphawithlgt'); // Must allow 'name '
$object->title = (string) GETPOST("title");
$object->sujet = (string) GETPOST("sujet");
$object->body = (string) GETPOST("bodyemail", 'restricthtml');
@@ -521,11 +531,11 @@ if (empty($reshook)) {
if ($action == 'settitle') {
$object->title = trim(GETPOST('title', 'alpha'));
} elseif ($action == 'setemail_from') {
- $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name '
+ $object->email_from = trim(GETPOST('email_from', 'alphawithlgt')); // Must allow 'name '
} elseif ($action == 'setemail_replyto') {
- $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name '
+ $object->email_replyto = trim(GETPOST('email_replyto', 'alphawithlgt')); // Must allow 'name '
} elseif ($action == 'setemail_errorsto') {
- $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name '
+ $object->email_errorsto = trim(GETPOST('email_errorsto', 'alphawithlgt')); // Must allow 'name '
} elseif ($action == 'settitle' && empty($object->title)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
} elseif ($action == 'setfrom' && empty($object->email_from)) {
diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
index cfdca4a1fc2..f4295fa6583 100644
--- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
+++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
@@ -230,7 +230,7 @@ class FormAdvTargetEmailing extends Form
$InfoFieldList = explode(":", $param_list [0]);
// 0 1 : tableName
- // 1 2 : label field name Nom du champ contenant le libelle
+ // 1 2 : label field name Name of field that contains the label
// 2 3 : key fields name (if differ of rowid)
// 3 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
@@ -304,7 +304,7 @@ class FormAdvTargetEmailing extends Form
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
- // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
+ // If a translation exists, we use it, else we use the default label
$label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : ''));
$options_array[$obj->code] = $label;
diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php
index cb900f7ac7b..8050b85f180 100644
--- a/htdocs/comm/mailing/class/mailing.class.php
+++ b/htdocs/comm/mailing/class/mailing.class.php
@@ -754,7 +754,7 @@ class Mailing extends CommonObject
/**
* Return label of status of emailing (draft, validated, ...)
*
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto
* @return string Label
*/
public function getLibStatut($mode = 0)
@@ -764,10 +764,10 @@ class Mailing extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Renvoi le libelle d'un statut donne
+ * Return the label of a given status
*
* @param int $status Id status
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto
* @return string Label
*/
public function LibStatut($status, $mode = 0)
@@ -792,11 +792,11 @@ class Mailing extends CommonObject
/**
- * Renvoi le libelle d'un statut donne
+ * Return the label of a given status of a recipient
* TODO Add class mailin_target.class.php
*
* @param int $status Id status
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto
* @param string $desc Desc error
* @return string Label
*/
diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php
index 94db62d7b19..be458d41fe3 100644
--- a/htdocs/comm/mailing/list.php
+++ b/htdocs/comm/mailing/list.php
@@ -28,8 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
// Load translation files required by the page
$langs->load("mails");
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$optioncss = GETPOST('optioncss', 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 9a8e7318db3..a9cc64bd847 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -14,7 +14,7 @@
* Copyright (C) 2016 Marcos García
* Copyright (C) 2018-2021 Frédéric France
* Copyright (C) 2020 Nicolas ZABOURI
- * Copyright (C) 2021 Gauthier VERDOL
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
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 da524f98ced..b92e3229aa1 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1,21 +1,23 @@
- * 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) 2021 Gauthier VERDOL
+/* 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
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
@@ -1720,12 +1722,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
@@ -1744,6 +1747,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);
@@ -3695,12 +3701,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/comm/propal/document.php b/htdocs/comm/propal/document.php
index 1135dfcf0c2..804fedd623b 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -53,8 +53,8 @@ $result = restrictedArea($user, 'propal', $id);
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index fd154cd90b5..b6977940411 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -130,8 +130,8 @@ $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
$page = 0;
diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php
index 1e1caa796b5..0bcf2662a44 100644
--- a/htdocs/comm/prospect/index.php
+++ b/htdocs/comm/prospect/index.php
@@ -77,7 +77,7 @@ if (!empty($conf->propal->enabled)) {
*
*/
-$sql = "SELECT count(*) as cc, st.libelle, st.picto, st.id";
+$sql = "SELECT count(*) as cc, st.libelle as stcomm, st.picto, st.id";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
if (empty($user->rights->societe->client->voir) && !$socid) {
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 1d450faa960..df4fc0ee3e2 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -13,7 +13,7 @@
* Copyright (C) 2014 Ferran Marcet
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2018-2021 Frédéric France
- * Copyright (C) 2021 Gauthier VERDOL
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
@@ -212,6 +212,8 @@ if (empty($reshook)) {
// Remove a product line
$result = $object->deleteline($user, $lineid);
if ($result > 0) {
+ // reorder lines
+ $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang = '';
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index e407a06ce91..0080d027561 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -12,7 +12,7 @@
* Copyright (C) 2018 Nicolas ZABOURI
* Copyright (C) 2016-2018 Ferran Marcet
* Copyright (C) 2021 Frédéric France
- * Copyright (C) 2021 Gauthier VERDOL
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
@@ -262,6 +262,11 @@ class Commande extends CommonOrder
//! key of pos source ('0', '1', ...)
public $pos_source;
+ /**
+ * @var array Array with line of all shipments
+ */
+ public $expeditions;
+
/**
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
@@ -491,7 +496,8 @@ class Commande extends CommonOrder
$sql .= " SET ref = '".$this->db->escape($num)."',";
$sql .= " fk_statut = ".self::STATUS_VALIDATED.",";
$sql .= " date_valid='".$this->db->idate($now)."',";
- $sql .= " fk_user_valid = ".((int) $user->id);
+ $sql .= " fk_user_valid = ".((int) $user->id).",";
+ $sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this)."::valid", LOG_DEBUG);
@@ -621,7 +627,8 @@ class Commande extends CommonOrder
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql .= " SET fk_statut = ".self::STATUS_DRAFT;
+ $sql .= " SET fk_statut = ".self::STATUS_DRAFT."',";
+ $sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id);
if ($this->db->query($sql)) {
@@ -695,7 +702,8 @@ class Commande extends CommonOrder
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql .= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0';
+ $sql .= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0,';
+ $sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG);
@@ -756,7 +764,8 @@ class Commande extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET fk_statut = '.self::STATUS_CLOSED.',';
$sql .= ' fk_user_cloture = '.((int) $user->id).',';
- $sql .= " date_cloture = '".$this->db->idate($now)."'";
+ $sql .= " date_cloture = '".$this->db->idate($now)."',";
+ $sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > '.self::STATUS_DRAFT;
if ($this->db->query($sql)) {
@@ -804,7 +813,8 @@ class Commande extends CommonOrder
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql .= " SET fk_statut = ".self::STATUS_CANCELED;
+ $sql .= " SET fk_statut = ".self::STATUS_CANCELED.",";
+ $sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id);
$sql .= " AND fk_statut = ".self::STATUS_VALIDATED;
@@ -1785,7 +1795,7 @@ class Commande extends CommonOrder
return -1;
}
- $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut';
+ $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_user_modif, c.fk_statut';
$sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
$sql .= ', c.fk_account';
$sql .= ', c.date_commande, c.date_valid, c.tms';
@@ -1850,6 +1860,7 @@ class Commande extends CommonOrder
$this->user_author_id = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid;
+ $this->user_modification = $obj->fk_user_modif;
$this->total_ht = $obj->total_ht;
$this->total_tva = $obj->total_tva;
$this->total_localtax1 = $obj->total_localtax1;
@@ -2010,9 +2021,9 @@ class Commande extends CommonOrder
/**
* Load array lines
*
- * @param int $only_product Return only physical products, not services
+ * @param int $only_product Return only physical products, not services
* @param int $loadalsotranslation Return translation for products
- * @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)
{
@@ -2207,9 +2218,10 @@ class Commande extends CommonOrder
* Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
*
* @param int $filtre_statut Filter on shipment status
+ * @param int $fk_product Add a filter on a product
* @return int <0 if KO, Nb of lines found if OK
*/
- public function loadExpeditions($filtre_statut = -1)
+ public function loadExpeditions($filtre_statut = -1, $fk_product = 0)
{
$this->expeditions = array();
diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php
index 96efda7c187..e181cc03c6a 100644
--- a/htdocs/commande/customer.php
+++ b/htdocs/commande/customer.php
@@ -46,8 +46,8 @@ if (!$user->rights->facture->creer) {
$langs->loadLangs(array("companies", "orders"));
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index b2b024f686a..684d8e61334 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -46,8 +46,8 @@ $ref = GETPOST('ref');
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index d0645ccdc02..717b57ae8b1 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -116,8 +116,8 @@ $diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/ma
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
$page = 0;
@@ -1854,10 +1854,13 @@ if ($resql) {
print '';
if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) {
if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
- $generic_commande->getLinesArray(); // This set ->lines
+ $generic_commande->getLinesArray(); // Load array ->lines
+ $generic_commande->loadExpeditions(); // Load array ->expeditions
$numlines = count($generic_commande->lines); // Loop on each line of order
for ($lig = 0; $lig < $numlines; $lig++) {
+ $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id];
+
if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service
$nbprod++; // order contains real products
$generic_product->id = $generic_commande->lines[$lig]->fk_product;
@@ -1872,15 +1875,15 @@ if ($resql) {
$generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
}
+ if ($reliquat > $generic_product->stock_reel) {
+ $notshippable++;
+ }
if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case.
- $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25);
+ $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20);
$text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.' ';
$text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.' ';
+ $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).') ' : '');
$text_info .= ' ';
-
- if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) {
- $notshippable++;
- }
} else { // BUGGED CODE.
// DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
// COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
@@ -1908,32 +1911,31 @@ if ($resql) {
$stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
}
}
- $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25);
+ $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20);
$text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
$warning++;
$text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.' ';
}
- if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) {
- $notshippable++;
+ if ($reliquat > $generic_product->stock_reel) {
$text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.' ';
} else {
$text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.' ';
}
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
- $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.' ';
- } else {
- $text_info .= ' ';
+ $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier;
}
+ $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).') ' : '');
+ $text_info .= ' ';
}
}
}
if ($notshippable == 0) {
$text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft');
- $text_info = $langs->trans('Shippable').' '.$text_info;
+ $text_info = $text_icon.' '.$langs->trans('Shippable').' '.$text_info;
} else {
$text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft');
- $text_info = $langs->trans('NonShippable').' '.$text_info;
+ $text_info = $text_icon.' '.$langs->trans('NonShippable').' '.$text_info;
}
}
diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php
index f36d455dc74..09cf9709aee 100644
--- a/htdocs/compta/bank/account_statement_document.php
+++ b/htdocs/compta/bank/account_statement_document.php
@@ -53,8 +53,8 @@ if ($user->socid) {
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 3800edb42ae..3d8e6f8bd98 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -107,8 +107,8 @@ if (empty($dateop)) {
}
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$pageplusone = GETPOST("pageplusone", 'int');
if ($pageplusone) {
@@ -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/bank/document.php b/htdocs/compta/bank/document.php
index 389c8195f37..78d45beadf3 100644
--- a/htdocs/compta/bank/document.php
+++ b/htdocs/compta/bank/document.php
@@ -50,8 +50,8 @@ if ($user->socid) {
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index ea656141639..6815a8d664b 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -79,8 +79,8 @@ if (!$allowed) {
$diroutputmassaction = $conf->bank->dir_output.'/temp/massgeneration/'.$user->id;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php
index 87fd36c498f..3417f05c817 100644
--- a/htdocs/compta/bank/releve.php
+++ b/htdocs/compta/bank/releve.php
@@ -78,8 +78,8 @@ if ($user->rights->banque->consolidate && $action == 'dvprev' && !empty($dvid))
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$pageplusone = GETPOST("pageplusone", 'int');
if ($pageplusone) {
diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php
index fec2d025c7a..bbec4f23fc6 100644
--- a/htdocs/compta/bank/various_payment/list.php
+++ b/htdocs/compta/bank/various_payment/list.php
@@ -77,8 +77,8 @@ if (empty($search_datev_end)) {
$search_datev_end = GETPOST("search_datev_end", 'int');
}
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php
index 2f3004ae1d6..149710c975b 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_card.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_card.php
@@ -46,8 +46,8 @@ $smonth = (GETPOSTISSET('closemonth') ?GETPOST('closemonth', 'int') : dol_print_
$sday = (GETPOSTISSET('closeday') ?GETPOST('closeday', 'int') : dol_print_date($now, "%d"));
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php
index be7c88c0a1a..07c1176b9d2 100644
--- a/htdocs/compta/charges/index.php
+++ b/htdocs/compta/charges/index.php
@@ -62,8 +62,8 @@ if (!$year) {
$search_account = GETPOST('search_account', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php
index b39364690a6..bc1d3790280 100644
--- a/htdocs/compta/clients.php
+++ b/htdocs/compta/clients.php
@@ -45,8 +45,8 @@ $langs->load("companies");
$mode = GETPOST("mode");
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php
index d588b7bff80..8af897378f5 100644
--- a/htdocs/compta/deplacement/index.php
+++ b/htdocs/compta/deplacement/index.php
@@ -38,8 +38,8 @@ if ($user->socid) {
$result = restrictedArea($user, 'deplacement', '', '');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php
index e7593406ad6..9f92cecc4a7 100644
--- a/htdocs/compta/deplacement/list.php
+++ b/htdocs/compta/deplacement/list.php
@@ -45,8 +45,8 @@ $search_ref = GETPOST('search_ref', 'int');
$search_name = GETPOST('search_name', 'alpha');
$search_company = GETPOST('search_company', 'alpha');
// $search_amount=GETPOST('search_amount','alpha');
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
if (empty($page) || $page == -1) {
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index 2e6ac4b6174..3909d9437b4 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -71,8 +71,8 @@ $year_date_when = GETPOST('year_date_when');
$month_date_when = GETPOST('month_date_when');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
@@ -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 e27f554e7d8..c54868d5c7b 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -15,7 +15,7 @@
* Copyright (C) 2014-2019 Ferran Marcet
* Copyright (C) 2015-2016 Marcos García
* Copyright (C) 2018-2021 Frédéric France
- * Copyright (C) 2021 Gauthier VERDOL
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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,6 +132,7 @@ $usercanread = $user->rights->facture->lire;
$usercancreate = $user->rights->facture->creer;
$usercanissuepayment = $user->rights->facture->paiement;
$usercandelete = $user->rights->facture->supprimer;
+$usercancreatecontract = $user->rights->contrat->creer;
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send)));
$usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen)));
@@ -266,6 +267,8 @@ if (empty($reshook)) {
$result = $object->deleteline(GETPOST('lineid', 'int'));
if ($result > 0) {
+ // reorder lines
+ $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang = '';
@@ -609,7 +612,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);
@@ -637,6 +640,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');
+ }
+ }
}
}
@@ -3417,6 +3428,10 @@ if ($action == 'create') {
$optionsav .= 'fetch_optionals($key);
+ $object->array_options = $newinvoice_static->array_options;
}
$optionsav .= '>';
$optionsav .= $newinvoice_static->ref;
@@ -5378,6 +5393,17 @@ if ($action == 'create') {
}
}
+ // Create contract
+ if (!empty($conf->global->CONTRACT_CREATE_FROM_INVOICE)) {
+ if ($conf->contrat->enabled && $object->statut == Facture::STATUS_VALIDATED) {
+ $langs->load("contracts");
+
+ if ($usercancreatecontract) {
+ print '' . $langs->trans('AddContract') . ' ';
+ }
+ }
+ }
+
// Validate
if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
if ($usercanvalidate) {
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 192157b86bf..7dcb6bfe8a8 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -17,7 +17,7 @@
* Copyright (C) 2016 Ferran Marcet
* Copyright (C) 2018 Alexandre Spangaro
* Copyright (C) 2018 Nicolas ZABOURI
- * Copyright (C) 2021 Gauthier VERDOL
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
@@ -528,9 +528,9 @@ class Facture extends CommonInvoice
// Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI
$this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project;
- $this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'restricthtml') : $_facrec->note_public;
- $this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'restricthtml') : $_facrec->note_private;
- $this->model_pdf = GETPOST('model', 'alpha') ? GETPOST('model', 'alpha') : $_facrec->model_pdf;
+ $this->note_public = GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : $_facrec->note_public;
+ $this->note_private = GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : $_facrec->note_private;
+ $this->model_pdf = GETPOSTISSET('model') ? GETPOST('model', 'alpha') : $_facrec->model_pdf;
$this->cond_reglement_id = GETPOST('cond_reglement_id', 'int') > 0 ? ((int) GETPOST('cond_reglement_id', 'int')) : $_facrec->cond_reglement_id;
$this->mode_reglement_id = GETPOST('mode_reglement_id', 'int') > 0 ? ((int) GETPOST('mode_reglement_id', 'int')) : $_facrec->mode_reglement_id;
$this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account;
@@ -1623,7 +1623,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)."'";
}
@@ -5703,22 +5703,25 @@ class FactureLigne extends CommonInvoiceLine
}
/**
- * Delete line in database
- * TODO Add param User $user and notrigger (see skeleton)
+ * Delete line in database
*
- * @return int <0 if KO, >0 if OK
+ * @param User $tmpuser User that deletes
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
*/
- public function delete()
+ public function delete($tmpuser = null, $notrigger = false)
{
global $user;
$this->db->begin();
// Call trigger
- $result = $this->call_trigger('LINEBILL_DELETE', $user);
- if ($result < 0) {
- $this->db->rollback();
- return -1;
+ if (empty($notrigger)) {
+ $result = $this->call_trigger('LINEBILL_DELETE', $user);
+ if ($result < 0) {
+ $this->db->rollback();
+ return -1;
+ }
}
// End call triggers
@@ -5730,7 +5733,7 @@ class FactureLigne extends CommonInvoiceLine
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->rowid);
- dol_syslog(get_class($this)."::delete", LOG_DEBUG);
+
if ($this->db->query($sql)) {
$this->db->commit();
return 1;
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 89a67e75cb7..6eb05a16922 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -50,8 +50,8 @@ $confirm = GETPOST('confirm', 'alpha');
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index d785ccbce93..a07d95094dd 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -96,8 +96,8 @@ $search_unit_frequency = GETPOST('search_unit_frequency', 'alpha');
$search_status = GETPOST('search_status', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 5a0adb02d4a..c244229c5f8 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -147,8 +147,8 @@ if ($option == 'late') {
$filtre = GETPOST('filtre', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
$page = 0;
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index cf0fb079fcb..635727233d3 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -48,7 +48,7 @@ $paymentnum = GETPOST('num_paiement', 'alpha');
$socid = GETPOST('socid', 'int');
$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'alpha');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$amounts = array();
diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index ab6f0f5e574..93fdd415513 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -295,7 +295,7 @@ print ' ';
if (!empty($conf->banque->enabled)) {
if ($object->fk_account > 0) {
if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) {
- dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php');
+ include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
$bordereau = new RemiseCheque($db);
$bordereau->fetch($bankline->fk_bordereau);
diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php
index f4d6c9e2686..d12caf36bbe 100644
--- a/htdocs/compta/paiement/cheque/list.php
+++ b/htdocs/compta/paiement/cheque/list.php
@@ -45,8 +45,8 @@ $search_account = GETPOST('search_account', 'int');
$search_amount = GETPOST('search_amount', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 0d928cf188f..3732e76b880 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -71,8 +71,8 @@ $search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be
$search_status = GETPOST('search_status', 'intcomma');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
@@ -340,7 +340,6 @@ print ' ';
print ' ';
print ' ';
print ' ';
-print ' ';
print ' ';
print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index fb9809bd9f2..3812d72f405 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -439,6 +439,8 @@ if ($id > 0 || $ref) {
}
if ($num > 0) {
+ $total = price2num($total, 'MT');
+
print '';
print ''.$langs->trans("Total").' ';
print ' ';
diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php
index 5ac0c07ede7..86f1bcf583c 100644
--- a/htdocs/compta/prelevement/demandes.php
+++ b/htdocs/compta/prelevement/demandes.php
@@ -49,8 +49,8 @@ $search_societe = GETPOST('search_societe', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php
index 3d05a17611c..342360bd454 100644
--- a/htdocs/compta/resultat/clientfourn.php
+++ b/htdocs/compta/resultat/clientfourn.php
@@ -52,8 +52,8 @@ $date_endyear = GETPOST('date_endyear', 'int');
$showaccountdetail = GETPOST('showaccountdetail', 'aZ09') ? GETPOST('showaccountdetail', 'aZ09') : 'yes';
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
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 "