* Copyright (C) 2010-2011 Laurent Destailleur * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry * Copyright (C) 2017 Juanjo Menent * * 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 * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Need to have following variables defined: * $object (invoice, order, ...) * $conf * $langs * $dateSelector * $forceall (0 by default, 1 for supplier invoices/orders) * $element (used to test $user->rights->$element->creer) * $permtoedit (used to replace test $user->rights->$element->creer) * $senderissupplier (0 by default, 1 for supplier invoices/orders) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $outputalsopricetotalwithtax * $usemargins (0 to disable all margins columns, 1 to show according to margin setup) * $object_rights->creer initialized from = $object->getRights() * $disableedit, $disablemove, $disableremove * * $text, $description, $line */ // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } global $mysoc; global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax; if(strcmp($line->element, "facturedet") == 0){ if ($line->fk_product > 0) { // $extrafields->fetch_name_optionals_label($object->table_element); // print '
';
		// 	print_r($extrafields->attributes);
		// print '
'; $producto_cfdimx = new Product($this->db); $producto_cfdimx->fetch($line->fk_product); $tipo_producto = ($producto_cfdimx->type == 0 ? 'Producto' : 'Servicio'); $label = ""; $label .= "Información del Cátalogo
"; if($producto_cfdimx->type == 0){ $label .= img_picto('', 'product').' '.$langs->trans("Product").'
'; } if($producto_cfdimx->type == 1){ $label .= img_picto('', 'service').' '.$langs->trans("Service").'
'; } if($producto_cfdimx->array_options["options_claveprodserv"] != "" && $producto_cfdimx->array_options["options_claveprodserv"] != -1){ $label .= " ClaveProdServ: ".$producto_cfdimx->array_options["options_claveprodserv"]."
"; } if($producto_cfdimx->array_options["options_umed"] != "" && $producto_cfdimx->array_options["options_umed"] != -1){ $label .= " Unidad de Medida: ".$producto_cfdimx->array_options["options_umed"]."
"; // $label .= "Unidad de Medida: ".$extrafields->showOutputField('umed', $producto_cfdimx->array_options["options_umed"], '', $producto_cfdimx->table_element); } if($producto_cfdimx->array_options["options_noidenticfdi"] != ""){ $label .= " No. Identificación: ".$producto_cfdimx->array_options["options_noidenticfdi"]."
"; } if($producto_cfdimx->array_options["options_aplicar_ret_individual"] != ""){ $label .= " Aplicar Retención Individual: ".$producto_cfdimx->array_options["options_aplicar_ret_individual"]."
"; } if($producto_cfdimx->array_options["options_exentoiva"] != ""){ $label .= " Exento de I.V.A.: ".$producto_cfdimx->array_options["options_exentoiva"]."
"; } if($producto_cfdimx->array_options["options_objimp"] != "" && $producto_cfdimx->array_options["options_objimp"] != -1){ $label .= " Objeto de Impuesto: ".$producto_cfdimx->array_options["options_objimp"]."
"; } $target = ""; $linkclose = ($target ? ' target="'.$target.'"' : ''); if (empty($notooltip) && $user->rights->facture->lire) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Invoice"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip"'; } $ruta_cfdimx = "../../product/card.php?id=".$line->fk_product; $linkstart = ''; $linkend = ''; if ($option == 'nolink') { $linkstart = ''; $linkend = ''; } $result .= $linkstart; if ($withpicto) { $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ''; $result .= 'CFDIMX'; $result .= ' '; $result .= ''; } $result .= $linkend; $text .= " - ".$result; } } $usemargins = 0; if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) { $usemargins = 1; } if (empty($dateSelector)) { $dateSelector = 0; } if (empty($forceall)) { $forceall = 0; } if (empty($senderissupplier)) { $senderissupplier = 0; } if (empty($inputalsopricewithtax)) { $inputalsopricewithtax = 0; } if (empty($outputalsopricetotalwithtax)) { $outputalsopricetotalwithtax = 0; } // add html5 elements $domData = ' data-element="'.$line->element.'"'; $domData .= ' data-id="'.$line->id.'"'; $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; $sign = 1; if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && in_array($object->element, array('facture', 'invoice_supplier')) && $object->type == $object::TYPE_CREDIT_NOTE) { $sign = -1; } $coldisplay = 0; ?> > global->MAIN_VIEW_LINE_NUMBER)) { ?>
info_bits & 2) == 2) { print ''; $txt = ''; print img_object($langs->trans("ShowReduc"), 'reduc').' '; if ($line->description == '(DEPOSIT)') { $txt = $langs->trans("Deposit"); } elseif ($line->description == '(EXCESS RECEIVED)') { $txt = $langs->trans("ExcessReceived"); } elseif ($line->description == '(EXCESS PAID)') { $txt = $langs->trans("ExcessPaid"); } //else $txt=$langs->trans("Discount"); print $txt; print ''; if ($line->description) { if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) { include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) { include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); // Add date of deposit if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { print ' ('.dol_print_date($discount->datec).')'; } } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); } elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); } else { print ($txt ? ' - ' : '').dol_htmlentitiesbr($line->description); } } } else { $format = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 'dayhour' : 'day'); if ($line->fk_product > 0) { print $form->textwithtooltip($text, $description, 3, 0, '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type); if ($type == 1) { $text = img_object($langs->trans('Service'), 'service'); } else { $text = img_object($langs->trans('Product'), 'product'); } if (!empty($line->label)) { $text .= ' '.$line->label.''; print $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, 0, '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { if (!empty($line->fk_parent_line)) { print img_picto('', 'rightarrow'); } if (preg_match('/^\(DEPOSIT\)/', $line->description)) { $newdesc = preg_replace('/^\(DEPOSIT\)/', $langs->trans("Deposit"), $line->description); print $text.' '.dol_htmlentitiesbr($newdesc); } else { print $text.' '.dol_htmlentitiesbr($line->description); } } } // Show date range if ($line->element == 'facturedetrec') { if ($line->date_start_fill || $line->date_end_fill) { print '
'; } if ($line->date_start_fill) { print ''.$langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill); } if ($line->date_start_fill && $line->date_end_fill) { print ' - '; } if ($line->date_end_fill) { print ''.$langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill); } if ($line->date_start_fill || $line->date_end_fill) { print '
'; } } else { if ($line->date_start || $line->date_end) { print '
'.get_date_range($line->date_start, $line->date_end, $format).'
'; } 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); } // Add description in form if ($line->fk_product > 0 && !empty($conf->global->PRODUIT_DESC_IN_FORM)) { if ($line->element == 'facturedetrec') { print (!empty($line->description) && $line->description != $line->product_label) ? (($line->date_start_fill || $line->date_end_fill) ? '' : '
').'
'.dol_htmlentitiesbr($line->description) : ''; } else { print (!empty($line->description) && $line->description != $line->product_label) ? (($line->date_start || $line->date_end) ? '' : '
').'
'.dol_htmlentitiesbr($line->description) : ''; } } if (!empty($extrafields)) { $temps = $line->showOptionals($extrafields, 'view', array(), '', '', 1, 'line'); if (!empty($temps)) { print '
'; print $temps; print '
'; } } } if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0 && empty($conf->global->SUPPLIER_HIDE_SUPPLIER_OBJECTLINES)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productfourn = new ProductFournisseur($this->db); $productfourn->fetch_product_fournisseur_price($line->fk_fournprice); print '
'; print ''.$langs->trans('Supplier').' : '.$productfourn->getSocNomUrl(1, 'supplier').' - '.$langs->trans('Ref').' : '; // Supplier ref if ($user->rights->produit->creer || $user->rights->service->creer) { // change required right here print $productfourn->getNomUrl(); } else { print $productfourn->ref_supplier; } } if (!empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) { $accountingaccount = new AccountingAccount($this->db); $accountingaccount->fetch($line->fk_accounting_account); print '

'.$langs->trans('AccountingAffectation').' : '.$accountingaccount->getNomUrl(0, 1, 1); } print ''; if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') { // We must have same test in printObjectLines print ''; print ($line->ref_fourn ? $line->ref_fourn : $line->ref_supplier); print ''; } // VAT Rate print ''; $coldisplay++; $positiverates = ''; if (price2num($line->tva_tx)) { $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); } if (price2num($line->total_localtax1)) { $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); } if (price2num($line->total_localtax2)) { $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); } if (empty($positiverates)) { $positiverates = '0'; } print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), '%', $line->info_bits); //print vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); ?> subprice); ?> multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> multicurrency_subprice); ?> pu_ttc) ? price($sign * $line->pu_ttc) : price($sign * $line->subprice)); ?> info_bits & 2) != 2) && $line->special_code != 3) { // I comment this because it shows info even when not required // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated // must also not be output for most entities (proposal, intervention, ...) //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; print price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price } else { print ' '; } print ''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; $label = $line->getLabelOfUnit('short'); if ($label !== '') { print $langs->trans($label); } print ''; } if (!empty($line->remise_percent) && $line->special_code != 3) { print ''; $coldisplay++; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print dol_print_reduction($line->remise_percent, $langs); print ''; } else { print ' '; $coldisplay++; } // Fields for situation invoices if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $coldisplay++; print ''.$line->situation_percent.'%'; $coldisplay++; $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier ? $mysoc : $object->thirdparty), ($senderissupplier ? $object->thirdparty : $mysoc)); $tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier ? $object->thirdparty : $mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice); print ''.price($sign * $tmp[0]).''; } if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid)) { if (!empty($user->rights->margins->creer)) { ?> pa_ht); ?> global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?> pa_ht == 0) ? 'n/a' : price(price2num($line->marge_tx, 'MT')).'%'); ?> global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> marque_tx, 'MT')).'%'; ?> special_code == 3) { ?> trans('Option'); ?> '; $coldisplay++; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht); $tooltiponprice .= '
'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); if (!$senderissupplier && is_object($object->thirdparty)) { if ($mysoc->useLocalTax(1)) { if (($mysoc->country_code == $object->thirdparty->country_code) || $object->thirdparty->useLocalTax(1)) { $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_localtax1); } else { $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.$langs->trans("NotUsedForThisCustomer").''; } } if ($mysoc->useLocalTax(2)) { if (($mysoc->country_code == $object->thirdparty->country_code) || $object->thirdparty->useLocalTax(2)) { $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_localtax2); } else { $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.$langs->trans("NotUsedForThisCustomer").''; } } } $tooltiponprice .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); print ''; } print price($sign * $line->total_ht); if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { print ''; } print ''; if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { print ''.price($sign * $line->multicurrency_total_ht).''; $coldisplay++; } } if ($outputalsopricetotalwithtax) { print ''.price($sign * $line->total_ttc).''; $coldisplay++; } if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlines') { $situationinvoicelinewithparent = 0; if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) { if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice // Set constant to disallow editing during a situation cycle $situationinvoicelinewithparent = 1; } } print ''; $coldisplay++; if (($line->info_bits & 2) == 2 || !empty($disableedit)) { } else { ?> id.'#line_'.$line->id; ?>"> '; } print ''; print ''; $coldisplay++; if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company. print 'id.'">'; print img_delete(); print ''; } print ''; if ($num > 1 && $conf->browser->layout != 'phone' && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) { print ''; $coldisplay++; if ($i > 0) { ?> id; ?>"> id; ?>"> '; } else { print 'browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>'; $coldisplay++; } } else { print ''; $coldisplay = $coldisplay + 3; } if ($action == 'selectlines') { ?> \n"; print "\n";