';
}
+ if (!$line->date_start || !$line->date_end) {
+ // show warning under line
+ // we need to fetch product associated to line for some test
+ if ($object->element == 'propal' || $object->element == 'order' || $object->element == 'propal_supplier' || $object->element == 'supplier_proposal' || $object->element == 'commande') {
+ $res = $line->fetch_product();
+ if ($res > 0 ) {
+ if ($line->product->isService() && $line->product->isMandatoryPeriod()) {
+ print '
'.$langs->trans("mandatoryPeriodNeedTobeSet").'
';
+ }
+ }
+ }
+ }
+
+
+
+
//print get_date_range($line->date_start, $line->date_end, $format);
}
diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
index fb0969dc7ef..f4f6e9e349f 100644
--- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
+++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
@@ -57,6 +57,7 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private,
-- v15
+ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0;
ALTER TABLE llx_holiday ADD COLUMN date_approve DATETIME DEFAULT NULL;
ALTER TABLE llx_holiday ADD COLUMN fk_user_approve integer DEFAULT NULL;
diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql
index e89a7658e5a..463ed33a86e 100644
--- a/htdocs/install/mysql/tables/llx_product.sql
+++ b/htdocs/install/mysql/tables/llx_product.sql
@@ -103,6 +103,9 @@ create table llx_product
desiredstock float DEFAULT 0,
fk_unit integer DEFAULT NULL,
price_autogen tinyint DEFAULT 0,
+ fk_project integer DEFAULT NULL, -- Used when product was generated by a project or is specifif to a project
+ mandatory_period tinyint DEFAULT 0 -- is used to signal to the user that the start and end dates are mandatory for this type of product the fk_product_type == 1 (service) (non-blocking action)
+
fk_default_bom integer DEFAULT NULL,
fk_project integer DEFAULT NULL -- Used when the product was generated by a project or is specific to a project
)ENGINE=innodb;
diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index 294e2afbc03..128eb120e0b 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -401,5 +401,11 @@ DeleteLinkedProduct=Delete the child product linked to the combination
AmountUsedToUpdateWAP=Amount to use to update the Weighted Average Price
PMPValue=Weighted average price
PMPValueShort=WAP
+
+mandatoryperiod=Mandatory periods
+mandatoryPeriodNeedTobeSet=Attention periods not entered and mandatory
+mandatoryPeriodNeedTobeSetMsgValidate=A service requires a start and end period
+mandatoryHelper=Message to the user on the need to enter a start date and an end date on a service when creating / validating an invoice, commercial proposal, sales order. This action is not blocking in the process of confirmation
DefaultBOM=Default BOM
-DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'.
\ No newline at end of file
+DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'.
+
diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang
index 013d75d2ec0..83514bd95ff 100644
--- a/htdocs/langs/fr_FR/products.lang
+++ b/htdocs/langs/fr_FR/products.lang
@@ -399,3 +399,7 @@ ProductSupplierExtraFields=Attributs supplémentaires (Prix fournisseur)
DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison
PMPValue=Prix moyen pondéré (PMP)
PMPValueShort=PMP
+mandatoryperiod=Périodes obligatoires
+mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires
+mandatoryPeriodNeedTobeSetMsgValidate=Un service nécessite une période de début et de fin
+mandatoryHelper=Message à l'utilisateur sur la necessité de saisir une date de début et une date de fin sur un service lors de la création/validation de facture, proposition commerciale , commande client. Cette action n'est pas bloquante dans le processus de validation
diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php
index 77acafbbd55..9ba8d9cec09 100644
--- a/htdocs/product/ajax/products.php
+++ b/htdocs/product/ajax/products.php
@@ -91,7 +91,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) {
$outtype = $object->type;
$outqty = 1;
$outdiscount = 0;
-
+ $mandatory_period = $object->mandatory_period;
$found = false;
$price_level = 1;
@@ -203,6 +203,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) {
'tva_tx' => $outtva_tx,
'qty' => $outqty,
'discount' => $outdiscount,
+ 'mandatory_period' => $mandatory_period,
'array_options'=>$object->array_options);
}
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index b6820bddddd..9e7a9b6d52d 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -105,6 +105,7 @@ $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
$accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha');
$accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha');
+$checkmandatory = GETPOST('accountancy_code_buy_export', 'alpha');
// by default 'alphanohtml' (better security); hidden conf MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML allows basic html
$label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml';
@@ -298,7 +299,7 @@ if (empty($reshook)) {
$object->ref = $ref;
$object->label = GETPOST('label', $label_security_check);
$object->price_base_type = GETPOST('price_base_type', 'aZ09');
-
+ $object->mandatory_period = !empty(GETPOST("mandatoryperiod", 'alpha')) ? 1 : 0;
if ($object->price_base_type == 'TTC') {
$object->price_ttc = GETPOST('price');
} else {
@@ -599,7 +600,7 @@ if (empty($reshook)) {
$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
$accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha');
$accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha');
-
+ $checkmandatory = GETPOST('mandatoryperiod', 'alpha');
if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') {
$object->accountancy_code_sell = '';
} else {
@@ -630,6 +631,11 @@ if (empty($reshook)) {
} else {
$object->accountancy_code_buy_export = $accountancy_code_buy_export;
}
+ if ($object->isService()) {
+ $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
+ }
+
+
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
@@ -1446,6 +1452,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1);
print '';
+ if (!empty($conf->service->enabled)) {
+ if ($object->isService()) {
+ // Mandatory period
+ print '