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
This commit is contained in:
Laurent Destailleur 2016-02-15 01:37:23 +01:00
commit 3bcc7b0f8f
12 changed files with 69 additions and 39 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@uers.sourceforge.net> * 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 * 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 * 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[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[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[4],2); $other5=(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) // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions)
$substitutionarray=array( $substitutionarray=array(
'__ID__' => $obj->source_id, '__ID__' => $obj->source_id,
@ -234,6 +236,7 @@ if (empty($reshook))
'__OTHER3__' => $other3, '__OTHER3__' => $other3,
'__OTHER4__' => $other4, '__OTHER4__' => $other4,
'__OTHER5__' => $other5, '__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"/>', '__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>' '__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>'
); );

View File

@ -288,7 +288,7 @@ if (empty($reshook))
{ {
$db->begin(); $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 (GETPOST('createmode') == 'copy' && GETPOST('copie_propal'))
{ {
if ($object->fetch(GETPOST('copie_propal')) > 0) { if ($object->fetch(GETPOST('copie_propal')) > 0) {
@ -316,7 +316,8 @@ if (empty($reshook))
$object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $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 { } else {
setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors'); setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors');
} }

View File

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

View File

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

View File

@ -384,7 +384,7 @@ abstract class CommonObject
*/ */
function errorsToString() 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)):'');
} }
/** /**
@ -3222,6 +3222,8 @@ abstract class CommonObject
$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. $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) // Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
@ -3244,7 +3246,7 @@ abstract class CommonObject
if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"'; if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"';
else $placeholder=' title="'.$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) // Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer

View File

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

View File

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

View File

@ -9,6 +9,7 @@
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr> * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Francis Appels <francis.appels@yahoo.com> * Copyright (C) 2014 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 * 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 * it under the terms of the GNU General Public License as published by
@ -944,7 +945,7 @@ if ($action == 'create')
if ($defaultqty<=0) { if ($defaultqty<=0) {
$defaultqty=0; $defaultqty=0;
} else { } else {
$defaultqty -= min($defaultqty,$substock); $defaultqty -= ($substock > 0 ? min($defaultqty,$substock) : 0);
} }
$subj++; $subj++;
} }

View File

@ -8,7 +8,8 @@
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr> * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014-2015 Francis Appels <francis.appels@yahoo.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 * 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 * it under the terms of the GNU General Public License as published by
@ -897,7 +898,7 @@ class Expedition extends CommonObject
*/ */
function addline_batch($dbatch,$array_options=0) function addline_batch($dbatch,$array_options=0)
{ {
global $conf; global $conf,$langs;
$num = count($this->lines); $num = count($this->lines);
if ($dbatch['qty']>0) if ($dbatch['qty']>0)
@ -924,7 +925,17 @@ class Expedition extends CommonObject
if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) 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); //var_dump($linebatch);
@ -941,6 +952,7 @@ class Expedition extends CommonObject
//var_dump($line); //var_dump($line);
$this->lines[$num] = $line; $this->lines[$num] = $line;
return 1;
} }
} }

View File

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

View File

@ -212,9 +212,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
't.fk_soc' => $object->id 't.fk_soc' => $object->id
); );
$search_soc = GETPOST('search_soc'); $search_prod = GETPOST('search_prod');
if (! empty($search_soc)) { if (! empty($search_prod)) {
$filter['soc.nom'] = $search_soc; $filter ['prod.ref'] = $search_prod;
} }
if ($action == 'add_customer_price') { if ($action == 'add_customer_price') {
@ -479,7 +479,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); 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, ''); 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 '<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 '<td colspan="8">&nbsp;</td>';
// Print the search button // Print the search button
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';

View File

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