From 2164729bad0d20906f66e002e416a22d1bd1703a Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 4 Jun 2015 13:34:08 +0200 Subject: [PATCH 1/2] if duration is present on service, we use it not logic to entered always 1h --- htdocs/fichinter/card.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index dac78d9ae3b..b5a00b694bf 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -248,7 +248,24 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $prod = new Product($db); $prod->id=$lines[$i]->fk_product; $prod->getMultiLangs(); + // We show if duration is present on service (so we get it) + $prod->fetch($lines[$i]->fk_product); + if ($prod->duration_value) + { + switch($prod->duration_unit) + { + case 'h': + $durationproduct=$prod->duration_value * 3600 * $lines[$i]->qty; + break; + case 'd': + $durationproduct=$prod->duration_value * 3600 * 24 * $lines[$i]->qty; + break; + case 'w': + $durationproduct=$prod->duration_value * 3600 * 24 * 7 * $lines[$i]->qty; + break; + } + } $outputlangs = $langs; $newlang=''; if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); @@ -268,7 +285,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $desc = $label; $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; - } + else { $desc = dol_htmlentitiesbr($lines[$i]->desc); $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; @@ -277,7 +294,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $date_intervention=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']); if ($product_type == 1) { //service - $duration = 3600; + $duration = ($durationproduct ? $durationproduct : 3600); } else { //product From bcf9bdc92e9d2c97cbd9232637e45edd05a9e998 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sun, 7 Jun 2015 23:18:51 +0200 Subject: [PATCH 2/2] Update card.php new setting vars FICHINTER_USE_SERVICE_DURATION --- htdocs/fichinter/card.php | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index b5a00b694bf..73f8b16fdb3 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -5,6 +5,7 @@ * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 201 Charlie Benke * * 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 @@ -250,22 +251,12 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $prod->getMultiLangs(); // We show if duration is present on service (so we get it) $prod->fetch($lines[$i]->fk_product); - if ($prod->duration_value) + if ($prod->duration_value && $prod->duration_unit == 'h' && $conf->global->FICHINTER_USE_SERVICE_DURATION) { - switch($prod->duration_unit) - { - case 'h': - $durationproduct=$prod->duration_value * 3600 * $lines[$i]->qty; - break; - case 'd': - $durationproduct=$prod->duration_value * 3600 * 24 * $lines[$i]->qty; - break; - case 'w': - $durationproduct=$prod->duration_value * 3600 * 24 * 7 * $lines[$i]->qty; - break; - - } + $durationproduct=$prod->duration_value * 3600 * $lines[$i]->qty; } + else + $durationproduct=3600; $outputlangs = $langs; $newlang=''; if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); @@ -294,11 +285,11 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $date_intervention=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']); if ($product_type == 1) { //service - $duration = ($durationproduct ? $durationproduct : 3600); + $duration = $durationproduct; } else { //product - $duration = 0; + $duration = 0; } $predef = '';