diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index e54aeb1c8a5..2cb2337d177 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * * 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__' => '', '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'' ); @@ -1093,10 +1096,10 @@ else } print ''; - + dol_fiche_end(); - - + + print "\n"; print '
'."\n"; @@ -1108,7 +1111,7 @@ else print load_fiche_titre($langs->trans("EMail"),'',''); dol_fiche_head(); - + print ''; // Subject @@ -1175,7 +1178,7 @@ else print '
'; dol_fiche_end(); - + print '
'; print ''; print '     '; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e039342dd38..f6870cbd595 100644 --- a/htdocs/comm/propal.php +++ b/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'); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index cda28c80b37..902ee8c0bf4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/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); diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index a08e0a66a6f..a5c0a89f29d 100644 --- a/htdocs/comm/remise.php +++ b/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) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 78f544cc8ab..d29d30139c0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/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 diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1ef841a975a..9f5742af1bc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/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') { diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 41fd00e5463..778fd7a9865 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/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; } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index e565d015a93..9ef7bdee925 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014 Francis Appels * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2016 Ferran Marcet * * 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++; } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index c885a03145d..64436dd8bdd 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -8,7 +8,8 @@ * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014-2015 Marcos GarcĂ­a * Copyright (C) 2014-2015 Francis Appels - * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2016 Ferran Marcet * * 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; } } diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index a4905c30075..c92f09ffbaf 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/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; } diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 589c102c8a3..711c7d0b613 100644 --- a/htdocs/societe/price.php +++ b/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 ''; - print ''; + print ''; print ' '; // Print the search button print ''; diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index f1ebe332372..98455b2a233 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -1,8 +1,9 @@ #!/usr/bin/env php - * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2005-2016 Regis Houssin * * 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__' => ''.$obj2->email.'', @@ -251,7 +252,7 @@ if ($resql) $error++; } } - + if (!empty($conf->global->MAILING_DELAY)) { sleep($conf->global->MAILING_DELAY); }