Skip to content

Commit

Permalink
FIX : Optimisation de la création des PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
ATM-Nicolas committed Mar 20, 2018
1 parent 0fad26c commit 3a6d6a4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
6 changes: 3 additions & 3 deletions class/actions_subtotal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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();
Expand Down
45 changes: 26 additions & 19 deletions class/subtotal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 3a6d6a4

Please sign in to comment.