Forráskód Böngészése

psr2 Squiz.WhiteSpace.ScopeClosingBrace.Indent

Frédéric FRANCE 6 éve
szülő
commit
80a12fcd1c
100 módosított fájl, 2053 hozzáadás és 2077 törlés
  1. 43 46
      dev/initdata/generate-order.php
  2. 2 0
      dev/setup/codesniffer/ruleset.xml
  3. 2 2
      htdocs/accountancy/admin/accountmodel.php
  4. 2 2
      htdocs/accountancy/admin/categories_list.php
  5. 2 2
      htdocs/accountancy/admin/journals_list.php
  6. 1 1
      htdocs/accountancy/bookkeeping/list.php
  7. 2 2
      htdocs/accountancy/expensereport/index.php
  8. 3 3
      htdocs/accountancy/supplier/index.php
  9. 8 8
      htdocs/adherents/class/subscription.class.php
  10. 8 7
      htdocs/adherents/stats/geo.php
  11. 7 7
      htdocs/adherents/subscription/card.php
  12. 8 8
      htdocs/adherents/subscription/list.php
  13. 5 5
      htdocs/admin/dict.php
  14. 5 5
      htdocs/admin/mailman.php
  15. 4 4
      htdocs/admin/menus/edit.php
  16. 24 50
      htdocs/admin/receiptprinter.php
  17. 10 11
      htdocs/admin/socialnetworks.php
  18. 2 2
      htdocs/admin/website.php
  19. 6 7
      htdocs/api/admin/explorer.php
  20. 2 2
      htdocs/blockedlog/class/blockedlog.class.php
  21. 30 30
      htdocs/categories/class/api_categories.class.php
  22. 23 23
      htdocs/comm/action/class/api_agendaevents.class.php
  23. 26 26
      htdocs/comm/mailing/class/advtargetemailing.class.php
  24. 39 44
      htdocs/comm/mailing/index.php
  25. 74 75
      htdocs/comm/propal/class/api_proposals.class.php
  26. 7 7
      htdocs/comm/propal/class/propal.class.php
  27. 15 15
      htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
  28. 4 4
      htdocs/compta/bank/treso.php
  29. 66 66
      htdocs/compta/compta-files.php
  30. 12 12
      htdocs/compta/facture/fiche-rec.php
  31. 5 5
      htdocs/compta/facture/list.php
  32. 10 12
      htdocs/compta/paiement/cheque/index.php
  33. 2 2
      htdocs/compta/paiement/class/paiement.class.php
  34. 79 79
      htdocs/compta/prelevement/bons.php
  35. 4 4
      htdocs/compta/prelevement/create.php
  36. 40 41
      htdocs/compta/stats/cabyuser.php
  37. 29 30
      htdocs/compta/stats/casoc.php
  38. 2 1
      htdocs/contact/class/contact.class.php
  39. 5 5
      htdocs/contrat/class/api_contracts.class.php
  40. 1 2
      htdocs/core/class/commonobject.class.php
  41. 37 37
      htdocs/core/class/html.form.class.php
  42. 1 1
      htdocs/core/class/html.formfile.class.php
  43. 1 1
      htdocs/core/class/menubase.class.php
  44. 16 20
      htdocs/core/db/sqlite3.class.php
  45. 13 8
      htdocs/core/lib/functions.lib.php
  46. 3 3
      htdocs/core/lib/pdf.lib.php
  47. 15 16
      htdocs/core/modules/commande/doc/pdf_einstein.modules.php
  48. 20 21
      htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
  49. 7 6
      htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
  50. 23 23
      htdocs/core/modules/facture/doc/pdf_crabe.modules.php
  51. 2 2
      htdocs/core/modules/facture/doc/pdf_sponge.modules.php
  52. 5 5
      htdocs/core/modules/fichinter/mod_arctic.php
  53. 9 8
      htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
  54. 128 128
      htdocs/core/modules/project/doc/pdf_beluga.modules.php
  55. 4 4
      htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
  56. 7 6
      htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
  57. 5 5
      htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php
  58. 4 4
      htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php
  59. 4 1
      htdocs/core/tpl/contacts.tpl.php
  60. 13 9
      htdocs/core/tpl/login.tpl.php
  61. 31 27
      htdocs/core/tpl/objectline_edit.tpl.php
  62. 15 9
      htdocs/core/tpl/objectline_view.tpl.php
  63. 1 2
      htdocs/datapolicy/class/actions_datapolicy.class.php
  64. 1 1
      htdocs/datapolicy/class/datapolicy.class.php
  65. 3 3
      htdocs/don/tpl/linkedobjectblock.tpl.php
  66. 83 83
      htdocs/expedition/class/api_shipments.class.php
  67. 27 27
      htdocs/expensereport/class/api_expensereports.class.php
  68. 11 12
      htdocs/expensereport/payment/payment.php
  69. 1 1
      htdocs/exports/export.php
  70. 17 18
      htdocs/fichinter/class/api_interventions.class.php
  71. 51 49
      htdocs/fourn/class/fournisseur.commande.class.php
  72. 2 2
      htdocs/fourn/class/fournisseur.commande.dispatch.class.php
  73. 1 1
      htdocs/fourn/class/fournisseur.facture.class.php
  74. 151 151
      htdocs/fourn/commande/card.php
  75. 20 20
      htdocs/fourn/commande/dispatch.php
  76. 6 6
      htdocs/index.php
  77. 15 15
      htdocs/install/check.php
  78. 3 4
      htdocs/modulebuilder/admin/setup.php
  79. 264 264
      htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php
  80. 25 25
      htdocs/modulebuilder/template/myobject_card.php
  81. 34 35
      htdocs/multicurrency/class/multicurrency.class.php
  82. 1 1
      htdocs/product/class/product.class.php
  83. 15 15
      htdocs/product/dynamic_price/class/price_expression.class.php
  84. 13 13
      htdocs/product/dynamic_price/class/price_global_variable.class.php
  85. 13 13
      htdocs/product/dynamic_price/class/price_global_variable_updater.class.php
  86. 29 29
      htdocs/product/stock/class/api_stockmovements.class.php
  87. 29 29
      htdocs/product/stock/class/api_warehouses.class.php
  88. 9 10
      htdocs/product/stock/movement_list.php
  89. 1 1
      htdocs/projet/card.php
  90. 110 112
      htdocs/projet/class/api_projects.class.php
  91. 76 78
      htdocs/projet/class/api_tasks.class.php
  92. 1 1
      htdocs/projet/class/project.class.php
  93. 4 1
      htdocs/societe/canvas/company/tpl/card_edit.tpl.php
  94. 4 1
      htdocs/societe/canvas/individual/tpl/card_edit.tpl.php
  95. 3 4
      htdocs/societe/class/societe.class.php
  96. 16 17
      htdocs/societe/list.php
  97. 17 18
      htdocs/takepos/takepos.php
  98. 2 2
      htdocs/ticket/class/api_tickets.class.php
  99. 6 6
      htdocs/user/card.php
  100. 6 6
      htdocs/user/clicktodial.php

+ 43 - 46
dev/initdata/generate-order.php

@@ -20,8 +20,8 @@
  */
 
 /**
- * 	    \file       dev/initdata/generate-order.php
- * 		\brief      Script example to inject random orders (for load tests)
+ *      \file       dev/initdata/generate-order.php
+ *      \brief      Script example to inject random orders (for load tests)
  */
 
 // Test si mode batch
@@ -113,13 +113,13 @@ $societesid = array();
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe where client in (1, 3)";
 $resql=$db->query($sql);
 if ($resql) {
-	$num_thirdparties = $db->num_rows($resql);
-	$i = 0;
-	while ($i < $num_thirdparties) {
-		$i++;
-	    $row = $db->fetch_row($resql);
-		$societesid[$i] = $row[0];
-	}
+    $num_thirdparties = $db->num_rows($resql);
+    $i = 0;
+    while ($i < $num_thirdparties) {
+        $i++;
+        $row = $db->fetch_row($resql);
+        $societesid[$i] = $row[0];
+    }
 }
 else { print "err"; }
 
@@ -127,35 +127,32 @@ $commandesid = array();
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande";
 $resql=$db->query($sql);
 if ($resql) {
-	$num = $db->num_rows($resql);
-	$i = 0;
-	while ($i < $num) {
-		$i++;
-	    $row = $db->fetch_row($resql);
-		$commandesid[$i] = $row[0];
-	}
+    $num = $db->num_rows($resql);
+    $i = 0;
+    while ($i < $num) {
+        $i++;
+        $row = $db->fetch_row($resql);
+        $commandesid[$i] = $row[0];
+    }
 }
 else { print "err"; }
 
 $prodids = array();
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
 $resql = $db->query($sql);
-if ($resql)
-{
-  $num_prods = $db->num_rows($resql);
-  $i = 0;
-  while ($i < $num_prods)
-    {
-      $i++;
+if ($resql) {
+    $num_prods = $db->num_rows($resql);
+    $i = 0;
+    while ($i < $num_prods) {
+        $i++;
 
-      $row = $db->fetch_row($resql);
-      $prodids[$i] = $row[0];
+        $row = $db->fetch_row($resql);
+        $prodids[$i] = $row[0];
     }
 }
 
 
 
-
 print "Build ".GEN_NUMBER_COMMANDE." orders\n";
 for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
 {
@@ -173,18 +170,18 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
     $object->cond_reglement_id = mt_rand(0, 2);
     $object->more_reglement_id = mt_rand(0, 7);
     $object->availability_id = mt_rand(0, 1);
-    
+
     $listofuserid=array(12,13,16);
-    
+
     $fuser = new User($db);
     $fuser->fetch($listofuserid[mt_rand(0,2)]);
     $fuser->getRights();
-    
+
     $db->begin();
 
     $result=$object->create($fuser);
-	if ($result >= 0)
-	{
+    if ($result >= 0)
+    {
         $nbp = mt_rand(2, 5);
         $xnbp = 0;
         while ($xnbp < $nbp)
@@ -200,23 +197,23 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
             $xnbp++;
         }
 
-	    $result=$object->valid($fuser);
-		if ($result > 0)
-		{
+        $result=$object->valid($fuser);
+        if ($result > 0)
+        {
             $db->commit();
             print " OK with ref ".$object->ref."\n";
-		}
-		else
-		{
+        }
+        else
+        {
             print " KO\n";
-		    $db->rollback();
-		    dol_print_error($db,$object->error);
-		}
-	}
-	else
-	{
+            $db->rollback();
+            dol_print_error($db,$object->error);
+        }
+    }
+    else
+    {
         print " KO\n";
-	    $db->rollback();
-	    dol_print_error($db,$object->error);
-	}
+        $db->rollback();
+        dol_print_error($db,$object->error);
+    }
 }

+ 2 - 0
dev/setup/codesniffer/ruleset.xml

@@ -173,6 +173,8 @@
 	<!-- Disabled as this does not support tab -->
 	<!-- <rule ref="Generic.WhiteSpace.ScopeIndent" /> -->
 
+    <rule ref="Squiz.WhiteSpace.ScopeClosingBrace.Indent" />
+
     <!-- There MUST NOT be trailing whitespace at the end of non-blank lines. -->
     <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
         <properties>

+ 2 - 2
htdocs/accountancy/admin/accountmodel.php

@@ -538,8 +538,8 @@ if ($id)
 				elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
 				else print $valuetoshow;
 				print '</td>';
-			 }
-			 if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
+			}
+			if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
 		}
 
 		print '<td>';

+ 2 - 2
htdocs/accountancy/admin/categories_list.php

@@ -495,8 +495,8 @@ if ($id)
             	elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
             	else print $valuetoshow;
                 print '</td>';
-             }
-             if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
+            }
+            if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
         }
 
         print '<td>';

+ 2 - 2
htdocs/accountancy/admin/journals_list.php

@@ -444,8 +444,8 @@ if ($id)
 				elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
 				else print $valuetoshow;
 				print '</td>';
-			 }
-			 if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
+			}
+			if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
 		}
 
 		print '<td>';

+ 1 - 1
htdocs/accountancy/bookkeeping/list.php

@@ -280,7 +280,7 @@ if (! empty($search_credit)) {
 if (! empty($search_lettering_code)) {
 	$filter['t.lettering_code'] = $search_lettering_code;
 	$param .= '&search_lettering_code=' . urlencode($search_lettering_code);
- }
+}
 
 
 if ($action == 'delbookkeeping') {

+ 2 - 2
htdocs/accountancy/expensereport/index.php

@@ -326,11 +326,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
     dol_syslog('htdocs/accountancy/expensereport/index.php');
     $resql = $db->query($sql);
     if ($resql) {
-    	$num = $db->num_rows($resql);
+        $num = $db->num_rows($resql);
 
     	while ($row = $db->fetch_row($resql)) {
     		print '<tr><td>' . $row[0] . '</td>';
-    			for($i = 1; $i <= 12; $i ++) {
+            for($i = 1; $i <= 12; $i ++) {
     			print '<td class="right">' . price($row[$i]) . '</td>';
     		}
     		print '<td class="right"><b>' . price($row[13]) . '</b></td>';

+ 3 - 3
htdocs/accountancy/supplier/index.php

@@ -328,15 +328,15 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
 
     	while ($row = $db->fetch_row($resql)) {
     		print '<tr><td>' . $row[0] . '</td>';
-    			for($i = 1; $i <= 12; $i ++) {
+            for($i = 1; $i <= 12; $i ++) {
     			print '<td class="right">' . price($row[$i]) . '</td>';
     		}
     		print '<td class="right"><b>' . price($row[13]) . '</b></td>';
     		print '</tr>';
     	}
-    	$db->free($resql);
+        $db->free($resql);
     } else {
-    	print $db->lasterror(); // Show last sql error
+        print $db->lasterror(); // Show last sql error
     }
     print "</table>\n";
     print '</div>';

+ 8 - 8
htdocs/adherents/class/subscription.class.php

@@ -105,14 +105,14 @@ class Subscription extends CommonObject
 
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)";
 
-		if ($this->fk_type == null) {
-require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
-$member=new Adherent($this->db);
-$result=$member->fetch($this->fk_adherent);
-$type=$member->typeid;
-} else {
-$type=$this->fk_type;
-}
+        if ($this->fk_type == null) {
+            require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
+            $member=new Adherent($this->db);
+            $result=$member->fetch($this->fk_adherent);
+            $type=$member->typeid;
+        } else {
+            $type=$this->fk_type;
+        }
 		$sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',";
 		$sql.= " '".$this->db->idate($this->dateh)."',";
 		$sql.= " '".$this->db->idate($this->datef)."',";

+ 8 - 7
htdocs/adherents/stats/geo.php

@@ -157,15 +157,16 @@ if ($mode)
 							'lastdate'=>$db->jdate($obj->lastdate)
                 );
             }
-	    if ($mode == 'memberbyregion') //+
+            if ($mode == 'memberbyregion') //+
             {
-                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-				            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
-							'nb'=>$obj->nb,
-							'lastdate'=>$db->jdate($obj->lastdate)
+                $data[]=array(
+                    'label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                    'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+				    'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
+					'nb'=>$obj->nb,
+					'lastdate'=>$db->jdate($obj->lastdate)
                 );
-	}
+	        }
             if ($mode == 'memberbystate')
             {
                 $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),

+ 7 - 7
htdocs/adherents/subscription/card.php

@@ -308,17 +308,17 @@ if ($rowid && $action != 'edit')
     print '<div class="underbanner clearboth"></div>';
 
     print '<table class="border" width="100%">';
-    
+
     // Type
     print '<tr>';
     print '<td class="titlefield">'.$langs->trans("Type").'</td>';
     print '<td class="valeur">';
-    if (  ! empty($object->fk_type) ) {
-      $adht->fetch($object->fk_type);
-    print $adht->getNomUrl(1);
-      } else {
-    print $langs->trans("NoType");
-      }
+    if (! empty($object->fk_type) ) {
+        $adht->fetch($object->fk_type);
+        print $adht->getNomUrl(1);
+    } else {
+        print $langs->trans("NoType");
+    }
     print '</td></tr>';
 
     // Member

+ 8 - 8
htdocs/adherents/subscription/list.php

@@ -459,8 +459,8 @@ while ($i < min($num, $limit))
 	$adherent->statut=$obj->statut;
 	$adherent->login=$obj->login;
 	$adherent->photo=$obj->photo;
-  
-  $adht = new AdherentType($db);
+
+    $adht = new AdherentType($db);
 	$adht->fetch($obj->fk_type);
 
 	print '<tr class="oddeven">';
@@ -471,13 +471,13 @@ while ($i < min($num, $limit))
 		print '<td>'.$subscription->getNomUrl(1).'</td>';
 		if (! $i) $totalarray['nbfield']++;
 	}
-  // Type
-  if (! empty($arrayfields['d.fk_type']['checked']))
+    // Type
+    if (! empty($arrayfields['d.fk_type']['checked']))
 	{
-    print '<td>';
-    if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1);
-    print '</td>';
-    if (! $i) $totalarray['nbfield']++;
+        print '<td>';
+        if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1);
+        print '</td>';
+        if (! $i) $totalarray['nbfield']++;
 	}
 
 	// Lastname

+ 5 - 5
htdocs/admin/dict.php

@@ -1124,12 +1124,12 @@ if ($id)
             if ($valuetoshow != '')
             {
                 print '<td'.($class?' class="'.$class.'"':'').'>';
-            	if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
-            	elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
-            	else print $valuetoshow;
+                if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
+                elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
+                else print $valuetoshow;
                 print '</td>';
-             }
-             if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
+            }
+            if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
         }
 
         if ($id == 4) print '<td></td>';

+ 5 - 5
htdocs/admin/mailman.php

@@ -127,7 +127,7 @@ if (($action == 'testsubscribe' || $action == 'testunsubscribe') && ! empty($con
         if ($action == 'testunsubscribe')
         {
             $result=$mailmanspip->del_to_mailman($object);
-        			if ($result < 0)
+            if ($result < 0)
 			{
 				$error++;
 				setEventMessages($mailmanspip->error,$mailmanspip->errors,'errors');
@@ -160,7 +160,7 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN))
     print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 
     dol_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user');
-    
+
     //$link=img_picto($langs->trans("Active"),'tick').' ';
     $link='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_MAILMAN">';
     //$link.=$langs->trans("Disable");
@@ -200,10 +200,10 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN))
     </script>';
 
     form_constantes($constantes,2);
-    
+
     print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
     print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL% <br>';
-    
+
     dol_fiche_end();
 
     print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
@@ -213,7 +213,7 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN))
 else
 {
     dol_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user');
-    
+
     $link='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_MAILMAN">';
     //$link.=img_$langs->trans("Activate")
     $link.=img_picto($langs->trans("Disabled"),'switch_off');

+ 4 - 4
htdocs/admin/menus/edit.php

@@ -219,12 +219,12 @@ if ($action == 'add')
         	$menu->fk_menu=GETPOST('menuId','int');
         }
         else
-       {
-	       	if (GETPOST('type','alpha') == 'top') $menu->fk_menu=0;
-	       	else $menu->fk_menu=-1;
+        {
+           	if (GETPOST('type','alpha') == 'top') $menu->fk_menu=0;
+           	else $menu->fk_menu=-1;
         	$menu->fk_mainmenu=$mainmenu;
         	$menu->fk_leftmenu=$leftmenu;
-       }
+        }
 
         $result=$menu->create($user);
         if ($result > 0)

+ 24 - 50
htdocs/admin/receiptprinter.php

@@ -68,8 +68,7 @@ if (!function_exists('gzdecode')) {
  * Action
  */
 
-if ($action == 'addprinter' && $user->admin)
-{
+if ($action == 'addprinter' && $user->admin) {
     $error=0;
     $db->begin();
     if (empty($printername)) {
@@ -81,8 +80,7 @@ if ($action == 'addprinter' && $user->admin)
         setEventMessages($langs->trans("PrinterParameterEmpty"), null, 'warnings');
     }
 
-    if (! $error)
-    {
+    if (! $error) {
         $result= $printer->AddPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter);
         if ($result > 0) $error++;
 
@@ -100,8 +98,7 @@ if ($action == 'addprinter' && $user->admin)
     $action = '';
 }
 
-if ($action == 'deleteprinter' && $user->admin)
-{
+if ($action == 'deleteprinter' && $user->admin) {
     $error=0;
     $db->begin();
     if (empty($printerid)) {
@@ -109,8 +106,7 @@ if ($action == 'deleteprinter' && $user->admin)
         setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
     }
 
-    if (! $error)
-    {
+    if (! $error) {
         $result= $printer->DeletePrinter($printerid);
         if ($result > 0) $error++;
 
@@ -128,8 +124,7 @@ if ($action == 'deleteprinter' && $user->admin)
     $action = '';
 }
 
-if ($action == 'updateprinter' && $user->admin)
-{
+if ($action == 'updateprinter' && $user->admin) {
     $error=0;
     $db->begin();
     if (empty($printerid)) {
@@ -137,18 +132,14 @@ if ($action == 'updateprinter' && $user->admin)
         setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
     }
 
-    if (! $error)
-    {
+    if (! $error) {
         $result= $printer->UpdatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid);
         if ($result > 0) $error++;
 
-        if (! $error)
-        {
+        if (! $error) {
             $db->commit();
             setEventMessages($langs->trans("PrinterUpdated",$printername), null);
-        }
-        else
-        {
+        } else {
             $db->rollback();
             dol_print_error($db);
         }
@@ -156,24 +147,19 @@ if ($action == 'updateprinter' && $user->admin)
     $action = '';
 }
 
-if ($action == 'testprinter' && $user->admin)
-{
+if ($action == 'testprinter' && $user->admin) {
     $error=0;
     if (empty($printerid)) {
         $error++;
         setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
     }
 
-    if (! $error)
-    {
+    if (! $error) {
         // test
         $ret = $printer->SendTestToPrinter($printerid);
-        if ($ret == 0)
-        {
+        if ($ret == 0) {
             setEventMessages($langs->trans("TestSentToPrinter", $printername), null);
-        }
-        else
-        {
+        } else {
             setEventMessages($printer->error, $printer->errors, 'errors');
         }
     }
@@ -181,8 +167,7 @@ if ($action == 'testprinter' && $user->admin)
 }
 
 
-if ($action == 'updatetemplate' && $user->admin)
-{
+if ($action == 'updatetemplate' && $user->admin) {
     $error=0;
     $db->begin();
     if (empty($templateid)) {
@@ -190,18 +175,14 @@ if ($action == 'updatetemplate' && $user->admin)
         setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors');
     }
 
-    if (! $error)
-    {
+    if (! $error) {
         $result= $printer->UpdateTemplate($templatename, $template, $templateid);
         if ($result > 0) $error++;
 
-        if (! $error)
-        {
+        if (! $error) {
             $db->commit();
             setEventMessages($langs->trans("TemplateUpdated",$templatename), null);
-        }
-        else
-        {
+        } else {
             $db->rollback();
             dol_print_error($db);
         }
@@ -223,8 +204,7 @@ print load_fiche_titre($langs->trans("ReceiptPrinterSetup"),$linkback,'title_set
 
 $head = receiptprinteradmin_prepare_head($mode);
 
-if ($mode == 'config' && $user->admin)
-{
+if ($mode == 'config' && $user->admin) {
     print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=config" autocomplete="off">';
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
     if ($action!='editprinter') {
@@ -253,11 +233,9 @@ if ($mode == 'config' && $user->admin)
     if ($ret > 0) {
         setEventMessages($printer->error, $printer->errors, 'errors');
     } else {
-        for ($line=0; $line < $nbofprinters; $line++)
-        {
+        for ($line=0; $line < $nbofprinters; $line++) {
             print '<tr class="oddeven">';
-            if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid)
-            {
+            if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid) {
                 print '<input type="hidden" name="printerid" value="'.$printer->listprinters[$line]['rowid'].'">';
                 print '<td><input size="50" type="text" name="printername" value="'.$printer->listprinters[$line]['name'].'"></td>';
                 $ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']);
@@ -269,7 +247,7 @@ if ($mode == 'config' && $user->admin)
                 print '<td></td>';
                 print '<td></td>';
                 print '</tr>';
-             } else {
+            } else {
                 print '<td>'.$printer->listprinters[$line]['name'].'</td>';
                 print '<td>'.$langs->trans($printer->listprinters[$line]['fk_type_name']).'</td>';
                 print '<td>'.$langs->trans($printer->listprinters[$line]['fk_profile_name']).'</td>';
@@ -291,10 +269,8 @@ if ($mode == 'config' && $user->admin)
         }
     }
 
-    if ($action!='editprinter')
-    {
-        if ($nbofprinters > 0)
-        {
+    if ($action!='editprinter') {
+        if ($nbofprinters > 0) {
             print '<tr class="liste_titre">';
             print '<th>'.$langs->trans("Name").'</th>';
             print '<th>'.$langs->trans("Type").'</th>';
@@ -357,8 +333,7 @@ if ($mode == 'config' && $user->admin)
     dol_fiche_end();
 }
 
-if ($mode == 'template' && $user->admin)
-{
+if ($mode == 'template' && $user->admin) {
     print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=template" autocomplete="off">';
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
     if ($action!='edittemplate') {
@@ -429,8 +404,7 @@ if ($mode == 'template' && $user->admin)
     print '<th>'.$langs->trans("Description").'</th>';
     print "</tr>\n";
     $max = count($printer->tags);
-    for ($tag=0; $tag < $max; $tag++)
-    {
+    for ($tag=0; $tag < $max; $tag++) {
         print '<tr class="oddeven">';
         print '<td>&lt;'.$printer->tags[$tag].'&gt;</td><td>'.$langs->trans(strtoupper($printer->tags[$tag])).'</td>';
         print '</tr>';

+ 10 - 11
htdocs/admin/socialnetworks.php

@@ -98,17 +98,16 @@ print '<br>';
 
 $arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook');
 
-foreach($arrayofsocialnetworks as $snkey => $snlabel)
-{
-	$consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey);
-  if ($conf->use_javascript_ajax) {
-    $link = ajax_constantonoff($consttocheck);
-} else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck);
-}
-  
-	print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'<br><br>';
+foreach($arrayofsocialnetworks as $snkey => $snlabel) {
+    $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey);
+    if ($conf->use_javascript_ajax) {
+        $link = ajax_constantonoff($consttocheck);
+    } else {
+        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+        $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck);
+    }
+
+    print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'<br><br>';
 }
 
 

+ 2 - 2
htdocs/admin/website.php

@@ -478,8 +478,8 @@ if ($id)
            		}
             	else print $valuetoshow;
                 print '</td>';
-             }
-             if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
+            }
+            if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
         }
 
         print '<td colspan="4">';

+ 6 - 7
htdocs/api/admin/explorer.php

@@ -89,15 +89,14 @@ foreach ($modulesdir as $dir)
 					$obj = 'facture';
 				}
                 if ($module == 'ficheinter') {
-                                       $obj = 'fichinter';
-                                       $part = 'fichinter';
-                                       $module='fichinter';
-                               }
+                    $obj = 'fichinter';
+                    $part = 'fichinter';
+                    $module='fichinter';
+                }
 
-		if (empty($conf->$module->enabled)) $enabled=false;
+                if (empty($conf->$module->enabled)) $enabled=false;
 
-                if ($enabled)
-                {
+                if ($enabled) {
                     /*
                      * If exists, load the API class for enable module
                      *

+ 2 - 2
htdocs/blockedlog/class/blockedlog.class.php

@@ -921,8 +921,8 @@ class BlockedLog
 	 *	@param int	$beforeid		ID of a record
 	 *  @return	string				Hash of previous record (if beforeid is defined) or hash of last record (if beforeid is 0)
 	 */
-	 public function getPreviousHash($withlock = 0, $beforeid = 0)
-	 {
+	public function getPreviousHash($withlock = 0, $beforeid = 0)
+	{
 		global $conf;
 
 		$previoussignature='';

+ 30 - 30
htdocs/categories/class/api_categories.class.php

@@ -55,8 +55,8 @@ class Categories extends DolibarrApi
      */
     function __construct()
     {
-		global $db, $conf;
-		$this->db = $db;
+        global $db, $conf;
+        $this->db = $db;
         $this->category = new Categorie($this->db);
     }
 
@@ -67,25 +67,25 @@ class Categories extends DolibarrApi
      *
      * @param 	int 	$id ID of category
      * @return 	array|mixed data without useless information
-	 *
+     *
      * @throws 	RestException
      */
     function get($id)
     {
-		if(! DolibarrApiAccess::$user->rights->categorie->lire) {
-			throw new RestException(401);
-		}
+        if(! DolibarrApiAccess::$user->rights->categorie->lire) {
+            throw new RestException(401);
+        }
 
         $result = $this->category->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'category not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
-		return $this->_cleanObjectDatas($this->category);
+        return $this->_cleanObjectDatas($this->category);
     }
 
     /**
@@ -101,7 +101,7 @@ class Categories extends DolibarrApi
      * @param string    $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
      * @return array                Array of category objects
      *
-	 * @throws RestException
+     * @throws RestException
      */
     function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '')
     {
@@ -109,9 +109,9 @@ class Categories extends DolibarrApi
 
         $obj_ret = array();
 
-         if(! DolibarrApiAccess::$user->rights->categorie->lire) {
-			throw new RestException(401);
-		}
+        if(! DolibarrApiAccess::$user->rights->categorie->lire) {
+            throw new RestException(401);
+        }
 
         $sql = "SELECT t.rowid";
         $sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
@@ -127,7 +127,7 @@ class Categories extends DolibarrApi
             {
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
             }
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+            $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
             $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
         }
 
@@ -145,7 +145,7 @@ class Categories extends DolibarrApi
         $result = $db->query($sql);
         if ($result)
         {
-        	$i=0;
+            $i=0;
             $num = $db->num_rows($result);
             $min = min($num, ($limit <= 0 ? $num : $limit));
             while ($i < $min)
@@ -164,7 +164,7 @@ class Categories extends DolibarrApi
         if( ! count($obj_ret)) {
             throw new RestException(404, 'No category found');
         }
-		return $obj_ret;
+        return $obj_ret;
     }
 
     /**
@@ -176,8 +176,8 @@ class Categories extends DolibarrApi
     function post($request_data = null)
     {
         if(! DolibarrApiAccess::$user->rights->categorie->creer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
 
         // Check mandatory fields
         $result = $this->_validate($request_data);
@@ -201,17 +201,17 @@ class Categories extends DolibarrApi
     function put($id, $request_data = null)
     {
         if(! DolibarrApiAccess::$user->rights->categorie->creer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
 
         $result = $this->category->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'category not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
         foreach($request_data as $field => $value) {
             if ($field == 'id') continue;
@@ -224,7 +224,7 @@ class Categories extends DolibarrApi
         }
         else
         {
-        	throw new RestException(500, $this->category->error);
+            throw new RestException(500, $this->category->error);
         }
     }
 
@@ -237,16 +237,16 @@ class Categories extends DolibarrApi
     function delete($id)
     {
         if(! DolibarrApiAccess::$user->rights->categorie->supprimer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
         $result = $this->category->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'category not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
         if (! $this->category->delete(DolibarrApiAccess::$user)) {
             throw new RestException(401,'error when delete category');

+ 23 - 23
htdocs/comm/action/class/api_agendaevents.class.php

@@ -58,7 +58,7 @@ class AgendaEvents extends DolibarrApi
      *
      * @param       int         $id         ID of Agenda Events
      * @return 	    array|mixed             Data without useless information
-	 *
+     *
      * @throws 	RestException
      */
     function get($id)
@@ -83,7 +83,7 @@ class AgendaEvents extends DolibarrApi
 		$result = $this->actioncomm->fetch_optionals();
 
         $this->actioncomm->fetchObjectLinked();
-		return $this->_cleanObjectDatas($this->actioncomm);
+        return $this->_cleanObjectDatas($this->actioncomm);
     }
 
     /**
@@ -116,7 +116,7 @@ class AgendaEvents extends DolibarrApi
         // If the internal user must only see his customers, force searching by him
         $search_sale = 0;
         if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
-		if (empty($conf->societe->enabled)) $search_sale = 0;	// If module thirdparty not enabled, sale representative is something that does not exists
+        if (empty($conf->societe->enabled)) $search_sale = 0;	// If module thirdparty not enabled, sale representative is something that does not exists
 
         $sql = "SELECT t.id as rowid";
         if (! empty($conf->societe->enabled))
@@ -160,7 +160,7 @@ class AgendaEvents extends DolibarrApi
 
         if ($result)
         {
-        	$i=0;
+            $i=0;
             $num = $db->num_rows($result);
             $min = min($num, ($limit <= 0 ? $num : $limit));
             while ($i < $min)
@@ -179,7 +179,7 @@ class AgendaEvents extends DolibarrApi
         if ( ! count($obj_ret)) {
             throw new RestException(404, 'No Agenda Event found');
         }
-		return $obj_ret;
+        return $obj_ret;
     }
 
     /**
@@ -190,12 +190,12 @@ class AgendaEvents extends DolibarrApi
      */
     function post($request_data = null)
     {
-      if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) {
-			  throw new RestException(401, "Insuffisant rights to create your Agenda Event");
-		  }
-      if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
-		      throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
-		  }
+        if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) {
+            throw new RestException(401, "Insuffisant rights to create your Agenda Event");
+        }
+        if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
+            throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
+        }
 
         // Check mandatory fields
         $result = $this->_validate($request_data);
@@ -229,21 +229,21 @@ class AgendaEvents extends DolibarrApi
     /*
     function put($id, $request_data = null)
     {
-      if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) {
-			  throw new RestException(401, "Insuffisant rights to create your Agenda Event");
-		  }
-      if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
-		      throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
-		  }
+        if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) {
+            throw new RestException(401, "Insuffisant rights to create your Agenda Event");
+        }
+        if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
+            throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
+        }
 
         $result = $this->actioncomm->fetch($id);
         if ( ! $result ) {
             throw new RestException(404, 'actioncomm not found');
         }
 
-		if ( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if ( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
         foreach($request_data as $field => $value) {
             if ($field == 'id') continue;
             $this->actioncomm->$field = $value;
@@ -266,13 +266,13 @@ class AgendaEvents extends DolibarrApi
     function delete($id)
     {
         if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) {
-			  throw new RestException(401, "Insuffisant rights to delete your Agenda Event");
-		}
+            throw new RestException(401, "Insuffisant rights to delete your Agenda Event");
+        }
 
 		$result = $this->actioncomm->fetch($id);
 
         if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) {
-		      throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
+            throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
 		}
 
 		if( ! $result ) {

+ 26 - 26
htdocs/comm/mailing/class/advtargetemailing.class.php

@@ -875,32 +875,32 @@ class AdvanceTargetingMailing extends CommonObject
 
 						foreach($extralabels as $key=>$val) {
 
-							if (($extrafields->attribute_type[$key] == 'varchar') ||
-									($extrafields->attribute_type[$key] == 'text')) {
-										if (!empty($arrayquery['options_'.$key])) {
-											$sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
-										}
-									} elseif (($extrafields->attribute_type[$key] == 'int') ||
-											($extrafields->attribute_type[$key] == 'double')) {
-												if (!empty($arrayquery['options_'.$key.'_max'])) {
-													$sqlwhere[]= " (tse.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND tse.".$key." <= ".$arrayquery['options_'.$key.'_min'].")";
-												}
-									} elseif (($extrafields->attribute_type[$key] == 'date') ||
-											($extrafields->attribute_type[$key] == 'datetime')) {
-												if (!empty($arrayquery['options_'.$key.'_end_dt'])){
-													$sqlwhere[]= " (tse.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND tse.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')";
-												}
-											}elseif ($extrafields->attribute_type[$key] == 'boolean') {
-												if ($arrayquery['options_'.$key]!=''){
-													$sqlwhere[]= " (tse.".$key." = ".$arrayquery['options_'.$key].")";
-												}
-											}else{
-												if (is_array($arrayquery['options_'.$key])) {
-													$sqlwhere[]= " (tse.".$key." IN ('".implode("','",$arrayquery['options_'.$key])."'))";
-												} elseif (!empty($arrayquery['options_'.$key])) {
-													$sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
-												}
-											}
+                            if (($extrafields->attribute_type[$key] == 'varchar')
+                                || ($extrafields->attribute_type[$key] == 'text')) {
+								if (!empty($arrayquery['options_'.$key])) {
+									$sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
+								}
+							} elseif (($extrafields->attribute_type[$key] == 'int') ||
+								($extrafields->attribute_type[$key] == 'double')) {
+								if (!empty($arrayquery['options_'.$key.'_max'])) {
+									$sqlwhere[]= " (tse.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND tse.".$key." <= ".$arrayquery['options_'.$key.'_min'].")";
+								}
+							} elseif (($extrafields->attribute_type[$key] == 'date') ||
+								($extrafields->attribute_type[$key] == 'datetime')) {
+								if (!empty($arrayquery['options_'.$key.'_end_dt'])){
+									$sqlwhere[]= " (tse.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND tse.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')";
+								}
+							} elseif ($extrafields->attribute_type[$key] == 'boolean') {
+								if ($arrayquery['options_'.$key]!=''){
+									$sqlwhere[]= " (tse.".$key." = ".$arrayquery['options_'.$key].")";
+								}
+							} else {
+								if (is_array($arrayquery['options_'.$key])) {
+									$sqlwhere[]= " (tse.".$key." IN ('".implode("','",$arrayquery['options_'.$key])."'))";
+								} elseif (!empty($arrayquery['options_'.$key])) {
+									$sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
+								}
+							}
 						}
 					}
 				}

+ 39 - 44
htdocs/comm/mailing/index.php

@@ -109,20 +109,18 @@ if (is_resource($handle))
                         print '<tr class="oddeven">';
 
                         $result=$db->query($sql);
-                        if ($result)
-                        {
-                          $num = $db->num_rows($result);
+                        if ($result) {
+                            $num = $db->num_rows($result);
 
-                          $i = 0;
+                            $i = 0;
 
-                          while ($i < $num )
-                            {
-                              $obj = $db->fetch_object($result);
-                              print '<td>'.img_object('',$mailmodule->picto).' '.$obj->label.'</td><td class="right">'.$obj->nb.'<td>';
-                              $i++;
+                            while ($i < $num ) {
+                                $obj = $db->fetch_object($result);
+                                print '<td>'.img_object('',$mailmodule->picto).' '.$obj->label.'</td><td class="right">'.$obj->nb.'<td>';
+                                $i++;
                             }
 
-                          $db->free($result);
+                            $db->free($result);
                         }
                         else
                         {
@@ -154,45 +152,42 @@ $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m";
 $sql.= " ORDER BY m.date_creat DESC";
 $sql.= " LIMIT ".$limit;
 $result=$db->query($sql);
-if ($result)
-{
-  print '<table class="noborder" width="100%">';
-  print '<tr class="liste_titre">';
-  print '<td colspan="2">'.$langs->trans("LastMailings",$limit).'</td>';
-  print '<td align="center">'.$langs->trans("DateCreation").'</td>';
-  print '<td align="center">'.$langs->trans("NbOfEMails").'</td>';
-  print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td></tr>';
-
-  $num = $db->num_rows($result);
-  if ($num > 0)
-  {
-      $i = 0;
-
-    while ($i < $num )
-	{
-	  $obj = $db->fetch_object($result);
-
-	  print '<tr class="oddeven">';
-	  print '<td class="nowrap"><a href="card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.'</a></td>';
-	  print '<td>'.dol_trunc($obj->titre,38).'</td>';
-	  print '<td align="center">'.dol_print_date($db->jdate($obj->date_creat),'day').'</td>';
-	  print '<td align="center">'.($obj->nbemail?$obj->nbemail:"0").'</td>';
-	  $mailstatic=new Mailing($db);
-	  print '<td class="right">'.$mailstatic->LibStatut($obj->statut,5).'</td>';
-      print '</tr>';
-	  $i++;
-	}
+if ($result) {
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre">';
+    print '<td colspan="2">'.$langs->trans("LastMailings",$limit).'</td>';
+    print '<td align="center">'.$langs->trans("DateCreation").'</td>';
+    print '<td align="center">'.$langs->trans("NbOfEMails").'</td>';
+    print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td></tr>';
+
+    $num = $db->num_rows($result);
+    if ($num > 0) {
+        $i = 0;
+
+        while ($i < $num ) {
+            $obj = $db->fetch_object($result);
+
+            print '<tr class="oddeven">';
+            print '<td class="nowrap"><a href="card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.'</a></td>';
+            print '<td>'.dol_trunc($obj->titre,38).'</td>';
+            print '<td align="center">'.dol_print_date($db->jdate($obj->date_creat),'day').'</td>';
+            print '<td align="center">'.($obj->nbemail?$obj->nbemail:"0").'</td>';
+            $mailstatic=new Mailing($db);
+            print '<td class="right">'.$mailstatic->LibStatut($obj->statut,5).'</td>';
+            print '</tr>';
+            $i++;
+        }
     }
-  else
+    else
     {
-     print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
+        print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
     }
-  print "</table><br>";
-  $db->free($result);
+    print "</table><br>";
+    $db->free($result);
 }
 else
 {
-  dol_print_error($db);
+    dol_print_error($db);
 }
 
 
@@ -207,7 +202,7 @@ if ($langs->file_exists("html/spam.html",0)) {
     print '</div>';
 
     print '<br>';
- }
+}
 
 // End of page
 llxFooter();

+ 74 - 75
htdocs/comm/propal/class/api_proposals.class.php

@@ -184,11 +184,11 @@ class Proposals extends DolibarrApi
 	 */
 	function post($request_data = null)
 	{
-	  if(! DolibarrApiAccess::$user->rights->propal->creer) {
-			  throw new RestException(401, "Insuffisant rights");
-		  }
-		// Check mandatory fields
-		$result = $this->_validate($request_data);
+        if(! DolibarrApiAccess::$user->rights->propal->creer) {
+            throw new RestException(401, "Insuffisant rights");
+        }
+        // Check mandatory fields
+        $result = $this->_validate($request_data);
 
 		foreach($request_data as $field => $value) {
 			$this->propal->$field = $value;
@@ -218,25 +218,25 @@ class Proposals extends DolibarrApi
 	 */
     function getLines($id)
     {
-	  if(! DolibarrApiAccess::$user->rights->propal->lire) {
-		  	throw new RestException(401);
-		  }
-
-	  $result = $this->propal->fetch($id);
-	  if( ! $result ) {
-		 throw new RestException(404, 'Commercial Proposal not found');
-	  }
-
-		  if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-	  }
-	  $this->propal->getLinesArray();
-	  $result = array();
-	  foreach ($this->propal->lines as $line) {
-		array_push($result,$this->_cleanObjectDatas($line));
-	  }
-	  return $result;
-	}
+        if(! DolibarrApiAccess::$user->rights->propal->lire) {
+            throw new RestException(401);
+        }
+
+        $result = $this->propal->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Commercial Proposal not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $this->propal->getLinesArray();
+        $result = array();
+        foreach ($this->propal->lines as $line) {
+            array_push($result,$this->_cleanObjectDatas($line));
+        }
+        return $result;
+    }
 
 	/**
 	 * Add a line to given commercial proposal
@@ -266,7 +266,7 @@ class Proposals extends DolibarrApi
 
 		$request_data = (object) $request_data;
 
-      	$updateRes = $this->propal->addline(
+        $updateRes = $this->propal->addline(
                         $request_data->desc,
                         $request_data->subprice,
                         $request_data->qty,
@@ -293,15 +293,14 @@ class Proposals extends DolibarrApi
                         $request_data->origin_id,
                         $request_data->multicurrency_subprice,
                         $request_data->fk_remise_except
-      );
+        );
 
-      if ($updateRes > 0) {
-        return $updateRes;
-	  }
-		else {
-			throw new RestException(400, $this->propal->error);
-		}
-	}
+        if ($updateRes > 0) {
+            return $updateRes;
+        } else {
+            throw new RestException(400, $this->propal->error);
+        }
+    }
 
 	/**
 	 * Update a line of given commercial proposal
@@ -360,14 +359,14 @@ class Proposals extends DolibarrApi
 						isset($request_data->array_options)?$request_data->array_options:$propalline->array_options,
 						isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit,
 	  					isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice
-	  );
-
-	  if ($updateRes > 0) {
-		$result = $this->get($id);
-		unset($result->line);
-		return $this->_cleanObjectDatas($result);
-	  }
-	  return false;
+	    );
+
+	    if ($updateRes > 0) {
+		    $result = $this->get($id);
+		    unset($result->line);
+		    return $this->_cleanObjectDatas($result);
+	    }
+	    return false;
 	}
 
 	/**
@@ -386,7 +385,7 @@ class Proposals extends DolibarrApi
     function deleteLine($id, $lineid)
     {
 		if(! DolibarrApiAccess::$user->rights->propal->creer) {
-		  	throw new RestException(401);
+            throw new RestException(401);
 		}
 
 		$result = $this->propal->fetch($id);
@@ -417,12 +416,12 @@ class Proposals extends DolibarrApi
 	 * @param array $request_data   Datas
 	 *
 	 * @return int
-	 */
+     */
     function put($id, $request_data = null)
     {
-	  if(! DolibarrApiAccess::$user->rights->propal->creer) {
-		  	throw new RestException(401);
-		  }
+        if(! DolibarrApiAccess::$user->rights->propal->creer) {
+            throw new RestException(401);
+        }
 
 		$result = $this->propal->fetch($id);
 		if( ! $result ) {
@@ -654,35 +653,35 @@ class Proposals extends DolibarrApi
      */
     function setinvoiced($id)
     {
-            if(! DolibarrApiAccess::$user->rights->propal->creer) {
-                    throw new RestException(401);
-            }
-            $result = $this->propal->fetch($id);
-            if( ! $result ) {
-                    throw new RestException(404, 'Commercial Proposal not found');
-            }
-
-            if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
-                    throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-            }
-
-            $result = $this->propal->classifyBilled(DolibarrApiAccess::$user );
-            if ($result < 0) {
-                    throw new RestException(500, 'Error : '.$this->propal->error);
-            }
-
-            $result = $this->propal->fetch($id);
-            if( ! $result ) {
-            	throw new RestException(404, 'Proposal not found');
-            }
-
-            if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
-            	throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-            }
-
-            $this->propal->fetchObjectLinked();
-
-            return $this->_cleanObjectDatas($this->propal);
+        if(! DolibarrApiAccess::$user->rights->propal->creer) {
+            throw new RestException(401);
+        }
+        $result = $this->propal->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Commercial Proposal not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+
+        $result = $this->propal->classifyBilled(DolibarrApiAccess::$user );
+        if ($result < 0) {
+            throw new RestException(500, 'Error : '.$this->propal->error);
+        }
+
+        $result = $this->propal->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Proposal not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+
+        $this->propal->fetchObjectLinked();
+
+        return $this->_cleanObjectDatas($this->propal);
     }
 
 

+ 7 - 7
htdocs/comm/propal/class/propal.class.php

@@ -1063,13 +1063,13 @@ class Propal extends CommonObject
 					for ($i=0;$i<$num;$i++)
 					{
                         if (! is_object($this->lines[$i]))	// If this->lines is not array of objects, coming from REST API
-                            {   // Convert into object this->lines[$i].
-                                $line = (object) $this->lines[$i];
-                            }
-                            else
-                            {
-                                    $line = $this->lines[$i];
-                            }
+                        {   // Convert into object this->lines[$i].
+                            $line = (object) $this->lines[$i];
+                        }
+                        else
+                        {
+                            $line = $this->lines[$i];
+                        }
 						// Reset fk_parent_line for line that are not child lines or special product
 						if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
 							$fk_parent_line = 0;

+ 15 - 15
htdocs/comm/propal/tpl/linkedobjectblock.tpl.php

@@ -24,10 +24,9 @@
  */
 
 // Protection to avoid direct call of template
-if (empty($conf) || ! is_object($conf))
-{
-	print "Error, template page can't be called as URL";
-	exit;
+if (empty($conf) || ! is_object($conf)) {
+    print "Error, template page can't be called as URL";
+    exit;
 }
 
 ?>
@@ -54,21 +53,22 @@ foreach($linkedObjectBlock as $key => $objectlink)
 ?>
     <tr class="<?php echo $trclass; ?>"  data-element="<?php echo $objectlink->element; ?>"  data-id="<?php echo $objectlink->id; ?>" >
         <td class="linkedcol-element" ><?php echo $langs->trans("Proposal"); ?>
-        <?php if(!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)
-            {
-                $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id;
-                print '<a class="objectlinked_importbtn" href="'.$url.'&amp;action=selectlines"  data-element="'.$objectlink->element.'"  data-id="'.$objectlink->id.'"  > <i class="fa fa-indent"></i> </a>';
-            }
-        ?>
+    <?php
+    if(!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)
+    {
+        $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id;
+        print '<a class="objectlinked_importbtn" href="'.$url.'&amp;action=selectlines"  data-element="'.$objectlink->element.'"  data-id="'.$objectlink->id.'"  > <i class="fa fa-indent"></i> </a>';
+    }
+    ?>
         </td>
         <td class="linkedcol-name" ><?php echo $objectlink->getNomUrl(1); ?></td>
     	<td class="linkedcol-ref" ><?php echo $objectlink->ref_client; ?></td>
     	<td class="linkedcol-date" align="center"><?php echo dol_print_date($objectlink->date,'day'); ?></td>
     	<td class="linkedcol-amount" align="right"><?php
-    		if ($user->rights->propale->lire) {
-    			$total = $total + $objectlink->total_ht;
-    			echo price($objectlink->total_ht);
-    		} ?></td>
+    if ($user->rights->propale->lire) {
+    	$total = $total + $objectlink->total_ht;
+    	echo price($objectlink->total_ht);
+    } ?></td>
     	<td class="linkedcol-statut" align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
     	<td class="linkedcol-action" align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
     </tr>
@@ -86,7 +86,7 @@ if (count($linkedObjectBlock) > 1)
     	<td class="right"></td>
     	<td class="right"></td>
     </tr>
-    <?php
+<?php
 }
 ?>
 

+ 4 - 4
htdocs/compta/bank/treso.php

@@ -3,7 +3,7 @@
  * Copyright (C) 2008-2009 Laurent Destailleur (Eldy)  <eldy@users.sourceforge.net>
  * Copyright (C) 2008      Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  * Copyright (C) 2015	   Marcos García			   <marcosgdf@gmail.com
- * Copyright (C) 2016      Frédéric France              <frederic.france@free.fr>
+ * Copyright (C) 2016       Frédéric France             <frederic.france@free.fr>
  *
  * 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
@@ -183,13 +183,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
 
 	foreach($sqls as $sql){
 		$resql = $db->query($sql);
-		if($resql){
-			while($sqlobj = $db->fetch_object($resql)){
+		if ($resql) {
+			while ($sqlobj = $db->fetch_object($resql)) {
 				$tab_sqlobj[] = $sqlobj;
 				$tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr);
 			}
 			$db->free($resql);
-			}else{
+		} else {
 			$error++;
 		}
 	}

+ 66 - 66
htdocs/compta/compta-files.php

@@ -112,16 +112,16 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){
 
     if ($resd)
     {
-         $numd = $db->num_rows($resd);
+        $numd = $db->num_rows($resd);
 
-         $tmpinvoice=new Facture($db);
-         $tmpinvoicesupplier=new FactureFournisseur($db);
-         $tmpdonation=new Don($db);
+        $tmpinvoice=new Facture($db);
+        $tmpinvoicesupplier=new FactureFournisseur($db);
+        $tmpdonation=new Don($db);
 
-         $upload_dir ='';
-         $i=0;
-         while($i<$numd)
-         {
+        $upload_dir ='';
+        $i=0;
+        while($i<$numd)
+        {
             $objd = $db->fetch_object($resd);
 
             switch($objd->item)
@@ -197,14 +197,14 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){
                 }
             }
             $i++;
-         }
-     }
-     else
-     {
-         dol_print_error($db);
-     }
-
-     $db->free($resd);
+        }
+    }
+    else
+    {
+        dol_print_error($db);
+    }
+
+    $db->free($resd);
 }
 
 /*
@@ -315,57 +315,57 @@ if (!empty($date_start) && !empty($date_stop))
     if ($result)
     {
         $TData = dol_sort_array($filesarray, 'date', 'ASC');
-            if(empty($TData)) {
-                            print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td></tr>';
-            } else {
-                            // Sort array by date ASC to calucalte balance
-
-                            $totalDebit = 0;
-                            $totalCredit = 0;
-                            // Balance calculation
-                            $balance = 0;
-                            foreach($TData as &$data1) {
-                                    if($data1['item']!='Invoice'&& $data1['item']!='Donation' ){
-                                         $data1['amount']=-$data1['amount'];
-                                    }
-                                    if ($data1['amount']>0){
-                                   }else{
-                                   }
-                                   $balance += $data1['amount'];
-                                    $data1['balance'] = $balance;
-                            }
-                    // Display array
-                    foreach($TData as $data) {
-                            $html_class = '';
-                            //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
-                            //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
-                            print '<tr class="oddeven '.$html_class.'">';
-                            print "<td align=\"center\">";
-                            print dol_print_date($data['date'],'day');
-                            print "</td>\n";
-                            print '<td aling="left">'.$data['item'].'</td>';
-                            print '<td aling="left">'.$data['ref'].'</td>';
-
-                            // File link
-                            print '<td><a href='.DOL_URL_ROOT.'/'.$data['link'].">".$data['name']."</a></td>\n";
-
-                            print '<td aling="left">'.$data['paid'].'</td>';
-                            print '<td align="right">'.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."</td>\n";
-                            $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0;
-                            print '<td align="right">'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."</td>\n";
-                            $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']);
-                            // Balance
-                            print '<td align="right">'.price($data['balance'])."</td>\n";
-                            print "</tr>\n";
-                    }
-                    print '<tr class="liste_total">';
-                    print '<td colspan="5">&nbsp;</td>';
-                    print '<td align="right">'.price($totalDebit).'</td>';
-                    print '<td align="right">'.price($totalCredit).'</td>';
-                    print '<td align="right">'.price(price2num($totalDebit - $totalCredit, 'MT')).'</td>';
-                    print "</tr>\n";
-                    }
+        if(empty($TData)) {
+            print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td></tr>';
+        } else {
+            // Sort array by date ASC to calucalte balance
+
+            $totalDebit = 0;
+            $totalCredit = 0;
+            // Balance calculation
+            $balance = 0;
+            foreach($TData as &$data1) {
+                if($data1['item']!='Invoice'&& $data1['item']!='Donation' ){
+                    $data1['amount']=-$data1['amount'];
+                }
+                if ($data1['amount']>0){
+                }else{
+                }
+                $balance += $data1['amount'];
+                $data1['balance'] = $balance;
             }
+            // Display array
+            foreach($TData as $data) {
+                $html_class = '';
+                //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
+                //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
+                print '<tr class="oddeven '.$html_class.'">';
+                print "<td align=\"center\">";
+                print dol_print_date($data['date'],'day');
+                print "</td>\n";
+                print '<td aling="left">'.$data['item'].'</td>';
+                print '<td aling="left">'.$data['ref'].'</td>';
+
+                // File link
+                print '<td><a href='.DOL_URL_ROOT.'/'.$data['link'].">".$data['name']."</a></td>\n";
+
+                print '<td aling="left">'.$data['paid'].'</td>';
+                print '<td align="right">'.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."</td>\n";
+                $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0;
+                print '<td align="right">'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."</td>\n";
+                $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']);
+                // Balance
+                print '<td align="right">'.price($data['balance'])."</td>\n";
+                print "</tr>\n";
+            }
+            print '<tr class="liste_total">';
+            print '<td colspan="5">&nbsp;</td>';
+            print '<td align="right">'.price($totalDebit).'</td>';
+            print '<td align="right">'.price($totalCredit).'</td>';
+            print '<td align="right">'.price(price2num($totalDebit - $totalCredit, 'MT')).'</td>';
+            print "</tr>\n";
+        }
+    }
     print "</table>";
     print '</div>';
 }

+ 12 - 12
htdocs/compta/facture/fiche-rec.php

@@ -837,12 +837,12 @@ if (empty($reshook))
 			$type = GETPOST('type');
 			$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
 
-				// Check parameters
-				if (GETPOST('type') < 0) {
-					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
-					$error ++;
-				}
+			// Check parameters
+			if (GETPOST('type') < 0) {
+				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
+				$error ++;
 			}
+		}
 		if ($qty < 0) {
 			$langs->load("errors");
 			setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
@@ -1481,13 +1481,13 @@ else
 		}
 		else
 		{
-				if ($object->frequency > 0)
-				{
-					print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
-				}
-				else
-				{
-					print $langs->trans("NotARecurringInvoiceTemplate");
+			if ($object->frequency > 0)
+			{
+				print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
+			}
+			else
+			{
+				print $langs->trans("NotARecurringInvoiceTemplate");
 			}
 		}
 		print '</td></tr>';

+ 5 - 5
htdocs/compta/facture/list.php

@@ -582,12 +582,12 @@ if ($resql)
 	}
 	if ($user->rights->facture->supprimer) {
 		if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) {
-        		$arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft");
+        	$arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft");
 		}
-        	elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) {	// mass deletion never possible on invoices on such situation
-            		$arrayofmassactions['predelete'] = $langs->trans("Delete");
-        	}
-    	}
+        elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) {	// mass deletion never possible on invoices on such situation
+            $arrayofmassactions['predelete'] = $langs->trans("Delete");
+        }
+    }
 	if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
 	$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
 

+ 10 - 12
htdocs/compta/paiement/cheque/index.php

@@ -66,22 +66,20 @@ print '<tr class="liste_titre">';
 print '<th colspan="2">'.$langs->trans("BankChecks")."</th>\n";
 print "</tr>\n";
 
-if ($resql)
-{
-  if ($row = $db->fetch_row($resql) )
-    {
-      $num = $row[0];
+if ($resql) {
+    if ($row = $db->fetch_row($resql) ) {
+        $num = $row[0];
     }
-  print '<tr class="oddeven">';
-  print '<td>'.$langs->trans("BankChecksToReceipt").'</td>';
-  print '<td align="right">';
-  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?leftmenu=customers_bills_checks&action=new">'.$num.'</a>';
-  print '</td></tr>';
-  print "</table>\n";
+    print '<tr class="oddeven">';
+    print '<td>'.$langs->trans("BankChecksToReceipt").'</td>';
+    print '<td align="right">';
+    print '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?leftmenu=customers_bills_checks&action=new">'.$num.'</a>';
+    print '</td></tr>';
+    print "</table>\n";
 }
 else
 {
-  dol_print_error($db);
+    dol_print_error($db);
 }
 
 

+ 2 - 2
htdocs/compta/paiement/class/paiement.class.php

@@ -551,8 +551,8 @@ class Paiement extends CommonObject
 			{
 			    $this->db->rollback();
 			    return -1;
-			 }
-		    // End call triggers
+            }
+            // End call triggers
 		}
 
 		// Delete payment (into paiement_facture and paiement)

+ 79 - 79
htdocs/compta/prelevement/bons.php

@@ -88,8 +88,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
     $nbtotalofrecords = $db->num_rows($result);
     if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
     {
-    	$page = 0;
-    	$offset = 0;
+        $page = 0;
+        $offset = 0;
     }
 }
 
@@ -98,89 +98,89 @@ $sql.= $db->plimit($limit + 1,$offset);
 $result = $db->query($sql);
 if ($result)
 {
-  $num = $db->num_rows($result);
-  $i = 0;
-
-  $urladd= "&amp;statut=".$statut;
-
-  $selectedfields='';
-
-  $newcardbutton='';
-  if ($user->rights->prelevement->bons->creer)
-  {
-  	$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/compta/prelevement/create.php"><span class="valignmiddle">'.$langs->trans('NewStandingOrder').'</span>';
-  	$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
-  	$newcardbutton.= '</a>';
-  }
-
-  // Lines of title fields
-  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
-  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
-  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
-  print '<input type="hidden" name="action" value="list">';
-  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
-  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
-  print '<input type="hidden" name="page" value="'.$page.'">';
-  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
-
-  print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit);
-
-  $moreforfilter='';
-
-  print '<div class="div-table-responsive">';
-  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
-
-  print '<tr class="liste_titre">';
-  print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'. dol_escape_htmltag($search_ref).'"></td>';
-  print '<td class="liste_titre">&nbsp;</td>';
-  print '<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'. dol_escape_htmltag($search_amount).'"></td>';
-  print '<td class="liste_titre">&nbsp;</td>';
-  print '<td class="liste_titre" align="right">';
-  $searchpicto=$form->showFilterButtons();
-  print $searchpicto;
-  print '</td>';
-  print '</tr>';
-
-  print '<tr class="liste_titre">';
-  print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder);
-  print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder);
-  print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder);
-  print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder);
-  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
-  print "</tr>\n";
-
-  while ($i < min($num,$limit))
-  {
-      $obj = $db->fetch_object($result);
-
-      print '<tr class="oddeven"><td>';
-
-      print '<a href="card.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
-
-      print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
-
-      print '<td align="right">'.price($obj->amount)."</td>\n";
-
-      print '<td align="right">';
-      print $bon->LibStatut($obj->statut, 3);
-      print '</td>';
-
-      print '<td align="right"></td>'."\n";
-
-      print "</tr>\n";
-      $i++;
+    $num = $db->num_rows($result);
+    $i = 0;
+
+    $urladd= "&amp;statut=".$statut;
+
+    $selectedfields='';
+
+    $newcardbutton='';
+    if ($user->rights->prelevement->bons->creer)
+    {
+        $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/compta/prelevement/create.php"><span class="valignmiddle">'.$langs->trans('NewStandingOrder').'</span>';
+        $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
+        $newcardbutton.= '</a>';
+    }
+
+    // Lines of title fields
+    print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
+    if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
+    print '<input type="hidden" name="action" value="list">';
+    print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
+    print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
+    print '<input type="hidden" name="page" value="'.$page.'">';
+    print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
+
+    print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit);
+
+    $moreforfilter='';
+
+    print '<div class="div-table-responsive">';
+    print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
+
+    print '<tr class="liste_titre">';
+    print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'. dol_escape_htmltag($search_ref).'"></td>';
+    print '<td class="liste_titre">&nbsp;</td>';
+    print '<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'. dol_escape_htmltag($search_amount).'"></td>';
+    print '<td class="liste_titre">&nbsp;</td>';
+    print '<td class="liste_titre" align="right">';
+    $searchpicto=$form->showFilterButtons();
+    print $searchpicto;
+    print '</td>';
+    print '</tr>';
+
+    print '<tr class="liste_titre">';
+    print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder);
+    print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder);
+    print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder);
+    print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder);
+    print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
+    print "</tr>\n";
+
+    while ($i < min($num,$limit))
+    {
+        $obj = $db->fetch_object($result);
+
+        print '<tr class="oddeven"><td>';
+
+        print '<a href="card.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
+
+        print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
+
+        print '<td align="right">'.price($obj->amount)."</td>\n";
+
+        print '<td align="right">';
+        print $bon->LibStatut($obj->statut, 3);
+        print '</td>';
+
+        print '<td align="right"></td>'."\n";
+
+        print "</tr>\n";
+        $i++;
     }
-  print "</table>";
-  print '</div>';
+    print "</table>";
+    print '</div>';
 
-  print '</form>';
+    print '</form>';
 
-  $db->free($result);
+    $db->free($result);
 }
 else
 {
-  dol_print_error($db);
+    dol_print_error($db);
 }
 
 // End of page

+ 4 - 4
htdocs/compta/prelevement/create.php

@@ -162,9 +162,9 @@ if ($nb) {
         } else {
             print '<a class="butAction"  type="submit" href="create.php?action=create&format=ALL">' . $langs->trans("CreateAll") . "</a>\n";
 		}
-		}
-		else
-		{
+	}
+	else
+	{
 		if ($mysoc->isInEEC())
 		{
 			print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateForSepaFRST")."</a>\n";
@@ -178,7 +178,7 @@ if ($nb) {
 }
 else
 {
-	print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")."</a>\n";
+    print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")."</a>\n";
 }
 
 print "</div>\n";

+ 40 - 41
htdocs/compta/stats/cabyuser.php

@@ -57,8 +57,7 @@ $date_startday = GETPOST("date_startday");
 $date_endyear = GETPOST("date_endyear");
 $date_endmonth = GETPOST("date_endmonth");
 $date_endday = GETPOST("date_endday");
-if (empty($year))
-{
+if (empty($year)) {
 	$year_current = strftime("%Y",dol_now());
 	$month_current = strftime("%m",dol_now());
 	$year_start = $year_current;
@@ -211,7 +210,7 @@ if ($modecompta == 'CREANCES-DETTES') {
     $sql.= " WHERE f.fk_statut in (1,2)";
 	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
 	    $sql.= " AND f.type IN (0,1,2,5)";
-	    } else {
+    } else {
 	    $sql.= " AND f.type IN (0,1,2,3,5)";
 	}
 	if ($date_start && $date_end) {
@@ -243,12 +242,12 @@ if ($result) {
     $i=0;
     while ($i < $num) {
          $obj = $db->fetch_object($result);
-	 $amount_ht[$obj->rowid] = $obj->amount;
-	 $amount[$obj->rowid] = $obj->amount_ttc;
-	 $name[$obj->rowid] = $obj->name.' '.$obj->firstname;
-	 $catotal_ht+=$obj->amount;
-	 $catotal+=$obj->amount_ttc;
-	 $i++;
+        $amount_ht[$obj->rowid] = $obj->amount;
+        $amount[$obj->rowid] = $obj->amount_ttc;
+        $name[$obj->rowid] = $obj->name.' '.$obj->firstname;
+        $catotal_ht+=$obj->amount;
+        $catotal+=$obj->amount_ttc;
+        $i++;
     }
 } else {
     dol_print_error($db);
@@ -302,7 +301,7 @@ print_liste_field_titre(
 	"",
 	$sortfield,
 	$sortorder
-	);
+);
 if ($modecompta == 'CREANCES-DETTES') {
     print_liste_field_titre(
            $langs->trans('AmountHT'),
@@ -313,8 +312,8 @@ if ($modecompta == 'CREANCES-DETTES') {
            'align="right"',
            $sortfield,
            $sortorder
-	   );
-    } else {
+	);
+} else {
 	print_liste_field_titre('');
 }
 print_liste_field_titre(
@@ -326,7 +325,7 @@ print_liste_field_titre(
 	'align="right"',
 	$sortfield,
 	$sortorder
-	);
+);
 print_liste_field_titre(
 	$langs->trans("Percentage"),
 	$_SERVER["PHP_SELF"],"amount_ttc",
@@ -335,7 +334,7 @@ print_liste_field_titre(
 	'align="right"',
 	$sortfield,
 	$sortorder
-	);
+);
 print_liste_field_titre(
 	$langs->trans("OtherStatistics"),
 	$_SERVER["PHP_SELF"],
@@ -343,7 +342,7 @@ print_liste_field_titre(
 	"",
 	"",
 	'align="center" width="20%"'
-	);
+);
 print "</tr>\n";
 
 if (count($amount)) {
@@ -390,22 +389,22 @@ if (count($amount)) {
         }
         print "<td>".$linkname."</td>\n";
 
-	// Amount w/o VAT
+        // Amount w/o VAT
         print '<td align="right">';
         if ($modecompta != 'CREANCES-DETTES')
         {
             if ($key > 0) {
-		print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid='.$key.'">';
-		} else {
-		    print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid=-1">';
-		}
+                print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid='.$key.'">';
+            } else {
+                print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid=-1">';
+            }
         } else {
             if ($key > 0) {
-		print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
-	    } else {
-		print '<a href="#">';
-	    }
-	    print price($amount_ht[$key]);
+                print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
+            } else {
+                print '<a href="#">';
+            }
+            print price($amount_ht[$key]);
         }
         print '</td>';
 
@@ -413,16 +412,16 @@ if (count($amount)) {
         print '<td align="right">';
         if ($modecompta != 'CREANCES-DETTES') {
             if ($key > 0) {
-		print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid='.$key.'">';
-		} else {
-		    print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid=-1">';
-		}
+                print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid='.$key.'">';
+            } else {
+                print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?userid=-1">';
+            }
         } else {
             if ($key > 0) {
-		print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
-	    } else {
-		print '<a href="#">';
-	    }
+                print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
+            } else {
+                print '<a href="#">';
+            }
         }
         print price($amount[$key]);
         print '</td>';
@@ -433,14 +432,14 @@ if (count($amount)) {
         // Other stats
         print '<td align="center">';
         if (! empty($conf->propal->enabled) && $key>0) {
-	    print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("ProposalStats"),"stats").'</a>&nbsp;';
-	}
+            print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("ProposalStats"),"stats").'</a>&nbsp;';
+        }
         if (! empty($conf->commande->enabled) && $key>0) {
-	    print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("OrderStats"),"stats").'</a>&nbsp;';
-	}
+            print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("OrderStats"),"stats").'</a>&nbsp;';
+        }
         if (! empty($conf->facture->enabled) && $key>0) {
-	    print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("InvoiceStats"),"stats").'</a>&nbsp;';
-	}
+            print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("InvoiceStats"),"stats").'</a>&nbsp;';
+        }
         print '</td>';
         print "</tr>\n";
         $i++;
@@ -450,9 +449,9 @@ if (count($amount)) {
     print '<tr class="liste_total">';
     print '<td>'.$langs->trans("Total").'</td>';
     if ($modecompta != 'CREANCES-DETTES') {
-	print '<td colspan="1"></td>';
+        print '<td colspan="1"></td>';
     } else {
-	    print '<td align="right">'.price($catotal_ht).'</td>';
+        print '<td align="right">'.price($catotal_ht).'</td>';
     }
     print '<td align="right">'.price($catotal).'</td>';
     print '<td>&nbsp;</td>';

+ 29 - 30
htdocs/compta/stats/casoc.php

@@ -74,8 +74,7 @@ $date_startday = GETPOST("date_startday",'alpha');
 $date_endyear = GETPOST("date_endyear",'alpha');
 $date_endmonth = GETPOST("date_endmonth",'alpha');
 $date_endday = GETPOST("date_endday",'alpha');
-if (empty($year))
-{
+if (empty($year)) {
 	$year_current = strftime("%Y",dol_now());
 	$month_current = strftime("%m",dol_now());
 	$year_start = $year_current;
@@ -451,9 +450,9 @@ if ($modecompta == 'CREANCES-DETTES') {
            'align="right"',
            $sortfield,
            $sortorder
-	);
-    } else {
-	print_liste_field_titre('');
+    );
+} else {
+    print_liste_field_titre('');
 }
 print_liste_field_titre(
 	$langs->trans("AmountTTC"),
@@ -464,7 +463,7 @@ print_liste_field_titre(
 	'align="right"',
 	$sortfield,
 	$sortorder
-	);
+);
 print_liste_field_titre(
 	$langs->trans("Percentage"),
 	$_SERVER["PHP_SELF"],
@@ -474,7 +473,7 @@ print_liste_field_titre(
 	'align="right"',
 	$sortfield,
 	$sortorder
-	);
+);
 print_liste_field_titre(
 	$langs->trans("OtherStatistics"),
 	$_SERVER["PHP_SELF"],
@@ -482,7 +481,7 @@ print_liste_field_titre(
 	"",
 	"",
 	'align="center" width="20%"'
-	);
+);
 print "</tr>\n";
 
 
@@ -569,34 +568,34 @@ if (count($amount)) {
 		// Amount w/o VAT
 		print '<td align="right">';
 		if ($modecompta != 'CREANCES-DETTES') {
-                    if ($key > 0) {
-			print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid='.$key.'">';
+            if ($key > 0) {
+                print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid='.$key.'">';
 		    } else {
-			print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid=-1">';
-		    }
+                print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid=-1">';
+            }
 		} else {
 		    if ($key > 0) {
-			print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
+                print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
 		    } else {
-			print '<a href="#">';
+                print '<a href="#">';
 		    }
-		print price($amount_ht[$key]);
+            print price($amount_ht[$key]);
 		}
 		print '</td>';
 
 		// Amount with VAT
 		print '<td align="right">';
 		if ($modecompta != 'CREANCES-DETTES') {
-                    if ($key > 0) {
-                        print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid='.$key.'">';
+            if ($key > 0) {
+                print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid='.$key.'">';
 		    } else {
-			print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?orphelins=1">';
+                print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?orphelins=1">';
 		    }
 		} else {
-                    if ($key > 0) {
-                        print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
+            if ($key > 0) {
+                print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
 		    } else {
-			print '<a href="#">';
+                print '<a href="#">';
 		    }
 		}
 		print price($amount[$key]);
@@ -609,18 +608,18 @@ if (count($amount)) {
         // Other stats
         print '<td align="center">';
         if (! empty($conf->propal->enabled) && $key>0) {
-	    print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"),"stats").'</a>&nbsp;';
-	}
+            print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"),"stats").'</a>&nbsp;';
+        }
         if (! empty($conf->commande->enabled) && $key>0) {
-	    print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("OrderStats"),"stats").'</a>&nbsp;';
-	}
+            print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("OrderStats"),"stats").'</a>&nbsp;';
+        }
         if (! empty($conf->facture->enabled) && $key>0) {
-	    print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"),"stats").'</a>&nbsp;';
-	}
+            print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"),"stats").'</a>&nbsp;';
+        }
         print '</td>';
-	print "</tr>\n";
-	$i++;
-	}
+        print "</tr>\n";
+        $i++;
+    }
 
 	// Total
 	print '<tr class="liste_total">';

+ 2 - 1
htdocs/contact/class/contact.class.php

@@ -1010,7 +1010,8 @@ class Contact extends CommonObject
 		}
 
 		// Removed extrafields
-		 if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { // For avoid conflicts if trigger used
+        if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) {
+            // For avoid conflicts if trigger used
 			$result=$this->deleteExtraFields($this);
 			if ($result < 0) $error++;
 		}

+ 5 - 5
htdocs/contrat/class/api_contracts.class.php

@@ -186,9 +186,9 @@ class Contracts extends DolibarrApi
      */
     function post($request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->contrat->creer) {
-			  throw new RestException(401, "Insuffisant rights");
-		  }
+        if(! DolibarrApiAccess::$user->rights->contrat->creer) {
+            throw new RestException(401, "Insuffisant rights");
+        }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
@@ -220,9 +220,9 @@ class Contracts extends DolibarrApi
      */
     function getLines($id)
     {
-        if(! DolibarrApiAccess::$user->rights->contrat->lire) {
+        if (! DolibarrApiAccess::$user->rights->contrat->lire) {
             throw new RestException(401);
-		}
+        }
 
         $result = $this->contract->fetch($id);
         if( ! $result ) {

+ 1 - 2
htdocs/core/class/commonobject.class.php

@@ -5434,8 +5434,7 @@ abstract class CommonObject
 			elseif (in_array($type,array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
 			{
 				$morecss = 'maxwidth75';
-                        }elseif ($type == 'url')
-			{
+            } elseif ($type == 'url') {
 				$morecss='minwidth400';
 			}
 			elseif ($type == 'boolean')

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

@@ -1470,43 +1470,43 @@ class Form
 					$contactstatic->id=$obj->rowid;
 					$contactstatic->lastname=$obj->lastname;
 					$contactstatic->firstname=$obj->firstname;
-					if ($obj->statut == 1){
-					if ($htmlname != 'none')
-					{
-						$disabled=0;
-						if (is_array($exclude) && count($exclude) && in_array($obj->rowid,$exclude)) $disabled=1;
-						if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1;
-						if (!empty($selected) && in_array($obj->rowid, $selected))
-						{
-							$out.= '<option value="'.$obj->rowid.'"';
-							if ($disabled) $out.= ' disabled';
-							$out.= ' selected>';
-							$out.= $contactstatic->getFullName($langs);
-							if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')';
-							if (($showsoc > 0) && $obj->company) $out.= ' - ('.$obj->company.')';
-							$out.= '</option>';
-						}
-						else
-						{
-							$out.= '<option value="'.$obj->rowid.'"';
-							if ($disabled) $out.= ' disabled';
-							$out.= '>';
-							$out.= $contactstatic->getFullName($langs);
-							if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')';
-							if (($showsoc > 0) && $obj->company) $out.= ' - ('.$obj->company.')';
-							$out.= '</option>';
-						}
-					}
-					else
-					{
-						if (in_array($obj->rowid, $selected))
-						{
-							$out.= $contactstatic->getFullName($langs);
-							if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')';
-							if (($showsoc > 0) && $obj->company) $out.= ' - ('.$obj->company.')';
-						}
-					}
-				}
+					if ($obj->statut == 1) {
+					    if ($htmlname != 'none')
+					    {
+						    $disabled=0;
+						    if (is_array($exclude) && count($exclude) && in_array($obj->rowid,$exclude)) $disabled=1;
+						    if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1;
+						    if (!empty($selected) && in_array($obj->rowid, $selected))
+						    {
+							    $out.= '<option value="'.$obj->rowid.'"';
+							    if ($disabled) $out.= ' disabled';
+							    $out.= ' selected>';
+							    $out.= $contactstatic->getFullName($langs);
+							    if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')';
+							    if (($showsoc > 0) && $obj->company) $out.= ' - ('.$obj->company.')';
+							    $out.= '</option>';
+						    }
+						    else
+						    {
+							    $out.= '<option value="'.$obj->rowid.'"';
+							    if ($disabled) $out.= ' disabled';
+							    $out.= '>';
+							    $out.= $contactstatic->getFullName($langs);
+							    if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')';
+							    if (($showsoc > 0) && $obj->company) $out.= ' - ('.$obj->company.')';
+							    $out.= '</option>';
+						    }
+					    }
+					    else
+					    {
+						    if (in_array($obj->rowid, $selected))
+						    {
+							    $out.= $contactstatic->getFullName($langs);
+							    if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')';
+							    if (($showsoc > 0) && $obj->company) $out.= ' - ('.$obj->company.')';
+						    }
+					    }
+				    }
 					$i++;
 				}
 			}

+ 1 - 1
htdocs/core/class/html.formfile.class.php

@@ -1346,7 +1346,7 @@ class FormFile
 							   	print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"').'>';
 							   	print '</td>';
 							}
-					   }
+					    }
 					}
 					else
 					{

+ 1 - 1
htdocs/core/class/menubase.class.php

@@ -712,5 +712,5 @@ class Menubase
                 $this->recur($tab, $tab[$x]['rowid'], ($level+1));
             }
         }
-   }
+    }
 }

+ 16 - 20
htdocs/core/db/sqlite3.class.php

@@ -1403,32 +1403,28 @@ class DoliDBSqlite3 extends DoliDB
         $weekday=self::calc_weekday($first_daynr, !$monday_first);
         $calc_year=$year;
 
-        if ($month == 1 && $day <= 7-$weekday)
-        {
+        if ($month == 1 && $day <= 7-$weekday) {
             if (!$week_year && (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)))
                 return 0;
             $week_year= 1;
             $calc_year--;
             $first_daynr-= ($days=self::calc_days_in_year($calc_year));
             $weekday= ($weekday + 53*7- $days) % 7;
-      }
-
-      if (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)) {
-        $days= $daynr - ($first_daynr+ (7-$weekday));
-      }
-      else {
-        $days= $daynr - ($first_daynr - $weekday);
-      }
-
-      if ($week_year && $days >= 52*7)
-      {
-        $weekday= ($weekday + self::calc_days_in_year($calc_year)) % 7;
-        if ((!$first_weekday && $weekday < 4) || ($first_weekday && $weekday == 0))
-        {
-          $calc_year++;
-          return 1;
         }
-      }
-      return floor($days/7+1);
+
+        if (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)) {
+            $days= $daynr - ($first_daynr+ (7-$weekday));
+        } else {
+            $days= $daynr - ($first_daynr - $weekday);
+        }
+
+        if ($week_year && $days >= 52*7) {
+            $weekday= ($weekday + self::calc_days_in_year($calc_year)) % 7;
+            if ((!$first_weekday && $weekday < 4) || ($first_weekday && $weekday == 0)) {
+                $calc_year++;
+                return 1;
+            }
+        }
+        return floor($days/7+1);
     }
 }

+ 13 - 8
htdocs/core/lib/functions.lib.php

@@ -2365,15 +2365,18 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
 		{//ex: +66_A_BCD_EF_GHI
 			$newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,3);
 		}
-		}
+	}
 	elseif (strtoupper($countrycode) == "MU")
-	{//Maurice
+	{
+        //Maurice
 		if(dol_strlen($phone) == 11)
-		{//ex: +230_ABC_DE_FG
+		{
+            //ex: +230_ABC_DE_FG
 			$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2);
 		}
 		elseif(dol_strlen($phone) == 12)
-		{//ex: +230_ABCD_EF_GH
+		{
+            //ex: +230_ABCD_EF_GH
 			$newphone = substr($newphone,0,4).$separ.substr($newphone,4,4).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
 		}
 	}
@@ -2514,9 +2517,11 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
 		}
 	}
 	elseif(strtoupper($countrycode) == "AU")
-	{//Australie
-		 if(dol_strlen($phone) == 12)
-		{//ex: +61_A_BCDE_FGHI
+	{
+        //Australie
+		if(dol_strlen($phone) == 12)
+		{
+            //ex: +61_A_BCDE_FGHI
 			$newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,4).$separ.substr($newphone,8,4);
 		}
 	}
@@ -2593,7 +2598,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
 		$rep.=($withpicto?img_picto($titlealt, 'object_'.$picto.'.png').' ':'').$newphone;
 		if ($adddivfloat) $rep.='</div>';
 		else $rep.='</span>';
-	  }
+	}
 
 	return $rep;
 }

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

@@ -900,7 +900,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
 	// First line of company infos
 	$line1=""; $line2=""; $line3=""; $line4="";
 
-		if ($showdetails == 1 || $showdetails == 3)
+    if ($showdetails == 1 || $showdetails == 3)
 	{
 		// Company name
 		if ($fromcompany->name)
@@ -1969,9 +1969,9 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0)
         	}
         	else
 			$result.=price($sign * $total_ht, 0, $outputlangs);
-	}
+        }
     }
-	return $result;
+    return $result;
 }
 
 /**

+ 15 - 16
htdocs/core/modules/commande/doc/pdf_einstein.modules.php

@@ -768,23 +768,22 @@ class pdf_einstein extends ModelePDFCommandes
 			$posy=$pdf->GetY()+1;
 		}
 
-      	// Show payment mode
+        // Show payment mode
         if ($object->mode_reglement_code
-        	 && $object->mode_reglement_code != 'CHQ'
-           	 && $object->mode_reglement_code != 'VIR')
-           	 {
-	            $pdf->SetFont('','B', $default_font_size - 2);
-	            $pdf->SetXY($this->marge_gauche, $posy);
-	            $titre = $outputlangs->transnoentities("PaymentMode").':';
-	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
-
-				$pdf->SetFont('','', $default_font_size - 2);
-	            $pdf->SetXY($posxval, $posy);
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
-
-	            $posy=$pdf->GetY()+2;
-           	 }
+            && $object->mode_reglement_code != 'CHQ'
+           	&& $object->mode_reglement_code != 'VIR') {
+            $pdf->SetFont('','B', $default_font_size - 2);
+            $pdf->SetXY($this->marge_gauche, $posy);
+            $titre = $outputlangs->transnoentities("PaymentMode").':';
+            $pdf->MultiCell(80, 5, $titre, 0, 'L');
+
+            $pdf->SetFont('','', $default_font_size - 2);
+            $pdf->SetXY($posxval, $posy);
+            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
+
+            $posy=$pdf->GetY()+2;
+        }
 
 		// Show payment mode CHQ
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')

+ 20 - 21
htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php

@@ -828,30 +828,29 @@ class pdf_eratosthene extends ModelePDFCommandes
 			$posy=$pdf->GetY()+1;
 		}
 
-      	// Show payment mode
+        // Show payment mode
         if ($object->mode_reglement_code
-        	 && $object->mode_reglement_code != 'CHQ'
-           	 && $object->mode_reglement_code != 'VIR')
-           	 {
-	            $pdf->SetFont('','B', $default_font_size - 2);
-	            $pdf->SetXY($this->marge_gauche, $posy);
-	            $titre = $outputlangs->transnoentities("PaymentMode").':';
-	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
-
-				$pdf->SetFont('','', $default_font_size - 2);
-	            $pdf->SetXY($posxval, $posy);
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
-
-	            $posy=$pdf->GetY()+2;
-           	 }
-
-		// Show payment mode CHQ
+            && $object->mode_reglement_code != 'CHQ'
+            && $object->mode_reglement_code != 'VIR') {
+            $pdf->SetFont('','B', $default_font_size - 2);
+            $pdf->SetXY($this->marge_gauche, $posy);
+            $titre = $outputlangs->transnoentities("PaymentMode").':';
+            $pdf->MultiCell(80, 5, $titre, 0, 'L');
+
+            $pdf->SetFont('','', $default_font_size - 2);
+            $pdf->SetXY($posxval, $posy);
+            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
+
+            $posy=$pdf->GetY()+2;
+        }
+
+        // Show payment mode CHQ
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
         {
-        	// Si mode reglement non force ou si force a CHQ
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
-	        {
+            // Si mode reglement non force ou si force a CHQ
+            if (! empty($conf->global->FACTURE_CHQ_NUMBER))
+            {
 	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
 	            {
 	                $account = new Account($this->db);

+ 7 - 6
htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php

@@ -294,12 +294,13 @@ class doc_generic_contract_odt extends ModelePDFContract
 				if (! empty($usecontact))
 				{
 					// On peut utiliser le nom de la societe du contact
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
-					else {
-                        			$socobject = $object->thirdparty;
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
-                        			$contactobject = $object->contact;
-                    			}
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
+                        $socobject = $object->contact;
+                    } else {
+                        $socobject = $object->thirdparty;
+                        // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+                        $contactobject = $object->contact;
+                    }
 				}
 				else
 				{

+ 23 - 23
htdocs/core/modules/facture/doc/pdf_crabe.modules.php

@@ -1286,37 +1286,37 @@ class pdf_crabe extends ModelePDFFactures
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach( $this->localtax2 as $localtax_type => $localtax_rate )
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach( $localtax_rate as $tvakey => $tvaval )
+					foreach( $localtax_rate as $tvakey => $tvaval )
+					{
+					    // retrieve global local tax
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-						    // retrieve global local tax
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/',$tvakey))
-								{
-									$tvakey=str_replace('*','',$tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
+							$tvacompl='';
+							if (preg_match('/\*/',$tvakey))
+							{
+								$tvakey=str_replace('*','',$tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
 
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
-					//}
+					}
 				}
+				//}
 
 				// Revenue stamp
 				if (price2num($object->revenuestamp) != 0)

+ 2 - 2
htdocs/core/modules/facture/doc/pdf_sponge.modules.php

@@ -1377,8 +1377,8 @@ class pdf_sponge extends ModelePDFFactures
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 							}
 						}
-					//}
-				}
+					}
+				//}
 
 				// Revenue stamp
 				if (price2num($object->revenuestamp) != 0)

+ 5 - 5
htdocs/core/modules/fichinter/mod_arctic.php

@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/fichinter/modules_fichinter.php';
  */
 class mod_arctic extends ModeleNumRefFicheinter
 {
-	/**
+    /**
      * Dolibarr version of the loaded document
      * @public string
      */
@@ -130,7 +130,7 @@ class mod_arctic extends ModeleNumRefFicheinter
 
 		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
 
-		// On dfini critere recherche compteur
+		// On défini critere recherche compteur
 		$mask=$conf->global->FICHINTER_ARTIC_MASK;
 
 		if (! $mask)
@@ -142,14 +142,14 @@ class mod_arctic extends ModeleNumRefFicheinter
 		$numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc,$object->datec);
 
 		return  $numFinal;
-  }
+    }
 
 
 	/**
-	 * 	Return next free value
+	 *  Return next free value
 	 *
      *  @param	Societe		$objsoc     Object third party
-	 * 	@param	Object		$objforref	Object for number to search
+	 *  @param	Object		$objforref	Object for number to search
      *  @return string      			Next free value
      */
     function getNumRef($objsoc, $objforref)

+ 9 - 8
htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php

@@ -1,6 +1,6 @@
 <?php
-/* Copyright (C) 2010-2012 	Laurent Destailleur <eldy@products.sourceforge.net>
- * Copyright (C) 2012		Juanjo Menent		<jmenent@2byte.es>
+/* Copyright (C) 2010-2012  Laurent Destailleur     <eldy@products.sourceforge.net>
+ * Copyright (C) 2012       Juanjo Menent           <jmenent@2byte.es>
  * Copyright (C) 2018       Frédéric France         <frederic.france@netlogic.fr>
  *
 * This program is free software; you can redistribute it and/or modify
@@ -321,12 +321,13 @@ class doc_generic_product_odt extends ModelePDFProduct
 				if (! empty($usecontact))
 				{
 					// On peut utiliser le nom de la societe du contact
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
-					else {
-                        			$socobject = $object->thirdparty;
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
-                        			$contactobject = $object->contact;
-                    			}
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
+                        $socobject = $object->contact;
+                    } else {
+                        $socobject = $object->thirdparty;
+                        // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+                        $contactobject = $object->contact;
+                    }
 				}
 				else
 				{

+ 128 - 128
htdocs/core/modules/project/doc/pdf_beluga.modules.php

@@ -425,26 +425,26 @@ class pdf_beluga extends ModelePDFProjects
                             $total_ttc = 0;
                             $num = count($elementarray);
 
-				// Loop on each lines
-				for ($i = 0; $i < $num; $i ++)
-				{
-					$curY = $nexY;
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
-					$pdf->SetTextColor(0,0,0);
-
-					$pdf->setTopMargin($tab_top_newpage);
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
-					$pageposbefore=$pdf->getPage();
-
-					// Description of line
-					$idofelement=$elementarray[$i];
-                             	if ($classname == 'ExpenseReport')
-                               	{
-                               		// We get id of expense report
-                               		$expensereportline=new ExpenseReportLine($this->db);
-                               		$expensereportline->fetch($idofelement);
-                               		$idofelement = $expensereportline->fk_expensereport;
-                               	}
+			                // Loop on each lines
+				            for ($i = 0; $i < $num; $i ++)
+				            {
+					            $curY = $nexY;
+					            $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
+					            $pdf->SetTextColor(0,0,0);
+
+					            $pdf->setTopMargin($tab_top_newpage);
+					            $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					            $pageposbefore=$pdf->getPage();
+
+					            // Description of line
+					            $idofelement=$elementarray[$i];
+                                if ($classname == 'ExpenseReport')
+                                {
+                                    // We get id of expense report
+                                    $expensereportline=new ExpenseReportLine($this->db);
+                                    $expensereportline->fetch($idofelement);
+                                    $idofelement = $expensereportline->fk_expensereport;
+                                }
 
                                 $element = new $classname($this->db);
                                 $element->fetch($idofelement);
@@ -457,114 +457,114 @@ class pdf_beluga extends ModelePDFProjects
                                         $qualifiedfortotal = false; // Replacement invoice
                                 }
 
-					$showpricebeforepagebreak=1;
-
-					$pdf->startTransaction();
-					// Label
-					$pdf->SetXY($this->posxref, $curY);
-					$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
-					$pageposafter=$pdf->getPage();
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
-					{
-						$pdf->rollbackTransaction(true);
-						$pageposafter=$pageposbefore;
-						//print $pageposafter.'-'.$pageposbefore;exit;
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
-						// Label
-						$pdf->SetXY($this->posxref, $curY);
-						$posybefore=$pdf->GetY();
-						$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
-						$pageposafter=$pdf->getPage();
-						$posyafter=$pdf->GetY();
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
-						{
-							if ($i == ($num-1))	// No more lines, and no space left to show total, so we create a new page
-							{
-								$pdf->AddPage('','',true);
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								$pdf->setPage($pageposafter+1);
-							}
-						}
-						else
-						{
-							// We found a page break
-							$showpricebeforepagebreak=0;
-							$forcedesconsamepage=1;
-							if ($forcedesconsamepage)
-							{
-								$pdf->rollbackTransaction(true);
-								$pageposafter=$pageposbefore;
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
-
-								$pdf->AddPage('','',true);
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								$pdf->setPage($pageposafter+1);
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
-								$pdf->SetTextColor(0,0,0);
-
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
-								$curY = $tab_top_newpage + $heightoftitleline + 1;
-
-								// Label
-								$pdf->SetXY($this->posxref, $curY);
-								$posybefore=$pdf->GetY();
-								$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
-								$pageposafter=$pdf->getPage();
-								$posyafter=$pdf->GetY();
-							}
-						}
-						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
-					}
-					else	// No pagebreak
-					{
-						$pdf->commitTransaction();
-					}
-					$posYAfterDescription=$pdf->GetY();
-
-					$nexY = $pdf->GetY();
-					$pageposafter=$pdf->getPage();
-					$pdf->setPage($pageposbefore);
-					$pdf->setTopMargin($this->marge_haute);
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
-
-					// We suppose that a too long description is moved completely on next page
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
-						//var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
-					}
-
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
-
-					// Date
-					if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
-						$date = $element->date_commande;
-					else {
-						$date = $element->date;
-						if (empty($date))
-							$date = $element->datep;
-						if (empty($date))
-							$date = $element->date_contrat;
-						if (empty($date))
-							$date = $element->datev; // Fiche inter
-					}
-
-					$pdf->SetXY($this->posxdate, $curY);
-					$pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C');
-
-					$pdf->SetXY($this->posxsociety, $curY);
-					if ($classname == 'ExpenseReport')
-					{
-						$fuser=new User($this->db);
-						$fuser->fetch($element->fk_user_author);
-						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
-					}
-					else
-					{
-						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L');
-					}
+					            $showpricebeforepagebreak=1;
+
+					            $pdf->startTransaction();
+					            // Label
+					            $pdf->SetXY($this->posxref, $curY);
+					            $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
+					            $pageposafter=$pdf->getPage();
+					            if ($pageposafter > $pageposbefore)	// There is a pagebreak
+					            {
+						            $pdf->rollbackTransaction(true);
+						            $pageposafter=$pageposbefore;
+						            //print $pageposafter.'-'.$pageposbefore;exit;
+						            $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
+						            // Label
+						            $pdf->SetXY($this->posxref, $curY);
+						            $posybefore=$pdf->GetY();
+						            $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
+						            $pageposafter=$pdf->getPage();
+						            $posyafter=$pdf->GetY();
+						            if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
+						            {
+							            if ($i == ($num-1))	// No more lines, and no space left to show total, so we create a new page
+							            {
+								            $pdf->AddPage('','',true);
+								            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+								            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+								            $pdf->setPage($pageposafter+1);
+							            }
+						            }
+						            else
+						            {
+							            // We found a page break
+							            $showpricebeforepagebreak=0;
+							            $forcedesconsamepage=1;
+							            if ($forcedesconsamepage)
+							            {
+								            $pdf->rollbackTransaction(true);
+								            $pageposafter=$pageposbefore;
+								            $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
+
+								            $pdf->AddPage('','',true);
+								            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+								            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+								            $pdf->setPage($pageposafter+1);
+								            $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
+								            $pdf->MultiCell(0, 3, '');		// Set interline to 3
+								            $pdf->SetTextColor(0,0,0);
+
+								            $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
+								            $curY = $tab_top_newpage + $heightoftitleline + 1;
+
+								            // Label
+								            $pdf->SetXY($this->posxref, $curY);
+								            $posybefore=$pdf->GetY();
+								            $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
+								            $pageposafter=$pdf->getPage();
+								            $posyafter=$pdf->GetY();
+							            }
+						            }
+						        //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
+					            }
+					            else	// No pagebreak
+					            {
+						            $pdf->commitTransaction();
+					            }
+					        $posYAfterDescription=$pdf->GetY();
+
+					        $nexY = $pdf->GetY();
+					        $pageposafter=$pdf->getPage();
+					        $pdf->setPage($pageposbefore);
+					        $pdf->setTopMargin($this->marge_haute);
+					        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
+					        // We suppose that a too long description is moved completely on next page
+					        if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
+						        //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
+						        $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
+					        }
+
+					        $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
+
+					        // Date
+					        if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
+						            $date = $element->date_commande;
+					            else {
+						            $date = $element->date;
+						        if (empty($date))
+							        $date = $element->datep;
+						        if (empty($date))
+							        $date = $element->date_contrat;
+						        if (empty($date))
+							        $date = $element->datev; // Fiche inter
+					            }
+
+					            $pdf->SetXY($this->posxdate, $curY);
+					            $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C');
+
+					            $pdf->SetXY($this->posxsociety, $curY);
+					            if ($classname == 'ExpenseReport')
+					            {
+						            $fuser=new User($this->db);
+						            $fuser->fetch($element->fk_user_author);
+						            $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
+					            }
+					            else
+					            {
+						            $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L');
+					            }
 
                                 // Amount without tax
                                 if (empty($value['disableamount'])) {

+ 4 - 4
htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php

@@ -336,10 +336,10 @@ class doc_generic_proposal_odt extends ModelePDFPropales
 					// On peut utiliser le nom de la societe du contact
 					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
 					else {
-                        			$socobject = $object->thirdparty;
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
-                        			$contactobject = $object->contact;
-                    			}
+                        $socobject = $object->thirdparty;
+                        // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+                        $contactobject = $object->contact;
+                    }
 				}
 				else
 				{

+ 7 - 6
htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php

@@ -321,12 +321,13 @@ class doc_generic_stock_odt extends ModelePDFStock
 				if (! empty($usecontact))
 				{
 					// On peut utiliser le nom de la societe du contact
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
-					else {
-                        			$socobject = $object->thirdparty;
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
-                        			$contactobject = $object->contact;
-                    			}
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
+                        $socobject = $object->contact;
+                    } else {
+                        $socobject = $object->thirdparty;
+                        // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+                        $contactobject = $object->contact;
+                    }
 				}
 				else
 				{

+ 5 - 5
htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php

@@ -65,7 +65,7 @@ class doc_generic_user_odt extends ModelePDFUser
 		global $conf, $langs, $mysoc;
 
 		// Load translation files required by the page
-    $langs->loadLangs(array("main","companies"));
+        $langs->loadLangs(array("main","companies"));
 
 		$this->db = $db;
 		$this->name = "ODT templates";
@@ -318,10 +318,10 @@ class doc_generic_user_odt extends ModelePDFUser
 					// On peut utiliser le nom de la societe du contact
 					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
 					else {
-                        			$socobject = $object->thirdparty;
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
-                        			$contactobject = $object->contact;
-                    			}
+                        $socobject = $object->thirdparty;
+                        // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+                        $contactobject = $object->contact;
+                    }
 				}
 				else
 				{

+ 4 - 4
htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php

@@ -320,10 +320,10 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
 					// On peut utiliser le nom de la societe du contact
 					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
 					else {
-                        			$socobject = $object->thirdparty;
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
-                        			$contactobject = $object->contact;
-                    			}
+                        $socobject = $object->thirdparty;
+                        // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+                        $contactobject = $object->contact;
+                    }
 				}
 				else
 				{

+ 4 - 1
htdocs/core/tpl/contacts.tpl.php

@@ -235,7 +235,10 @@ if ($permission) {
 	</form>
 
 <?php $i++; ?>
-<?php } } ?>
+<?php
+        }
+    }
+?>
 
 </div>
 </div>

+ 13 - 9
htdocs/core/tpl/login.tpl.php

@@ -21,10 +21,9 @@
 
 
 // Protection to avoid direct call of template
-if (empty($conf) || ! is_object($conf))
-{
-	print "Error, template page can't be called as URL";
-	exit;
+if (empty($conf) || ! is_object($conf)) {
+    print "Error, template page can't be called as URL";
+    exit;
 }
 
 
@@ -61,19 +60,24 @@ print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disable
 
 $colorbackhmenu1='60,70,100';      // topmenu
 if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1=$colorbackhmenu1;
-$colorbackhmenu1     =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1):(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1);
+$colorbackhmenu1 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1):(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1);
 $colorbackhmenu1=join(',',colorStringToArray($colorbackhmenu1));    // Normalize value to 'x,y,z'
 
 ?>
 <!-- BEGIN PHP TEMPLATE LOGIN.TPL.PHP -->
 
-<?php if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) {
+<?php
+if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) {
 	// For example $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND = 'https://source.unsplash.com/random'
-	?>
+?>
 	<body class="body bodylogin" style="background-image: url('<?php echo $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND; ?>'); background-repeat: no-repeat; background-position: center center; background-attachment: fixed; background-size: cover; background-color: #ffffff;">
-	<?php } else { ?>
+<?php
+} else {
+?>
 	<body class="body bodylogin"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file=logos/'.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
-<?php } ?>
+<?php
+}
+?>
 
 <?php if (empty($conf->dol_use_jmobile)) { ?>
 <script type="text/javascript">

+ 31 - 27
htdocs/core/tpl/objectline_edit.tpl.php

@@ -193,16 +193,19 @@ $coldisplay=-1; // We remove first td
 		&nbsp;
 	<?php } ?>
 	</td>
-	<?php
+<?php
 	if ($this->situation_cycle_ref) {
 		$coldisplay++;
 		print '<td class="nowrap right"><input class="right" type="text" size="1" value="' . $line->situation_percent . '" name="progress">%</td>';
 	}
 	if (! empty($usemargins))
 	{
-	?>
-		<?php if (!empty($user->rights->margins->creer)) { ?>
-		<td class="margininfos right"><?php $coldisplay++; ?>
+        if (!empty($user->rights->margins->creer)) {
+?>
+        <td class="margininfos right">
+<?php
+            $coldisplay++;
+?>
 			<!-- For predef product -->
 			<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
 			<select id="fournprice_predef" name="fournprice_predef" class="flat right" style="display: none;"></select>
@@ -211,30 +214,31 @@ $coldisplay=-1; // We remove first td
 			<input class="flat right" type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>">
 		</td>
 		<?php } ?>
-	    <?php if ($user->rights->margins->creer) {
-				if (! empty($conf->global->DISPLAY_MARGIN_RATES))
-				  {
-				    $margin_rate = (isset($_POST["np_marginRate"])?GETPOST("np_marginRate","alpha",2):(($line->pa_ht == 0)?'':price($line->marge_tx)));
-				    // if credit note, dont allow to modify margin
-					if ($line->subprice < 0)
-						echo '<td class="right nowrap margininfos">'.$margin_rate.'<span class="hideonsmartphone">%</span></td>';
-					else
-						echo '<td class="right nowrap margininfos"><input class="right" type="text" size="2" name="np_marginRate" value="'.$margin_rate.'"><span class="hideonsmartphone">%</span></td>';
-					$coldisplay++;
-				  }
-				elseif (! empty($conf->global->DISPLAY_MARK_RATES))
-				  {
-				    $mark_rate = (isset($_POST["np_markRate"])?GETPOST("np_markRate",'alpha',2):price($line->marque_tx));
-				    // if credit note, dont allow to modify margin
-					if ($line->subprice < 0)
-						echo '<td class="right nowrap margininfos">'.$mark_rate.'<span class="hideonsmartphone">%</span></td>';
-					else
-						echo '<td class="right nowrap margininfos"><input class="right" type="text" size="2" name="np_markRate" value="'.$mark_rate.'"><span class="hideonsmartphone">%</span></td>';
-					$coldisplay++;
-				  }
-			  }
+<?php
+        if ($user->rights->margins->creer) {
+			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
+			{
+				$margin_rate = (isset($_POST["np_marginRate"])?GETPOST("np_marginRate","alpha",2):(($line->pa_ht == 0)?'':price($line->marge_tx)));
+				// if credit note, dont allow to modify margin
+				if ($line->subprice < 0)
+					echo '<td class="right nowrap margininfos">'.$margin_rate.'<span class="hideonsmartphone">%</span></td>';
+				else
+					echo '<td class="right nowrap margininfos"><input class="right" type="text" size="2" name="np_marginRate" value="'.$margin_rate.'"><span class="hideonsmartphone">%</span></td>';
+				$coldisplay++;
+			}
+			elseif (! empty($conf->global->DISPLAY_MARK_RATES))
+			{
+				$mark_rate = (isset($_POST["np_markRate"])?GETPOST("np_markRate",'alpha',2):price($line->marque_tx));
+				// if credit note, dont allow to modify margin
+				if ($line->subprice < 0)
+					echo '<td class="right nowrap margininfos">'.$mark_rate.'<span class="hideonsmartphone">%</span></td>';
+				else
+					echo '<td class="right nowrap margininfos"><input class="right" type="text" size="2" name="np_markRate" value="'.$mark_rate.'"><span class="hideonsmartphone">%</span></td>';
+				$coldisplay++;
+			}
+		}
 	}
-	?>
+?>
 
 	<!-- colspan=4 for this td because it replace total_ht+3 td for buttons -->
 	<td class="center valignmiddle" colspan="<?php echo $colspan; ?>"><?php $coldisplay+=4; ?>

+ 15 - 9
htdocs/core/tpl/objectline_view.tpl.php

@@ -204,13 +204,15 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
 	<?php } ?>
 
 	<td class="linecolqty nowrap right"><?php $coldisplay++; ?>
-	<?php if ((($line->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;"')." ";
-			echo 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 echo '&nbsp;';	?>
+    <?php
+    if ((($line->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;"')." ";
+		echo 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 echo '&nbsp;';
+    ?>
 	</td>
 
 	<?php
@@ -308,9 +310,13 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
     <?php } else { ?>
     <td <?php echo (($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"'); ?>><?php $coldisplay++; ?></td>
 	<?php } ?>
-<?php } else { ?>
+<?php
+    } else {
+?>
 	<td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
-<?php } ?>
+<?php
+    }
+?>
 	<?php  if($action == 'selectlines'){ ?>
 	<td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
 	<?php } ?>

+ 1 - 2
htdocs/datapolicy/class/actions_datapolicy.class.php

@@ -206,8 +206,7 @@ class ActionsDatapolicy
             require_once  DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
             require_once  DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php';
             DataPolicy::sendMailDataPolicyContact($object);
-        }
-         elseif ($parameters['currentcontext'] == 'membercard' && $action == 'send_datapolicy') {
+        } elseif ($parameters['currentcontext'] == 'membercard' && $action == 'send_datapolicy') {
              $object->fetch(GETPOST('id'));
             require_once  DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
             require_once  DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php';

+ 1 - 1
htdocs/datapolicy/class/datapolicy.class.php

@@ -258,7 +258,7 @@ Class DataPolicy
      	if ($message) {
      		if ($sendtocc) {
                  $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
-             }
+            }
             $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
             $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
             $actionmsg .= dol_concatdesc($actionmsg, $message);

+ 3 - 3
htdocs/don/tpl/linkedobjectblock.tpl.php

@@ -46,9 +46,9 @@ foreach($linkedObjectBlock as $key => $objectlink)
     	<td align="center"><?php echo $objectlink->ref_client; ?></td>
     	<td align="center"><?php echo dol_print_date($objectlink->date, 'day'); ?></td>
     	<td align="right"><?php
-    			$total = $total + $objectlink->total_ht;
-    			echo price($objectlink->total_ht);
-		} ?>
+    $total = $total + $objectlink->total_ht;
+    echo price($objectlink->total_ht);
+} ?>
 		</td>
     	<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
     </tr>

+ 83 - 83
htdocs/expedition/class/api_shipments.class.php

@@ -34,8 +34,8 @@ class Shipments extends DolibarrApi
      */
     static $FIELDS = array(
         'socid',
-    	'origin_id',
-    	'origin_type',
+        'origin_id',
+        'origin_type',
     );
 
     /**
@@ -184,9 +184,9 @@ class Shipments extends DolibarrApi
      */
     function post($request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->expedition->creer) {
-			  throw new RestException(401, "Insuffisant rights");
-		  }
+        if (! DolibarrApiAccess::$user->rights->expedition->creer) {
+            throw new RestException(401, "Insuffisant rights");
+        }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
@@ -194,11 +194,11 @@ class Shipments extends DolibarrApi
             $this->shipment->$field = $value;
         }
         if (isset($request_data["lines"])) {
-          $lines = array();
-          foreach ($request_data["lines"] as $line) {
-            array_push($lines, (object) $line);
-          }
-          $this->shipment->lines = $lines;
+            $lines = array();
+            foreach ($request_data["lines"] as $line) {
+                array_push($lines, (object) $line);
+            }
+            $this->shipment->lines = $lines;
         }
 
         if ($this->shipment->create(DolibarrApiAccess::$user) < 0) {
@@ -220,26 +220,26 @@ class Shipments extends DolibarrApi
     /*
     function getLines($id)
     {
-      if(! DolibarrApiAccess::$user->rights->expedition->lire) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->shipment->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Shipment not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-      $this->shipment->getLinesArray();
-      $result = array();
-      foreach ($this->shipment->lines as $line) {
-        array_push($result,$this->_cleanObjectDatas($line));
-      }
-      return $result;
+        if(! DolibarrApiAccess::$user->rights->expedition->lire) {
+            throw new RestException(401);
+        }
+
+        $result = $this->shipment->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Shipment not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $this->shipment->getLinesArray();
+        $result = array();
+        foreach ($this->shipment->lines as $line) {
+            array_push($result,$this->_cleanObjectDatas($line));
+        }
+        return $result;
     }
-	*/
+    */
 
     /**
      * Add a line to given shipment
@@ -254,20 +254,20 @@ class Shipments extends DolibarrApi
     /*
     function postLine($id, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->expedition->creer) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->shipment->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Shipment not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-			$request_data = (object) $request_data;
-      $updateRes = $this->shipment->addline(
+        if(! DolibarrApiAccess::$user->rights->expedition->creer) {
+            throw new RestException(401);
+        }
+
+        $result = $this->shipment->fetch($id);
+        if ( ! $result ) {
+            throw new RestException(404, 'Shipment not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $request_data = (object) $request_data;
+        $updateRes = $this->shipment->addline(
                         $request_data->desc,
                         $request_data->subprice,
                         $request_data->qty,
@@ -294,13 +294,13 @@ class Shipments extends DolibarrApi
                         $request_data->origin,
                         $request_data->origin_id,
                         $request_data->multicurrency_subprice
-      );
+        );
 
-      if ($updateRes > 0) {
-        return $updateRes;
+        if ($updateRes > 0) {
+            return $updateRes;
 
-      }
-      return false;
+        }
+        return false;
     }*/
 
     /**
@@ -317,20 +317,20 @@ class Shipments extends DolibarrApi
     /*
     function putLine($id, $lineid, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->expedition->creer) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->shipment->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Shipment not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-			$request_data = (object) $request_data;
-      $updateRes = $this->shipment->updateline(
+        if (! DolibarrApiAccess::$user->rights->expedition->creer) {
+            throw new RestException(401);
+        }
+
+        $result = $this->shipment->fetch($id);
+        if ( ! $result ) {
+            throw new RestException(404, 'Shipment not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $request_data = (object) $request_data;
+        $updateRes = $this->shipment->updateline(
                         $lineid,
                         $request_data->desc,
                         $request_data->subprice,
@@ -352,15 +352,15 @@ class Shipments extends DolibarrApi
                         $request_data->special_code,
                         $request_data->array_options,
                         $request_data->fk_unit,
-      					$request_data->multicurrency_subprice
-      );
-
-      if ($updateRes > 0) {
-        $result = $this->get($id);
-        unset($result->line);
-        return $this->_cleanObjectDatas($result);
-      }
-      return false;
+                        $request_data->multicurrency_subprice
+        );
+
+        if ($updateRes > 0) {
+            $result = $this->get($id);
+            unset($result->line);
+            return $this->_cleanObjectDatas($result);
+        }
+        return false;
     }*/
 
     /**
@@ -414,9 +414,9 @@ class Shipments extends DolibarrApi
      */
     function put($id, $request_data = null)
     {
-      if (! DolibarrApiAccess::$user->rights->expedition->creer) {
-		  	throw new RestException(401);
-		  }
+        if (! DolibarrApiAccess::$user->rights->expedition->creer) {
+            throw new RestException(401);
+        }
 
         $result = $this->shipment->fetch($id);
         if (! $result) {
@@ -495,15 +495,15 @@ class Shipments extends DolibarrApi
      */
     function validate($id, $notrigger = 0)
     {
-        if(! DolibarrApiAccess::$user->rights->expedition->creer) {
+        if (! DolibarrApiAccess::$user->rights->expedition->creer) {
 			throw new RestException(401);
 		}
         $result = $this->shipment->fetch($id);
-        if( ! $result ) {
+        if ( ! $result ) {
             throw new RestException(404, 'Shipment not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
+		if ( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
 		}
 
@@ -514,14 +514,14 @@ class Shipments extends DolibarrApi
 		if ($result < 0) {
 		    throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error);
 		}
-	$result = $this->shipment->fetch($id);
-        if( ! $result ) {
+        $result = $this->shipment->fetch($id);
+        if ( ! $result ) {
             throw new RestException(404, 'Shipment not found');
         }
 
-	if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
+        if ( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-       }
+        }
 
         $this->shipment->fetchObjectLinked();
         return $this->_cleanObjectDatas($this->shipment);
@@ -631,8 +631,8 @@ class Shipments extends DolibarrApi
 
         if (! empty($object->lines) && is_array($object->lines))
         {
-        	foreach ($object->lines as $line)
-        	{
+            foreach ($object->lines as $line)
+            {
         		unset($line->tva_tx);
         		unset($line->vat_src_code);
         		unset($line->total_ht);

+ 27 - 27
htdocs/expensereport/class/api_expensereports.class.php

@@ -47,8 +47,8 @@ class ExpenseReports extends DolibarrApi
      */
     function __construct()
     {
-		global $db, $conf;
-		$this->db = $db;
+        global $db, $conf;
+        $this->db = $db;
         $this->expensereport = new ExpenseReport($this->db);
     }
 
@@ -163,9 +163,9 @@ class ExpenseReports extends DolibarrApi
      */
     function post($request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->expensereport->creer) {
-			  throw new RestException(401, "Insuffisant rights");
-		  }
+        if(! DolibarrApiAccess::$user->rights->expensereport->creer) {
+            throw new RestException(401, "Insuffisant rights");
+        }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
@@ -198,24 +198,24 @@ class ExpenseReports extends DolibarrApi
 /*
     function getLines($id)
     {
-      if(! DolibarrApiAccess::$user->rights->expensereport->lire) {
-		  	throw new RestException(401);
-		  }
+        if(! DolibarrApiAccess::$user->rights->expensereport->lire) {
+            throw new RestException(401);
+        }
 
-      $result = $this->expensereport->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'expensereport not found');
-      }
+        $result = $this->expensereport->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'expensereport not found');
+        }
 
-		  if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-      $this->expensereport->getLinesArray();
-      $result = array();
-      foreach ($this->expensereport->lines as $line) {
-        array_push($result,$this->_cleanObjectDatas($line));
-      }
-      return $result;
+        if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $this->expensereport->getLinesArray();
+        $result = array();
+        foreach ($this->expensereport->lines as $line) {
+            array_push($result,$this->_cleanObjectDatas($line));
+        }
+        return $result;
     }
 */
 
@@ -387,18 +387,18 @@ class ExpenseReports extends DolibarrApi
      */
     function put($id, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->expensereport->creer) {
-		  	throw new RestException(401);
-		  }
+        if(! DolibarrApiAccess::$user->rights->expensereport->creer) {
+            throw new RestException(401);
+        }
 
         $result = $this->expensereport->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'expensereport not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
         foreach($request_data as $field => $value) {
             if ($field == 'id') continue;
             $this->expensereport->$field = $value;

+ 11 - 12
htdocs/expensereport/payment/payment.php

@@ -188,18 +188,17 @@ if ($action == 'create' || empty($action))
 	$total = $expensereport->total_ttc;
 
 	// autofill remainder amount
-	if (! empty($conf->use_javascript_ajax))
-		{
-			print "\n".'<script type="text/javascript" language="javascript">';
-			//Add js for AutoFill
-			print ' $(document).ready(function () {';
-			print ' 	$(".AutoFillAmount").on(\'click touchstart\', function(){
-                            var amount = $(this).data("value");
-							document.getElementById($(this).data(\'rowid\')).value = amount ;
-						});';
-			print '	});'."\n";
-			print '	</script>'."\n";
-		}
+	if (! empty($conf->use_javascript_ajax)) {
+		print "\n".'<script type="text/javascript" language="javascript">';
+		//Add js for AutoFill
+		print ' $(document).ready(function () {';
+		print ' 	$(".AutoFillAmount").on(\'click touchstart\', function(){
+                        var amount = $(this).data("value");
+						document.getElementById($(this).data(\'rowid\')).value = amount ;
+					});';
+        print "\t});\n";
+        print "</script>\n";
+    }
 
 	print load_fiche_titre($langs->trans("DoPayment"));
 

+ 1 - 1
htdocs/exports/export.php

@@ -806,7 +806,7 @@ if ($step == 3 && $datatoexport)
 
 		$tablename=getablenamefromfield($code,$sqlmaxforexport);
 		$htmltext ='<b>'.$langs->trans("Name").':</b> '.$text.'<br>';
-			if (! empty($objexport->array_export_special[0][$code]))
+        if (! empty($objexport->array_export_special[0][$code]))
 		{
 		    $htmltext.='<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
 		}

+ 17 - 18
htdocs/fichinter/class/api_interventions.class.php

@@ -191,9 +191,9 @@ class Interventions extends DolibarrApi
      */
     function post($request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->ficheinter->creer) {
-			  throw new RestException(401, "Insuffisant rights");
-		  }
+        if(! DolibarrApiAccess::$user->rights->ficheinter->creer) {
+            throw new RestException(401, "Insuffisant rights");
+        }
         // Check mandatory fields
         $result = $this->_validate($request_data);
         foreach($request_data as $field => $value) {
@@ -254,8 +254,8 @@ class Interventions extends DolibarrApi
     function postLine($id, $request_data = null)
     {
         if(! DolibarrApiAccess::$user->rights->ficheinter->creer) {
-                          throw new RestException(401, "Insuffisant rights");
-                  }
+            throw new RestException(401, "Insuffisant rights");
+        }
         // Check mandatory fields
         $result = $this->_validateLine($request_data);
 
@@ -267,9 +267,9 @@ class Interventions extends DolibarrApi
             throw new RestException(404, 'Intervention not found');
         }
 
-                if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
-                        throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-                }
+        if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
         $updateRes = $this->fichinter->addLine(
                 DolibarrApiAccess::$user,
@@ -280,10 +280,9 @@ class Interventions extends DolibarrApi
         );
 
         if ($updateRes > 0) {
-        	return $updateRes;
-        }
-        else {
-        	throw new RestException(400, $this->fichinter->error);
+            return $updateRes;
+        } else {
+            throw new RestException(400, $this->fichinter->error);
         }
     }
 
@@ -337,8 +336,8 @@ class Interventions extends DolibarrApi
     function validate($id, $notrigger = 0)
     {
         if(! DolibarrApiAccess::$user->rights->ficheinter->creer) {
-                          throw new RestException(401, "Insuffisant rights");
-                  }
+            throw new RestException(401, "Insuffisant rights");
+        }
         $result = $this->fichinter->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'Intervention not found');
@@ -350,10 +349,10 @@ class Interventions extends DolibarrApi
 
         $result = $this->fichinter->setValid(DolibarrApiAccess::$user, $notrigger);
         if ($result == 0) {
-        	throw new RestException(304, 'Error nothing done. May be object is already validated');
+            throw new RestException(304, 'Error nothing done. May be object is already validated');
         }
         if ($result < 0) {
-        	throw new RestException(500, 'Error when validating Intervention: '.$this->commande->error);
+            throw new RestException(500, 'Error when validating Intervention: '.$this->commande->error);
         }
 
         $this->fichinter->fetchObjectLinked();
@@ -388,10 +387,10 @@ class Interventions extends DolibarrApi
         $result = $this->fichinter->setStatut(3);
 
         if ($result == 0) {
-        	throw new RestException(304, 'Error nothing done. May be object is already closed');
+            throw new RestException(304, 'Error nothing done. May be object is already closed');
         }
         if ($result < 0) {
-        	throw new RestException(500, 'Error when closing Intervention: '.$this->fichinter->error);
+            throw new RestException(500, 'Error when closing Intervention: '.$this->fichinter->error);
         }
 
         $this->fichinter->fetchObjectLinked();

+ 51 - 49
htdocs/fourn/class/fournisseur.commande.class.php

@@ -3082,54 +3082,56 @@ class CommandeFournisseur extends CommonOrder
     					    }
     					    return 4;
     					}
-    				}elseif(! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) )
-				{//set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...)
+    				} elseif (! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) {
+                        //set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...)
 
-					$close=0;
+					    $close=0;
 
-					if( count($diff_array) > 0 )
-					{//there are some difference between  the two arrays
+					    if( count($diff_array) > 0 )
+					    {
+                            //there are some difference between  the two arrays
 
-						//scan the array of results
-						foreach($diff_array as $key => $value)
-						{//if the quantity delivered is greater or equal to wish quantity
-							if($qtydelivered[$key] >= $qtywished[$key] )
-							{
-								$close++;
-							}
-						}
-					}
-
-
-					if($close == count($diff_array))
-					{//all the products are received equal or more than the wished quantity
-						if ($closeopenorder)
-    						{
-    							$ret = $this->Livraison($user, $date_liv, 'tot', $comment);   // GETPOST("type") is 'tot', 'par', 'nev', 'can'
-        						if ($ret<0) {
-        							return -1;
-        						}
-    					    		return 5;
-    						}
-    						else
-    						{
-    					   	 	//Diff => received partially
-    					  		$ret = $this->Livraison($user, $date_liv, 'par', $comment);   // GETPOST("type") is 'tot', 'par', 'nev', 'can'
-							if ($ret<0) {
-								return -1;
-							}
-							return 4;
-						}
-					}
-					else
-					{//all the products are not received
-						$ret = $this->Livraison($user, $date_liv, 'par', $comment);   // GETPOST("type") is 'tot', 'par', 'nev', 'can'
-						if ($ret<0) {
-							return -1;
-						}
-						return 4;
-					}
-				}
+						    //scan the array of results
+						    foreach($diff_array as $key => $value)
+						    {
+                                //if the quantity delivered is greater or equal to wish quantity
+							    if($qtydelivered[$key] >= $qtywished[$key] )
+							    {
+								    $close++;
+							    }
+						    }
+					    }
+
+
+					    if($close == count($diff_array)) {
+                            //all the products are received equal or more than the wished quantity
+						    if ($closeopenorder) {
+    						    $ret = $this->Livraison($user, $date_liv, 'tot', $comment);   // GETPOST("type") is 'tot', 'par', 'nev', 'can'
+        					    if ($ret<0) {
+        						    return -1;
+        					    }
+    					        return 5;
+    					    }
+    					    else
+    					    {
+    					        //Diff => received partially
+    					        $ret = $this->Livraison($user, $date_liv, 'par', $comment);   // GETPOST("type") is 'tot', 'par', 'nev', 'can'
+							    if ($ret<0) {
+								    return -1;
+							    }
+							    return 4;
+						    }
+					    }
+					    else
+					    {
+                            //all the products are not received
+						    $ret = $this->Livraison($user, $date_liv, 'par', $comment);   // GETPOST("type") is 'tot', 'par', 'nev', 'can'
+						    if ($ret<0) {
+							    return -1;
+						    }
+						    return 4;
+					    }
+				    }
     				else
     				{
     					//Diff => received partially
@@ -3145,7 +3147,7 @@ class CommandeFournisseur extends CommonOrder
     	}
     	return 0;
     }
-	
+
     /**
      *	Load array this->receptions of lines of shipments with nb of products sent for each order line
      *  Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
@@ -3169,7 +3171,7 @@ class CommandeFournisseur extends CommonOrder
         if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product;
         if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut;
         $sql.= ' GROUP BY cd.rowid, cd.fk_product';
-        
+
 
         dol_syslog(get_class($this)."::loadReceptions", LOG_DEBUG);
         $result = $this->db->query($sql);
@@ -3184,7 +3186,7 @@ class CommandeFournisseur extends CommonOrder
                 $i++;
             }
             $this->db->free();
-			
+
             return $num;
         }
         else
@@ -3319,7 +3321,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
 	            $this->total_ttc        = $objp->total_ttc;
 	            $this->product_type     = $objp->product_type;
 	            $this->special_code     = $objp->special_code;
-	
+
     	        $this->ref	            = $objp->product_ref;
 	            $this->product_ref      = $objp->product_ref;
 	            $this->product_libelle  = $objp->product_libelle;

+ 2 - 2
htdocs/fourn/class/fournisseur.commande.dispatch.class.php

@@ -312,7 +312,7 @@ class CommandeFournisseurDispatch extends CommonObject
         }
         else
         {
-      	    $this->error="Error ".$this->db->lasterror();
+            $this->error="Error ".$this->db->lasterror();
             return -1;
         }
     }
@@ -391,7 +391,7 @@ class CommandeFournisseurDispatch extends CommonObject
 	            $result=$this->call_trigger('LINERECEPTION_UPDATE',$user);
 	            if ($result < 0) $error++;
 	            //// End call triggers
-			 }
+			}
 		}
 
         // Commit or rollback

+ 1 - 1
htdocs/fourn/class/fournisseur.facture.class.php

@@ -3218,4 +3218,4 @@ class SupplierInvoiceLine extends CommonObjectLine
             return -2;
         }
     }
- }
+}

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

@@ -2224,227 +2224,227 @@ elseif (! empty($object->id))
 
 	dol_fiche_end();
 
-		/**
-		 * Boutons actions
-		 */
+	/**
+	 * Boutons actions
+	 */
+
+	if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete')
+	{
+		print '<div	class="tabsAction">';
 
-		if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete')
+		$parameters = array();
+		$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
+		// modified by hook
+		if (empty($reshook))
 		{
-			print '<div	class="tabsAction">';
+			$object->fetchObjectLinked();		// Links are used to show or not button, so we load them now.
 
-			$parameters = array();
-			$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
-			// modified by hook
-			if (empty($reshook))
+			// Validate
+			if ($object->statut == 0 && $num > 0)
 			{
-				$object->fetchObjectLinked();		// Links are used to show or not button, so we load them now.
-
-				// Validate
-				if ($object->statut == 0 && $num > 0)
+				if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer))
+			   	|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate)))
 				{
-					if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer))
-				   	|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate)))
-					{
-						$tmpbuttonlabel=$langs->trans('Validate');
-						if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove");
+					$tmpbuttonlabel=$langs->trans('Validate');
+					if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove");
 
-						print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid">';
-						print $tmpbuttonlabel;
-						print '</a>';
-					}
+					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid">';
+					print $tmpbuttonlabel;
+					print '</a>';
 				}
-				// Create event
-				/*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) 	// Add hidden condition because this is not a "workflow" action so should appears somewhere else on page.
+			}
+			// Create event
+			/*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) 	// Add hidden condition because this is not a "workflow" action so should appears somewhere else on page.
+			{
+				print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a></div>';
+			}*/
+
+			// Modify
+			if ($object->statut == 1)
+			{
+				if ($user->rights->fournisseur->commande->commander)
 				{
-					print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a></div>';
-				}*/
+					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a>';
+				}
+			}
 
-				// Modify
-				if ($object->statut == 1)
+			// Approve
+			if ($object->statut == 1)
+			{
+				if ($user->rights->fournisseur->commande->approuver)
 				{
-					if ($user->rights->fournisseur->commande->commander)
+					if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && ! empty($object->user_approve_id))
 					{
-						print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a>';
+						print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("FirstApprovalAlreadyDone")).'">'.$langs->trans("ApproveOrder").'</a>';
+					}
+					else
+					{
+						print '<a class="butAction"	href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve">'.$langs->trans("ApproveOrder").'</a>';
 					}
 				}
+				else
+				{
+					print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("ApproveOrder").'</a>';
+				}
+			}
 
-				// Approve
+			// Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set)
+			if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)
+			{
 				if ($object->statut == 1)
 				{
-					if ($user->rights->fournisseur->commande->approuver)
+					if ($user->rights->fournisseur->commande->approve2)
 					{
-						if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && ! empty($object->user_approve_id))
+						if (! empty($object->user_approve_id2))
 						{
-							print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("FirstApprovalAlreadyDone")).'">'.$langs->trans("ApproveOrder").'</a>';
+							print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("SecondApprovalAlreadyDone")).'">'.$langs->trans("Approve2Order").'</a>';
 						}
 						else
 						{
-							print '<a class="butAction"	href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve">'.$langs->trans("ApproveOrder").'</a>';
+							print '<a class="butAction"	href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve2">'.$langs->trans("Approve2Order").'</a>';
 						}
 					}
 					else
 					{
-						print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("ApproveOrder").'</a>';
+						print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("Approve2Order").'</a>';
 					}
 				}
+			}
 
-				// Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set)
-				if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)
+			// Refuse
+			if ($object->statut == 1)
+			{
+				if ($user->rights->fournisseur->commande->approuver || $user->rights->fournisseur->commande->approve2)
 				{
-					if ($object->statut == 1)
-					{
-						if ($user->rights->fournisseur->commande->approve2)
-						{
-							if (! empty($object->user_approve_id2))
-							{
-								print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("SecondApprovalAlreadyDone")).'">'.$langs->trans("Approve2Order").'</a>';
-							}
-							else
-							{
-								print '<a class="butAction"	href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve2">'.$langs->trans("Approve2Order").'</a>';
-							}
-						}
-						else
-						{
-							print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("Approve2Order").'</a>';
-						}
-					}
+					print '<a class="butAction"	href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=refuse">'.$langs->trans("RefuseOrder").'</a>';
 				}
-
-				// Refuse
-				if ($object->statut == 1)
+				else
 				{
-					if ($user->rights->fournisseur->commande->approuver || $user->rights->fournisseur->commande->approve2)
-					{
-						print '<a class="butAction"	href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=refuse">'.$langs->trans("RefuseOrder").'</a>';
-					}
-					else
-					{
-						print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("RefuseOrder").'</a>';
-					}
+					print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("RefuseOrder").'</a>';
 				}
+			}
 
-				// Send
-				if (in_array($object->statut, array(2, 3, 4, 5)))
+			// Send
+			if (in_array($object->statut, array(2, 3, 4, 5)))
+			{
+				if ($user->rights->fournisseur->commande->commander)
 				{
-					if ($user->rights->fournisseur->commande->commander)
-					{
-						print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>';
-					}
+					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>';
 				}
+			}
 
-				// Reopen
-				if (in_array($object->statut, array(2)))
+			// Reopen
+			if (in_array($object->statut, array(2)))
+			{
+				$buttonshown=0;
+				if (! $buttonshown && $user->rights->fournisseur->commande->approuver)
 				{
-					$buttonshown=0;
-					if (! $buttonshown && $user->rights->fournisseur->commande->approuver)
-					{
-						if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY)
-							|| (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id))
-						{
-							print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>';
-							$buttonshown++;
-						}
-					}
-					if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
+					if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY)
+						|| (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id))
 					{
-						if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY)
-							|| (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2))
-						{
-							print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>';
-						}
+						print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>';
+						$buttonshown++;
 					}
 				}
-				if (in_array($object->statut, array(3, 4, 5, 6, 7, 9)))
+				if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
 				{
-					if ($user->rights->fournisseur->commande->commander)
+					if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY)
+						|| (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2))
 					{
-						print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
+						print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>';
 					}
 				}
+			}
+			if (in_array($object->statut, array(3, 4, 5, 6, 7, 9)))
+			{
+				if ($user->rights->fournisseur->commande->commander)
+				{
+					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
+				}
+			}
 
-				// Ship
+			// Ship
 
-				if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
-				{
-					if (in_array($object->statut, array(3,4,5))) {
-						if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) {
-							print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fourn/commande/dispatch.php?id=' . $object->id . '">' . $langs->trans('ReceiveProducts') . '</a></div>';
-						} else {
-							print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('ReceiveProducts') . '</a></div>';
-						}
+			if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
+			{
+				if (in_array($object->statut, array(3,4,5))) {
+					if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) {
+						print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fourn/commande/dispatch.php?id=' . $object->id . '">' . $langs->trans('ReceiveProducts') . '</a></div>';
+					} else {
+						print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('ReceiveProducts') . '</a></div>';
 					}
 				}
+			}
 
-				if ($object->statut == 2)
+			if ($object->statut == 2)
+			{
+				if ($user->rights->fournisseur->commande->commander)
 				{
-					if ($user->rights->fournisseur->commande->commander)
-					{
-						print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=makeorder#makeorder">'.$langs->trans("MakeOrder").'</a></div>';
-					}
-					else
-					{
-						print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("MakeOrder").'</a></div>';
-					}
+					print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=makeorder#makeorder">'.$langs->trans("MakeOrder").'</a></div>';
 				}
-
-				// Create bill
-				if (! empty($conf->facture->enabled))
+				else
 				{
-					if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1))  // statut 2 means approved, 7 means canceled
-					{
-						if ($user->rights->fournisseur->facture->creer)
-						{
-							print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
-						}
-					}
+					print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("MakeOrder").'</a></div>';
 				}
+			}
 
-				// Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not)
-				if ($user->rights->fournisseur->commande->creer && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1)  // statut 2 means approved
+			// Create bill
+			if (! empty($conf->facture->enabled))
+			{
+				if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1))  // statut 2 means approved, 7 means canceled
 				{
-					if (empty($conf->facture->enabled))
+					if ($user->rights->fournisseur->facture->creer)
 					{
-						print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
-					}
-					elseif (!empty($object->linkedObjectsIds['invoice_supplier']))
-					{
-						if ($user->rights->fournisseur->facture->creer)
-						{
-							print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
-						}
+						print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
 					}
 				}
+			}
 
-				// Create a remote order using WebService only if module is activated
-				if (! empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted
-				{
-					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=webservice&amp;mode=init">'.$langs->trans('CreateRemoteOrder').'</a>';
-				}
-
-				// Clone
-				if ($user->rights->fournisseur->commande->creer)
+			// Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not)
+			if ($user->rights->fournisseur->commande->creer && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1)  // statut 2 means approved
+			{
+				if (empty($conf->facture->enabled))
 				{
-					print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>';
+					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
 				}
-
-				// Cancel
-				if ($object->statut == 2)
+				elseif (!empty($object->linkedObjectsIds['invoice_supplier']))
 				{
-					if ($user->rights->fournisseur->commande->commander)
+					if ($user->rights->fournisseur->facture->creer)
 					{
-						print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>';
+						print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
 					}
 				}
+			}
 
-				// Delete
-				if ($user->rights->fournisseur->commande->supprimer)
+			// Create a remote order using WebService only if module is activated
+			if (! empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted
+			{
+				print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=webservice&amp;mode=init">'.$langs->trans('CreateRemoteOrder').'</a>';
+			}
+
+			// Clone
+			if ($user->rights->fournisseur->commande->creer)
+			{
+				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>';
+			}
+
+			// Cancel
+			if ($object->statut == 2)
+			{
+				if ($user->rights->fournisseur->commande->commander)
 				{
-					print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
+					print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>';
 				}
 			}
 
-			print "</div>";
+			// Delete
+			if ($user->rights->fournisseur->commande->supprimer)
+			{
+				print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
+			}
+		}
+
+		print "</div>";
 
 
 

+ 20 - 20
htdocs/fourn/commande/dispatch.php

@@ -461,7 +461,7 @@ if ($id > 0 || ! empty($ref)) {
 
 		if(empty($conf->reception->enabled))print '<form method="POST" action="dispatch.php?id=' . $object->id . '">';
         else print  '<form method="post" action="'.dol_buildpath('/reception/card.php',1).'?originid='.$object->id.'&origin=supplierorder">';
-		
+
 		print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
 		if(empty($conf->reception->enabled))print '<input type="hidden" name="action" value="dispatch">';
 		else print '<input type="hidden" name="action" value="create">';
@@ -726,19 +726,19 @@ if ($id > 0 || ! empty($ref)) {
 			// modified by hook
 			if (empty($reshook))
 			{
-				if(empty($conf->reception->enabled)){
-				print $langs->trans("Comment").' : ';
-				print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
-				print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
-				// print ' / '.$object->ref_supplier; // Not yet available
-				print '" class="flat"><br>';
-
-				print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
-			}
-			empty($conf->reception->enabled)?$dispatchBt=$langs->trans("DispatchVerb"):$dispatchBt=$langs->trans("Receive");
-
-			print '<br><input type="submit" class="button" value="' . $dispatchBt. '"';
-				if (count($listwarehouses) <= 0)
+                if (empty($conf->reception->enabled)){
+                    print $langs->trans("Comment").' : ';
+                    print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
+                    print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
+                    // print ' / '.$object->ref_supplier; // Not yet available
+                    print '" class="flat"><br>';
+
+                    print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
+                }
+                empty($conf->reception->enabled)?$dispatchBt=$langs->trans("DispatchVerb"):$dispatchBt=$langs->trans("Receive");
+
+                print '<br><input type="submit" class="button" value="' . $dispatchBt. '"';
+                if (count($listwarehouses) <= 0)
 					print ' disabled';
 				print '>';
 			}
@@ -787,7 +787,7 @@ if ($id > 0 || ! empty($ref)) {
 
 			print '<tr class="liste_titre">';
 			if($conf->reception->enabled)print '<td>' . $langs->trans("Reception") . '</td>';
-			
+
 			print '<td>' . $langs->trans("Product") . '</td>';
 			print '<td>' . $langs->trans("DateCreation") . '</td>';
 			print '<td>' . $langs->trans("DateDeliveryPlanned") . '</td>';
@@ -809,19 +809,19 @@ if ($id > 0 || ! empty($ref)) {
 				$objp = $db->fetch_object($resql);
 
 				print "<tr " . $bc[$var] . ">";
-				
+
 				if(!empty($conf->reception->enabled) ){
 					print '<td>';
 					if (!empty($objp->fk_reception)){
-						
+
 						$reception = new Reception($db);
 						$reception->fetch($objp->fk_reception);
 						print $reception->getNomUrl(1);
 					}
-				
+
 					print "</td>";
 				}
-				
+
 				print '<td>';
 				print '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp->fk_product . '">' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . '</a>';
 				print ' - ' . $objp->label;
@@ -895,7 +895,7 @@ if ($id > 0 || ! empty($ref)) {
 					print '</td>';
 					print '<td align="center">';
 					print '</td>';
-				
+
 
 
 				print "</tr>\n";

+ 6 - 6
htdocs/index.php

@@ -552,8 +552,8 @@ if ($showweather)
 $nbworkboardempty=0;
 if (! empty($valid_dashboardlines))
 {
-	$boxwork.='<tr class="nohover"><td class="tdboxstats nohover flexcontainer centpercent"><div style="display: flex: flex-wrap: wrap">';
-	
+    $boxwork.='<tr class="nohover"><td class="tdboxstats nohover flexcontainer centpercent"><div style="display: flex: flex-wrap: wrap">';
+
     foreach($valid_dashboardlines as $board)
     {
         if (empty($board->nbtodo)) $nbworkboardempty++;
@@ -567,9 +567,9 @@ if (! empty($valid_dashboardlines))
         $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' '.$board->label.'</span><br>';
         $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0)?' dashboardlineok':'').'">'.$board->nbtodo.'</span></a>';
         if ($board->total > 0 && ! empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX))
-	{
-		$boxwork .= '&nbsp;/&nbsp;<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0)?' dashboardlineok':'').'">'.price($board->total)	.'</span></a>';
-	}
+        {
+            $boxwork .= '&nbsp;/&nbsp;<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0)?' dashboardlineok':'').'">'.price($board->total)	.'</span></a>';
+        }
         $boxwork .= '</div>';
         if ($board->nbtodolate > 0)
         {
@@ -593,7 +593,7 @@ if (! empty($valid_dashboardlines))
     $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
     $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
     $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
-    
+
     $boxwork .='</div>';
     $boxwork .='</td></tr>';
 }

+ 15 - 15
htdocs/install/check.php

@@ -312,19 +312,19 @@ else
 				}
 				else
 				{
-            require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
+                    require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
 
-            // If password is encoded, we decode it
-            if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
-            {
-                require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
-                if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
-                {
-                    $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);	// We need to set this as it is used to know the password was initially crypted
-                    $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
-                }
-                else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
-            }
+                    // If password is encoded, we decode it
+                    if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
+                    {
+                        require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
+                        if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
+                        {
+                            $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);	// We need to set this as it is used to know the password was initially crypted
+                            $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+                        }
+                        else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+                    }
 
     				// $conf already created in inc.php
     				$conf->db->type = $dolibarr_main_db_type;
@@ -333,12 +333,12 @@ else
     				$conf->db->name = $dolibarr_main_db_name;
     				$conf->db->user = $dolibarr_main_db_user;
     				$conf->db->pass = $dolibarr_main_db_pass;
-            $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
+                    $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
     				if ($db->connected && $db->database_selected)
     				{
     					$ok=true;
     				}
-        }
+                }
 			}
 		}
 
@@ -569,7 +569,7 @@ else
             print '</table>'."\n";
             print '</div>';
         }
-	}
+    }
 }
 
 print '<script type="text/javascript">

+ 3 - 4
htdocs/modulebuilder/admin/setup.php

@@ -35,10 +35,9 @@ $backtopage = GETPOST('backtopage', 'alpha');
 /*
  * Actions
  */
-if($action=="update"){
-   $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README'), 'chaine', 0, '', $conf->entity);
-   if ($res1 < 0)
-    {
+if ($action=="update"){
+    $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README'), 'chaine', 0, '', $conf->entity);
+    if ($res1 < 0) {
         setEventMessages('ErrorFailedToSaveDate', null, 'errors');
         $db->rollback();
     }

+ 264 - 264
htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php

@@ -40,274 +40,274 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
  */
 class InterfaceMyModuleTriggers extends DolibarrTriggers
 {
-	/**
-	 * @var DoliDB Database handler
-	 */
-	protected $db;
-
-	/**
-	 * Constructor
-	 *
-	 * @param DoliDB $db Database handler
-	 */
-	public function __construct($db)
-	{
-		$this->db = $db;
-
-		$this->name = preg_replace('/^Interface/i', '', get_class($this));
-		$this->family = "demo";
-		$this->description = "MyModule triggers.";
-		// 'development', 'experimental', 'dolibarr' or version
-		$this->version = 'development';
-		$this->picto = 'mymodule@mymodule';
-	}
-
-	/**
-	 * Trigger name
-	 *
-	 * @return string Name of trigger file
-	 */
-	public function getName()
-	{
-		return $this->name;
-	}
-
-	/**
-	 * Trigger description
-	 *
-	 * @return string Description of trigger file
-	 */
-	public function getDesc()
-	{
-		return $this->description;
-	}
-
-
-	/**
-	 * Function called when a Dolibarrr business event is done.
-	 * All functions "runTrigger" are triggered if file
-	 * is inside directory core/triggers
-	 *
-	 * @param string 		$action 	Event action code
-	 * @param CommonObject 	$object 	Object
-	 * @param User 			$user 		Object user
-	 * @param Translate 	$langs 		Object langs
-	 * @param Conf 			$conf 		Object conf
-	 * @return int              		<0 if KO, 0 if no triggered ran, >0 if OK
-	 */
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
-	{
+    /**
+     * @var DoliDB Database handler
+     */
+    protected $db;
+
+    /**
+     * Constructor
+     *
+     * @param DoliDB $db Database handler
+     */
+    public function __construct($db)
+    {
+        $this->db = $db;
+
+        $this->name = preg_replace('/^Interface/i', '', get_class($this));
+        $this->family = "demo";
+        $this->description = "MyModule triggers.";
+        // 'development', 'experimental', 'dolibarr' or version
+        $this->version = 'development';
+        $this->picto = 'mymodule@mymodule';
+    }
+
+    /**
+     * Trigger name
+     *
+     * @return string Name of trigger file
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Trigger description
+     *
+     * @return string Description of trigger file
+     */
+    public function getDesc()
+    {
+        return $this->description;
+    }
+
+
+    /**
+     * Function called when a Dolibarrr business event is done.
+     * All functions "runTrigger" are triggered if file
+     * is inside directory core/triggers
+     *
+     * @param string 		$action 	Event action code
+     * @param CommonObject 	$object 	Object
+     * @param User 			$user 		Object user
+     * @param Translate 	$langs 		Object langs
+     * @param Conf 			$conf 		Object conf
+     * @return int              		<0 if KO, 0 if no triggered ran, >0 if OK
+     */
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
+    {
         if (empty($conf->mymodule->enabled)) return 0;     // Module not active, we do nothing
 
-	    // Put here code you want to execute when a Dolibarr business events occurs.
-		// Data and type of action are stored into $object and $action
+        // Put here code you want to execute when a Dolibarr business events occurs.
+        // Data and type of action are stored into $object and $action
 
         switch ($action) {
 
             // Users
-		    //case 'USER_CREATE':
-		    //case 'USER_MODIFY':
-		    //case 'USER_NEW_PASSWORD':
-		    //case 'USER_ENABLEDISABLE':
-		    //case 'USER_DELETE':
-		    //case 'USER_SETINGROUP':
-		    //case 'USER_REMOVEFROMGROUP':
-
-		    // Actions
-		    //case 'ACTION_MODIFY':
-		    //case 'ACTION_CREATE':
-		    //case 'ACTION_DELETE':
-
-		    // Groups
-		    //case 'GROUP_CREATE':
-		    //case 'GROUP_MODIFY':
-		    //case 'GROUP_DELETE':
-
-		    // Companies
-		    //case 'COMPANY_CREATE':
-		    //case 'COMPANY_MODIFY':
-		    //case 'COMPANY_DELETE':
-
-		    // Contacts
-		    //case 'CONTACT_CREATE':
-		    //case 'CONTACT_MODIFY':
-		    //case 'CONTACT_DELETE':
-		    //case 'CONTACT_ENABLEDISABLE':
-
-		    // Products
-		    //case 'PRODUCT_CREATE':
-		    //case 'PRODUCT_MODIFY':
-		    //case 'PRODUCT_DELETE':
-		    //case 'PRODUCT_PRICE_MODIFY':
-		    //case 'PRODUCT_SET_MULTILANGS':
-		    //case 'PRODUCT_DEL_MULTILANGS':
-
-		    //Stock mouvement
-		    //case 'STOCK_MOVEMENT':
-
-		    //MYECMDIR
-		    //case 'MYECMDIR_CREATE':
-		    //case 'MYECMDIR_MODIFY':
-		    //case 'MYECMDIR_DELETE':
-
-		    // Customer orders
-		    //case 'ORDER_CREATE':
-		    //case 'ORDER_MODIFY':
-		    //case 'ORDER_VALIDATE':
-		    //case 'ORDER_DELETE':
-		    //case 'ORDER_CANCEL':
-		    //case 'ORDER_SENTBYMAIL':
-		    //case 'ORDER_CLASSIFY_BILLED':
-		    //case 'ORDER_SETDRAFT':
-		    //case 'LINEORDER_INSERT':
-		    //case 'LINEORDER_UPDATE':
-		    //case 'LINEORDER_DELETE':
-
-		    // Supplier orders
-		    //case 'ORDER_SUPPLIER_CREATE':
-		    //case 'ORDER_SUPPLIER_MODIFY':
-		    //case 'ORDER_SUPPLIER_VALIDATE':
-		    //case 'ORDER_SUPPLIER_DELETE':
-		    //case 'ORDER_SUPPLIER_APPROVE':
-		    //case 'ORDER_SUPPLIER_REFUSE':
-		    //case 'ORDER_SUPPLIER_CANCEL':
-		    //case 'ORDER_SUPPLIER_SENTBYMAIL':
-		    //case 'ORDER_SUPPLIER_DISPATCH':
-		    //case 'LINEORDER_SUPPLIER_DISPATCH':
-		    //case 'LINEORDER_SUPPLIER_CREATE':
-		    //case 'LINEORDER_SUPPLIER_UPDATE':
-		    //case 'LINEORDER_SUPPLIER_DELETE':
-
-		    // Proposals
-		    //case 'PROPAL_CREATE':
-		    //case 'PROPAL_MODIFY':
-		    //case 'PROPAL_VALIDATE':
-		    //case 'PROPAL_SENTBYMAIL':
-		    //case 'PROPAL_CLOSE_SIGNED':
-		    //case 'PROPAL_CLOSE_REFUSED':
-		    //case 'PROPAL_DELETE':
-		    //case 'LINEPROPAL_INSERT':
-		    //case 'LINEPROPAL_UPDATE':
-		    //case 'LINEPROPAL_DELETE':
-
-		    // SupplierProposal
-		    //case 'SUPPLIER_PROPOSAL_CREATE':
-		    //case 'SUPPLIER_PROPOSAL_MODIFY':
-		    //case 'SUPPLIER_PROPOSAL_VALIDATE':
-		    //case 'SUPPLIER_PROPOSAL_SENTBYMAIL':
-		    //case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED':
-		    //case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED':
-		    //case 'SUPPLIER_PROPOSAL_DELETE':
-		    //case 'LINESUPPLIER_PROPOSAL_INSERT':
-		    //case 'LINESUPPLIER_PROPOSAL_UPDATE':
-		    //case 'LINESUPPLIER_PROPOSAL_DELETE':
-
-		    // Contracts
-		    //case 'CONTRACT_CREATE':
-		    //case 'CONTRACT_MODIFY':
-		    //case 'CONTRACT_ACTIVATE':
-		    //case 'CONTRACT_CANCEL':
-		    //case 'CONTRACT_CLOSE':
-		    //case 'CONTRACT_DELETE':
-		    //case 'LINECONTRACT_INSERT':
-		    //case 'LINECONTRACT_UPDATE':
-		    //case 'LINECONTRACT_DELETE':
-
-		    // Bills
-		    //case 'BILL_CREATE':
-		    //case 'BILL_MODIFY':
-		    //case 'BILL_VALIDATE':
-		    //case 'BILL_UNVALIDATE':
-		    //case 'BILL_SENTBYMAIL':
-		    //case 'BILL_CANCEL':
-		    //case 'BILL_DELETE':
-		    //case 'BILL_PAYED':
-		    //case 'LINEBILL_INSERT':
-		    //case 'LINEBILL_UPDATE':
-		    //case 'LINEBILL_DELETE':
-
-		    //Supplier Bill
-		    //case 'BILL_SUPPLIER_CREATE':
-		    //case 'BILL_SUPPLIER_UPDATE':
-		    //case 'BILL_SUPPLIER_DELETE':
-		    //case 'BILL_SUPPLIER_PAYED':
-		    //case 'BILL_SUPPLIER_UNPAYED':
-		    //case 'BILL_SUPPLIER_VALIDATE':
-		    //case 'BILL_SUPPLIER_UNVALIDATE':
-		    //case 'LINEBILL_SUPPLIER_CREATE':
-		    //case 'LINEBILL_SUPPLIER_UPDATE':
-		    //case 'LINEBILL_SUPPLIER_DELETE':
-
-		    // Payments
-		    //case 'PAYMENT_CUSTOMER_CREATE':
-		    //case 'PAYMENT_SUPPLIER_CREATE':
-		    //case 'PAYMENT_ADD_TO_BANK':
-		    //case 'PAYMENT_DELETE':
-
-		    // Online
-		    //case 'PAYMENT_PAYBOX_OK':
-		    //case 'PAYMENT_PAYPAL_OK':
-		    //case 'PAYMENT_STRIPE_OK':
-
-		    // Donation
-		    //case 'DON_CREATE':
-		    //case 'DON_UPDATE':
-		    //case 'DON_DELETE':
-
-		    // Interventions
-		    //case 'FICHINTER_CREATE':
-		    //case 'FICHINTER_MODIFY':
-		    //case 'FICHINTER_VALIDATE':
-		    //case 'FICHINTER_DELETE':
-		    //case 'LINEFICHINTER_CREATE':
-		    //case 'LINEFICHINTER_UPDATE':
-		    //case 'LINEFICHINTER_DELETE':
-
-		    // Members
-		    //case 'MEMBER_CREATE':
-		    //case 'MEMBER_VALIDATE':
-		    //case 'MEMBER_SUBSCRIPTION':
-		    //case 'MEMBER_MODIFY':
-		    //case 'MEMBER_NEW_PASSWORD':
-		    //case 'MEMBER_RESILIATE':
-		    //case 'MEMBER_DELETE':
-
-		    // Categories
-		    //case 'CATEGORY_CREATE':
-		    //case 'CATEGORY_MODIFY':
-		    //case 'CATEGORY_DELETE':
-		    //case 'CATEGORY_SET_MULTILANGS':
-
-		    // Projects
-		    //case 'PROJECT_CREATE':
-		    //case 'PROJECT_MODIFY':
-		    //case 'PROJECT_DELETE':
-
-		    // Project tasks
-		    //case 'TASK_CREATE':
-		    //case 'TASK_MODIFY':
-		    //case 'TASK_DELETE':
-
-		    // Task time spent
-		    //case 'TASK_TIMESPENT_CREATE':
-		    //case 'TASK_TIMESPENT_MODIFY':
-		    //case 'TASK_TIMESPENT_DELETE':
-
-		    // Shipping
-		    //case 'SHIPPING_CREATE':
-		    //case 'SHIPPING_MODIFY':
-		    //case 'SHIPPING_VALIDATE':
-		    //case 'SHIPPING_SENTBYMAIL':
-		    //case 'SHIPPING_BILLED':
-		    //case 'SHIPPING_CLOSED':
-		    //case 'SHIPPING_REOPEN':
-			//case 'SHIPPING_DELETE':
-			//	break;
-			default:
-		        dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
-		        break;
-		    }
-
-		return 0;
-	}
+            //case 'USER_CREATE':
+            //case 'USER_MODIFY':
+            //case 'USER_NEW_PASSWORD':
+            //case 'USER_ENABLEDISABLE':
+            //case 'USER_DELETE':
+            //case 'USER_SETINGROUP':
+            //case 'USER_REMOVEFROMGROUP':
+
+            // Actions
+            //case 'ACTION_MODIFY':
+            //case 'ACTION_CREATE':
+            //case 'ACTION_DELETE':
+
+            // Groups
+            //case 'GROUP_CREATE':
+            //case 'GROUP_MODIFY':
+            //case 'GROUP_DELETE':
+
+            // Companies
+            //case 'COMPANY_CREATE':
+            //case 'COMPANY_MODIFY':
+            //case 'COMPANY_DELETE':
+
+            // Contacts
+            //case 'CONTACT_CREATE':
+            //case 'CONTACT_MODIFY':
+            //case 'CONTACT_DELETE':
+            //case 'CONTACT_ENABLEDISABLE':
+
+            // Products
+            //case 'PRODUCT_CREATE':
+            //case 'PRODUCT_MODIFY':
+            //case 'PRODUCT_DELETE':
+            //case 'PRODUCT_PRICE_MODIFY':
+            //case 'PRODUCT_SET_MULTILANGS':
+            //case 'PRODUCT_DEL_MULTILANGS':
+
+            //Stock mouvement
+            //case 'STOCK_MOVEMENT':
+
+            //MYECMDIR
+            //case 'MYECMDIR_CREATE':
+            //case 'MYECMDIR_MODIFY':
+            //case 'MYECMDIR_DELETE':
+
+            // Customer orders
+            //case 'ORDER_CREATE':
+            //case 'ORDER_MODIFY':
+            //case 'ORDER_VALIDATE':
+            //case 'ORDER_DELETE':
+            //case 'ORDER_CANCEL':
+            //case 'ORDER_SENTBYMAIL':
+            //case 'ORDER_CLASSIFY_BILLED':
+            //case 'ORDER_SETDRAFT':
+            //case 'LINEORDER_INSERT':
+            //case 'LINEORDER_UPDATE':
+            //case 'LINEORDER_DELETE':
+
+            // Supplier orders
+            //case 'ORDER_SUPPLIER_CREATE':
+            //case 'ORDER_SUPPLIER_MODIFY':
+            //case 'ORDER_SUPPLIER_VALIDATE':
+            //case 'ORDER_SUPPLIER_DELETE':
+            //case 'ORDER_SUPPLIER_APPROVE':
+            //case 'ORDER_SUPPLIER_REFUSE':
+            //case 'ORDER_SUPPLIER_CANCEL':
+            //case 'ORDER_SUPPLIER_SENTBYMAIL':
+            //case 'ORDER_SUPPLIER_DISPATCH':
+            //case 'LINEORDER_SUPPLIER_DISPATCH':
+            //case 'LINEORDER_SUPPLIER_CREATE':
+            //case 'LINEORDER_SUPPLIER_UPDATE':
+            //case 'LINEORDER_SUPPLIER_DELETE':
+
+            // Proposals
+            //case 'PROPAL_CREATE':
+            //case 'PROPAL_MODIFY':
+            //case 'PROPAL_VALIDATE':
+            //case 'PROPAL_SENTBYMAIL':
+            //case 'PROPAL_CLOSE_SIGNED':
+            //case 'PROPAL_CLOSE_REFUSED':
+            //case 'PROPAL_DELETE':
+            //case 'LINEPROPAL_INSERT':
+            //case 'LINEPROPAL_UPDATE':
+            //case 'LINEPROPAL_DELETE':
+
+            // SupplierProposal
+            //case 'SUPPLIER_PROPOSAL_CREATE':
+            //case 'SUPPLIER_PROPOSAL_MODIFY':
+            //case 'SUPPLIER_PROPOSAL_VALIDATE':
+            //case 'SUPPLIER_PROPOSAL_SENTBYMAIL':
+            //case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED':
+            //case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED':
+            //case 'SUPPLIER_PROPOSAL_DELETE':
+            //case 'LINESUPPLIER_PROPOSAL_INSERT':
+            //case 'LINESUPPLIER_PROPOSAL_UPDATE':
+            //case 'LINESUPPLIER_PROPOSAL_DELETE':
+
+            // Contracts
+            //case 'CONTRACT_CREATE':
+            //case 'CONTRACT_MODIFY':
+            //case 'CONTRACT_ACTIVATE':
+            //case 'CONTRACT_CANCEL':
+            //case 'CONTRACT_CLOSE':
+            //case 'CONTRACT_DELETE':
+            //case 'LINECONTRACT_INSERT':
+            //case 'LINECONTRACT_UPDATE':
+            //case 'LINECONTRACT_DELETE':
+
+            // Bills
+            //case 'BILL_CREATE':
+            //case 'BILL_MODIFY':
+            //case 'BILL_VALIDATE':
+            //case 'BILL_UNVALIDATE':
+            //case 'BILL_SENTBYMAIL':
+            //case 'BILL_CANCEL':
+            //case 'BILL_DELETE':
+            //case 'BILL_PAYED':
+            //case 'LINEBILL_INSERT':
+            //case 'LINEBILL_UPDATE':
+            //case 'LINEBILL_DELETE':
+
+            //Supplier Bill
+            //case 'BILL_SUPPLIER_CREATE':
+            //case 'BILL_SUPPLIER_UPDATE':
+            //case 'BILL_SUPPLIER_DELETE':
+            //case 'BILL_SUPPLIER_PAYED':
+            //case 'BILL_SUPPLIER_UNPAYED':
+            //case 'BILL_SUPPLIER_VALIDATE':
+            //case 'BILL_SUPPLIER_UNVALIDATE':
+            //case 'LINEBILL_SUPPLIER_CREATE':
+            //case 'LINEBILL_SUPPLIER_UPDATE':
+            //case 'LINEBILL_SUPPLIER_DELETE':
+
+            // Payments
+            //case 'PAYMENT_CUSTOMER_CREATE':
+            //case 'PAYMENT_SUPPLIER_CREATE':
+            //case 'PAYMENT_ADD_TO_BANK':
+            //case 'PAYMENT_DELETE':
+
+            // Online
+            //case 'PAYMENT_PAYBOX_OK':
+            //case 'PAYMENT_PAYPAL_OK':
+            //case 'PAYMENT_STRIPE_OK':
+
+            // Donation
+            //case 'DON_CREATE':
+            //case 'DON_UPDATE':
+            //case 'DON_DELETE':
+
+            // Interventions
+            //case 'FICHINTER_CREATE':
+            //case 'FICHINTER_MODIFY':
+            //case 'FICHINTER_VALIDATE':
+            //case 'FICHINTER_DELETE':
+            //case 'LINEFICHINTER_CREATE':
+            //case 'LINEFICHINTER_UPDATE':
+            //case 'LINEFICHINTER_DELETE':
+
+            // Members
+            //case 'MEMBER_CREATE':
+            //case 'MEMBER_VALIDATE':
+            //case 'MEMBER_SUBSCRIPTION':
+            //case 'MEMBER_MODIFY':
+            //case 'MEMBER_NEW_PASSWORD':
+            //case 'MEMBER_RESILIATE':
+            //case 'MEMBER_DELETE':
+
+            // Categories
+            //case 'CATEGORY_CREATE':
+            //case 'CATEGORY_MODIFY':
+            //case 'CATEGORY_DELETE':
+            //case 'CATEGORY_SET_MULTILANGS':
+
+            // Projects
+            //case 'PROJECT_CREATE':
+            //case 'PROJECT_MODIFY':
+            //case 'PROJECT_DELETE':
+
+            // Project tasks
+            //case 'TASK_CREATE':
+            //case 'TASK_MODIFY':
+            //case 'TASK_DELETE':
+
+            // Task time spent
+            //case 'TASK_TIMESPENT_CREATE':
+            //case 'TASK_TIMESPENT_MODIFY':
+            //case 'TASK_TIMESPENT_DELETE':
+
+            // Shipping
+            //case 'SHIPPING_CREATE':
+            //case 'SHIPPING_MODIFY':
+            //case 'SHIPPING_VALIDATE':
+            //case 'SHIPPING_SENTBYMAIL':
+            //case 'SHIPPING_BILLED':
+            //case 'SHIPPING_CLOSED':
+            //case 'SHIPPING_REOPEN':
+            //case 'SHIPPING_DELETE':
+            //    break;
+            default:
+                dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+                break;
+        }
+
+        return 0;
+    }
 }

+ 25 - 25
htdocs/modulebuilder/template/myobject_card.php

@@ -115,31 +115,31 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
 
 if (empty($reshook))
 {
-	$error=0;
-
-	$permissiontoadd = $user->rights->mymodule->write;
-	$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
-    	$backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1);
-	if (empty($backtopage)) {
-	    if (empty($id)) $backtopage = $backurlforlist;
-	    else $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).($id > 0 ? $id : '__ID__');
-    	}
-	$triggermodname = 'MYMODULE_MYOBJECT_MODIFY';	// Name of trigger action code to execute when we modify record
-
-	// Actions cancel, add, update, delete or clone
-	include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
-
-	// Actions when linking object each other
-	include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';		// Must be include, not include_once
-
-	// Actions when printing a doc from card
-	include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
-
-	// Actions to send emails
-	$trigger_name='MYOBJECT_SENTBYMAIL';
-	$autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
-	$trackid='myobject'.$object->id;
-	include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
+    $error=0;
+
+    $permissiontoadd = $user->rights->mymodule->write;
+    $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
+    $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1);
+    if (empty($backtopage)) {
+        if (empty($id)) $backtopage = $backurlforlist;
+        else $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).($id > 0 ? $id : '__ID__');
+    }
+    $triggermodname = 'MYMODULE_MYOBJECT_MODIFY';	// Name of trigger action code to execute when we modify record
+
+    // Actions cancel, add, update, delete or clone
+    include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
+
+    // Actions when linking object each other
+    include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';		// Must be include, not include_once
+
+    // Actions when printing a doc from card
+    include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
+
+    // Actions to send emails
+    $trigger_name='MYOBJECT_SENTBYMAIL';
+    $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
+    $trackid='myobject'.$object->id;
+    include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
 }
 
 

+ 34 - 35
htdocs/multicurrency/class/multicurrency.class.php

@@ -419,7 +419,7 @@ class MultiCurrency extends CommonObject
 			$this->rate = null;
 			return -1;
 		}
-	 }
+	}
 
 	/**
 	 * Try get label of code in llx_currency then add rate.
@@ -466,8 +466,8 @@ class MultiCurrency extends CommonObject
 	 */
 	public function updateRate($rate)
 	{
-	 	return $this->addRate($rate);
-	 }
+        return $this->addRate($rate);
+    }
 
 	/**
 	 * Fetch CurrencyRate object in $this->rate
@@ -487,7 +487,7 @@ class MultiCurrency extends CommonObject
 			$this->rate = new CurrencyRate($this->db);
 			return $this->rate->fetch($obj->rowid);
 		}
-	 }
+    }
 
 	 /**
 	 * Get id of currency from code
@@ -507,7 +507,7 @@ class MultiCurrency extends CommonObject
 		$resql = $db->query($sql);
 		if ($resql && $obj = $db->fetch_object($resql)) return $obj->rowid;
 		else return 0;
-	 }
+    }
 
 	 /**
 	 * Get id and rate of currency from code
@@ -545,30 +545,30 @@ class MultiCurrency extends CommonObject
 
 			return array(0, 1);
 		}
-	 }
+    }
 
-	 /**
-	  * Get the conversion of amount with invoice rate
-	  *
-	  * @param	int		$fk_facture		id of facture
-	  * @param	double	$amount			amount to convert
-	  * @param	string	$way			dolibarr mean the amount is in dolibarr currency
-	  * @param	string	$table			facture or facture_fourn
-	  * @return	double					amount converted
-	  */
-	  public static function getAmountConversionFromInvoiceRate($fk_facture, $amount, $way = 'dolibarr', $table = 'facture')
-	  {
-		 global $db;
-
-		 $multicurrency_tx = self::getInvoiceRate($fk_facture, $table);
-
-		 if ($multicurrency_tx)
-		 {
-		 	if ($way == 'dolibarr') return $amount * $multicurrency_tx;
-			else return $amount / $multicurrency_tx;
-		 }
-		 else return $amount;
-	  }
+    /**
+     * Get the conversion of amount with invoice rate
+     *
+     * @param	int		$fk_facture		id of facture
+     * @param	double	$amount			amount to convert
+     * @param	string	$way			dolibarr mean the amount is in dolibarr currency
+     * @param	string	$table			facture or facture_fourn
+     * @return	double					amount converted
+     */
+    public static function getAmountConversionFromInvoiceRate($fk_facture, $amount, $way = 'dolibarr', $table = 'facture')
+    {
+        global $db;
+
+        $multicurrency_tx = self::getInvoiceRate($fk_facture, $table);
+
+        if ($multicurrency_tx)
+        {
+            if ($way == 'dolibarr') return $amount * $multicurrency_tx;
+            else return $amount / $multicurrency_tx;
+        }
+        else return $amount;
+    }
 
 	/**
 	 *  Get current invoite rate
@@ -633,14 +633,13 @@ class MultiCurrency extends CommonObject
 	{
 		global $db,$conf;
 
-		$ch = curl_init('http://apilayer.net/api/live?access_key='.$key.'');
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-                $response = curl_exec($ch);
-                curl_close($ch);
-                $response = json_decode($response);
+        $ch = curl_init('http://apilayer.net/api/live?access_key='.$key.'');
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        $response = curl_exec($ch);
+        curl_close($ch);
+        $response = json_decode($response);
 
-                if ($response->success)
-                {
+        if ($response->success) {
 
 			$TRate = $response->quotes;
 			$timestamp = $response->timestamp;

+ 1 - 1
htdocs/product/class/product.class.php

@@ -4326,7 +4326,7 @@ class Product extends CommonObject
 			$this->stock_theorique=$this->stock_reel-$stock_commande_client;
 		}
 		// Stock Increase mode
-		 if (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
+        if (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
             $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
         }
 		if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {

+ 15 - 15
htdocs/product/dynamic_price/class/price_expression.class.php

@@ -275,21 +275,21 @@ class PriceExpression
 
     	dol_syslog(__METHOD__);
         $resql = $this->db->query($sql);
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
-
-		if (! $error)
-		{
-			if (! $notrigger)
-			{
-	            // Uncomment this and change MYOBJECT to your own tag if you
-	            // want this action calls a trigger.
-
-	            //// Call triggers
-	            //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
-	            //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
-	            //// End call triggers
-			 }
-		}
+        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+		// if (! $error)
+		// {
+		//     if (! $notrigger)
+		//     {
+	    //         // Uncomment this and change MYOBJECT to your own tag if you
+	    //         // want this action calls a trigger.
+
+	    //         //// Call triggers
+	    //         //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
+	    //         //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+	    //         //// End call triggers
+		//     }
+		// }
 
         // Commit or rollback
 		if ($error)

+ 13 - 13
htdocs/product/dynamic_price/class/price_global_variable.class.php

@@ -201,19 +201,19 @@ class PriceGlobalVariable
         $resql = $this->db->query($sql);
         if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
 
-        if (! $error)
-        {
-            if (! $notrigger)
-            {
-                // Uncomment this and change MYOBJECT to your own tag if you
-                // want this action calls a trigger.
-
-                //// Call triggers
-                //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
-                //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
-                //// End call triggers
-             }
-        }
+        // if (! $error)
+        // {
+        //     if (! $notrigger)
+        //     {
+        //         // Uncomment this and change MYOBJECT to your own tag if you
+        //         // want this action calls a trigger.
+
+        //         //// Call triggers
+        //         //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
+        //         //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+        //         //// End call triggers
+        //     }
+        // }
 
         // Commit or rollback
         if ($error)

+ 13 - 13
htdocs/product/dynamic_price/class/price_global_variable_updater.class.php

@@ -225,19 +225,19 @@ class PriceGlobalVariableUpdater
         $resql = $this->db->query($sql);
         if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
 
-        if (! $error)
-        {
-            if (! $notrigger)
-            {
-                // Uncomment this and change MYOBJECT to your own tag if you
-                // want this action calls a trigger.
-
-                //// Call triggers
-                //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
-                //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
-                //// End call triggers
-             }
-        }
+        // if (! $error)
+        // {
+        //     if (! $notrigger)
+        //     {
+        //         // Uncomment this and change MYOBJECT to your own tag if you
+        //         // want this action calls a trigger.
+
+        //         //// Call triggers
+        //         //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
+        //         //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+        //         //// End call triggers
+        //     }
+        // }
 
         // Commit or rollback
         if ($error)

+ 29 - 29
htdocs/product/stock/class/api_stockmovements.class.php

@@ -47,8 +47,8 @@ class StockMovements extends DolibarrApi
      */
     function __construct()
     {
-		global $db, $conf;
-		$this->db = $db;
+        global $db, $conf;
+        $this->db = $db;
         $this->stockmovement = new MouvementStock($this->db);
     }
 
@@ -59,26 +59,26 @@ class StockMovements extends DolibarrApi
      *
      * @param 	int 	$id ID of movement
      * @return 	array|mixed data without useless information
-	 *
+     *
      * @throws 	RestException
      */
     /*
     function get($id)
     {
-		if(! DolibarrApiAccess::$user->rights->stock->lire) {
-			throw new RestException(401);
-		}
+        if(! DolibarrApiAccess::$user->rights->stock->lire) {
+            throw new RestException(401);
+        }
 
         $result = $this->stockmovement->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'warehouse not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->stockmovement->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->stockmovement->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
-		return $this->_cleanObjectDatas($this->stockmovement);
+        return $this->_cleanObjectDatas($this->stockmovement);
     }*/
 
     /**
@@ -91,7 +91,7 @@ class StockMovements extends DolibarrApi
      * @param string    $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.product_id:=:1) and (t.date_creation:<:'20160101')"
      * @return array                Array of warehouse objects
      *
-	 * @throws RestException
+     * @throws RestException
      */
     function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
     {
@@ -99,9 +99,9 @@ class StockMovements extends DolibarrApi
 
         $obj_ret = array();
 
-         if(! DolibarrApiAccess::$user->rights->stock->lire) {
-			throw new RestException(401);
-		}
+        if(! DolibarrApiAccess::$user->rights->stock->lire) {
+            throw new RestException(401);
+        }
 
         $sql = "SELECT t.rowid";
         $sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as t";
@@ -114,7 +114,7 @@ class StockMovements extends DolibarrApi
             {
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
             }
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+            $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
             $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
         }
 
@@ -132,7 +132,7 @@ class StockMovements extends DolibarrApi
         $result = $db->query($sql);
         if ($result)
         {
-        	$i=0;
+            $i=0;
             $num = $db->num_rows($result);
             $min = min($num, ($limit <= 0 ? $num : $limit));
             while ($i < $min)
@@ -151,7 +151,7 @@ class StockMovements extends DolibarrApi
         if( ! count($obj_ret)) {
             throw new RestException(404, 'No stock movement found');
         }
-		return $obj_ret;
+        return $obj_ret;
     }
 
     /*
@@ -177,8 +177,8 @@ class StockMovements extends DolibarrApi
     function post($request_data = null)
     {
         if(! DolibarrApiAccess::$user->rights->stock->creer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
 
         // Check mandatory fields
         //$result = $this->_validate($request_data);
@@ -216,17 +216,17 @@ class StockMovements extends DolibarrApi
     function put($id, $request_data = null)
     {
         if(! DolibarrApiAccess::$user->rights->stock->creer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
 
         $result = $this->stockmovement->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'stock movement not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
         foreach($request_data as $field => $value) {
             if ($field == 'id') continue;
@@ -249,16 +249,16 @@ class StockMovements extends DolibarrApi
     function delete($id)
     {
         if(! DolibarrApiAccess::$user->rights->stock->supprimer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
         $result = $this->stockmovement->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'stock movement not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
         if (! $this->stockmovement->delete(DolibarrApiAccess::$user)) {
             throw new RestException(401,'error when delete stock movement');

+ 29 - 29
htdocs/product/stock/class/api_warehouses.class.php

@@ -45,8 +45,8 @@ class Warehouses extends DolibarrApi
      */
     function __construct()
     {
-		global $db, $conf;
-		$this->db = $db;
+        global $db, $conf;
+        $this->db = $db;
         $this->warehouse = new Entrepot($this->db);
     }
 
@@ -57,25 +57,25 @@ class Warehouses extends DolibarrApi
      *
      * @param 	int 	$id ID of warehouse
      * @return 	array|mixed data without useless information
-	 *
+     *
      * @throws 	RestException
      */
     function get($id)
     {
-		if(! DolibarrApiAccess::$user->rights->stock->lire) {
-			throw new RestException(401);
-		}
+        if(! DolibarrApiAccess::$user->rights->stock->lire) {
+            throw new RestException(401);
+        }
 
         $result = $this->warehouse->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'warehouse not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->warehouse->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->warehouse->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
-		return $this->_cleanObjectDatas($this->warehouse);
+        return $this->_cleanObjectDatas($this->warehouse);
     }
 
     /**
@@ -90,7 +90,7 @@ class Warehouses extends DolibarrApi
      * @param string    $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'WH-%') and (t.date_creation:<:'20160101')"
      * @return array                Array of warehouse objects
      *
-	 * @throws RestException
+     * @throws RestException
      */
     function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
     {
@@ -98,9 +98,9 @@ class Warehouses extends DolibarrApi
 
         $obj_ret = array();
 
-         if(! DolibarrApiAccess::$user->rights->stock->lire) {
-			throw new RestException(401);
-		}
+        if(! DolibarrApiAccess::$user->rights->stock->lire) {
+            throw new RestException(401);
+        }
 
         $sql = "SELECT t.rowid";
         $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as t";
@@ -112,7 +112,7 @@ class Warehouses extends DolibarrApi
             {
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
             }
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+            $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
             $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
         }
 
@@ -130,7 +130,7 @@ class Warehouses extends DolibarrApi
         $result = $db->query($sql);
         if ($result)
         {
-        	$i=0;
+            $i=0;
             $num = $db->num_rows($result);
             $min = min($num, ($limit <= 0 ? $num : $limit));
             while ($i < $min)
@@ -149,7 +149,7 @@ class Warehouses extends DolibarrApi
         if( ! count($obj_ret)) {
             throw new RestException(404, 'No warehouse found');
         }
-		return $obj_ret;
+        return $obj_ret;
     }
 
 
@@ -162,8 +162,8 @@ class Warehouses extends DolibarrApi
     function post($request_data = null)
     {
         if(! DolibarrApiAccess::$user->rights->stock->creer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
 
         // Check mandatory fields
         $result = $this->_validate($request_data);
@@ -187,17 +187,17 @@ class Warehouses extends DolibarrApi
     function put($id, $request_data = null)
     {
         if(! DolibarrApiAccess::$user->rights->stock->creer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
 
         $result = $this->warehouse->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'warehouse not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('stock',$this->warehouse->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('stock',$this->warehouse->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
         foreach($request_data as $field => $value) {
             if ($field == 'id') continue;
@@ -219,16 +219,16 @@ class Warehouses extends DolibarrApi
     function delete($id)
     {
         if(! DolibarrApiAccess::$user->rights->stock->supprimer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
         $result = $this->warehouse->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'warehouse not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('stock',$this->warehouse->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('stock',$this->warehouse->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
         if (! $this->warehouse->delete(DolibarrApiAccess::$user)) {
             throw new RestException(401,'error when delete warehouse');

+ 9 - 10
htdocs/product/stock/movement_list.php

@@ -36,10 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-if (! empty($conf->projet->enabled))
-{
-	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
-	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+if (! empty($conf->projet->enabled)) {
+    require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+    require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
 }
 
 // Load translation files required by the page
@@ -226,11 +225,11 @@ if ($action == "correct_stock")
             exit;
         }
         else
-       {
-       		$error++;
-        	setEventMessages($product->error, $product->errors, 'errors');
-        	$action='correction';
-       }
+        {
+            $error++;
+            setEventMessages($product->error, $product->errors, 'errors');
+            $action='correction';
+        }
     }
 
     if (! $error) $action='';
@@ -1048,7 +1047,7 @@ if ($resql)
 		if (! empty($arrayfields['m.type_mouvement']['checked']))
         {
             // Type of movement
-        		switch($objp->type_mouvement){
+            switch($objp->type_mouvement){
                 case "0":
                     print '<td align="center">'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</td>';
                     break;

+ 1 - 1
htdocs/projet/card.php

@@ -1241,7 +1241,7 @@ elseif ($object->id > 0)
 					print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Delete').'</a></div>';
 				}
 			}
-		 }
+		}
 	}
 
 	print "</div>";

+ 110 - 112
htdocs/projet/class/api_projects.class.php

@@ -48,8 +48,8 @@ class Projects extends DolibarrApi
      */
     function __construct()
     {
-		global $db, $conf;
-		$this->db = $db;
+        global $db, $conf;
+        $this->db = $db;
         $this->project = new Project($this->db);
         $this->task = new Task($this->db);
     }
@@ -61,26 +61,26 @@ class Projects extends DolibarrApi
      *
      * @param       int         $id         ID of project
      * @return 	array|mixed data without useless information
-	 *
+     *
      * @throws 	RestException
      */
     function get($id)
     {
-		if(! DolibarrApiAccess::$user->rights->projet->lire) {
-			throw new RestException(401);
-		}
+        if(! DolibarrApiAccess::$user->rights->projet->lire) {
+            throw new RestException(401);
+        }
 
         $result = $this->project->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'Project not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
         $this->project->fetchObjectLinked();
-		return $this->_cleanObjectDatas($this->project);
+        return $this->_cleanObjectDatas($this->project);
     }
 
 
@@ -133,7 +133,7 @@ class Projects extends DolibarrApi
             {
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
             }
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+            $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
             $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
         }
 
@@ -171,7 +171,7 @@ class Projects extends DolibarrApi
         if( ! count($obj_ret)) {
             throw new RestException(404, 'No project found');
         }
-		return $obj_ret;
+        return $obj_ret;
     }
 
     /**
@@ -182,9 +182,9 @@ class Projects extends DolibarrApi
      */
     function post($request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->creer) {
-			  throw new RestException(401, "Insuffisant rights");
-		  }
+        if(! DolibarrApiAccess::$user->rights->projet->creer) {
+            throw new RestException(401, "Insuffisant rights");
+        }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
@@ -217,34 +217,32 @@ class Projects extends DolibarrApi
      */
     function getLines($id, $includetimespent = 0)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->lire) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->project->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Project not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-      $this->project->getLinesArray(DolibarrApiAccess::$user);
-      $result = array();
-      foreach ($this->project->lines as $line)      // $line is a task
-      {
-          if ($includetimespent == 1)
-          {
-              $timespent = $line->getSummaryOfTimeSpent(0);
-          }
-          if ($includetimespent == 1)
-          {
+        if (! DolibarrApiAccess::$user->rights->projet->lire) {
+            throw new RestException(401);
+        }
+
+        $result = $this->project->fetch($id);
+        if ( ! $result ) {
+            throw new RestException(404, 'Project not found');
+        }
+
+        if ( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $this->project->getLinesArray(DolibarrApiAccess::$user);
+        $result = array();
+        foreach ($this->project->lines as $line) {
+            // $line is a task
+            if ($includetimespent == 1) {
+                $timespent = $line->getSummaryOfTimeSpent(0);
+            }
+            if ($includetimespent == 1) {
                 // TODO
                 // Add class for timespent records and loop and fill $line->lines with records of timespent
-          }
-          array_push($result,$this->_cleanObjectDatas($line));
-      }
-      return $result;
+            }
+            array_push($result,$this->_cleanObjectDatas($line));
+        }
+        return $result;
     }
 
 
@@ -262,16 +260,16 @@ class Projects extends DolibarrApi
     {
         global $db;
 
-        if(! DolibarrApiAccess::$user->rights->projet->lire) {
+        if (! DolibarrApiAccess::$user->rights->projet->lire) {
             throw new RestException(401);
         }
 
         $result = $this->project->fetch($id);
-        if( ! $result ) {
+        if ( ! $result ) {
             throw new RestException(404, 'Project not found');
         }
 
-        if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+        if ( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
@@ -305,20 +303,20 @@ class Projects extends DolibarrApi
     /*
     function postLine($id, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->creer) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->project->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Project not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-			$request_data = (object) $request_data;
-      $updateRes = $this->project->addline(
+        if(! DolibarrApiAccess::$user->rights->projet->creer) {
+            throw new RestException(401);
+        }
+
+        $result = $this->project->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Project not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $request_data = (object) $request_data;
+        $updateRes = $this->project->addline(
                         $request_data->desc,
                         $request_data->subprice,
                         $request_data->qty,
@@ -344,13 +342,13 @@ class Projects extends DolibarrApi
                         $request_data->fk_unit,
                         $this->element,
                         $request_data->id
-      );
+        );
 
-      if ($updateRes > 0) {
-        return $updateRes;
+        if ($updateRes > 0) {
+            return $updateRes;
 
-      }
-      return false;
+        }
+        return false;
     }
     */
 
@@ -368,20 +366,20 @@ class Projects extends DolibarrApi
     /*
     function putLine($id, $lineid, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->creer) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->project->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Project not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-			$request_data = (object) $request_data;
-      $updateRes = $this->project->updateline(
+        if(! DolibarrApiAccess::$user->rights->projet->creer) {
+            throw new RestException(401);
+        }
+
+        $result = $this->project->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Project not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $request_data = (object) $request_data;
+        $updateRes = $this->project->updateline(
                         $lineid,
                         $request_data->desc,
                         $request_data->subprice,
@@ -403,14 +401,14 @@ class Projects extends DolibarrApi
                         $request_data->special_code,
                         $request_data->array_options,
                         $request_data->fk_unit
-      );
-
-      if ($updateRes > 0) {
-        $result = $this->get($id);
-        unset($result->line);
-        return $this->_cleanObjectDatas($result);
-      }
-      return false;
+        );
+
+        if ($updateRes > 0) {
+            $result = $this->get($id);
+            unset($result->line);
+            return $this->_cleanObjectDatas($result);
+        }
+        return false;
     }*/
 
 
@@ -425,24 +423,24 @@ class Projects extends DolibarrApi
      */
     function put($id, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->creer) {
-		  	throw new RestException(401);
-		  }
+        if (! DolibarrApiAccess::$user->rights->projet->creer) {
+            throw new RestException(401);
+        }
 
         $result = $this->project->fetch($id);
         if ($result <= 0) {
             throw new RestException(404, 'Project not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if ( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
         foreach($request_data as $field => $value) {
             if ($field == 'id') continue;
             $this->project->$field = $value;
         }
 
-        if($this->project->update(DolibarrApiAccess::$user) >= 0)
+        if ($this->project->update(DolibarrApiAccess::$user) >= 0)
         {
             return $this->get($id);
         }
@@ -461,19 +459,19 @@ class Projects extends DolibarrApi
      */
     function delete($id)
     {
-        if(! DolibarrApiAccess::$user->rights->projet->supprimer) {
-			throw new RestException(401);
-		}
+        if (! DolibarrApiAccess::$user->rights->projet->supprimer) {
+            throw new RestException(401);
+        }
         $result = $this->project->fetch($id);
-        if( ! $result ) {
+        if ( ! $result ) {
             throw new RestException(404, 'Project not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if ( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
-        if( ! $this->project->delete(DolibarrApiAccess::$user)) {
+        if ( ! $this->project->delete(DolibarrApiAccess::$user)) {
             throw new RestException(500, 'Error when delete project : '.$this->project->error);
         }
 
@@ -506,24 +504,24 @@ class Projects extends DolibarrApi
     function validate($id, $notrigger = 0)
     {
         if(! DolibarrApiAccess::$user->rights->projet->creer) {
-			throw new RestException(401);
-		}
+            throw new RestException(401);
+        }
         $result = $this->project->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'Project not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
 
-		$result = $this->project->setValid(DolibarrApiAccess::$user, $notrigger);
-		if ($result == 0) {
-		    throw new RestException(304, 'Error nothing done. May be object is already validated');
-		}
-		if ($result < 0) {
-		    throw new RestException(500, 'Error when validating Project: '.$this->project->error);
-		}
+        $result = $this->project->setValid(DolibarrApiAccess::$user, $notrigger);
+        if ($result == 0) {
+            throw new RestException(304, 'Error nothing done. May be object is already validated');
+        }
+        if ($result < 0) {
+            throw new RestException(500, 'Error when validating Project: '.$this->project->error);
+        }
 
         return array(
             'success' => array(

+ 76 - 78
htdocs/projet/class/api_tasks.class.php

@@ -190,9 +190,9 @@ class Tasks extends DolibarrApi
      */
     function post($request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->creer) {
-			  throw new RestException(401, "Insuffisant rights");
-		  }
+        if (! DolibarrApiAccess::$user->rights->projet->creer) {
+            throw new RestException(401, "Insuffisant rights");
+        }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
@@ -224,34 +224,34 @@ class Tasks extends DolibarrApi
     /*
     function getLines($id, $includetimespent=0)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->lire) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->project->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Project not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-      $this->project->getLinesArray(DolibarrApiAccess::$user);
-      $result = array();
-      foreach ($this->project->lines as $line)      // $line is a task
-      {
-          if ($includetimespent == 1)
-          {
-              $timespent = $line->getSummaryOfTimeSpent(0);
-          }
-          if ($includetimespent == 1)
-          {
+        if(! DolibarrApiAccess::$user->rights->projet->lire) {
+            throw new RestException(401);
+        }
+
+        $result = $this->project->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Project not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $this->project->getLinesArray(DolibarrApiAccess::$user);
+        $result = array();
+        foreach ($this->project->lines as $line)      // $line is a task
+        {
+            if ($includetimespent == 1)
+            {
+                $timespent = $line->getSummaryOfTimeSpent(0);
+            }
+            if ($includetimespent == 1)
+            {
                 // TODO
                 // Add class for timespent records and loop and fill $line->lines with records of timespent
-          }
-          array_push($result,$this->_cleanObjectDatas($line));
-      }
-      return $result;
+            }
+            array_push($result,$this->_cleanObjectDatas($line));
+        }
+        return $result;
     }
     */
 
@@ -310,20 +310,20 @@ class Tasks extends DolibarrApi
     /*
     function postLine($id, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->creer) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->project->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Project not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-			$request_data = (object) $request_data;
-      $updateRes = $this->project->addline(
+        if(! DolibarrApiAccess::$user->rights->projet->creer) {
+            throw new RestException(401);
+        }
+
+        $result = $this->project->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Project not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $request_data = (object) $request_data;
+        $updateRes = $this->project->addline(
                         $request_data->desc,
                         $request_data->subprice,
                         $request_data->qty,
@@ -349,13 +349,13 @@ class Tasks extends DolibarrApi
                         $request_data->fk_unit,
                         $this->element,
                         $request_data->id
-      );
+        );
 
-      if ($updateRes > 0) {
-        return $updateRes;
+        if ($updateRes > 0) {
+            return $updateRes;
 
-      }
-      return false;
+        }
+        return false;
     }
     */
 
@@ -373,20 +373,20 @@ class Tasks extends DolibarrApi
     /*
     function putLine($id, $lineid, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->creer) {
-		  	throw new RestException(401);
-		  }
-
-      $result = $this->project->fetch($id);
-      if( ! $result ) {
-         throw new RestException(404, 'Project not found');
-      }
-
-		  if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
-			  throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-			$request_data = (object) $request_data;
-      $updateRes = $this->project->updateline(
+        if(! DolibarrApiAccess::$user->rights->projet->creer) {
+            throw new RestException(401);
+        }
+
+        $result = $this->project->fetch($id);
+        if( ! $result ) {
+            throw new RestException(404, 'Project not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+        $request_data = (object) $request_data;
+        $updateRes = $this->project->updateline(
                         $lineid,
                         $request_data->desc,
                         $request_data->subprice,
@@ -408,14 +408,14 @@ class Tasks extends DolibarrApi
                         $request_data->special_code,
                         $request_data->array_options,
                         $request_data->fk_unit
-      );
-
-      if ($updateRes > 0) {
-        $result = $this->get($id);
-        unset($result->line);
-        return $this->_cleanObjectDatas($result);
-      }
-      return false;
+        );
+
+        if ($updateRes > 0) {
+            $result = $this->get($id);
+            unset($result->line);
+            return $this->_cleanObjectDatas($result);
+        }
+        return false;
     }*/
 
 
@@ -429,18 +429,18 @@ class Tasks extends DolibarrApi
      */
     function put($id, $request_data = null)
     {
-      if(! DolibarrApiAccess::$user->rights->projet->creer) {
-		  	throw new RestException(401);
-		  }
+        if (! DolibarrApiAccess::$user->rights->projet->creer) {
+            throw new RestException(401);
+        }
 
         $result = $this->task->fetch($id);
         if( ! $result ) {
             throw new RestException(404, 'Task not found');
         }
 
-		if( ! DolibarrApi::_checkAccessToResource('tasks',$this->project->id)) {
-			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-		}
+        if( ! DolibarrApi::_checkAccessToResource('tasks',$this->project->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
         foreach($request_data as $field => $value) {
             if ($field == 'id') continue;
             $this->task->$field = $value;
@@ -507,8 +507,6 @@ class Tasks extends DolibarrApi
      */
     function addTimeSpent($id, $date, $duration, $user_id = 0, $note = '')
     {
-
-
         if( ! DolibarrApiAccess::$user->rights->projet->creer) {
             throw new RestException(401);
         }

+ 1 - 1
htdocs/projet/class/project.class.php

@@ -1771,7 +1771,7 @@ class Project extends CommonObject
                 }
                 $this->db->free($resql);
                 return 1;
-         }
+        }
         else
         {
                 $this->error="Error ".$this->db->lasterror();

+ 4 - 1
htdocs/societe/canvas/company/tpl/card_edit.tpl.php

@@ -116,7 +116,10 @@ if ($this->control->tpl['fournisseur']) {
 	<td><?php echo $langs->trans('SupplierCategory'); ?></td>
 	<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
 </tr>
-<?php } }?>
+<?php
+    }
+}
+?>
 
 <?php if (! empty($conf->barcode->enabled)) { ?>
 <tr>

+ 4 - 1
htdocs/societe/canvas/individual/tpl/card_edit.tpl.php

@@ -113,7 +113,10 @@ if ($this->control->tpl['fournisseur']) {
 	<td><?php echo $langs->trans('SupplierCategory'); ?></td>
 	<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
 </tr>
-<?php } }?>
+<?php
+    }
+}
+?>
 
 <?php if (! empty($conf->barcode->enabled)) { ?>
 <tr>

+ 3 - 4
htdocs/societe/class/societe.class.php

@@ -2011,10 +2011,9 @@ class Societe extends CommonObject
 		$name=$this->name?$this->name:$this->nom;
 
 		if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){
-
-             if(empty($option) && $this->client > 0) $option = 'customer';
-             if(empty($option) && $this->fournisseur > 0) $option = 'supplier';
-         }
+            if(empty($option) && $this->client > 0) $option = 'customer';
+            if(empty($option) && $this->fournisseur > 0) $option = 'supplier';
+        }
 
 
 		if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto)))

+ 16 - 17
htdocs/societe/list.php

@@ -457,23 +457,22 @@ $num = $db->num_rows($resql);
 
 $arrayofselected=is_array($toselect)?$toselect:array();
 
-if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list')
-{
-	$obj = $db->fetch_object($resql);
-	$id = $obj->rowid;
-	if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){
-              if( $obj->client > 0) {
-                       header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
-                       exit;
-               }
-               if( $obj->fournisseur > 0){
-                       header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
-                       exit;
-               }
-       }
-
-	header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
-	exit;
+if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') {
+    $obj = $db->fetch_object($resql);
+    $id = $obj->rowid;
+    if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) {
+        if ( $obj->client > 0) {
+            header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
+            exit;
+        }
+        if ( $obj->fournisseur > 0){
+            header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
+            exit;
+        }
+    }
+
+    header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
+    exit;
 }
 
 $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';

+ 17 - 18
htdocs/takepos/takepos.php

@@ -134,7 +134,7 @@ function LoadProducts(position, issubcat=false){
     if (currentcat=="") return;
 	pageproducts=0;
 	ishow=0; //product to show counter
-	
+
 	jQuery.each(subcategories, function(i, val) {
 		if (currentcat==val.fk_parent){
 			$("#prodesc"+ishow).text(val.label);
@@ -144,13 +144,13 @@ function LoadProducts(position, issubcat=false){
 			ishow++;
 		}
 	});
-	
-	idata=0; //product data counter	
+
+	idata=0; //product data counter
 	$.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) {
 		while (idata < 30) {
 			if (typeof (data[idata]) == "undefined") {
-				$("#prodesc"+ishow).text(""); 
-				$("#proimg"+ishow).attr("src",""); 
+				$("#prodesc"+ishow).text("");
+				$("#proimg"+ishow).attr("src","");
 				$("#prodiv"+ishow).data("rowid","");
 				ishow++; //Next product to show after print data product
 			}
@@ -188,8 +188,8 @@ function MoreProducts(moreorless){
 		ishow=0; //product to show counter
 		while (idata < 30) {
 			if (typeof (data[idata]) == "undefined") {
-				$("#prodesc"+ishow).text(""); 
-				$("#proimg"+ishow).attr("src",""); 
+				$("#prodesc"+ishow).text("");
+				$("#proimg"+ishow).attr("src","");
 				$("#prodiv"+ishow).data("rowid","");
 				ishow++; //Next product to show after print data product
 			}
@@ -373,11 +373,11 @@ function MoreActions(totalactions){
 	}
 	else if (pageactions==1){
 		pageactions=0;
-		for (i = 0; i <= totalactions; i++){ 
+		for (i = 0; i <= totalactions; i++){
 			if (i<9) $("#action"+i).show();
 			else $("#action"+i).hide();
 		}
-	}		
+	}
 }
 
 $( document ).ready(function() {
@@ -453,10 +453,9 @@ if ($conf->global->TAKEPOSCONNECTOR){
 
 $hookmanager->initHooks(array('takeposfrontend'));
 $reshook=$hookmanager->executeHooks('ActionButtons');
-if (!empty($reshook))
-	{
-		$menus[$r++]=$reshook;
-	}
+if (!empty($reshook)) {
+    $menus[$r++]=$reshook;
+}
 
 ?>
 		<div class="div3">
@@ -498,17 +497,17 @@ foreach($menus as $menu) {
 <?php
 $count=0;
 while ($count<32)
-	{
-	?>
+{
+?>
 			<div class='wrapper2' id='prodiv<?php echo $count;?>' <?php if ($count==30) {?> onclick="MoreProducts('less');" <?php } if ($count==31) {?> onclick="MoreProducts('more');" <?php } else echo 'onclick="ClickProduct('.$count.');"';?>>
 				<img class='imgwrapper' <?php if ($count==30) echo 'src="img/arrow-prev-top.png"'; if ($count==31) echo 'src="img/arrow-next-top.png"';?> width="95%" id='proimg<?php echo $count;?>'/>
 				<div class='description'>
 					<div class='description_content' id='prodesc<?php echo $count;?>'></div>
 				</div>
 			</div>
-	<?php
-	$count++;
-	}
+<?php
+    $count++;
+}
 ?>
 		</div>
 	</div>

+ 2 - 2
htdocs/ticket/class/api_tickets.class.php

@@ -386,8 +386,8 @@ class Tickets extends DolibarrApi
     {
         $ticketstatic = new Ticket($this->db);
         if (! DolibarrApiAccess::$user->rights->ticket->write) {
-      throw new RestException(401);
-    }
+            throw new RestException(401);
+        }
         // Check mandatory fields
         $result = $this->_validateMessage($request_data);
 

+ 6 - 6
htdocs/user/card.php

@@ -269,7 +269,7 @@ if (empty($reshook)) {
 				if (GETPOST('password')) {
 					$object->setPassword($user, GETPOST('password'));
 				}
-						if (! empty($conf->categorie->enabled)) {
+				if (! empty($conf->categorie->enabled)) {
 					// Categories association
 					$usercats = GETPOST('usercats', 'array');
 					$object->setCategories($usercats);
@@ -1125,7 +1125,7 @@ if ($action == 'create' || $action == 'adduserldap')
 			{
 				 print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
 			}
-		 }
+		}
 	}
 
 	// Other attributes
@@ -1639,8 +1639,8 @@ else
 				// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
 				if (! method_exists($mc, 'formObjectOptions'))
 				{
-				     if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
-				     {
+				    if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
+				    {
 				     	print '<tr><td>' . $langs->trans("Entity") . '</td><td>';
 				     	if (empty($object->entity)) {
 				     		print $langs->trans("AllEntities");
@@ -1649,8 +1649,8 @@ else
 				     		print $mc->label;
 				     	}
 				     	print "</td></tr>\n";
-				     }
-			     }
+				    }
+                }
 			}
 
 			// Other attributes

+ 6 - 6
htdocs/user/clicktodial.php

@@ -110,7 +110,7 @@ if ($id > 0)
     // Edit mode
     if ($action == 'edit')
     {
-	   print '<table class="border" width="100%">';
+       print '<table class="border" width="100%">';
 
         if ($user->admin)
         {
@@ -123,11 +123,11 @@ if ($id > 0)
                 print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>';
             }
             else
-           {
-            	print ' &nbsp; &nbsp; '.$form->textwithpicto($langs->trans("KeepEmptyToUseDefault").': '.$conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc"));
-           }
+            {
+                print ' &nbsp; &nbsp; '.$form->textwithpicto($langs->trans("KeepEmptyToUseDefault").': '.$conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc"));
+            }
             print '</td>';
-        	print '</tr>';
+            print '</tr>';
         }
 
         print '<tr><td class="titlefield">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
@@ -138,7 +138,7 @@ if ($id > 0)
         print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
         print '<td class="valeur">';
         print '<input name="login" value="'.(! empty($object->clicktodial_login)?$object->clicktodial_login:'').'"></td>';
-		print '</tr>';
+        print '</tr>';
 
         print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
         print '<td class="valeur">';

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott