Merge remote-tracking branch 'upstream/3.9' into 3.9

This commit is contained in:
Juanjo Menent 2016-08-31 01:50:04 +02:00
commit b1401d6566
14 changed files with 152 additions and 141 deletions

View File

@ -167,7 +167,7 @@ if ($action == 'edit') // Edit
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Multilangual GUI // Multilingual GUI
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>'; print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1); print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1);
@ -181,7 +181,7 @@ if ($action == 'edit') // Edit
show_theme(null,1); show_theme(null,1);
print '<br>'; print '<br>';
// Liste des zone de recherche permanantes supportees // List of permanent supported search box
if (! empty($searchform)) if (! empty($searchform))
{ {
print '<table summary="search" class="noborder" width="100%">'; print '<table summary="search" class="noborder" width="100%">';

View File

@ -587,10 +587,13 @@ if ($resql)
print dol_print_date($db->jdate($objp->date_commande), 'day'); print dol_print_date($db->jdate($objp->date_commande), 'day');
print '</td>'; print '</td>';
if (empty($conf->global->ORDER_DISABLE_DELIVERY_DATE))
{
// Delivery date // Delivery date
print '<td align="center">'; print '<td align="center">';
print dol_print_date($db->jdate($objp->date_delivery), 'day'); print dol_print_date($db->jdate($objp->date_delivery), 'day');
print '</td>'; print '</td>';
}
// Amount HT // Amount HT
print '<td align="right" class="nowrap">'.price($objp->total_ht).'</td>'; print '<td align="right" class="nowrap">'.price($objp->total_ht).'</td>';

View File

@ -595,6 +595,10 @@ abstract class CommonObject
} }
} }
if(! empty($id_type_contact)) {
$datecreate = dol_now(); $datecreate = dol_now();
$this->db->begin(); $this->db->begin();
@ -604,7 +608,7 @@ abstract class CommonObject
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= "'".$this->db->idate($datecreate)."'"; $sql.= "'".$this->db->idate($datecreate)."'";
$sql.= ", 4, '". $id_type_contact . "' "; $sql.= ", 4, ". $id_type_contact . " ";
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::add_contact", LOG_DEBUG); dol_syslog(get_class($this)."::add_contact", LOG_DEBUG);
@ -640,6 +644,8 @@ abstract class CommonObject
} }
} }
} }
return 1;
}
/** /**
* Copy contact from one element to current * Copy contact from one element to current

View File

@ -1232,7 +1232,14 @@ class ExtraFields
{ {
$sql.= ' as main'; $sql.= ' as main';
} }
if ($selectkey=='rowid' && empty($value)) {
$sql.= " WHERE ".$selectkey."=0";
} elseif ($selectkey=='rowid') {
$sql.= " WHERE ".$selectkey."=".$this->db->escape($value);
}else {
$sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
}
//$sql.= ' AND entity = '.$conf->entity; //$sql.= ' AND entity = '.$conf->entity;
dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG); dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG);

View File

@ -1093,7 +1093,7 @@ class DoliDBPgsql extends DoliDB
*/ */
function DDLDropField($table,$field_name) function DDLDropField($table,$field_name)
{ {
$sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; $sql= "ALTER TABLE ".$table." DROP COLUMN ".$field_name;
dol_syslog($sql,LOG_DEBUG); dol_syslog($sql,LOG_DEBUG);
if (! $this->query($sql)) if (! $this->query($sql))
{ {

View File

@ -1493,6 +1493,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
/** /**
* This function evaluates a string that should be a valid IPv4 * This function evaluates a string that should be a valid IPv4
* Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patchs of PHP (5.6.25). See https://github.com/php/php-src/pull/1954.
* *
* @param string $ip IP Address * @param string $ip IP Address
* @return int 0 if not valid or reserved range, 1 if valid and public IP, 2 if valid and private range IP * @return int 0 if not valid or reserved range, 1 if valid and public IP, 2 if valid and private range IP

View File

@ -87,11 +87,11 @@ abstract class ModeleNumRefBarCode
/** /**
* Return next value available * Return next value available
* *
* @param Societe $objsoc Object thirdparty * @param Societe $objproduct Object Product
* @param int $type Type * @param int $type Type
* @return string Value * @return string Value
*/ */
function getNextValue($objsoc=0,$type=-1) function getNextValue($objproduct,$type='')
{ {
global $langs; global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking"); return $langs->trans("Function_getNextValue_InModuleNotWorking");

View File

@ -1023,11 +1023,9 @@ class Cronjob extends CommonObject
} }
if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
} }
}
dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG); dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG);
// Update with result // Update with result
$this->lastoutput=''; $this->lastoutput='';
if (is_array($output_arr) && count($output_arr)>0) if (is_array($output_arr) && count($output_arr)>0)
@ -1038,6 +1036,8 @@ class Cronjob extends CommonObject
} }
} }
$this->lastresult=$retval; $this->lastresult=$retval;
}
$this->datelastresult=dol_now(); $this->datelastresult=dol_now();
$result = $this->update($user); $result = $this->update($user);
if ($result < 0) if ($result < 0)

View File

@ -92,7 +92,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_deplacement FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_deplacement FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_date_u(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_date_m();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_resources FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_resources FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_entrepot FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_entrepot FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_events FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_events FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();

View File

@ -3690,11 +3690,11 @@ class Product extends CommonObject
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
{ {
$return.= '<!-- Show thumb -->'; $return.= '<!-- Show thumb -->';
$return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
} }
else { else {
$return.= '<!-- Show original file -->'; $return.= '<!-- Show original file -->';
$return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
} }
if (empty($nolink)) $return.= '</a>'; if (empty($nolink)) $return.= '</a>';

View File

@ -50,7 +50,7 @@ $cancel=GETPOST('cancel');
$id=GETPOST('id', 'int'); $id=GETPOST('id', 'int');
$ref=GETPOST('ref', 'alpha'); $ref=GETPOST('ref', 'alpha');
$stocklimit = GETPOST('stocklimit'); $stocklimit = GETPOST('seuil_stock_alerte');
$desiredstock = GETPOST('desiredstock'); $desiredstock = GETPOST('desiredstock');
$cancel = GETPOST('cancel'); $cancel = GETPOST('cancel');
$fieldid = isset($_GET["ref"])?'ref':'rowid'; $fieldid = isset($_GET["ref"])?'ref':'rowid';
@ -70,7 +70,7 @@ $result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldi
if ($cancel) $action=''; if ($cancel) $action='';
// Set stock limit // Set stock limit
if ($action == 'setstocklimit') if ($action == 'setseuil_stock_alerte')
{ {
$object = new Product($db); $object = new Product($db);
$result=$object->fetch($id); $result=$object->fetch($id);

View File

@ -339,7 +339,7 @@ class Resource extends CommonObject
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
$sql.= " WHERE element_type='resource' AND resource_id ='".$this->db->escape($rowid)."'"; $sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -393,7 +393,6 @@ class Resource extends CommonObject
} }
} }
} }
$sql.= " GROUP BY t.rowid";
$sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->order($sortfield,$sortorder);
$this->num_all = 0; $this->num_all = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@ -410,10 +409,10 @@ class Resource extends CommonObject
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num)
{ {
$i = 0; $this->lines=array();
while ($i < $num) while ($obj = $this->db->fetch_object($resql))
{ {
$obj = $this->db->fetch_object($resql);
$line = new Resource($this->db); $line = new Resource($this->db);
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->ref = $obj->ref; $line->ref = $obj->ref;
@ -421,8 +420,7 @@ class Resource extends CommonObject
$line->fk_code_type_resource = $obj->fk_code_type_resource; $line->fk_code_type_resource = $obj->fk_code_type_resource;
$line->type_label = $obj->type_label; $line->type_label = $obj->type_label;
$this->lines[$i] = $line; $this->lines[] = $line;
$i++;
} }
$this->db->free($resql); $this->db->free($resql);
} }
@ -473,7 +471,6 @@ class Resource extends CommonObject
} }
} }
} }
$sql.= " GROUP BY t.rowid";
$sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->order($sortfield,$sortorder);
if ($limit) $sql.= $this->db->plimit($limit+1,$offset); if ($limit) $sql.= $this->db->plimit($limit+1,$offset);
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
@ -484,10 +481,9 @@ class Resource extends CommonObject
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num)
{ {
$i = 0; $this->lines=array();
while ($i < $num) while ($obj = $this->db->fetch_object($resql))
{ {
$obj = $this->db->fetch_object($resql);
$line = new Resource($this->db); $line = new Resource($this->db);
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->resource_id = $obj->resource_id; $line->resource_id = $obj->resource_id;
@ -502,9 +498,8 @@ class Resource extends CommonObject
$line->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type); $line->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type);
if($obj->element_id && $obj->element_type) if($obj->element_id && $obj->element_type)
$line->objelement = fetchObjectByElement($obj->element_id,$obj->element_type); $line->objelement = fetchObjectByElement($obj->element_id,$obj->element_type);
$this->lines[$i] = $line; $this->lines[] = $line;
$i++;
} }
$this->db->free($resql); $this->db->free($resql);
} }
@ -559,7 +554,6 @@ class Resource extends CommonObject
} }
} }
} }
$sql.= " GROUP BY t.resource_id";
$sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->order($sortfield,$sortorder);
if ($limit) $sql.= $this->db->plimit($limit+1,$offset); if ($limit) $sql.= $this->db->plimit($limit+1,$offset);
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
@ -570,10 +564,9 @@ class Resource extends CommonObject
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num)
{ {
$i = 0; $this->lines=array();
while ($i < $num) while ($obj = $this->db->fetch_object($resql))
{ {
$obj = $this->db->fetch_object($resql);
$line = new Resource($this->db); $line = new Resource($this->db);
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->resource_id = $obj->resource_id; $line->resource_id = $obj->resource_id;
@ -584,9 +577,7 @@ class Resource extends CommonObject
$line->mandatory = $obj->mandatory; $line->mandatory = $obj->mandatory;
$line->fk_user_create = $obj->fk_user_create; $line->fk_user_create = $obj->fk_user_create;
$this->lines[$i] = fetchObjectByElement($obj->resource_id,$obj->resource_type); $this->lines[] = fetchObjectByElement($obj->resource_id,$obj->resource_type);
$i++;
} }
$this->db->free($resql); $this->db->free($resql);
} }
@ -757,10 +748,13 @@ class Resource extends CommonObject
} }
/* /**
* Return an array with resources linked to the element * Return an array with resources linked to the element
* *
* * @param string $element Element
* @param int $element_id Id
* @param string $resource_type Type
* @return array Aray of resources
*/ */
function getElementResources($element,$element_id,$resource_type='') function getElementResources($element,$element_id,$resource_type='')
{ {
@ -768,7 +762,7 @@ class Resource extends CommonObject
// Links beetween objects are stored in this table // Links beetween objects are stored in this table
$sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory';
$sql.= ' FROM '.MAIN_DB_PREFIX.'element_resources'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_resources';
$sql.= " WHERE element_id='".$element_id."' AND element_type='".$element."'"; $sql.= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'";
if($resource_type) if($resource_type)
$sql.=" AND resource_type LIKE '%".$resource_type."%'"; $sql.=" AND resource_type LIKE '%".$resource_type."%'";
$sql .= ' ORDER BY resource_type'; $sql .= ' ORDER BY resource_type';

View File

@ -223,7 +223,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase
$ip='169.254.0.0'; $ip='169.254.0.0';
$result=is_ip($ip); $result=is_ip($ip);
print __METHOD__." for ".$ip." result=".$result."\n"; print __METHOD__." for ".$ip." result=".$result."\n";
$this->assertEquals(0,$result,$ip); //$this->assertEquals(2,$result,$ip); // Assertion disabled because returned value differs between PHP patch version
$ip='1.2.3.4'; $ip='1.2.3.4';
$result=is_ip($ip); $result=is_ip($ip);