Browse Source

Merge remote-tracking branch 'origin/3.9' into develop

Conflicts:
	htdocs/fourn/commande/card.php
	htdocs/imports/import.php
	htdocs/langs/en_US/admin.lang
Laurent Destailleur 9 years ago
parent
commit
293c8e145a

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

@@ -2570,7 +2570,7 @@ class Propal extends CommonObject
 	        $response = new WorkboardResponse();
 	        $response->warning_delay = $delay_warning/60/60/24;
 	        $response->label = $label;
-	        $response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut;
+	        $response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals';
 	        $response->img = img_object($langs->trans("Propals"),"propal");
 
             // This assignment in condition is not a bug. It allows walking the results.

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

@@ -2974,7 +2974,7 @@ class Commande extends CommonOrder
 	        $response = new WorkboardResponse();
 	        $response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
 	        $response->label=$langs->trans("OrdersToProcess");
-	        $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3';
+	        $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders';
 	        $response->img=img_object($langs->trans("Orders"),"order");
 
             $generic_commande = new Commande($this->db);

+ 1 - 1
htdocs/compta/facture/class/facture.class.php

@@ -3464,7 +3464,7 @@ class Facture extends CommonInvoice
 			$response = new WorkboardResponse();
 			$response->warning_delay=$conf->facture->client->warning_delay/60/60/24;
 			$response->label=$langs->trans("CustomerBillsUnpaid");
-			$response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1';
+			$response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills';
 			$response->img=img_object($langs->trans("Bills"),"bill");
 
 			$generic_facture = new Facture($this->db);

+ 2 - 2
htdocs/compta/index.php

@@ -2,7 +2,7 @@
 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2015 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2015 	   Juanjo Menent	    <jmenent@2byte.es>
+ * Copyright (C) 2015-2016 Juanjo Menent	    <jmenent@2byte.es>
  * Copyright (C) 2015      Jean-François Ferry	<jfefe@aternatik.fr>
  * Copyright (C) 2015      Raphaël Doursenaud   <rdoursenaud@gpcsolutions.fr>
  * Copyright (C) 2016      Marcos García        <marcosgdf@gmail.com>
@@ -877,7 +877,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
 	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 	if ($socid) $sql.= " AND ff.fk_soc = ".$socid;
 	$sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye,";
-	$sql.= " s.nom, s.rowid, s.code_client, s.code_fournisseur";
+	$sql.= " s.nom, s.rowid, s.code_client, s.code_fournisseur, ff.date_lim_reglement";
 	$sql.= " ORDER BY ff.date_lim_reglement ASC";
 
 	$resql=$db->query($sql);

+ 4 - 1
htdocs/core/ajax/ajaxdirpreview.php

@@ -240,7 +240,10 @@ if ($section)
 		require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
 		$useglobalvars=1;
 		$form = new Form($db);
-		$formquestion=array('urlfile'=>array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'));
+		$formquestion=array(
+			'urlfile'=>array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'),
+			'section'=>array('type'=>'hidden','value'=>$section,'name'=>'section')
+		);
 		print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
 	}
 

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

@@ -2329,7 +2329,7 @@ class Form
         $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
-        $sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
+        $sql.= " WHERE p.entity IN (".getEntity('productprice', 1).")";
         $sql.= " AND p.tobuy = 1";
         $sql.= " AND s.fournisseur = 1";
         $sql.= " AND p.rowid = ".$productid;

+ 67 - 64
htdocs/core/class/ldap.class.php

@@ -162,68 +162,52 @@ class Ldap
 			return -1;
 		}
 
-		if (! function_exists('ldap_connect'))
+		if (! function_exists("ldap_connect"))
 		{
-			$this->error='Your PHP need extension ldap';
+			$this->error='LDAPFunctionsNotAvailableOnPHP';
 			dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
-		    return -1;
+			$return=-1;
 		}
-		
-		// Loop on each ldap server
-		foreach ($this->server as $key => $host)
-		{
-			if ($connected) break;
-			if (empty($host)) continue;
-
-			if (preg_match('/^ldap/',$host))
-			{
-				$this->connection = ldap_connect($host);
-			}
-			else
-			{
-				$this->connection = ldap_connect($host,$this->serverPort);
-			}
 
-			if (is_resource($this->connection))
+		if (empty($this->error))
+		{
+			// Loop on each ldap server
+			foreach ($this->server as $key => $host)
 			{
-				// Begin TLS if requested by the configuration
-    			if (! empty($conf->global->LDAP_SERVER_USE_TLS)) 
-    			{
-    			    if (! ldap_start_tls($this->connection)) 
-    			    {
-    			        dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING);
-    			        $connected = 0;
-    			        $this->close();
-    				}
-    			}
-			
-			    // Execute the ldap_set_option here (after connect and before bind)
-				$this->setVersion();
-				ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); // no limit here. should return true.
-
-
-				if ($this->serverType == "activedirectory")
+				if ($connected) break;
+				if (empty($host)) continue;
+	
+				if (preg_match('/^ldap/',$host))
 				{
-					$result=$this->setReferrals();
-					dol_syslog(get_class($this)."::connect_bind try bindauth for activedirectory on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
-					$this->result=$this->bindauth($this->searchUser,$this->searchPassword);
-					if ($this->result)
-					{
-						$this->bind=$this->result;
-						$connected=2;
-						break;
-					}
-					else
-					{
-						$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
-					}
+					$this->connection = ldap_connect($host);
 				}
 				else
 				{
-					// Try in auth mode
-					if ($this->searchUser && $this->searchPassword)
+					$this->connection = ldap_connect($host,$this->serverPort);
+				}
+	
+				if (is_resource($this->connection))
+				{
+					// Begin TLS if requested by the configuration
+	    			if (! empty($conf->global->LDAP_SERVER_USE_TLS)) 
+	    			{
+	    			    if (! ldap_start_tls($this->connection)) 
+	    			    {
+	    			        dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING);
+	    			        $connected = 0;
+	    			        $this->close();
+	    				}
+	    			}
+			
+					// Execute the ldap_set_option here (after connect and before bind)
+					$this->setVersion();
+					ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); // no limit here. should return true.
+	
+	
+					if ($this->serverType == "activedirectory")
 					{
-						dol_syslog(get_class($this)."::connect_bind try bindauth on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
+						$result=$this->setReferrals();
+						dol_syslog(get_class($this)."::connect_bind try bindauth for activedirectory on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
 						$this->result=$this->bindauth($this->searchUser,$this->searchPassword);
 						if ($this->result)
 						{
@@ -236,26 +220,45 @@ class Ldap
 							$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
 						}
 					}
-					// Try in anonymous
-					if (! $this->bind)
+					else
 					{
-						dol_syslog(get_class($this)."::connect_bind try bind on ".$host,LOG_DEBUG);
-						$result=$this->bind();
-						if ($result)
+						// Try in auth mode
+						if ($this->searchUser && $this->searchPassword)
 						{
-							$this->bind=$this->result;
-							$connected=1;
-							break;
+							dol_syslog(get_class($this)."::connect_bind try bindauth on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
+							$this->result=$this->bindauth($this->searchUser,$this->searchPassword);
+							if ($this->result)
+							{
+								$this->bind=$this->result;
+								$connected=2;
+								break;
+							}
+							else
+							{
+								$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
+							}
 						}
-						else
+						// Try in anonymous
+						if (! $this->bind)
 						{
-							$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
+							dol_syslog(get_class($this)."::connect_bind try bind on ".$host,LOG_DEBUG);
+							$result=$this->bind();
+							if ($result)
+							{
+								$this->bind=$this->result;
+								$connected=1;
+								break;
+							}
+							else
+							{
+								$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
+							}
 						}
 					}
 				}
+	
+				if (! $connected) $this->close();
 			}
-
-			if (! $connected) $this->close();
 		}
 
 		if ($connected)

+ 7 - 0
htdocs/core/lib/admin.lib.php

@@ -736,17 +736,24 @@ function activateModule($value,$withdeps=1)
         if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends))
         {
             // Activation des modules dont le module depend
+            $TError=array();
             $num = count($objMod->depends);
             for ($i = 0; $i < $num; $i++)
             {
+            	$activate = false;
             	foreach ($modulesdir as $dir)
             	{
             		if (file_exists($dir.$objMod->depends[$i].".class.php"))
             		{
             			activateModule($objMod->depends[$i]);
+						$activate = true;
             		}
             	}
+				
+				if (!$activate) $TError[] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]);
             }
+            
+            setEventMessages('', $TError, 'errors');
         }
 
         if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith))

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

@@ -436,7 +436,7 @@ function dol_size($size,$type='')
  */
 function dol_sanitizeFileName($str,$newstr='_',$unaccent=1)
 {
-	$filesystem_forbidden_chars = array('<','>',':','/','\\','?','*','|','"');
+	$filesystem_forbidden_chars = array('<','>',':','/','\\','?','*','|','"','°');
 	return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars);
 }
 

+ 2 - 2
htdocs/core/menus/standard/eldy.lib.php

@@ -788,8 +788,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
 			if (! empty($conf->facture->enabled))
 			{
 				$langs->load("bills");
-				$newmenu->add("/compta/facture/list.php",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills');
-				$newmenu->add("/compta/facture.php?action=create",$langs->trans("NewBill"),1,$user->rights->facture->creer);
+				$newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills');
+				$newmenu->add("/compta/facture.php?action=create&leftmenu=customers_bills",$langs->trans("NewBill"),1,$user->rights->facture->creer);
 				$newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire);
 
 				if (empty($leftmenu) || ($leftmenu == 'customers_bills'))

+ 1 - 0
htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php

@@ -397,6 +397,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
 
 				$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
 				complete_substitutions_array($tmparray, $outputlangs, $object);
+				$object->fetch_optionals();
 				// Call the ODTSubstitution hook
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
 				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks

+ 1 - 2
htdocs/ecm/index.php

@@ -175,10 +175,9 @@ if ($action == 'confirm_deletefile')
 	    		dol_print_error($db,$ecmdir->error);
 	    		exit;
 	    	}
-	    	$relativepath=$ecmdir->getRelativePath();
     	}
     	else $relativepath='';
-    	$upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:'');
+    	$upload_dir = $conf->ecm->dir_output;
     	$file = $upload_dir . "/" . GETPOST('urlfile');	// Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
 
     	$ret=dol_delete_file($file);

+ 10 - 7
htdocs/expensereport/card.php

@@ -819,7 +819,7 @@ if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid)
 	}
 }
 
-if ($action == "addline")
+if ($action == "addline" && $user->rights->expensereport->creer)
 {
 	$error = 0;
 
@@ -911,7 +911,7 @@ if ($action == "addline")
 	$action='';
 }
 
-if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes")
+if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes" && $user->rights->expensereport->creer)
 {
 	$object = new ExpenseReport($db);
 	$object->fetch($id);
@@ -954,7 +954,7 @@ if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes")
 	}
 }
 
-if ($action == "updateligne" )
+if ($action == "updateligne" && $user->rights->expensereport->creer)
 {
 	$object = new ExpenseReport($db);
 	$object->fetch($id);
@@ -1640,8 +1640,11 @@ else
 							print '<td style="text-align:right;">'.$langs->trans('AmountHT').'</td>';
 							print '<td style="text-align:right;">'.$langs->trans('AmountTTC').'</td>';
 						}
-						print '<td style="text-align:right;"></td>';
-
+						// Ajout des boutons de modification/suppression
+						if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer)
+						{
+							print '<td style="text-align:right;"></td>';
+						}
 						print '</tr>';
 
 						$var=true;
@@ -1682,7 +1685,7 @@ else
 
 								// Ajout des boutons de modification/suppression
 								print '<td style="text-align:right;" class="nowrap">';
-								if($object->fk_statut<2 OR $object->fk_statut==99)
+								if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer)
 								{
 									print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;rowid='.$objp->rowid.'#'.$objp->rowid.'">';
 									print img_edit();
@@ -1768,7 +1771,7 @@ else
 					//print '</div>';
 
 					// Add a line
-					if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline')
+					if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline' && $user->rights->expensereport->creer)
 					{
 						print '<tr class="liste_titre">';
 						print '<td colspan="2"></td>';

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

@@ -2492,7 +2492,7 @@ class CommandeFournisseur extends CommonOrder
 	        $response = new WorkboardResponse();
 	        $response->warning_delay=$conf->commande->fournisseur->warning_delay/60/60/24;
 	        $response->label=$langs->trans("SuppliersOrdersToProcess");
-	        $response->url=DOL_URL_ROOT.'/fourn/commande/list.php?statut=1,2,3';
+	        $response->url=DOL_URL_ROOT.'/fourn/commande/list.php?statut=1,2,3&mainmenu=commercial&leftmenu=orders_suppliers';
 	        $response->img=img_object($langs->trans("Orders"),"order");
 
             while ($obj=$this->db->fetch_object($resql))

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

@@ -1507,7 +1507,7 @@ class FactureFournisseur extends CommonInvoice
 	        $response = new WorkboardResponse();
 	        $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24;
 	        $response->label=$langs->trans("SupplierBillsToPay");
-	        $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0';
+	        $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0&mainmenu=accountancy&leftmenu=suppliers_bills';
 	        $response->img=img_object($langs->trans("Bills"),"bill");
 
             $facturestatic = new FactureFournisseur($this->db);

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

@@ -445,7 +445,7 @@ class ProductFournisseur extends Product
         $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.unitcharges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation";
         $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
         $sql.= ", ".MAIN_DB_PREFIX."societe as s";
-        $sql.= " WHERE pfp.entity IN (".getEntity('product', 1).")";
+        $sql.= " WHERE pfp.entity IN (".getEntity('productprice', 1).")";
         $sql.= " AND pfp.fk_soc = s.rowid";
         $sql.= " AND s.status=1"; // only enabled company selected
         $sql.= " AND pfp.fk_product = ".$prodid;

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

@@ -1055,7 +1055,6 @@ if (empty($reshook))
 								}
 
 								$result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty);
-
 								if ($result>=0) 
 								{
 								    $tva_tx = $lines[$i]->tva_tx;
@@ -1089,6 +1088,7 @@ if (empty($reshook))
 										$lines[$i]->fk_unit
 									);
 								}
+									
 								if ($result < 0) {
 									$error++;
 									break;

+ 5 - 1
htdocs/imports/import.php

@@ -634,6 +634,10 @@ if ($step == 4 && $datatoimport)
         }
         
     }
+	
+	if(!empty(GETPOST('update'))) {
+		$array_match_file_to_database=array();
+	}
 
 	// Load source fields in input file
 	$fieldssource=array();
@@ -757,7 +761,7 @@ if ($step == 4 && $datatoimport)
 		print '<input type="text" size="1" name="separator" value="'.htmlentities($separator).'"/>';
 		print '&nbsp;&nbsp;&nbsp;&nbsp;'.$langs->trans("Enclosure").' : ';
 		print '<input type="text" size="1" name="enclosure" value="'.htmlentities($enclosure).'"/>';
-		print '<input type="submit" value="'.$langs->trans('Update').'" class="button" />';
+		print '<input name="update" type="submit" value="'.$langs->trans('Update').'" class="button" />';
 		print '</form>';
 		print '</td></tr>';
     }

+ 1 - 0
htdocs/langs/en_US/admin.lang

@@ -1753,3 +1753,4 @@ AddSubstitutions=Add keys substitutions
 DetectionNotPossible=Detection not possible
 UrlToGetKeyToUseAPIs=Url to get token to use API (once token has been received it is saved on database user table and will be checked on each future access) 
 ListOfAvailableAPIs=List of available APIs
+activateModuleDependNotSatisfied=Module "%s" depends on module "%s" that is missing, so module "%1$s" may not work correclty. Please install module "%2$s" or disable module "%1$s" if you want to be safe from any surprise

+ 1 - 0
htdocs/langs/en_US/main.lang

@@ -158,6 +158,7 @@ Save=Save
 SaveAs=Save As
 TestConnection=Test connection
 ToClone=Clone
+ConfirmCloneAction=Are you sure you want to clone this event ?
 ConfirmClone=Choose data you want to clone :
 NoCloneOptionsSpecified=No data to clone defined.
 Of=of

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

@@ -2666,7 +2666,7 @@ class Product extends CommonObject
     		$sql.= " WHERE fk_soc = ".$id_fourn;
     		$sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'";
     		$sql.= " AND fk_product != ".$this->id;
-    		$sql.= " AND entity = ".$conf->entity;
+    		$sql.= " AND entity IN (".getEntity('productprice', 1).")";
 
     		$resql=$this->db->query($sql);
     		if ($resql)
@@ -2689,7 +2689,7 @@ class Product extends CommonObject
 		else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)";
 		$sql.= " AND quantity = '".$quantity."'";
 		$sql.= " AND fk_product = ".$this->id;
-		$sql.= " AND entity = ".$conf->entity;
+		$sql.= " AND entity IN (".getEntity('productprice', 1).")";
 
 		$resql=$this->db->query($sql);
 		if ($resql)

+ 1 - 1
htdocs/product/fournisseurs.php

@@ -155,7 +155,7 @@ if (empty($reshook))
 		{
 			$error++;
 			$langs->load("errors");
-			setEventMessages($langs->trans("ErrorFieldMustBeANumeric",'eeee'), null, 'errors');
+			setEventMessages($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("VATRateForSupplierProduct")), null, 'errors');
 		}
 		if (empty($quantity))
 		{