From e395fd8096094046731d0950b138bbf473c655c2 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sun, 30 Nov 2014 15:24:39 +0100
Subject: [PATCH] Fix CRLF

---
 dev/optimize_images.sh                        | 26 +++++-
 htdocs/cashdesk/affContenu.php                |  8 +-
 htdocs/cashdesk/include/environnement.php     |  2 +-
 htdocs/cashdesk/validation_verif.php          | 80 +++++++++----------
 htdocs/commande/card.php                      |  2 +-
 .../modSyncSupplierWebServices.class.php      |  0
 htdocs/fourn/commande/card.php                |  2 +-
 htdocs/install/upgrade.php                    |  0
 htdocs/install/upgrade2.php                   |  0
 htdocs/product/stock/card.php                 |  6 +-
 test/phpunit/FunctionsLibTest.php             | 32 ++++----
 11 files changed, 91 insertions(+), 67 deletions(-)
 mode change 100755 => 100644 htdocs/core/modules/modSyncSupplierWebServices.class.php
 mode change 100755 => 100644 htdocs/install/upgrade.php
 mode change 100755 => 100644 htdocs/install/upgrade2.php

diff --git a/dev/optimize_images.sh b/dev/optimize_images.sh
index 616eec75757..1899d0221e1 100755
--- a/dev/optimize_images.sh
+++ b/dev/optimize_images.sh
@@ -37,7 +37,8 @@ optimize_image()
 	max_input_size=$(expr $max_input_size + $input_file_size)
 
 	if [ "${1##*.}" = "png" ]; then
-		optipng -o1 -clobber -quiet $1 -out $2.firstpass
+		#optipng -o1 -clobber -quiet $1 -out $2.firstpass
+		optipng -o1 -quiet $1 -out $2.firstpass
 		pngcrush -q -rem alla -reduce $2.firstpass $2 >/dev/null
 		rm -fr $2.firstpass
 	fi
@@ -67,6 +68,25 @@ get_max_file_length()
 
 main()
 {
+	test=`type pngcrush >/dev/null 2>&1`
+	result=$?
+	if [ "x$result" == "x1" ]; then
+		echo "Tool pngcrush not found" && exit 
+	fi
+	
+	test=`type optipng >/dev/null 2>&1`
+	result=$?
+	if [ "x$result" == "x1" ]; then
+		echo "Tool optipng not found" && exit 
+	fi
+
+	test=`type jpegtran >/dev/null 2>&1`
+	result=$?
+	if [ "x$result" == "x1" ]; then
+		echo "Tool jpegtran not found" && exit 
+	fi
+
+
 	# If $INPUT is empty, then we use current directory
 	if [[ "$INPUT" == "" ]]; then
 		INPUT=$(pwd)
@@ -81,6 +101,8 @@ main()
 		OUTPUT='/tmp/optimize'
 	fi
 
+	echo "Mode is $INPLACE (0=Images are replaced, 1=New images are stored into $OUTPUT)"
+	
 	# We create the output directory
 	mkdir -p $OUTPUT
 
@@ -96,6 +118,7 @@ main()
 
 	# Search of all jpg/jpeg/png in $INPUT
 	# We remove images from $OUTPUT if $OUTPUT is a subdirectory of $INPUT
+	echo "Scan $INPUT to find images"
 	IMAGES=$(find $INPUT -regextype posix-extended -regex '.*\.(jpg|jpeg|png)' | grep -v $OUTPUT)
 
 	if [ "$QUIET" == "0" ]; then
@@ -103,6 +126,7 @@ main()
 		echo
 	fi
 	for CURRENT_IMAGE in $IMAGES; do
+		echo "Process $CURRENT_IMAGE"
 		filename=$(basename $CURRENT_IMAGE)
 		if [ "$QUIET" == "0" ]; then
 			printf '%s ' "$filename"
diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php
index dd57a2fd988..6d8f5ca83ee 100644
--- a/htdocs/cashdesk/affContenu.php
+++ b/htdocs/cashdesk/affContenu.php
@@ -45,13 +45,13 @@ else
 
 
 
-$obj_facturation->calculTotaux();	// Redefine prix_total_ttc, prix_total_ht et montant_tva from $_SESSION['poscart']
+$obj_facturation->calculTotaux();	// Redefine prix_total_ttc, prix_total_ht et montant_tva from $_SESSION['poscart']
 
-$total_ttc = $obj_facturation->prixTotalTtc();
+$total_ttc = $obj_facturation->prixTotalTtc();
 
-/*var_dump($obj_facturation);
+/*var_dump($obj_facturation);
 var_dump($_SESSION['poscart']);
-var_dump($total_ttc);
+var_dump($total_ttc);
 exit;*/
 
 
diff --git a/htdocs/cashdesk/include/environnement.php b/htdocs/cashdesk/include/environnement.php
index 7411b998272..3e6a88f252a 100644
--- a/htdocs/cashdesk/include/environnement.php
+++ b/htdocs/cashdesk/include/environnement.php
@@ -32,7 +32,7 @@ $conf_db_base = $dolibarr_main_db_name;
 $conf_fksoc = (! empty($_SESSION["CASHDESK_ID_THIRDPARTY"]))?$_SESSION["CASHDESK_ID_THIRDPARTY"]:($conf->global->CASHDESK_ID_THIRDPARTY>0?$conf->global->CASHDESK_ID_THIRDPARTY:0);
 // Identifiant unique correspondant a l'entrepot a utiliser
 $conf_fkentrepot = (! empty($_SESSION["CASHDESK_ID_WAREHOUSE"]))?$_SESSION["CASHDESK_ID_WAREHOUSE"]:($conf->global->CASHDESK_ID_WAREHOUSE>0?$conf->global->CASHDESK_ID_WAREHOUSE:0);
-if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $conf_fkentrepot = 0;	// If option to disable stock decrease is on, we set warehouse id to 0.
+if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $conf_fkentrepot = 0;	// If option to disable stock decrease is on, we set warehouse id to 0.
 
 // Identifiant unique correspondant au compte caisse / liquide
 $conf_fkaccount_cash = (! empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]))?$_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]:($conf->global->CASHDESK_ID_BANKACCOUNT_CASH>0?$conf->global->CASHDESK_ID_BANKACCOUNT_CASH:0);
diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php
index fa943acda96..27ce3380dd4 100644
--- a/htdocs/cashdesk/validation_verif.php
+++ b/htdocs/cashdesk/validation_verif.php
@@ -226,25 +226,25 @@ switch ($action)
 				if ($warehouseidtodecrease > 0)
 				{
 					// Decrease
-					require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
-					$langs->load("agenda");
-					// Loop on each line
-					$cpt=count($invoice->lines);
-					for ($i = 0; $i < $cpt; $i++)
-					{
-						if ($invoice->lines[$i]->fk_product > 0)
-						{
-							$mouvP = new MouvementStock($db);
-							$mouvP->origin = &$invoice;
-							// We decrease stock for product
-							if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
-							else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
-							if ($result < 0) {
-								$error++;
-							}
-						}
+					require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
+					$langs->load("agenda");
+					// Loop on each line
+					$cpt=count($invoice->lines);
+					for ($i = 0; $i < $cpt; $i++)
+					{
+						if ($invoice->lines[$i]->fk_product > 0)
+						{
+							$mouvP = new MouvementStock($db);
+							$mouvP->origin = &$invoice;
+							// We decrease stock for product
+							if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+							else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+							if ($result < 0) {
+								$error++;
+							}
+						}
 					}
-				}
+				}
 			}
 			else
 			{
@@ -263,28 +263,28 @@ switch ($action)
 				
 				$resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0);
 
-				if ($warehouseidtodecrease > 0)
-				{
-					// Decrease
-					require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
-					$langs->load("agenda");
-					// Loop on each line
-					$cpt=count($invoice->lines);
-					for ($i = 0; $i < $cpt; $i++)
-					{
-						if ($invoice->lines[$i]->fk_product > 0)
-						{
-							$mouvP = new MouvementStock($db);
-							$mouvP->origin = &$invoice;
-							// We decrease stock for product
-							if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
-							else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
-							if ($result < 0) {
-								$error++;
-							}
-						}
-					}
-				}
+				if ($warehouseidtodecrease > 0)
+				{
+					// Decrease
+					require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
+					$langs->load("agenda");
+					// Loop on each line
+					$cpt=count($invoice->lines);
+					for ($i = 0; $i < $cpt; $i++)
+					{
+						if ($invoice->lines[$i]->fk_product > 0)
+						{
+							$mouvP = new MouvementStock($db);
+							$mouvP->origin = &$invoice;
+							// We decrease stock for product
+							if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+							else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+							if ($result < 0) {
+								$error++;
+							}
+						}
+					}
+				}
 
 				$id = $invoice->id;
 
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 79a6797245a..e31de409403 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1998,7 +1998,7 @@ if ($action == 'create' && $user->rights->commande->creer) {
 			$rowspan ++;
 
         // Bank Account
-		if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled))
+		if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled))
 		{	
 	        print '<tr><td class="nowrap">';
         	print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
diff --git a/htdocs/core/modules/modSyncSupplierWebServices.class.php b/htdocs/core/modules/modSyncSupplierWebServices.class.php
old mode 100755
new mode 100644
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 3c7269c3e6f..753f91fbdda 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -1544,7 +1544,7 @@ elseif (! empty($object->id))
 	print '</td></tr>';
 
     // Bank Account
-	if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled))
+	if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled))
 	{
 	    print '<tr><td class="nowrap">';
 	    print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php
old mode 100755
new mode 100644
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
old mode 100755
new mode 100644
diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php
index 4c8ac74c463..2a7f64ee475 100644
--- a/htdocs/product/stock/card.php
+++ b/htdocs/product/stock/card.php
@@ -82,7 +82,7 @@ if ($action == 'add' && $user->rights->stock->creer)
 			
 			if (! empty($backtopage))
 			{
-				header("Location: ".$backtopage);
+				header("Location: ".$backtopage);
 				exit;
 			}
 			else
@@ -93,7 +93,7 @@ if ($action == 'add' && $user->rights->stock->creer)
 		}
 		else
 		{
-			$action = 'create';
+			$action = 'create';
 			setEventMessage($object->error, 'errors');
 		}
 	}
@@ -179,7 +179,7 @@ if ($action == 'create')
 	print "<form action=\"card.php\" method=\"post\">\n";
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<input type="hidden" name="action" value="add">';
-	print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
+	print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
 	
 	dol_fiche_head();
 	
diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php
index af5f3393672..0ace96c6719 100755
--- a/test/phpunit/FunctionsLibTest.php
+++ b/test/phpunit/FunctionsLibTest.php
@@ -824,32 +824,32 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
 		$this->assertEquals(dol_nl2br($string, 1, 1), "a<br />a");
 	}
 
-	/**
-	 * testDolPrice2Num
-	 *
-	 * @return boolean
-	 */
-	public function testDolPrice2Num()
+	/**
+	 * testDolPrice2Num
+	 *
+	 * @return boolean
+	 */
+	public function testDolPrice2Num()
 	{
-		$this->assertEquals(1000, price2num('1 000.0'));
-		$this->assertEquals(1000, price2num('1 000','MT'));
-		$this->assertEquals(1000, price2num('1 000','MU'));
+		$this->assertEquals(1000, price2num('1 000.0'));
+		$this->assertEquals(1000, price2num('1 000','MT'));
+		$this->assertEquals(1000, price2num('1 000','MU'));
 		
 		$this->assertEquals(1000.123456, price2num('1 000.123456'));
 
 		// Round down
-		$this->assertEquals(1000.12, price2num('1 000.123452','MT'));
-		$this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU");
+		$this->assertEquals(1000.12, price2num('1 000.123452','MT'));
+		$this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU");
 
-		// Round up
-		$this->assertEquals(1000.13, price2num('1 000.125456','MT'));
-		$this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU");
+		// Round up
+		$this->assertEquals(1000.13, price2num('1 000.125456','MT'));
+		$this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU");
 
 		// Text can't be converted
 		$this->assertEquals('12.4$',price2num('12.4$'));
-		$this->assertEquals('12r.4$',price2num('12r.4$'));
+		$this->assertEquals('12r.4$',price2num('12r.4$'));
 		
-		return true;		
+		return true;		
 	}
 
 }
-- 
GitLab