diff --git a/admin/subtotal_about.php b/admin/subtotal_about.php index 412f14ff..c1ea3272 100644 --- a/admin/subtotal_about.php +++ b/admin/subtotal_about.php @@ -73,4 +73,4 @@ llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/admin/subtotal_setup.php b/admin/subtotal_setup.php index 242a6e6b..c490e5a4 100644 --- a/admin/subtotal_setup.php +++ b/admin/subtotal_setup.php @@ -45,28 +45,20 @@ // Parameters $action = GETPOST('action', 'alpha'); -if($action=='save') { - - foreach($_REQUEST['TDivers'] as $name=>$param) { - - dolibarr_set_const($db, $name, $param); - - } - +if ($action=='save') { + foreach ($_REQUEST['TDivers'] as $name=>$param) { + dolibarr_set_const($db, $name, $param); + } } -if (preg_match('/set_(.*)/',$action,$reg)) -{ - $code=$reg[1]; - if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - dol_print_error($db); - } +if (preg_match('/set_(.*)/', $action, $reg)) { + $code=$reg[1]; + if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } @@ -78,10 +70,10 @@ -llxHeader('','Gestion de sous-total, à propos',''); +llxHeader('', 'Gestion de sous-total, à propos', ''); $linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre('Gestion de subtotal',$linkback,'setup'); +print_fiche_titre('Gestion de subtotal', $linkback, 'setup'); // Configuration header $head = subtotalAdminPrepareHead(); @@ -95,13 +87,14 @@ showParameters(); -function showParameters() { - global $db,$conf,$langs; +function showParameters() +{ + global $db,$conf,$langs; - $html=new Form($db); + $html=new Form($db); - ?>
+ ?> @@ -110,34 +103,34 @@ function showParameters() { + ?> + ?>
Activer la gestion des sous-sous-totauxglobal->SUBTOTAL_MANAGE_SUBSUBTOTAL==0) { - - ?>trans("Disabled"),'switch_off'); ?>trans("Activated"),'switch_on'); ?>global->SUBTOTAL_MANAGE_SUBSUBTOTAL==0) { + ?>trans("Disabled"), 'switch_off'); + ?>trans("Activated"), 'switch_on'); + ?>
Activer l'utilisation avancéeglobal->SUBTOTAL_USE_NEW_FORMAT)) { - - ?>trans("Disabled"),'switch_off'); ?>trans("Activated"),'switch_on'); ?>global->SUBTOTAL_USE_NEW_FORMAT)) { + ?>trans("Disabled"), 'switch_off'); + ?>trans("Activated"), 'switch_on'); + ?>
@@ -156,7 +149,8 @@ function showParameters() { - selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY",$conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY,1); ?> + selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY", $conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY, 1); + ?> ">
@@ -168,20 +162,23 @@ function showParameters() {
- selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL",$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL,1); ?> + selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL", $conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL, 1); + ?> ">
- clilacevenements->enabled) { ?> + clilacevenements->enabled) { + ?> Afficher la quantité sur les lignes de sous-total (uniquement dans le cas d'un produit virtuel ajouté)
- selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES",$conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES,1); ?> + selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES", $conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES, 1); + ?> ">
@@ -193,16 +190,20 @@ function showParameters() {
- selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES",$conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES,1); ?> + selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES", $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES, 1); + ?> ">
- +

load('subtotal@subtotal'); + $langs->load('subtotal@subtotal'); - $contexts = explode(':',$parameters['context']); + $contexts = explode(':', $parameters['context']); - if(in_array('ordercard',$contexts) || in_array('propalcard',$contexts) || in_array('invoicecard',$contexts)) { - - if ($object->statut == 0 && $user->rights->{$object->element}->creer) { - - - if($object->element=='facture')$idvar = 'facid'; - else $idvar='id'; + if (in_array('ordercard', $contexts) || in_array('propalcard', $contexts) || in_array('invoicecard', $contexts)) { + if ($object->statut == 0 && $user->rights->{$object->element}->creer) { + if ($object->element=='facture') { + $idvar = 'facid'; + } else { + $idvar='id'; + } - if($action=='add_title_line' || $action=='add_total_line' || $action=='add_subtitle_line' || $action=='add_subtotal_line') { + if ($action=='add_title_line' || $action=='add_total_line' || $action=='add_subtitle_line' || $action=='add_subtotal_line') { + $level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT - $level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT - - if($action=='add_title_line') { - $title = GETPOST('title'); - if(empty($title)) $title = $langs->trans('title'); - $qty = $level ? $level : 1; - } - else if($action=='add_subtitle_line') { - $title = GETPOST('title'); - if(empty($title)) $title = $langs->trans('subtitle'); - $qty = 2; + if ($action=='add_title_line') { + $title = GETPOST('title'); + if (empty($title)) { + $title = $langs->trans('title'); + } + $qty = $level ? $level : 1; + } elseif ($action=='add_subtitle_line') { + $title = GETPOST('title'); + if (empty($title)) { + $title = $langs->trans('subtitle'); + } + $qty = 2; + } elseif ($action=='add_subtotal_line') { + $title = $langs->trans('SubSubTotal'); + $qty = 98; + } else { + $title = $langs->trans('SubTotal'); + $qty = $level ? 100-$level : 99; } - else if($action=='add_subtotal_line') { - $title = $langs->trans('SubSubTotal'); - $qty = 98; - } - else { - $title = $langs->trans('SubTotal'); - $qty = $level ? 100-$level : 99; - } - dol_include_once('/subtotal/class/subtotal.class.php'); - TSubtotal::addSubTotalLine($object, $title, $qty); - } - else if($action==='ask_deleteallline') { - $form=new Form($db); + dol_include_once('/subtotal/class/subtotal.class.php'); + TSubtotal::addSubTotalLine($object, $title, $qty); + } elseif ($action==='ask_deleteallline') { + $form=new Form($db); - $lineid = GETPOST('lineid','integer'); - $TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid); + $lineid = GETPOST('lineid', 'integer'); + $TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid); - $nbLines = count($TIdForGroup); + $nbLines = count($TIdForGroup); - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1); - print $formconfirm; - } + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1); + print $formconfirm; + } // New format is for 3.8 - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) - { - $this->printNewFormat($object, $conf, $langs, $idvar); - } - else - { - $this->printOldFormat($object, $conf, $langs, $idvar); + if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { + $this->printNewFormat($object, $conf, $langs, $idvar); + } else { + $this->printOldFormat($object, $conf, $langs, $idvar); } - - } - } + } + } - return 0; - } + return 0; + } - function printNewFormat(&$object, &$conf, &$langs, $idvar) - { - ?> + public function printNewFormat(&$object, &$conf, &$langs, $idvar) + { + ?> + public function printOldFormat(&$object, &$conf, &$langs, $idvar) + { + ?> + $out.= ' - + '; - $var = -$var; + $var = -$var; - $out.= ' + $out.= ' - + '; - $var = -$var; + $var = -$var; - $this->resprints = $out; - } + $this->resprints = $out; + } return 1; - } + } - function formEditProductOptions($parameters, &$object, &$action, $hookmanager) + public function formEditProductOptions($parameters, &$object, &$action, $hookmanager) { - - if (in_array('invoicecard',explode(':',$parameters['context']))) - { - + if (in_array('invoicecard', explode(':', $parameters['context']))) { } return 0; } - function ODTSubstitutionLine($parameters, &$object, $action, $hookmanager) { - global $conf; + public function ODTSubstitutionLine($parameters, &$object, $action, $hookmanager) + { + global $conf; - if($action === 'builddoc') { - - $line = &$parameters['line']; - $object = &$parameters['object']; - $substitutionarray = &$parameters['substitutionarray']; + if ($action === 'builddoc') { + $line = &$parameters['line']; + $object = &$parameters['object']; + $substitutionarray = &$parameters['substitutionarray']; - if($line->product_type == 9 && $line->special_code == $this->module_number) { - $substitutionarray['line_modsubtotal'] = true; + if ($line->product_type == 9 && $line->special_code == $this->module_number) { + $substitutionarray['line_modsubtotal'] = true; - $substitutionarray['line_price_ht'] - = $substitutionarray['line_price_vat'] + $substitutionarray['line_price_ht'] + = $substitutionarray['line_price_vat'] = $substitutionarray['line_price_ttc'] = $substitutionarray['line_vatrate'] - = $substitutionarray['line_qty'] + = $substitutionarray['line_qty'] = ''; - if($line->qty>90) { - $substitutionarray['line_modsubtotal_total'] = true; + if ($line->qty>90) { + $substitutionarray['line_modsubtotal_total'] = true; - $substitutionarray['line_price_ht'] = $substitutionarray['line_price_ttc'] = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL); - } else { - $substitutionarray['line_modsubtotal_title'] = true; - } - - - } - else{ - $substitutionarray['line_not_modsubtotal'] = true; - $substitutionarray['line_modsubtotal'] = false; - } - - } - - } - - function createFrom($parameters, &$object, $action, $hookmanager) { + $substitutionarray['line_price_ht'] = $substitutionarray['line_price_ttc'] = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL); + } else { + $substitutionarray['line_modsubtotal_title'] = true; + } + } else { + $substitutionarray['line_not_modsubtotal'] = true; + $substitutionarray['line_modsubtotal'] = false; + } + } + } - if ( - in_array('invoicecard',explode(':',$parameters['context'])) - || in_array('propalcard',explode(':',$parameters['context'])) - || in_array('ordercard',explode(':',$parameters['context'])) + public function createFrom($parameters, &$object, $action, $hookmanager) + { + if ( + in_array('invoicecard', explode(':', $parameters['context'])) + || in_array('propalcard', explode(':', $parameters['context'])) + || in_array('ordercard', explode(':', $parameters['context'])) ) { + global $db; - global $db; - - $objFrom = $parameters['objFrom']; + $objFrom = $parameters['objFrom']; - foreach($objFrom->lines as $k=> &$lineOld) { - - if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) { - - $line = & $object->lines[$k]; + foreach ($objFrom->lines as $k=> &$lineOld) { + if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) { + $line = & $object->lines[$k]; - $idLine = (int) ($line->id ? $line->id : $line->rowid); + $idLine = (int) ($line->id ? $line->id : $line->rowid); - $db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element." + $db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element." SET info_bits=".(int)$lineOld->info_bits." WHERE rowid = ".$idLine." "); - - } - - - } - - - } - - } + } + } + } + } - function doActions($parameters, &$object, $action, $hookmanager) { - global $conf; + public function doActions($parameters, &$object, $action, $hookmanager) + { + global $conf; - if($action === 'builddoc') { - - if ( - in_array('invoicecard',explode(':',$parameters['context'])) - || in_array('propalcard',explode(':',$parameters['context'])) - || in_array('ordercard',explode(':',$parameters['context'])) - ) - { - if(in_array('invoicecard',explode(':',$parameters['context']))) { - $sessname = 'subtotal_hideInnerLines_facture'; - $sessname2 = 'subtotal_hidedetails_facture'; - } - elseif(in_array('propalcard',explode(':',$parameters['context']))) { - $sessname = 'subtotal_hideInnerLines_propal'; - $sessname2 = 'subtotal_hidedetails_propal'; - } - elseif(in_array('ordercard',explode(':',$parameters['context']))) { - $sessname = 'subtotal_hideInnerLines_commande'; - $sessname2 = 'subtotal_hidedetails_commande'; - } - else { - $sessname = 'subtotal_hideInnerLines_unknown'; - $sessname2 = 'subtotal_hidedetails_unknown'; - } + if ($action === 'builddoc') { + if ( + in_array('invoicecard', explode(':', $parameters['context'])) + || in_array('propalcard', explode(':', $parameters['context'])) + || in_array('ordercard', explode(':', $parameters['context'])) + ) { + if (in_array('invoicecard', explode(':', $parameters['context']))) { + $sessname = 'subtotal_hideInnerLines_facture'; + $sessname2 = 'subtotal_hidedetails_facture'; + } elseif (in_array('propalcard', explode(':', $parameters['context']))) { + $sessname = 'subtotal_hideInnerLines_propal'; + $sessname2 = 'subtotal_hidedetails_propal'; + } elseif (in_array('ordercard', explode(':', $parameters['context']))) { + $sessname = 'subtotal_hideInnerLines_commande'; + $sessname2 = 'subtotal_hidedetails_commande'; + } else { + $sessname = 'subtotal_hideInnerLines_unknown'; + $sessname2 = 'subtotal_hidedetails_unknown'; + } - $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']); - $_SESSION[$sessname] = $hideInnerLines; + $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']); + $_SESSION[$sessname] = $hideInnerLines; - $hidedetails= (int)isset($_REQUEST['hidedetails']); - $_SESSION[$sessname2] = $hidedetails; + $hidedetails= (int)isset($_REQUEST['hidedetails']); + $_SESSION[$sessname2] = $hidedetails; - foreach($object->lines as &$line) { - if ($line->product_type == 9 && $line->special_code == $this->module_number) { - - if($line->qty>90) { + foreach ($object->lines as &$line) { + if ($line->product_type == 9 && $line->special_code == $this->module_number) { + if ($line->qty>90) { $line->modsubtotal_total = 1; - } - else{ + } else { $line->modsubtotal_title = 1; } - $line->total_ht = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL); - } - } - } - - } - else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { + $line->total_ht = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL); + } + } + } + } elseif ($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { + $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); - $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); - - foreach($Tab as $idLine) { - /** + foreach ($Tab as $idLine) { + /** * @var $object Facture */ - if($object->element=='facture') $object->deleteline($idLine); + if ($object->element=='facture') { + $object->deleteline($idLine); + } /** * @var $object Propal */ - else if($object->element=='propal') $object->deleteline($idLine); + elseif ($object->element=='propal') { + $object->deleteline($idLine); + } /** * @var $object Commande */ - else if($object->element=='commande') $object->deleteline($idLine); - } - - header('location:?id='.$object->id); - exit; + elseif ($object->element=='commande') { + $object->deleteline($idLine); + } + } - } + header('location:?id='.$object->id); + exit; + } - return 0; - } + return 0; + } - function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) { - return 0; - } + public function formAddObjectLine($parameters, &$object, &$action, $hookmanager) + { + return 0; + } - function getArrayOfLineForAGroup(&$object, $lineid) { - $rang = $line->rang; - $qty_line = $line->qty; + public function getArrayOfLineForAGroup(&$object, $lineid) + { + $rang = $line->rang; + $qty_line = $line->qty; - $total = 0; + $total = 0; - $found = false; + $found = false; - $Tab= array(); + $Tab= array(); - foreach($object->lines as $l) { - - if($l->rowid == $lineid) { - $found = true; - $qty_line = $l->qty; - } + foreach ($object->lines as $l) { + if ($l->rowid == $lineid) { + $found = true; + $qty_line = $l->qty; + } - if($found) { + if ($found) { + $Tab[] = $l->rowid; - $Tab[] = $l->rowid; - - if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2)) ) { - break; // end of story - } - } - - - } - + if ($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))) { + break; // end of story + } + } + } - return $Tab; - } + return $Tab; + } - function getTotalLineFromObject(&$object, &$line, $use_level=false) { - - $rang = $line->rang; - $qty_line = $line->qty; + public function getTotalLineFromObject(&$object, &$line, $use_level=false) + { + $rang = $line->rang; + $qty_line = $line->qty; - $total = 0; + $total = 0; - foreach($object->lines as $l) { - //print $l->rang.'>='.$rang.' '.$total.'
'; - if($l->rang>=$rang) { - //echo 'return!
'; + foreach ($object->lines as $l) { + //print $l->rang.'>='.$rang.' '.$total.'
'; + if ($l->rang>=$rang) { + //echo 'return!
'; return $total; - } - else if($l->special_code==$this->module_number && $l->qty == 100 - $qty_line) - { - $total = 0; - } - elseif($l->product_type!=9) { - $total += $l->total_ht; + } elseif ($l->special_code==$this->module_number && $l->qty == 100 - $qty_line) { + $total = 0; + } elseif ($l->product_type!=9) { + $total += $l->total_ht; } - - } + } - return $total; - } + return $total; + } /** * @param $pdf TCPDF PDF object @@ -523,42 +499,44 @@ function getTotalLineFromObject(&$object, &$line, $use_level=false) { * @param $w float width * @param $h float height */ - function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) { - global $conf; + public function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) + { + global $conf; - $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']); + $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']); - $hidePriceOnSubtotalLines = (int) isset($_REQUEST['hide_price_on_subtotal_lines']); + $hidePriceOnSubtotalLines = (int) isset($_REQUEST['hide_price_on_subtotal_lines']); - if($line->qty==99) - $pdf->SetFillColor(220,220,220); - elseif ($line->qty==98) - $pdf->SetFillColor(230,230,230); - else - $pdf->SetFillColor(240,240,240); + if ($line->qty==99) { + $pdf->SetFillColor(220, 220, 220); + } elseif ($line->qty==98) { + $pdf->SetFillColor(230, 230, 230); + } else { + $pdf->SetFillColor(240, 240, 240); + } - $pdf->SetFont('', 'B', 9); + $pdf->SetFont('', 'B', 9); - $y1 = $pdf->GetY(); - //Print label - $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true); - $y2 = $pdf->GetY(); + $y1 = $pdf->GetY(); + //Print label + $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true); + $y2 = $pdf->GetY(); //Print background $pdf->SetXY($posx, $posy); - $pdf->MultiCell(200-$posx, $y2-$y1-2, '', 0, '', 1); + $pdf->MultiCell(200-$posx, $y2-$y1-2, '', 0, '', 1); - if (!$hidePriceOnSubtotalLines) { - if($line->total == 0) { - $total = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL); + if (!$hidePriceOnSubtotalLines) { + if ($line->total == 0) { + $total = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL); - $line->total_ht = $total; - $line->total = $total; - } + $line->total_ht = $total; + $line->total = $total; + } - $pdf->SetXY($pdf->postotalht, $posy); - $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, price($line->total), 0, 'R', 0); - } + $pdf->SetXY($pdf->postotalht, $posy); + $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, price($line->total), 0, 'R', 0); + } } /** @@ -572,217 +550,208 @@ function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy * @param $w float width * @param $h float height */ - function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) { - - global $db,$conf; + public function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) + { + global $db,$conf; - $pdf->SetXY ($posx, $posy); + $pdf->SetXY($posx, $posy); - $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']); - if($hideInnerLines) { - - if($line->qty==1)$pdf->SetFont('', 'BU', 9); - else $pdf->SetFont('', $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES, 9); - - } - else { - - if($line->qty==1)$pdf->SetFont('', 'BU', 9); - else $pdf->SetFont('', 'BUI', 9); - - } + $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']); + if ($hideInnerLines) { + if ($line->qty==1) { + $pdf->SetFont('', 'BU', 9); + } else { + $pdf->SetFont('', $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES, 9); + } + } else { + if ($line->qty==1) { + $pdf->SetFont('', 'BU', 9); + } else { + $pdf->SetFont('', 'BUI', 9); + } + } - $pdf->MultiCell($w, $h, $label, 0, 'L'); + $pdf->MultiCell($w, $h, $label, 0, 'L'); - if($description && !$hidedesc) { - $posy = $pdf->GetY(); + if ($description && !$hidedesc) { + $posy = $pdf->GetY(); - $pdf->SetFont('', '', 8); + $pdf->SetFont('', '', 8); - $pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true); - - } + $pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true); + } } - function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') { - // ultimate PDF hook O_o - - return $this->pdf_writelinedesc($parameters,$object,$action); + public function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') + { + // ultimate PDF hook O_o - } + return $this->pdf_writelinedesc($parameters, $object, $action); + } - function isModSubtotalLine(&$parameters, &$object) { - - $i = & $parameters['i']; - - if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) { - return true; - } + public function isModSubtotalLine(&$parameters, &$object) + { + $i = & $parameters['i']; - return false; + if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) { + return true; + } - } + return false; + } - function pdf_getlineqty($parameters=array(), &$object, &$action='') { - - if($this->isModSubtotalLine($parameters,$object) ){ - - $this->resprints = ' '; - - return 1; + public function pdf_getlineqty($parameters=array(), &$object, &$action='') + { + if ($this->isModSubtotalLine($parameters, $object)) { + $this->resprints = ' '; - } - - } + return 1; + } + } - function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') { - - if($this->isModSubtotalLine($parameters,$object) ){ - - $this->resprints = ' '; - - return 1; + public function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') + { + if ($this->isModSubtotalLine($parameters, $object)) { + $this->resprints = ' '; - } - } + return 1; + } + } - function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') { - if($this->isModSubtotalLine($parameters,$object) ){ - - $this->resprints = ' '; + public function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') + { + if ($this->isModSubtotalLine($parameters, $object)) { + $this->resprints = ' '; - return 1; - } - } + return 1; + } + } - function pdf_getlineunit($parameters=array(), &$object, &$action='') { - if($this->isModSubtotalLine($parameters,$object) ){ - $this->resprints = ' '; + public function pdf_getlineunit($parameters=array(), &$object, &$action='') + { + if ($this->isModSubtotalLine($parameters, $object)) { + $this->resprints = ' '; - return 1; - } - } + return 1; + } + } - function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') { - if($this->isModSubtotalLine($parameters,$object) ){ - $this->resprints = ' '; + public function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') + { + if ($this->isModSubtotalLine($parameters, $object)) { + $this->resprints = ' '; - return 1; - } - } + return 1; + } + } - function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') { - if($this->isModSubtotalLine($parameters,$object) ){ - $this->resprints = ' '; - return 1; - } - } + public function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') + { + if ($this->isModSubtotalLine($parameters, $object)) { + $this->resprints = ' '; + return 1; + } + } - function pdf_getlinevatrate($parameters=array(), &$object, &$action='') { - if($this->isModSubtotalLine($parameters,$object) ){ - $this->resprints = ' '; - return 1; - } - } + public function pdf_getlinevatrate($parameters=array(), &$object, &$action='') + { + if ($this->isModSubtotalLine($parameters, $object)) { + $this->resprints = ' '; + return 1; + } + } - function pdf_getlineprogress($parameters=array(), &$object, &$action='') { - if($this->isModSubtotalLine($parameters,$object) ){ - $this->resprints = ' '; - return 1; - } - } + public function pdf_getlineprogress($parameters=array(), &$object, &$action='') + { + if ($this->isModSubtotalLine($parameters, $object)) { + $this->resprints = ' '; + return 1; + } + } - function pdf_writelinedesc($parameters=array(), &$object, &$action='') - { - /** + public function pdf_writelinedesc($parameters=array(), &$object, &$action='') + { + /** * @var $pdf TCPDF */ global $pdf,$conf; - foreach($parameters as $key=>$value) { - ${$key} = $value; - } - - $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']); - $hidedetails = (int)isset($_REQUEST['hidedetails']); + foreach ($parameters as $key=>$value) { + ${$key} = $value; + } - if($this->isModSubtotalLine($parameters,$object) ){ + $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']); + $hidedetails = (int)isset($_REQUEST['hidedetails']); - if ($hideInnerLines) { // si c une ligne de titre + if ($this->isModSubtotalLine($parameters, $object)) { + if ($hideInnerLines) { // si c une ligne de titre $fk_parent_line=0; - $TLines =array(); + $TLines =array(); - foreach($object->lines as $k=>&$line) - { - if($line->product_type==9 && $line->rowid>0) - { - $fk_parent_line = $line->rowid; + foreach ($object->lines as $k=>&$line) { + if ($line->product_type==9 && $line->rowid>0) { + $fk_parent_line = $line->rowid; - if($line->qty>90 && $line->total==0) - { - $total = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL); + if ($line->qty>90 && $line->total==0) { + $total = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL); - $line->total_ht = $total; - $line->total = $total; - } - - } + $line->total_ht = $total; + $line->total = $total; + } + } - if ($hideInnerLines) - { - if($line->product_type==9 && $line->rowid>0) - { - $TLines[] = $line; //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres - } - } - elseif ($hidedetails) - { - $TLines[] = $line; //Cas où je cache uniquement les prix des produits - } + if ($hideInnerLines) { + if ($line->product_type==9 && $line->rowid>0) { + $TLines[] = $line; //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres + } + } elseif ($hidedetails) { + $TLines[] = $line; //Cas où je cache uniquement les prix des produits + } - if ($line->product_type != 9) { // jusqu'au prochain titre ou total + if ($line->product_type != 9) { // jusqu'au prochain titre ou total //$line->fk_parent_line = $fk_parent_line; - - } + } /*if($hideTotal) { $line->total = 0; $line->subprice= 0; }*/ - } + } - $object->lines = $TLines; + $object->lines = $TLines; - if($i>count($object->lines)) return 1; - } + if ($i>count($object->lines)) { + return 1; + } + } - $line = &$object->lines[$i]; + $line = &$object->lines[$i]; - if($line->info_bits>0) { // PAGE BREAK + if ($line->info_bits>0) { // PAGE BREAK $pdf->addPage(); - $posy = $pdf->GetY(); - } + $posy = $pdf->GetY(); + } - if($line->label=='') { - $label = $outputlangs->convToOutputCharset($line->desc); - $description=''; - } - else { - $label = $outputlangs->convToOutputCharset($line->label); - $description=$outputlangs->convToOutputCharset(dol_htmlentitiesbr($line->desc)); - } + if ($line->label=='') { + $label = $outputlangs->convToOutputCharset($line->desc); + $description=''; + } else { + $label = $outputlangs->convToOutputCharset($line->label); + $description=$outputlangs->convToOutputCharset(dol_htmlentitiesbr($line->desc)); + } - if($line->qty>90) { + if ($line->qty>90) { + if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { + $label .= ' '.$this->getTitle($object, $line); + } - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line); - - $pageBefore = $pdf->getPage(); - $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); - $pageAfter = $pdf->getPage(); + $pageBefore = $pdf->getPage(); + $this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); + $pageAfter = $pdf->getPage(); /* if($pageAfter>$pageBefore) { print "ST $pageAfter>$pageBefore
"; @@ -793,15 +762,13 @@ function pdf_writelinedesc($parameters=array(), &$object, &$action='') $posy = $pdf->GetY(); print 'add ST'.$pdf->getPage().'
'; } - */ + */ $posy = $pdf->GetY(); - - } - else{ - $pageBefore = $pdf->getPage(); + } else { + $pageBefore = $pdf->getPage(); - $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); - $pageAfter = $pdf->getPage(); + $this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); + $pageAfter = $pdf->getPage(); /*if($pageAfter>$pageBefore) { print "T $pageAfter>$pageBefore
"; @@ -815,11 +782,11 @@ function pdf_writelinedesc($parameters=array(), &$object, &$action='') } */ $posy = $pdf->GetY(); - } + } // if($line->rowid==47) exit; return 1; - } + } /* TODO je desactive parce que je comprends pas PH Style, mais à test else { @@ -832,33 +799,30 @@ function pdf_writelinedesc($parameters=array(), &$object, &$action='') } }*/ - - - - } + } /** * Permet de récupérer le titre lié au sous-total * * @return string */ - function getTitle(&$object, &$currentLine) + public function getTitle(&$object, &$currentLine) { - $res = ''; + $res = ''; - foreach ($object->lines as $line) - { - if ($line->id == $currentLine->id) break; + foreach ($object->lines as $line) { + if ($line->id == $currentLine->id) { + break; + } - $qty_search = 100 - $currentLine->qty; + $qty_search = 100 - $currentLine->qty; - if ($line->product_type == 9 && $line->special_code == $this->module_number && $line->qty == $qty_search) - { - $res = ($line->label) ? $line->label : (($line->description) ? $line->description : $line->desc); - } - } + if ($line->product_type == 9 && $line->special_code == $this->module_number && $line->qty == $qty_search) { + $res = ($line->label) ? $line->label : (($line->description) ? $line->description : $line->desc); + } + } - return $res; + return $res; } /** @@ -868,46 +832,49 @@ function getTitle(&$object, &$currentLine) * @param $hookmanager HookManager * @return int */ - function printObjectLine ($parameters, &$object, &$action, $hookmanager){ - - global $conf,$langs,$user; + public function printObjectLine($parameters, &$object, &$action, $hookmanager) + { + global $conf,$langs,$user; - $num = &$parameters['num']; - $line = &$parameters['line']; - $i = &$parameters['i']; + $num = &$parameters['num']; + $line = &$parameters['line']; + $i = &$parameters['i']; - $contexts = explode(':',$parameters['context']); + $contexts = explode(':', $parameters['context']); - if($line->special_code!=$this->module_number || $line->product_type!=9) { - null; - } - else if (in_array('invoicecard',$contexts) || in_array('propalcard',$contexts) || in_array('ordercard',$contexts)) - { - - if($object->element=='facture')$idvar = 'facid'; - else $idvar='id'; + if ($line->special_code!=$this->module_number || $line->product_type!=9) { + null; + } elseif (in_array('invoicecard', $contexts) || in_array('propalcard', $contexts) || in_array('ordercard', $contexts)) { + if ($object->element=='facture') { + $idvar = 'facid'; + } else { + $idvar='id'; + } - if($action=='savelinetitle' && $_POST['lineid']===$line->id) { - - $description = ($line->qty>90) ? '' : GETPOST('linedescription'); - $pagebreak = (int)GETPOST('pagebreak'); + if ($action=='savelinetitle' && $_POST['lineid']===$line->id) { + $description = ($line->qty>90) ? '' : GETPOST('linedescription'); + $pagebreak = (int)GETPOST('pagebreak'); /** * @var $object Facture */ - if($object->element=='facture') $object->updateline($line->id,$description, 0,$line->qty,0,'','',0,0,0,'HT',$pagebreak,9,0,0,null,0,$_POST['linetitle'], $this->module_number); + if ($object->element=='facture') { + $object->updateline($line->id, $description, 0, $line->qty, 0, '', '', 0, 0, 0, 'HT', $pagebreak, 9, 0, 0, null, 0, $_POST['linetitle'], $this->module_number); + } /** * @var $object Propal */ - else if($object->element=='propal') $object->updateline($line->id, 0,$line->qty,0,0,0,0, $description ,'HT',$pagebreak,$this->module_number,0,0,0,0,$_POST['linetitle'],9); + elseif ($object->element=='propal') { + $object->updateline($line->id, 0, $line->qty, 0, 0, 0, 0, $description, 'HT', $pagebreak, $this->module_number, 0, 0, 0, 0, $_POST['linetitle'], 9); + } /** * @var $object Commande */ - else if($object->element=='commande') $object->updateline($line->id,$description, 0,$line->qty,0,0,0,0,'HT',$pagebreak,'','',9,0,0,null,0,$_POST['linetitle'], $this->module_number); - - } - else if($action=='editlinetitle') { - ?> + elseif ($object->element=='commande') { + $object->updateline($line->id, $description, 0, $line->qty, 0, 0, 0, 0, 'HT', $pagebreak, '', '', 9, 0, 0, null, 0, $_POST['linetitle'], $this->module_number); + } + } elseif ($action=='editlinetitle') { + ?> + + } else { + if ((float)DOL_VERSION <= 3.4) { + ?> description)) $line->description = $line->desc; - $colspan = 5; - if($conf->margin->enabled) $colspan++; - if($conf->global->DISPLAY_MARGIN_RATES) $colspan++; - if($conf->global->DISPLAY_MARK_RATES) $colspan++; - if($object->element == 'facture' && $conf->global->INVOICE_USE_SITUATION && $object->type == Facture::TYPE_SITUATION) $colspan++; - if($conf->global->PRODUCT_USE_UNITS) $colspan++; + if (empty($line->description)) { + $line->description = $line->desc; + } + $colspan = 5; + if ($conf->margin->enabled) { + $colspan++; + } + if ($conf->global->DISPLAY_MARGIN_RATES) { + $colspan++; + } + if ($conf->global->DISPLAY_MARK_RATES) { + $colspan++; + } + if ($object->element == 'facture' && $conf->global->INVOICE_USE_SITUATION && $object->type == Facture::TYPE_SITUATION) { + $colspan++; + } + if ($conf->global->PRODUCT_USE_UNITS) { + $colspan++; + } /* Titre */ //var_dump($line); ?> - id ) { - - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) - { - $qty_displayed = ($line->qty >=1 && $line->qty <= 9) ? $line->qty : 100 - $line->qty; - print img_picto('', 'subsubtotal@subtotal').''.$qty_displayed.'  '; - } - else - { - if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); - else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'     '; - } + ?>;"> + id) { + if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { + $qty_displayed = ($line->qty >=1 && $line->qty <= 9) ? $line->qty : 100 - $line->qty; + print img_picto('', 'subsubtotal@subtotal').''.$qty_displayed.'  '; + } else { + if ($line->qty<=1) { + print img_picto('', 'subtotal@subtotal'); + } elseif ($line->qty==2) { + print img_picto('', 'subsubtotal@subtotal').'     '; + } + } - if($line->label=='') { - $line->label = $line->description; - $line->description=''; - } + if ($line->label=='') { + $line->label = $line->description; + $line->description=''; + } - ?> + ?>