<?php
		global $conf, $langs, $user, $hookmanager, $rental_lines, $drafteditable;

        if (empty($drafteditable)) return;

		$element = $object->element;
		if ($element == 'propale') $element = 'propal';

		$langs->load('drafteditable@dolitools');

		if ($object->statut == 0 && ($element == 'propal' || $element == 'commande' || $element == 'facture') && $user->rights->{$element}->creer)
		{

			if ($conf->global->RENTAL_DONTMIX_LINES)
			{
				if ($rental_lines && empty($line->array_options['options_rental_line']))
				{
					if (
						($line->product_type == 9 && !empty($line->special_code) && $line->qty == 1 && isset($object->lines[$i+1]) && !empty($object->lines[$i+1]->array_options['options_rental_line'])) // titre
						|| ($line->product_type == 9 && !empty($line->special_code) && $line->qty == 99 && isset($object->lines[$i-1]) && !empty($object->lines[$i-1]->array_options['options_rental_line'])) // sous-total
						|| ($line->product_type == 9 && !empty($line->special_code) && $line->qty == 50 && ($i == 1 || (isset($object->lines[$i-1]) && !empty($object->lines[$i-1]->array_options['options_rental_line'])))) // free text
					)
						;
					else
					{
						return;
					}
				}
				elseif ( ! $rental_lines )
				{
					if ($line->array_options['options_rental_line'] == '1'
					|| (
						($line->product_type == 9 && !empty($line->special_code) && $line->qty == 1 && isset($object->lines[$i+1]) && !empty($object->lines[$i+1]->array_options['options_rental_line'])) // titre

						||

						($line->product_type == 9 && !empty($line->special_code) && $line->qty == 99 && isset($object->lines[$i-1]) && !empty($object->lines[$i-1]->array_options['options_rental_line'])) // sous-total

						||

						($line->product_type == 9 && !empty($line->special_code) && $line->qty == 50 && $i > 1 && isset($object->lines[$i-1]) && !empty($object->lines[$i-1]->array_options['options_rental_line'])) // free text

						||

						($line->special_code == 140015 && $i+1 == count($lines) && $this->total_selling == 0)
						)
					)
					{
						return;
					}
				}
			}

			if ($line->product_type == 9 && ! empty($line->special_code))
			{
				$actionedit = 'editline';
				$_GET['lineid'] = $line->id;

				if (empty($line->fk_parent_line))
				{
					$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
					$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $actionedit);    // Note that $action and $object may have been modified by some hooks
				}
				else
				{
					$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline, 'fk_parent_line'=>$line->fk_parent_line);
					$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $object, $actionedit);    // Note that $action and $object may have been modified by some hooks
				}

				print '<script type="text/javascript">
						$(document).ready(function()
						{
							$("tr#row-' . $line->id .' input[name^=lineid]").after("<input type=\"hidden\" name=\"line-qty_' . $line->id. '\" id=\"line-qty_' . $line->id. '\" value=\"' . $line->qty . '\" />");
						});
						</script>';
				return;
			}

			global $form,$bc,$bcdd;
			global $object_rights, $disableedit, $disablemove, $disableremove;   // TODO We should not use global var for this !

			$object_rights = $object->getRights();

			print '<style>.tredited { background: none !important; } </style>';

			$text=''; $description=''; $type=0;

			// Show product and description
			$type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type);
			// Try to enhance type detection using date_start and date_end for free lines where type was not saved.
			if (! empty($line->date_start)) $type=1; // deprecated
			if (! empty($line->date_end)) $type=1; // deprecated

			$label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : ''));
			$placeholder=' placeholder="'.$langs->trans("Label").'"';

			$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU');

			@include(dol_buildpath('/dolitools/core/tpl/objectline_edit.tpl.php'));

			return; // important
		}

		return; // important
