diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 51d0a6174c855470f6a81d6bbb3232b3450c04e7..3147538c8fe6d5f56a35c54890c66b193adedf8e 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -167,7 +167,7 @@ if ($action == 'edit') // Edit print '<td width="20"> </td>'; print '</tr>'; - // Multilangual GUI + // Multilingual GUI $var=!$var; print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>'; print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1); @@ -181,7 +181,7 @@ if ($action == 'edit') // Edit show_theme(null,1); print '<br>'; - // Liste des zone de recherche permanantes supportees + // List of permanent supported search box if (! empty($searchform)) { print '<table summary="search" class="noborder" width="100%">'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index cfb8486be6f7c8636e133ce95b1a4333033815fb..401be745957ed3f9b0af5deb91d2e8c1d35ca844 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -587,10 +587,13 @@ if ($resql) print dol_print_date($db->jdate($objp->date_commande), 'day'); print '</td>'; - // Delivery date - print '<td align="center">'; - print dol_print_date($db->jdate($objp->date_delivery), 'day'); - print '</td>'; + if (empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)) + { + // Delivery date + print '<td align="center">'; + print dol_print_date($db->jdate($objp->date_delivery), 'day'); + print '</td>'; + } // Amount HT print '<td align="right" class="nowrap">'.price($objp->total_ht).'</td>'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c314011874552ece1201991dbd7295f540e219fa..3279d372a0e1714374a876b51b383edfc9d5b8df 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -448,7 +448,7 @@ abstract class CommonObject global $conf, $langs; $countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS - + $contactid=0; $thirdpartyid=0; if ($this->element == 'societe') @@ -465,12 +465,12 @@ abstract class CommonObject $contactid=$this->contact_id; $thirdpartyid=$object->fk_soc; } - + $out='<!-- BEGIN part to show address block -->'; - + $outdone=0; $coords = $this->getFullAddress(1,', '); - if ($coords) + if ($coords) { 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 - && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) + && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) { $out.=($outdone?' - ':'').$this->state; $outdone++; @@ -516,15 +516,15 @@ abstract class CommonObject if (! empty($this->office_fax)) { $out.=dol_print_phone($this->fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX',' ','fax',$langs->trans("Fax")); $outdone++; } - + $out.='<div style="clear: both;"></div>'; $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); $outdone++; } - if (! empty($this->url)) + if (! empty($this->url)) { $out.=dol_print_url($this->url,'',0,1); $outdone++; @@ -535,12 +535,12 @@ abstract class CommonObject if ($this->skype) $out.=dol_print_skype($this->skype,$this->id,$object->id,'AC_SKYPE'); $outdone++; } - + $out.='<!-- END Part to show address block -->'; - + return $out; } - + /** * 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 ($resql) - { - if (! $notrigger) - { - $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); - if ($result < 0) - { - $this->db->rollback(); - return -1; + if(! empty($id_type_contact)) { + + $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 ($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; - } + $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)) { $sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE rowid = ".$id; - + dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG); $resql = $this->db->query($sql); 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) * - 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 - * - * + * + * * @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 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); $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) @@ -3662,7 +3668,7 @@ abstract class CommonObject return -1; } } - + // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; @@ -3726,13 +3732,13 @@ abstract class CommonObject /* 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: * 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. - * 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) - * + * * @param string $fieldname Name of field * @param string $alternatevalue Alternate value to use * @return string Default value @@ -3743,27 +3749,27 @@ abstract class CommonObject // If param is has been posted with use this value first. if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2); - + if (isset($alternatevalue)) return $alternatevalue; - + $newelement=$this->element; if ($newelement == 'facture') $newelement='invoice'; 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); return ''; } - + $keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname); //var_dump($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 */ @@ -3963,7 +3969,7 @@ abstract class CommonObject { $res=$object->fetch(0,$value); if ($res > 0) $this->array_options[$key]=$object->id; - else + else { $this->error="Ref '".$value."' for object '".$object->element."' not found"; $this->db->rollback(); @@ -4196,25 +4202,25 @@ abstract class CommonObject return true; } - + /** * define buy price if not defined * set buy price = sell price if ForceBuyingPriceIfNull configured, * else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, set pmp as buyprice * else set min buy price as buy price - * + * * @param float $unitPrice product unit price * @param float $discountPercent line discount percent * @param int $fk_product product id * * @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; - + $buyPrice = 0; - + if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { $buyPrice = $unitPrice * (1 - $discountPercent / 100); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d63c2536476e52d17d1338a8e231910b3fd5e2b1..52c3b2f5cb988f040095755ad177a909e8da7696 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -675,7 +675,7 @@ class ExtraFields if ($showsize > 48) $showsize=48; } } - + if (in_array($type,array('date','datetime'))) { $tmp=explode(',',$size); @@ -812,7 +812,7 @@ class ExtraFields if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); } - + // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); @@ -830,14 +830,14 @@ class ExtraFields $sqlwhere.= ' WHERE '.$InfoFieldList[4]; } } - else + else { $sqlwhere.= ' WHERE 1=1'; } // 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; //print $sql; @@ -996,19 +996,19 @@ class ExtraFields $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; if (! empty($InfoFieldList[4])) { - + // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); } - + // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); } else { $InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]); } - + // We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; @@ -1020,13 +1020,13 @@ class ExtraFields $sqlwhere .= ' WHERE 1=1'; } // 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; } // $sql.=preg_replace('/^ AND /','',$sqlwhere); // print $sql; - + $sql .= $sqlwhere; dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG); $resql = $this->db->query($sql); @@ -1232,7 +1232,14 @@ class ExtraFields { $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; dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG); @@ -1391,10 +1398,10 @@ class ExtraFields $showsize=round($size); if ($showsize > 48) $showsize=48; } - + //print $type.'-'.$size; $out=$value; - + return $out; } @@ -1411,7 +1418,7 @@ class ExtraFields $type=$this->attribute_type[$key]; $align=''; - + if ($type == 'date') { $align="center"; @@ -1440,10 +1447,10 @@ class ExtraFields { $align="center"; } - + return $align; } - + /** * Return HTML string to print separator extrafield * @@ -1523,7 +1530,7 @@ class ExtraFields return 0; } } - + /** * return array_options array for object by extrafields value (using for data send by forms) * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 048ef2d450d55de2c5140d78ddb227f4d2a82f49..304006402c271f26cbc96993cc4a10cb0958cc6c 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1093,7 +1093,7 @@ class DoliDBPgsql extends DoliDB */ 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); if (! $this->query($sql)) { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index deab2457c8be68a0106616744ccb3ea0b0c158ca..82449ac63cb8b95e1f8376a082408fceabd39ff7 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1493,7 +1493,8 @@ function getListOfModels($db,$type,$maxfilenamelength=0) /** * 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 * @return int 0 if not valid or reserved range, 1 if valid and public IP, 2 if valid and private range IP */ diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index aeb7ea4cd8fdf7cc95d0e5251627f7d93dce6394..12f4fb96545150abb832bbffbb70429341ae0687 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -278,7 +278,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); - + $newcodefortest=$codefortest; // 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); } } - + $result=check_value($mask,$newcodefortest); return $result; diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index d03302f36b7d0693b47067706fec3790fd162a63..43924165901fec3cd49f23adbc2347509480e508 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -87,11 +87,11 @@ abstract class ModeleNumRefBarCode /** * Return next value available * - * @param Societe $objsoc Object thirdparty + * @param Societe $objproduct Object Product * @param int $type Type * @return string Value */ - function getNextValue($objsoc=0,$type=-1) + function getNextValue($objproduct,$type='') { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 39eaacd303fbf240754aef5e5e117bb191b032fc..ed7ece5bc84f89f539f30c69ca57778b3bc02908 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1023,21 +1023,21 @@ class Cronjob extends CommonObject } 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 - $this->lastoutput=''; - if (is_array($output_arr) && count($output_arr)>0) - { - foreach($output_arr as $val) + // Update with result + $this->lastoutput=''; + if (is_array($output_arr) && count($output_arr)>0) { - $this->lastoutput.=$val."\n"; + foreach($output_arr as $val) + { + $this->lastoutput.=$val."\n"; + } } + $this->lastresult=$retval; } - $this->lastresult=$retval; + $this->datelastresult=dol_now(); $result = $this->update($user); if ($result < 0) diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index d742c5dd223042fcd60af892edb034d56364487b..8ff784b51ba6bf3c36447630e710d767edcb9c4d 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -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_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_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_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(); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 79c21cfcbdf8b1fea8e2fdd003f8f39a664fb56b..afff7d6f1c6b3deb0f820b88ff79df5443d17de1 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3690,11 +3690,11 @@ class Product extends CommonObject if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) { $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 { $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>'; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 9d84ccd6bfe48863203281e8410116c90015dc76..3170f329ea7e12c24d7e4678963d7336f0a9f0ad 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -50,7 +50,7 @@ $cancel=GETPOST('cancel'); $id=GETPOST('id', 'int'); $ref=GETPOST('ref', 'alpha'); -$stocklimit = GETPOST('stocklimit'); +$stocklimit = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel'); $fieldid = isset($_GET["ref"])?'ref':'rowid'; @@ -70,7 +70,7 @@ $result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldi if ($cancel) $action=''; // Set stock limit -if ($action == 'setstocklimit') +if ($action == 'setseuil_stock_alerte') { $object = new Product($db); $result=$object->fetch($id); diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/resource.class.php index c323ad17e69e25daee34f6e9c2286d738338674b..0f4809fc1b4f326898d43c47a5939ea301b2eacd 100644 --- a/htdocs/resource/class/resource.class.php +++ b/htdocs/resource/class/resource.class.php @@ -339,7 +339,7 @@ class Resource extends CommonObject if ($this->db->query($sql)) { $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); if ($this->db->query($sql)) { @@ -393,7 +393,6 @@ class Resource extends CommonObject } } } - $sql.= " GROUP BY t.rowid"; $sql.= $this->db->order($sortfield,$sortorder); $this->num_all = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -410,10 +409,10 @@ class Resource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + $this->lines=array(); + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); + $line = new Resource($this->db); $line->id = $obj->rowid; $line->ref = $obj->ref; @@ -421,8 +420,7 @@ class Resource extends CommonObject $line->fk_code_type_resource = $obj->fk_code_type_resource; $line->type_label = $obj->type_label; - $this->lines[$i] = $line; - $i++; + $this->lines[] = $line; } $this->db->free($resql); } @@ -473,7 +471,6 @@ class Resource extends CommonObject } } } - $sql.= " GROUP BY t.rowid"; $sql.= $this->db->order($sortfield,$sortorder); if ($limit) $sql.= $this->db->plimit($limit+1,$offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); @@ -484,10 +481,9 @@ class Resource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + $this->lines=array(); + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); $line = new Resource($this->db); $line->id = $obj->rowid; $line->resource_id = $obj->resource_id; @@ -502,9 +498,8 @@ class Resource extends CommonObject $line->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type); if($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); } @@ -559,7 +554,6 @@ class Resource extends CommonObject } } } - $sql.= " GROUP BY t.resource_id"; $sql.= $this->db->order($sortfield,$sortorder); if ($limit) $sql.= $this->db->plimit($limit+1,$offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); @@ -570,10 +564,9 @@ class Resource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + $this->lines=array(); + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); $line = new Resource($this->db); $line->id = $obj->rowid; $line->resource_id = $obj->resource_id; @@ -584,9 +577,7 @@ class Resource extends CommonObject $line->mandatory = $obj->mandatory; $line->fk_user_create = $obj->fk_user_create; - $this->lines[$i] = fetchObjectByElement($obj->resource_id,$obj->resource_type); - - $i++; + $this->lines[] = fetchObjectByElement($obj->resource_id,$obj->resource_type); } $this->db->free($resql); } @@ -757,10 +748,13 @@ class Resource extends CommonObject } - /* + /** * 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='') { @@ -768,7 +762,7 @@ class Resource extends CommonObject // Links beetween objects are stored in this table $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; $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) $sql.=" AND resource_type LIKE '%".$resource_type."%'"; $sql .= ' ORDER BY resource_type'; diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 13462afc601f6155603460fa39485a261fc4b4aa..470a570bf6efde6788cff5898e3c2929ce2f6a07 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -223,7 +223,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase $ip='169.254.0.0'; $result=is_ip($ip); 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'; $result=is_ip($ip);