Przeglądaj źródła

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

Conflicts:
	htdocs/comm/remise.php
	htdocs/expedition/card.php
	htdocs/expedition/class/expedition.class.php
	htdocs/filefunc.inc.php
	htdocs/societe/price.php
Laurent Destailleur 9 lat temu
rodzic
commit
3bcc7b0f8f

+ 9 - 6
htdocs/comm/mailing/card.php

@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2004		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
  * Copyright (C) 2005-2012	Laurent Destailleur		<eldy@uers.sourceforge.net>
- * Copyright (C) 2005-2012	Regis Houssin			<regis.houssin@capnetworks.com>
+ * Copyright (C) 2005-2016	Regis Houssin			<regis.houssin@capnetworks.com>
  *
  * 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
@@ -222,6 +222,8 @@ if (empty($reshook))
 	                    $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
 	                    $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
 	                    $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
+	                    $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
+
 	                    // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions)
 						$substitutionarray=array(
 								'__ID__' => $obj->source_id,
@@ -234,6 +236,7 @@ if (empty($reshook))
 								'__OTHER3__' => $other3,
 								'__OTHER4__' => $other4,
 								'__OTHER5__' => $other5,
+								'__SIGNATURE__' => $signature,	// Signature is empty when ran from command line or taken from user in parameter)
 								'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
 								'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'
 						);
@@ -1093,10 +1096,10 @@ else
 			}
 
 			print '</table>';
-			
+
 			dol_fiche_end();
-			
-			
+
+
 
 			print "\n";
 			print '<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'."\n";
@@ -1108,7 +1111,7 @@ else
 			print load_fiche_titre($langs->trans("EMail"),'','');
 
 			dol_fiche_head();
-			
+
 			print '<table class="border" width="100%">';
 
 			// Subject
@@ -1175,7 +1178,7 @@ else
 			print '</table>';
 
 			dol_fiche_end();
-			
+
 			print '<div class="center">';
 			print '<input type="submit" class="button" value="'.$langs->trans("Save").'" name="save">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

+ 3 - 2
htdocs/comm/propal.php

@@ -288,7 +288,7 @@ if (empty($reshook))
 		{
 			$db->begin();
 
-			// Si on a selectionne une propal a copier, on realise la copie
+			// If we select proposal to clone during creation (when option PROPAL_CLONE_ON_CREATE_PAGE is on)
 			if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal'))
 			{
 				if ($object->fetch(GETPOST('copie_propal')) > 0) {
@@ -316,7 +316,8 @@ if (empty($reshook))
 					$object->fk_incoterms = GETPOST('incoterm_id', 'int');
 					$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
 
-					$id = $object->create_from($user);
+					// the create is done below and further more the existing create_from function is quite hilarating
+					//$id = $object->create_from($user);
 				} else {
 					setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors');
 				}

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

@@ -1016,6 +1016,7 @@ class Propal extends CommonObject
      */
     function create_from($user)
     {
+    	// i love this function because $this->products is not used in create function...
         $this->products=$this->lines;
 
         return $this->create($user);

+ 4 - 2
htdocs/comm/remise.php

@@ -30,6 +30,8 @@ $langs->load("companies");
 $langs->load("orders");
 $langs->load("bills");
 
+$id=GETPOST("id",'int');
+
 $socid = GETPOST('id','int');
 // Security check
 if ($user->societe_id > 0)
@@ -53,8 +55,8 @@ if (GETPOST('cancel') && ! empty($backtopage))
 if (GETPOST("action") == 'setremise')
 {
 	$object = new Societe($db);
-	$object->fetch($_GET["id"]);
-	$result=$object->set_remise_client($_POST["remise"],$_POST["note"],$user);
+	$object->fetch($id);
+	$result=$object->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user);
 
 	if ($result > 0)
 	{

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

@@ -384,7 +384,7 @@ abstract class CommonObject
      */
     function errorsToString()
     {
-    	return $this->error.(is_array($this->errors)?(($this->error!=''?' ':'').join(',',$this->errors)):'');
+    	return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):'');
     }
 
     /**
@@ -3221,6 +3221,8 @@ abstract class CommonObject
 				$text.= ' - '.(! empty($line->label)?$line->label:$label);
 				$description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description));	// Description is what to show on popup. We shown nothing if already into desc.
 			}
+			
+			$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU');
 
 			// Output template part (modules that overwrite templates must declare this into descriptor)
 			// Use global variables + $dateSelector + $seller and $buyer
@@ -3244,7 +3246,7 @@ abstract class CommonObject
 			if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"';
 			else $placeholder=' title="'.$langs->trans("Label").'"';
 
-			$pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU');
+			$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU');
 
 			// Output template part (modules that overwrite templates must declare this into descriptor)
 			// Use global variables + $dateSelector + $seller and $buyer

+ 4 - 3
htdocs/core/lib/functions.lib.php

@@ -2037,11 +2037,12 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo
 {
 	global $conf;
 
-	if (empty($stringencoding)) $stringencoding='UTF-8';
-
 	if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string;
+	
+	if (empty($stringencoding)) $stringencoding='UTF-8';
 	// reduce for small screen
-    if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3);
+	if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3);
+
 	// We go always here
 	if ($trunc == 'right')
 	{

+ 5 - 1
htdocs/core/modules/modSociete.class.php

@@ -284,7 +284,11 @@ class modSociete extends DolibarrModules
         			case 'sellist':
 						$tmp='';
 						$tmpparam=unserialize($obj->param);	// $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
-						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
+						if ($tmpparam['options'] && is_array($tmpparam['options'])) 
+        				{
+							$stack=array_keys($tmpparam['options']);
+							$tmp=array_shift($stack);
+						}
 						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
 						break;
         		}

+ 2 - 1
htdocs/expedition/card.php

@@ -9,6 +9,7 @@
  * Copyright (C) 2014		Cedric GROSS			<c.gross@kreiz-it.fr>
  * Copyright (C) 2014		Francis Appels			<francis.appels@yahoo.com>
  * Copyright (C) 2015		Claudio Aschieri		<c.aschieri@19.coop>
+ * Copyright (C) 2016		Ferran Marcet			<fmarcet@2byte.es>
  *
  * 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
@@ -944,7 +945,7 @@ if ($action == 'create')
 							if ($defaultqty<=0) {
 								$defaultqty=0;
 							} else {
-								$defaultqty -= min($defaultqty,$substock);
+								$defaultqty -= ($substock > 0 ? min($defaultqty,$substock) : 0);
 							}
 							$subj++;
 						}

+ 16 - 4
htdocs/expedition/class/expedition.class.php

@@ -8,7 +8,8 @@
  * Copyright (C) 2014		Cedric GROSS			<c.gross@kreiz-it.fr>
  * Copyright (C) 2014-2015  Marcos García           <marcosgdf@gmail.com>
  * Copyright (C) 2014-2015  Francis Appels          <francis.appels@yahoo.com>
- * Copyright (C) 2015				Claudio Aschieri				<c.aschieri@19.coop>
+ * Copyright (C) 2015       Claudio Aschieri        <c.aschieri@19.coop>
+ * Copyright (C) 2016		Ferran Marcet			<fmarcet@2byte.es>
  *
  * 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
@@ -897,8 +898,8 @@ class Expedition extends CommonObject
 	 */
 	function addline_batch($dbatch,$array_options=0)
 	{
-		global $conf;
-		
+		global $conf,$langs;
+
 		$num = count($this->lines);
 		if ($dbatch['qty']>0)
 		{
@@ -924,7 +925,17 @@ class Expedition extends CommonObject
 
 					if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT)
 					{
-						// TODO
+						require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
+						$prod_batch = new Productbatch($this->db);
+						$prod_batch->fetch($value['id_batch']);
+
+						if ($prod_batch->qty < $linebatch->dluo_qty)
+						{
+							$this->errors[] = $langs->trans('ErrorStockIsNotEnough');
+							dol_syslog(get_class($this)."::addline_batch error=Product ".$prod_batch->batch.": ".$this->errorsToString(), LOG_ERR);
+							$this->db->rollback();
+							return -1;
+						}
 					}
 					
 					//var_dump($linebatch);
@@ -941,6 +952,7 @@ class Expedition extends CommonObject
 			
 			//var_dump($line);
 			$this->lines[$num] = $line;
+			return 1;
 		}
 	}
 

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

@@ -341,6 +341,8 @@ class Productcustomerprice extends CommonObject
 					$sql .= ' AND ' . $key . ' = \'' . $value . '\'';
 				} elseif ($key == 'soc.nom') {
 					$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
+				} elseif ($key == 'prod.ref') {
+					$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
 				} else {
 					$sql .= ' AND ' . $key . ' = ' . $value;
 				}

+ 5 - 5
htdocs/societe/price.php

@@ -212,9 +212,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
 		't.fk_soc' => $object->id
 	);
 
-	$search_soc = GETPOST('search_soc');
-	if (! empty($search_soc)) {
-		$filter['soc.nom'] = $search_soc;
+	$search_prod = GETPOST('search_prod');
+	if (! empty($search_prod)) {
+		$filter ['prod.ref'] = $search_prod;
 	}
 
 	if ($action == 'add_customer_price') {
@@ -479,7 +479,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
             setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
         }
         
-        $option = '&search_soc=' . $search_soc . '&id=' . $object->id;
+        $option = '&search_prod=' . $search_prod . '&id=' . $object->id;
         
         print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
         
@@ -505,7 +505,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
         {
             
             print '<tr class="liste_titre">';
-            print '<td><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>';
+			print '<td><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>';
             print '<td colspan="8">&nbsp;</td>';
             // Print the search button
             print '<td class="liste_titre" align="right">';

+ 14 - 13
scripts/emailings/mailing-send.php

@@ -1,8 +1,9 @@
 #!/usr/bin/env php
 <?php
 /*
- * Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2005-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2005-2013	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2016	Regis Houssin			<regis.houssin@capnetworks.com>
  *
  * 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
@@ -142,17 +143,17 @@ if ($resql)
 
 						// Make subtsitutions on topic and body
 						$other=explode(';',$obj2->other);
-						$other1=$other[0];
-						$other2=$other[1];
-						$other3=$other[2];
-						$other4=$other[3];
-						$other5=$other[4];
-						// Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions)
-						$signature = (!empty($user->signature))?$user->signature:''; 
-						
+						$tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
+	                    $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
+	                    $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
+	                    $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
+	                    $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
+	                    $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
+
+						// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
 						$substitutionarray=array(
-							'__ID__' => $obj->source_id,
-							'__EMAIL__' => $obj->email,
+							'__ID__' => $obj2->source_id,
+							'__EMAIL__' => $obj2->email,
 							'__LASTNAME__' => $obj2->lastname,
 							'__FIRSTNAME__' => $obj2->firstname,
 							'__MAILTOEMAIL__' => '<a href="mailto:'.$obj2->email.'">'.$obj2->email.'</a>',
@@ -251,7 +252,7 @@ if ($resql)
 										$error++;
 									}
 								}
-                                
+
                                 if (!empty($conf->global->MAILING_DELAY)) {
                                     sleep($conf->global->MAILING_DELAY);
                                 }