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>';
// Delivery date if (empty($conf->global->ORDER_DISABLE_DELIVERY_DATE))
print '<td align="center">'; {
print dol_print_date($db->jdate($objp->date_delivery), 'day'); // Delivery date
print '</td>'; print '<td align="center">';
print dol_print_date($db->jdate($objp->date_delivery), 'day');
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

@ -448,7 +448,7 @@ abstract class CommonObject
global $conf, $langs; global $conf, $langs;
$countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS $countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS
$contactid=0; $contactid=0;
$thirdpartyid=0; $thirdpartyid=0;
if ($this->element == 'societe') if ($this->element == 'societe')
@ -465,12 +465,12 @@ abstract class CommonObject
$contactid=$this->contact_id; $contactid=$this->contact_id;
$thirdpartyid=$object->fk_soc; $thirdpartyid=$object->fk_soc;
} }
$out='<!-- BEGIN part to show address block -->'; $out='<!-- BEGIN part to show address block -->';
$outdone=0; $outdone=0;
$coords = $this->getFullAddress(1,', '); $coords = $this->getFullAddress(1,', ');
if ($coords) if ($coords)
{ {
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
@ -485,7 +485,7 @@ abstract class CommonObject
} }
if (! in_array($this->country_code,$countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress if (! in_array($this->country_code,$countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress
&& empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state)
{ {
$out.=($outdone?' - ':'').$this->state; $out.=($outdone?' - ':'').$this->state;
$outdone++; $outdone++;
@ -516,15 +516,15 @@ abstract class CommonObject
if (! empty($this->office_fax)) { if (! empty($this->office_fax)) {
$out.=dol_print_phone($this->fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX','&nbsp;','fax',$langs->trans("Fax")); $outdone++; $out.=dol_print_phone($this->fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX','&nbsp;','fax',$langs->trans("Fax")); $outdone++;
} }
$out.='<div style="clear: both;"></div>'; $out.='<div style="clear: both;"></div>';
$outdone=0; $outdone=0;
if (! empty($this->email)) if (! empty($this->email))
{ {
$out.=dol_print_email($this->email,$this->id,$object->id,'AC_EMAIL',0,0,1); $out.=dol_print_email($this->email,$this->id,$object->id,'AC_EMAIL',0,0,1);
$outdone++; $outdone++;
} }
if (! empty($this->url)) if (! empty($this->url))
{ {
$out.=dol_print_url($this->url,'',0,1); $out.=dol_print_url($this->url,'',0,1);
$outdone++; $outdone++;
@ -535,12 +535,12 @@ abstract class CommonObject
if ($this->skype) $out.=dol_print_skype($this->skype,$this->id,$object->id,'AC_SKYPE'); if ($this->skype) $out.=dol_print_skype($this->skype,$this->id,$object->id,'AC_SKYPE');
$outdone++; $outdone++;
} }
$out.='<!-- END Part to show address block -->'; $out.='<!-- END Part to show address block -->';
return $out; return $out;
} }
/** /**
* Add a link between element $this->element and a contact * Add a link between element $this->element and a contact
* *
@ -595,50 +595,56 @@ abstract class CommonObject
} }
} }
$datecreate = dol_now();
$this->db->begin();
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= "'".$this->db->idate($datecreate)."'";
$sql.= ", 4, '". $id_type_contact . "' ";
$sql.= ")";
dol_syslog(get_class($this)."::add_contact", LOG_DEBUG);
$resql=$this->db->query($sql); if(! empty($id_type_contact)) {
if ($resql)
{ $datecreate = dol_now();
if (! $notrigger)
{ $this->db->begin();
$result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
if ($result < 0) // Insertion dans la base
{ $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$this->db->rollback(); $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= "'".$this->db->idate($datecreate)."'";
$sql.= ", 4, ". $id_type_contact . " ";
$sql.= ")";
dol_syslog(get_class($this)."::add_contact", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if (! $notrigger)
{
$result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
}
$this->db->commit();
return 1;
}
else
{
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$this->db->errno();
$this->db->rollback();
return -2;
}
else
{
$this->error=$this->db->error();
$this->db->rollback();
return -1; return -1;
} }
} }
$this->db->commit();
return 1;
}
else
{
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$this->db->errno();
$this->db->rollback();
return -2;
}
else
{
$this->error=$this->db->error();
$this->db->rollback();
return -1;
}
} }
return 1;
} }
/** /**
@ -1196,7 +1202,7 @@ abstract class CommonObject
if (!empty($id) && !empty($field) && !empty($table)) { if (!empty($id) && !empty($field) && !empty($table)) {
$sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table; $sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table;
$sql.= " WHERE rowid = ".$id; $sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG); dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -2275,8 +2281,8 @@ abstract class CommonObject
* - all parameters empty -> we look all link to current object (current object can be source or target) * - all parameters empty -> we look all link to current object (current object can be source or target)
* - one couple id+type is provided -> this will set $justsource or $justtarget * - one couple id+type is provided -> this will set $justsource or $justtarget
* - one couple id+type is provided and other type is provided -> this will set $justsource or $justtarget + criteria on other type * - one couple id+type is provided and other type is provided -> this will set $justsource or $justtarget + criteria on other type
* *
* *
* @param int $sourceid Object source id (if not defined, id of object) * @param int $sourceid Object source id (if not defined, id of object)
* @param string $sourcetype Object source type (if not defined, element name of object) * @param string $sourcetype Object source type (if not defined, element name of object)
* @param int $targetid Object target id (if not defined, id of object) * @param int $targetid Object target id (if not defined, id of object)
@ -3223,7 +3229,7 @@ abstract class CommonObject
$text.= ' - '.(! empty($line->label)?$line->label:$label); $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. $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'); $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)
@ -3662,7 +3668,7 @@ abstract class CommonObject
return -1; return -1;
} }
} }
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output; $sav_charset_output=$outputlangs->charset_output;
@ -3726,13 +3732,13 @@ abstract class CommonObject
/* For default values */ /* For default values */
/** /**
* Return the default value to use for a field when showing the create form of object. * Return the default value to use for a field when showing the create form of object.
* Return values in this order: * Return values in this order:
* 1) If parameter is available into POST, we return it first. * 1) If parameter is available into POST, we return it first.
* 2) If not but an alternate value was provided as parameter of function, we return it. * 2) If not but an alternate value was provided as parameter of function, we return it.
* 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table). * 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table).
* 4) Return value found into database (TODO No yet implemented) * 4) Return value found into database (TODO No yet implemented)
* *
* @param string $fieldname Name of field * @param string $fieldname Name of field
* @param string $alternatevalue Alternate value to use * @param string $alternatevalue Alternate value to use
* @return string Default value * @return string Default value
@ -3743,27 +3749,27 @@ abstract class CommonObject
// If param is has been posted with use this value first. // If param is has been posted with use this value first.
if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2); if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2);
if (isset($alternatevalue)) return $alternatevalue; if (isset($alternatevalue)) return $alternatevalue;
$newelement=$this->element; $newelement=$this->element;
if ($newelement == 'facture') $newelement='invoice'; if ($newelement == 'facture') $newelement='invoice';
if ($newelement == 'commande') $newelement='order'; if ($newelement == 'commande') $newelement='order';
if (empty($newelement)) if (empty($newelement))
{ {
dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING); dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING);
return ''; return '';
} }
$keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname); $keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname);
//var_dump($keyforfieldname); //var_dump($keyforfieldname);
if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname; if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname;
// TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname
} }
/* For triggers */ /* For triggers */
@ -3963,7 +3969,7 @@ abstract class CommonObject
{ {
$res=$object->fetch(0,$value); $res=$object->fetch(0,$value);
if ($res > 0) $this->array_options[$key]=$object->id; if ($res > 0) $this->array_options[$key]=$object->id;
else else
{ {
$this->error="Ref '".$value."' for object '".$object->element."' not found"; $this->error="Ref '".$value."' for object '".$object->element."' not found";
$this->db->rollback(); $this->db->rollback();
@ -4196,25 +4202,25 @@ abstract class CommonObject
return true; return true;
} }
/** /**
* define buy price if not defined * define buy price if not defined
* set buy price = sell price if ForceBuyingPriceIfNull configured, * set buy price = sell price if ForceBuyingPriceIfNull configured,
* else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, set pmp as buyprice * else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, set pmp as buyprice
* else set min buy price as buy price * else set min buy price as buy price
* *
* @param float $unitPrice product unit price * @param float $unitPrice product unit price
* @param float $discountPercent line discount percent * @param float $discountPercent line discount percent
* @param int $fk_product product id * @param int $fk_product product id
* *
* @return float <0 if ko, buyprice if ok * @return float <0 if ko, buyprice if ok
*/ */
public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0) public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0)
{ {
global $conf; global $conf;
$buyPrice = 0; $buyPrice = 0;
if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
{ {
$buyPrice = $unitPrice * (1 - $discountPercent / 100); $buyPrice = $unitPrice * (1 - $discountPercent / 100);

View File

@ -675,7 +675,7 @@ class ExtraFields
if ($showsize > 48) $showsize=48; if ($showsize > 48) $showsize=48;
} }
} }
if (in_array($type,array('date','datetime'))) if (in_array($type,array('date','datetime')))
{ {
$tmp=explode(',',$size); $tmp=explode(',',$size);
@ -812,7 +812,7 @@ class ExtraFields
if (strpos($InfoFieldList[4], '$SEL$')!==false) { if (strpos($InfoFieldList[4], '$SEL$')!==false) {
$InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]);
} }
// current object id can be use into filter // current object id can be use into filter
if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
@ -830,14 +830,14 @@ class ExtraFields
$sqlwhere.= ' WHERE '.$InfoFieldList[4]; $sqlwhere.= ' WHERE '.$InfoFieldList[4];
} }
} }
else else
{ {
$sqlwhere.= ' WHERE 1=1'; $sqlwhere.= ' WHERE 1=1';
} }
// Some tables may have field, some other not. For the moment we disable it. // Some tables may have field, some other not. For the moment we disable it.
if (in_array($InfoFieldList[0],array('tablewithentity'))) if (in_array($InfoFieldList[0],array('tablewithentity')))
{ {
$sqlwhere.= ' AND entity = '.$conf->entity; $sqlwhere.= ' AND entity = '.$conf->entity;
} }
$sql.=$sqlwhere; $sql.=$sqlwhere;
//print $sql; //print $sql;
@ -996,19 +996,19 @@ class ExtraFields
$sql = 'SELECT ' . $keyList; $sql = 'SELECT ' . $keyList;
$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
if (! empty($InfoFieldList[4])) { if (! empty($InfoFieldList[4])) {
// can use SELECT request // can use SELECT request
if (strpos($InfoFieldList[4], '$SEL$')!==false) { if (strpos($InfoFieldList[4], '$SEL$')!==false) {
$InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]);
} }
// current object id can be use into filter // current object id can be use into filter
if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
} else { } else {
$InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]); $InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]);
} }
// We have to join on extrafield table // We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra') !== false) { if (strpos($InfoFieldList[4], 'extra') !== false) {
$sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra';
@ -1020,13 +1020,13 @@ class ExtraFields
$sqlwhere .= ' WHERE 1=1'; $sqlwhere .= ' WHERE 1=1';
} }
// Some tables may have field, some other not. For the moment we disable it. // Some tables may have field, some other not. For the moment we disable it.
if (in_array($InfoFieldList[0], array ('tablewithentity'))) if (in_array($InfoFieldList[0], array ('tablewithentity')))
{ {
$sqlwhere .= ' AND entity = ' . $conf->entity; $sqlwhere .= ' AND entity = ' . $conf->entity;
} }
// $sql.=preg_replace('/^ AND /','',$sqlwhere); // $sql.=preg_replace('/^ AND /','',$sqlwhere);
// print $sql; // print $sql;
$sql .= $sqlwhere; $sql .= $sqlwhere;
dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG); dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1232,7 +1232,14 @@ class ExtraFields
{ {
$sql.= ' as main'; $sql.= ' as main';
} }
$sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; 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.= ' 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);
@ -1391,10 +1398,10 @@ class ExtraFields
$showsize=round($size); $showsize=round($size);
if ($showsize > 48) $showsize=48; if ($showsize > 48) $showsize=48;
} }
//print $type.'-'.$size; //print $type.'-'.$size;
$out=$value; $out=$value;
return $out; return $out;
} }
@ -1411,7 +1418,7 @@ class ExtraFields
$type=$this->attribute_type[$key]; $type=$this->attribute_type[$key];
$align=''; $align='';
if ($type == 'date') if ($type == 'date')
{ {
$align="center"; $align="center";
@ -1440,10 +1447,10 @@ class ExtraFields
{ {
$align="center"; $align="center";
} }
return $align; return $align;
} }
/** /**
* Return HTML string to print separator extrafield * Return HTML string to print separator extrafield
* *
@ -1523,7 +1530,7 @@ class ExtraFields
return 0; return 0;
} }
} }
/** /**
* return array_options array for object by extrafields value (using for data send by forms) * return array_options array for object by extrafields value (using for data send by forms)
* *

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,7 +1493,8 @@ 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

@ -278,7 +278,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
} }
dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
$newcodefortest=$codefortest; $newcodefortest=$codefortest;
// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
@ -290,7 +290,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
} }
} }
$result=check_value($mask,$newcodefortest); $result=check_value($mask,$newcodefortest);
return $result; return $result;

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,21 +1023,21 @@ 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)
{
foreach($output_arr as $val)
{ {
$this->lastoutput.=$val."\n"; foreach($output_arr as $val)
{
$this->lastoutput.=$val."\n";
}
} }
$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);