diff --git a/class/actions_subtotal.class.php b/class/actions_subtotal.class.php index 6833ce23..251d6180 100644 --- a/class/actions_subtotal.class.php +++ b/class/actions_subtotal.class.php @@ -962,7 +962,8 @@ function pdf_getlineqty($parameters=array(), &$object, &$action='') { if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) - $object->lines[$i]->fetch_optionals(); + if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals(); + if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) { if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) @@ -1576,7 +1577,6 @@ function getTitle(&$object, &$currentLine) * @return int */ function printObjectLine ($parameters, &$object, &$action, $hookmanager){ - global $conf,$langs,$user,$db,$bc; $num = &$parameters['num']; @@ -1966,7 +1966,7 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager){ function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) { global $conf,$langs; - + if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline') { $TSubNc = array(); diff --git a/class/subtotal.class.php b/class/subtotal.class.php index 373d84f1..fe7c7b1e 100644 --- a/class/subtotal.class.php +++ b/class/subtotal.class.php @@ -520,27 +520,30 @@ public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_ public static function getAllTitleFromLine(&$origin_line, $reverse = false) { - global $db; + global $db, $object; $TTitle = array(); - if ($origin_line->element == 'propaldet') - { - $object = new Propal($db); - $object->fetch($origin_line->fk_propal); - } - else if ($origin_line->element == 'commandedet') - { - $object = new Commande($db); - $object->fetch($origin_line->fk_commande); - } - else if ($origin_line->element == 'facturedet') - { - $object = new Facture($db); - $object->fetch($origin_line->fk_facture); - } - else - { - return $TTitle; + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} + else { + if ($origin_line->element == 'propaldet') + { + $object = new Propal($db); + $object->fetch($origin_line->fk_propal); + } + else if ($origin_line->element == 'commandedet') + { + $object = new Commande($db); + $object->fetch($origin_line->fk_commande); + } + else if ($origin_line->element == 'facturedet') + { + $object = new Facture($db); + $object->fetch($origin_line->fk_facture); + } + else + { + return $TTitle; + } } // Récupération de la position de la ligne @@ -1127,15 +1130,19 @@ public static function concat(&$outputlangs, $files, $fileoutput='') */ public static function hasNcTitle(&$line) { + if(isset($line->has_nc_title)) return $line->has_nc_title; + $TTitle = self::getAllTitleFromLine($line); foreach ($TTitle as &$line_title) { if (!empty($line_title->array_options['options_subtotal_nc'])) { + $line->has_nc_title = true; return true; } } + $line->has_nc_title = false; return false; }