diff --git a/ChangeLog b/ChangeLog
index dedb228131e..cc29d46bd26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.7 compared to 3.6.* *****
For users:
+- New: Enable feature developed for 3.6 we forgot to enabled: Adding prefix
+ on uploaded file names.
+- New: No more dependency between contract and service module.
- New: [ task #867 ] Remove ESAEB external module code from core.
- New: Can create proposal from an intervention.
- New: Can filter events on a group of users.
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 3779473eacb..010e023b285 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -544,7 +544,7 @@ class Form
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select)
- * @param string $forceall Force to show products and services in combo list, whatever are activated modules
+ * @param string $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, -1=Force none (and set hidden field to 'service')
* @return void
*/
function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
@@ -552,8 +552,8 @@ class Form
global $db,$langs,$user,$conf;
// If product & services are enabled or both disabled.
- if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled))
- || (empty($conf->product->enabled) && empty($conf->service->enabled)))
+ if ($forceall > 0 || (empty($forceall) && ! empty($conf->product->enabled) && ! empty($conf->service->enabled))
+ || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled)) )
{
if (empty($hidetext)) print $langs->trans("Type").': ';
print '';
//if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
- if (! $forceall && empty($conf->product->enabled) && ! empty($conf->service->enabled))
+ if (empty($forceall) && empty($conf->product->enabled) && ! empty($conf->service->enabled))
{
print $langs->trans("Service");
print '';
}
- if (! $forceall && ! empty($conf->product->enabled) && empty($conf->service->enabled))
+ if (empty($forceall) && ! empty($conf->product->enabled) && empty($conf->service->enabled))
{
print $langs->trans("Product");
print '';
}
-
+ if ($forceall < 0) // This should happened only for contracts when both predefined product and service are disabled.
+ {
+ print ''; // By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1
+ }
}
/**
diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php
index b1a4e7e63cf..2ffc46b60bb 100644
--- a/htdocs/core/modules/modContrat.class.php
+++ b/htdocs/core/modules/modContrat.class.php
@@ -60,7 +60,7 @@ class modContrat extends DolibarrModules
$this->dirs = array("/contract/temp");
// Dependances
- $this->depends = array("modSociete","modService");
+ $this->depends = array("modSociete");
$this->requiredby = array();
// Config pages
diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php
index 2b9bb8d44f8..cd4823d7eab 100644
--- a/htdocs/core/modules/modService.class.php
+++ b/htdocs/core/modules/modService.class.php
@@ -64,7 +64,7 @@ class modService extends DolibarrModules
// Dependancies
$this->depends = array();
- $this->requiredby = array("modContrat");
+ $this->requiredby = array();
// Config pages
$this->config_page_url = array("product.php@product");
diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php
index a662bd5be3d..d1a1cedca61 100644
--- a/htdocs/core/tpl/document_actions_post_headers.tpl.php
+++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php
@@ -41,6 +41,21 @@ if ($action == 'delete')
$formfile=new FormFile($db);
+// We define var to enable the feature to add prefix of uploaded files
+$savingdocmask='';
+if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
+{
+ //var_dump($modulepart);
+ if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','ficheinter','contract','project','project_task')))
+ {
+ $savingdocmask=$object->ref.'___file__';
+ }
+ /*if (in_array($modulepart,array('member')))
+ {
+ $savingdocmask=$object->login.'___file__';
+ }*/
+}
+
// Show upload form (document and links)
$formfile->form_attach_new_file(
$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject)?'':'&withproject=1'),
@@ -49,7 +64,10 @@ $formfile->form_attach_new_file(
0,
$permission,
50,
- $object
+ $object,
+ '',
+ 1,
+ $savingdocmask
);
// List of document
diff --git a/htdocs/core/tpl/document_actions_pre_headers.tpl.php b/htdocs/core/tpl/document_actions_pre_headers.tpl.php
index ca6929331ec..b74c4bedf4d 100644
--- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php
+++ b/htdocs/core/tpl/document_actions_pre_headers.tpl.php
@@ -19,12 +19,17 @@
// Variable $upload_dir must be defined when entering here
// Send file/link
-if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
- if ($object->id) {
- dol_add_file_process($upload_dir, 0, 1, 'userfile');
+if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
+{
+ if ($object->id)
+ {
+ dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask'));
}
-} elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
- if ($object->id) {
+}
+elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
+{
+ if ($object->id)
+ {
$link = GETPOST('link', 'alpha');
if ($link)
{
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 97e6224999f..2d33ec0e81f 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -91,10 +91,17 @@ else {
element == 'contrat')
+ {
+ if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
+ else $forceall=0;
+ }
+
// Free line
echo '';
// Show radio free line
- if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
+ if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
{
echo 'product->enabled) || empty($conf->service->enabled)))?' checked="true"':'') );
@@ -102,35 +109,25 @@ else {
echo '> ';
}
else echo '';
+
// Show type selector
-/* if (empty($conf->product->enabled) && empty($conf->service->enabled))
+ if ($forceall >= 0)
{
- // If module product and service disabled, by default this is a product except for contracts it is a service
- print '';
- }
- else {*/
echo '';
- /*
- if (empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans("Type");
- else if (! empty($forceall) || (! empty($conf->product->enabled) && ! empty($conf->service->enabled))) echo $langs->trans("FreeLineOfType");
- else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans("FreeLineOfType").' '.$langs->trans("Service");
- else if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans("FreeLineOfType").' '.$langs->trans("Product");*/
echo ' ';
- $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service)
- if ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))
- {
- $forceall=0;
- }
- echo $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1,1,$forceall);
-// }
+ }
+
+ echo $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1,1,$forceall);
+
echo '';
// Predefined product/service
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{
- echo ' ';
+ if ($forceall >= 0) echo ' ';
+ echo '';
echo ' ';
echo '