Browse Source

FIX Fix and move dolGetFirstLine function into main
FIX Hang on ->client not defined

Laurent Destailleur 9 years ago
parent
commit
bfc5be1aad

+ 2 - 2
htdocs/core/class/html.form.class.php

@@ -2060,7 +2060,7 @@ class Form
 
         if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT))
         {
-        	if (!empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED))
+        	if (!empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
 			{
 				print '<input type="hidden" id="idprod" name="idprod" value="0" />';
 			}
@@ -2071,7 +2071,7 @@ class Form
         }
         else
         {
-            if (!empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED))
+            if (!empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
 			{
 				print '<input type="hidden" id="idprod" name="idprod" value="0" />';
 				print '<script type="text/javascript">$("#'.$htmlname.'").change(function() { $("#idprod").val($(this).val());});</script>';

+ 25 - 1
htdocs/core/lib/functions.lib.php

@@ -4285,6 +4285,29 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
 }
 
 
+/**
+ * Return first line of text. Cut will depends if content is HTML or not.
+ *
+ * @param 	string	$text		Input text
+ * @return	string				Output text
+ * @see dol_nboflines_bis
+ */
+function dolGetFirstLineOfText($text)
+{
+	if (dol_textishtml($text))
+	{
+		$firstline=preg_replace('/<br[^>]*>.*$/s','',$text);		// The s pattern modifier means the . can match newline characters
+		$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline);	// The s pattern modifier means the . can match newline characters
+		
+	}
+	else
+	{
+    	$firstline=preg_replace('/[\n\r].*/','',$text);
+	}
+    return $firstline.((strlen($firstline) != strlen($text))?'...':'');
+}
+
+
 /**
  * Replace CRLF in string with a HTML BR tag
  *
@@ -4292,6 +4315,7 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
  * @param	int     $nl2brmode			0=Adding br before \n, 1=Replacing \n by br
  * @param   bool	$forxml             false=Use <br>, true=Use <br />
  * @return	string						String encoded
+ * @see dol_nboflines, dolGetFirstLineOfText
  */
 function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
 {
@@ -4429,7 +4453,7 @@ function dol_string_is_good_iso($s)
  *	@param	string	$s			String to check
  * 	@param	int     $maxchar	Not yet used
  *	@return	int					Number of lines
- *  @see	dol_nboflines_bis
+ *  @see	dol_nboflines_bis, dolGetFirstLineOfText
  */
 function dol_nboflines($s,$maxchar=0)
 {

+ 0 - 20
htdocs/core/lib/functions2.lib.php

@@ -30,26 +30,6 @@
 // Enable this line to trace path when function is called.
 //print xdebug_print_function_stack('Functions2.lib was called');exit;
 
-/**
- * Return first line of text. Cut will depends if content is HTML or not.
- *
- * @param 	string	$text		Input text
- * @return	string				Output text
- * @see dol_nboflines_bis
- */
-function dolGetFirstLineOfText($text)
-{
-	if (dol_textishtml($text))
-	{
-		$firstline=preg_replace('/<br[^>]*>.*$/s','',$text);		// The s pattern modifier means the . can match newline characters
-	}
-	else
-	{
-    	$firstline=preg_replace('/[\n\r].*/','',$text);
-	}
-    return $firstline.((strlen($firstline) != strlen($text))?'...':'');
-}
-
 /**
  * Same function than javascript unescape() function but in PHP.
  *

+ 1 - 1
htdocs/core/lib/pdf.lib.php

@@ -358,7 +358,7 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali
 	} elseif ($thirdparty instanceof Contact) {
 		$socname = $thirdparty->socname;
 	} else {
-		throw new InvalidArgumentException();
+		throw new InvalidArgumentException('Parameter 1=$thirdparty is not a Societe nor Contact');
 	}
 
 	return $outputlangs->convToOutputCharset($socname);

+ 3 - 3
htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php

@@ -615,12 +615,12 @@ class pdf_soleil extends ModelePDFFicheinter
 			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
 				$thirdparty = $object->contact;
 			} else {
-				$thirdparty = $object->client;
+				$thirdparty = $object->thirdparty;
 			}
 
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
+			$carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
 
-			$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, (isset($object->contact)?$object->contact:''), $usecontact, 'target',$object);
+			$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target',$object);
 
 			// Show recipient
 			$widthrecbox=100;

+ 3 - 2
htdocs/fichinter/list.php

@@ -227,10 +227,11 @@ if ($result)
 		$companystatic->client=$objp->client;
 		print $companystatic->getNomUrl(1,'',44);
 		print '</td>';
-        print '<td>'.dol_htmlentitiesbr(dol_trunc($objp->description,20)).'</td>';
+        print '<td>'.dol_trunc(dolGetFirstLineOfText($objp->description),48).'</td>';
 		if (empty($conf->global->FICHINTER_DISABLE_DETAILS))
 		{
-			print '<td>'.dol_htmlentitiesbr(dol_trunc($objp->descriptiondetail,20)).'</td>';
+			//print '<td>'.dol_trunc(dol_escape_htmltag(dolGetFirstLineOfText($objp->descriptiondetail)),48).'</td>';
+			print '<td>'.dolGetFirstLineOfText($objp->descriptiondetail).'</td>';
 			print '<td align="center">'.dol_print_date($db->jdate($objp->dp),'dayhour')."</td>\n";
 			print '<td align="right">'.convertSecondToTime($objp->duree).'</td>';
 		}

+ 1 - 1
htdocs/fourn/commande/card.php

@@ -346,7 +346,7 @@ if (empty($reshook))
 	    {
 	    	$productsupplier = new ProductFournisseur($db);
 
-	    	if (empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED))
+	    	if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
 	    	{
 				$idprod=0;
 				if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99;	// Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)

+ 1 - 1
htdocs/langs/en_US/interventions.lang

@@ -52,7 +52,7 @@ ArcticNumRefModelDesc1=Generic number model
 ArcticNumRefModelError=Failed to activate
 PacificNumRefModelDesc1=Return numero with format %syymm-nnnn where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
 PacificNumRefModelError=An intervention card starting with $syymm already exists and is not compatible with this model of sequence. Remove it or rename it to activate this module.
-PrintProductsOnFichinter=Print products on intervention card
+PrintProductsOnFichinter=Print also lines of type "product" (not only services) on intervention card
 PrintProductsOnFichinterDetails=interventions generated from orders
 InterventionStatistics=Statistics of interventions
 NbOfinterventions=Nb of intervention cards