diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index e54aeb1c8a5e22400b46a20cbbe66011539a60e6..2cb2337d17765c6b202ff47eb1ab752c91f45054 100644 --- a/htdocs/comm/mailing/card.php +++ b/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 ' '; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e039342dd381f53db3748ebb1939bdacdec79119..f6870cbd5957d08df7083d6598769caaf8ccb91f 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 cda28c80b376264125d7fa05fdb0290aa8c02319..902ee8c0bf4189f2a4a98f0f44edbfbd269ab477 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 a08e0a66a6f3534e2436d751d692994aff8b8dc8..a5c0a89f29dff645be483be76ed96bc344d27bcd 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 78f544cc8ab6fe3bf4ef70865436119b212f7b2a..d29d30139c037a1c5ddeaa6114b9d955a8b69206 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 1ef841a975a91d69ad591634a43061aeb083ccad..9f5742af1bcd57dd6478590a3a67e70bfe64a726 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 41fd00e546367a5bc8e994aab75b6a14aac07ba9..778fd7a9865cbae6f6ce8de8e6ce005a775ba28e 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 e565d015a9395c7f4b7e421b8953bdd960504d95..9ef7bdee9255ff2e80a78b3ba579a921a58891fb 100644 --- a/htdocs/expedition/card.php +++ b/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++; } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index c885a03145d78ad7aaf1c2b40101283c6d093ff8..64436dd8bddb5221efa610dbdf8bc23359931278 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/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; } } diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index a4905c300757d023acdd2437ef85e24789602600..c92f09ffbafb9a33f91718bee25ad2cbfcd17c66 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 589c102c8a3509af67fe3e9c3a90b16e7a0e169a..711c7d0b6139cc749ae9d7612d1b4ec7e58c46e1 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 '<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"> </td>'; // Print the search button print '<td class="liste_titre" align="right">'; diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index f1ebe3323729609942f718f666495ec3c38cb1c7..98455b2a2334875615e7149f400c64719bbbca94 100755 --- a/scripts/emailings/mailing-send.php +++ b/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); }