Merge branch '5.0' of git@github.com:Dolibarr/dolibarr.git into 6.0

Conflicts:
	htdocs/contrat/list.php
	htdocs/fichinter/list.php
This commit is contained in:
Laurent Destailleur 2017-07-23 19:09:00 +02:00
commit 25b107defb
16 changed files with 175 additions and 39 deletions

View File

@ -353,10 +353,12 @@ begin
begin
// TODO Copy file or ask to install package ?
//CustomMessage('YouWillInstallDoliWamp')+#13#13
MsgBox('The package vcredist_x86.exe must have been installed first. It seems it is not. Please install it first from <a href="http://ccc">http://www.microsoft.com/en-us/download/details.aspx?id=30679</a> then restart DoliWamp installation/upgrade.',mbInformation,MB_OK);
MsgBox('The package vcredist_x86.exe must have been installed first. It seems it is not. Please install it first from <a href="http://www.microsoft.com/en-us/download/details.aspx?id=30679">http://www.microsoft.com/en-us/download/details.aspx?id=30679</a> then restart DoliWamp installation/upgrade.',mbInformation,MB_OK);
end;
// Pb seems similar with msvcp110.dll
//vcredist_x64.exe
// If we have a new database version, we should only copy old my.ini file into new directory
// and change only all basedir= strings to use new version. Like this, data dir is still correct.
// Install of service and stop/start scripts are already rebuild by installer.

View File

@ -355,6 +355,7 @@ if ($resql)
$soc = new Societe($db);
$soc->fetch($socid);
$title = $langs->trans('ListOfProposals') . ' - '.$soc->name;
if (empty($search_societe)) $search_societe = $soc->name;
}
else
{

View File

@ -2039,7 +2039,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</form>';
} else {
print $object->date ? dol_print_date($object->date, 'day') : '&nbsp;';
if ($object->hasDelay() && empty($object->date_livraison)) {
if ($object->hasDelay() && ! empty($object->date_livraison)) {
print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning");
}
}

View File

@ -578,6 +578,7 @@ if ($resql)
$soc = new Societe($db);
$soc->fetch($socid);
$title = $langs->trans('ListOfOrders') . ' - '.$soc->name;
if (empty($search_company)) $search_company = $soc->name;
}
else
{

View File

@ -531,6 +531,7 @@ if ($resql)
{
$soc = new Societe($db);
$soc->fetch($socid);
if (empty($search_societe)) $search_societe = $soc->name;
}
$param='&socid='.$socid;

View File

@ -1642,8 +1642,8 @@ class Contrat extends CommonObject
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used
{
$contractline = new ContratLigne($this->db);
$contractline->array_options=$array_option;
$contractline->id= $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element);
$contractline->array_options=$array_options;
$contractline->id= $rowid;
$result=$contractline->insertExtraFields();
if ($result < 0)
{

View File

@ -306,6 +306,13 @@ if ($resql)
$arrayofselected=is_array($toselect)?$toselect:array();
if ($socid > 0)
{
$soc = new Societe($db);
$soc->fetch($socid);
if (empty($search_name)) $search_name = $soc->name;
}
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;

View File

@ -5625,6 +5625,14 @@ class Form
{
$listofidcompanytoscan=$object->thirdparty->id;
if (($object->thirdparty->parent > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan.=','.$object->thirdparty->parent;
if (($object->fk_project > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO))
{
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$tmpproject=new Project($this->db);
$tmpproject->fetch($object->fk_project);
if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan.=','.$tmpproject->socid;
unset($tmpproject);
}
$possiblelinks=array(
'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'),

View File

@ -271,7 +271,7 @@ class SMTPs
{
$this->_moreinheader = $_val;
}
/**
* get trackid
*
@ -291,7 +291,7 @@ class SMTPs
{
return $this->_moreinheader;
}
/**
* Set errors to
*
@ -411,7 +411,7 @@ class SMTPs
function _server_authenticate()
{
global $conf;
// Send the RFC2554 specified EHLO.
// This improvment as provided by 'SirSir' to
// accomodate both SMTP AND ESMTP capable servers
@ -462,7 +462,7 @@ class SMTPs
{
$this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
return $_retVal;
}
}
}
// Send Authentication to Server
// Check for errors along the way
@ -903,7 +903,7 @@ class SMTPs
if ( $_strReplyTo )
$this->_msgReplyTo = $this->_strip_email($_strReplyTo);
}
/**
* Retrieves the Address from which mail will be the reply-to
*
@ -913,15 +913,15 @@ class SMTPs
function getReplyTo($_part = true)
{
$_retValue = '';
if ( $_part === true )
$_retValue = $this->_msgReplyTo;
else
$_retValue = $this->_msgReplyTo[$_part];
return $_retValue;
}
/**
* Inserts given addresses into structured format.
* This method takes a list of given addresses, via an array
@ -1217,6 +1217,8 @@ class SMTPs
*/
function getHeader()
{
global $conf;
$_header = 'From: ' . $this->getFrom('org') . "\r\n"
. 'To: ' . $this->getTO() . "\r\n";
@ -1233,13 +1235,13 @@ class SMTPs
if ( $this->getBCC() )
$_header .= 'Bcc: ' . $this->getBCC() . "\r\n";
*/
$host=$this->getHost();
$host=preg_replace('@tcp://@i','',$host); // Remove prefix
$host=preg_replace('@ssl://@i','',$host); // Remove prefix
$host=dol_getprefix('email');
//NOTE: Message-ID should probably contain the username of the user who sent the msg
$_header .= 'Subject: ' . $this->getSubject() . "\r\n";
$_header .= 'Date: ' . date("r") . "\r\n";
@ -1258,7 +1260,7 @@ class SMTPs
}
if ( $this->getMoreInHeader() )
$_header .= $this->getMoreInHeader(); // Value must include the "\r\n";
//$_header .=
// 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
// 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
@ -1279,9 +1281,10 @@ class SMTPs
$_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
$_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n";
$_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n";
$_header .= 'Mime-Version: 1.0' . "\r\n";
return $_header;
}
@ -1310,17 +1313,17 @@ class SMTPs
$strContentAltText = html_entity_decode(strip_tags($strContent));
$strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n"));
}
// Make RFC2045 Compliant
//$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content
$strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content.
$this->_msgContent[$strType] = array();
$this->_msgContent[$strType]['mimeType'] = $strMimeType;
$this->_msgContent[$strType]['data'] = $strContent;
$this->_msgContent[$strType]['dataText'] = $strContentAltText;
if ( $this->getMD5flag() )
$this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3);
//}
@ -1334,7 +1337,7 @@ class SMTPs
function getBodyContent()
{
global $conf;
// Generate a new Boundary string
$this->_setBoundary();
@ -1382,7 +1385,7 @@ class SMTPs
$content .= "\r\n";
$content .= "--" . $this->_getBoundary('mixed') . "\r\n";
if (key_exists('image', $this->_msgContent)) // If inline image found
{
$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
@ -1390,7 +1393,7 @@ class SMTPs
$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
}
// $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment'
@ -1450,18 +1453,18 @@ class SMTPs
$content.= "\r\n";
$content.= "--" . $this->_getBoundary('related') . "\r\n";
}
if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part
{
$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
$content .= "\r\n";
$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
$content.= "\r\n". $_content['dataText'] . "\r\n";
$content.= "--" . $this->_getBoundary('alternative') . "\r\n";
}
}
$content .= 'Content-Type: ' . $_content['mimeType'] . '; '
// . 'charset="' . $this->getCharSet() . '"';
. 'charset=' . $this->getCharSet() . '';
@ -1483,7 +1486,7 @@ class SMTPs
{
$content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n";
}
$content .= "\r\n";
}
}

View File

@ -393,6 +393,7 @@ function dol_dir_is_emtpy($folder)
*
* @param string $file Filename
* @return int <0 if KO, Number of lines in files if OK
* @see dol_nboflines
*/
function dol_count_nb_of_line($file)
{

View File

@ -4766,22 +4766,57 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
* Return first line of text. Cut will depends if content is HTML or not.
*
* @param string $text Input text
* @param int $nboflines Nb of lines to get (default is 1 = first line only)
* @return string Output text
* @see dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag
*/
function dolGetFirstLineOfText($text)
function dolGetFirstLineOfText($text, $nboflines=1)
{
if (dol_textishtml($text))
if ($nboflines == 1)
{
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
if (dol_textishtml($text))
{
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
}
else
{
$firstline=preg_replace('/[\n\r].*/','',$text);
}
return $firstline.((strlen($firstline) != strlen($text))?'...':'');
}
else
{
$firstline=preg_replace('/[\n\r].*/','',$text);
$ishtml=0;
if (dol_textishtml($text))
{
$text=preg_replace('/\n/','',$text);
$ishtml=1;
$repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
}
else
{
$repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
}
$text = strtr($text, $repTable);
if ($charset == 'UTF-8') { $pattern = '/(<br[^>]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
else $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag.
$a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$firstline='';
$i=0;
$nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator
while (($i < $nba) && ($i < ($nboflines * 2)))
{
if ($i % 2 == 0) $firstline .= $a[$i];
elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) $firstline .= ($ishtml?"<br>\n":"\n");
$i++;
}
unset($a);
return $firstline.(($i < $nba)?'...':'');
}
return $firstline.((strlen($firstline) != strlen($text))?'...':'');
}
@ -4943,7 +4978,7 @@ function dol_nboflines($s,$maxchar=0)
/**
* Return nb of lines of a formated text with \n and <br> (we can't have both \n and br)
* Return nb of lines of a formated text with \n and <br> (WARNING: string must not have mixed \n and br separators)
*
* @param string $text Text
* @param int $maxlinesize Largeur de ligne en caracteres (ou 0 si pas de limite - defaut)
@ -4979,6 +5014,8 @@ function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8')
}
}
}
unset($a);
return $nblines;
}

View File

@ -253,6 +253,13 @@ if ($resql)
$arrayofselected=is_array($toselect)?$toselect:array();
if ($socid > 0)
{
$soc = new Societe($db);
$soc->fetch($socid);
if (empty($search_company)) $search_company = $soc->name;
}
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;

View File

@ -426,6 +426,7 @@ if ($resql)
{
$soc = new Societe($db);
$soc->fetch($socid);
if (empty($search_societe)) $search_societe = $soc->name;
}
$param='&socid='.$socid;

View File

@ -547,4 +547,6 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178,
-- VMYSQL4.1 ALTER TABLE llx_establishment CHANGE COLUMN fk_user_mod fk_user_mod integer NULL;
-- VPGSQL8.2 ALTER TABLE llx_establishment ALTER COLUMN fk_user_mod DROP NOT NULL;
ALTER TABLE llx_multicurrency_rate ADD COLUMN entity integer DEFAULT 1;
ALTER TABLE llx_multicurrency_rate ADD COLUMN entity integer DEFAULT 1;
ALTER TABLE llx_user MODIFY COLUMN login varchar(50);

View File

@ -33,7 +33,7 @@ create table llx_user
tms timestamp,
fk_user_creat integer,
fk_user_modif integer,
login varchar(24) NOT NULL,
login varchar(50) NOT NULL,
pass varchar(128),
pass_crypted varchar(128),
pass_temp varchar(128), -- temporary password when asked for forget password

View File

@ -122,10 +122,75 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
/**
* testDolGetFirstLineOfText
*
* @return void
*/
public function testDolGetFirstLineOfText()
{
// Nb of line is same than entry text
$input="aaaa";
$result=dolGetFirstLineOfText($input);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa", $result);
$input="aaaa\nbbbbbbbbbbbb\n";
$result=dolGetFirstLineOfText($input, 2);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa\nbbbbbbbbbbbb", $result);
$input="aaaa<br>bbbbbbbbbbbb<br>";
$result=dolGetFirstLineOfText($input, 2);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result);
// Nb of line is lower
$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
$result=dolGetFirstLineOfText($input);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa...", $result);
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
$result=dolGetFirstLineOfText($input);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa...", $result);
$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
$result=dolGetFirstLineOfText($input, 2);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result);
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
$result=dolGetFirstLineOfText($input, 2);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result);
// Nb of line is higher
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc";
$result=dolGetFirstLineOfText($input, 100);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a');
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
$result=dolGetFirstLineOfText($input, 100);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b');
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
$result=dolGetFirstLineOfText($input, 100);
print __METHOD__." result=".$result."\n";
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c');
}
/**
* testDolBuildPath
*
* @return boolean
* @return void
*/
public function testDolBuildPath()
{