diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 0f07a79d10a..cab31680ba3 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -126,26 +126,20 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } // Suppression de la propale -else if ($action == 'confirm_delete' && $confirm == 'yes') +else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propale->supprimer) { - if ($user->rights->propale->supprimer) + $object->fetch($id); + $result=$object->delete($user); + if ($result > 0) { - $object->fetch($id); - $result=$object->delete($user); - $id = 0; - $brouillon = 1; - - if ($result > 0) - { - Header('Location: '.$_SERVER["PHP_SELF"]); - exit; - } - else - { - $langs->load("errors"); - if ($object->error == 'ErrorFailToDeleteDir') $mesg='
'.$langs->trans('ErrorFailedToDeleteJoinedFiles').'
'; - else $mesg='
'.$object->error.'
'; - } + Header('Location: '.$_SERVER["PHP_SELF"]); + exit; + } + else + { + $langs->load("errors"); + if ($object->error == 'ErrorFailToDeleteDir') $mesg='
'.$langs->trans('ErrorFailedToDeleteJoinedFiles').'
'; + else $mesg='
'.$object->error.'
'; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 50e0372adce..439820a5ac5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1534,13 +1534,13 @@ abstract class CommonObject $sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')"; $sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')"; } - //print $sql; + print $sql; dol_syslog(get_class($this)."::fetchObjectLink sql=".$sql); $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); + $num = $this->db->num_rows($resql); echo 'num='.$num.'
'; $i = 0; while ($i < $num) { @@ -1549,13 +1549,14 @@ abstract class CommonObject { $this->linkedObjectsIds[$obj->targettype][]=$obj->fk_target; } + echo 'fk_target='.$obj->fk_target.' targetid='.$targetid.'
'; if ($obj->fk_target == $targetid) { $this->linkedObjectsIds[$obj->sourcetype][]=$obj->fk_source; } $i++; } - +var_dump($this->linkedObjectsIds); if (! empty($this->linkedObjectsIds)) { foreach($this->linkedObjectsIds as $objecttype => $objectids) @@ -1685,8 +1686,10 @@ abstract class CommonObject function deleteObjectLinked() { $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element"; - $sql.= " WHERE fk_target = ".$this->id; - $sql.= " AND targettype = '".$this->element."'"; + $sql.= " WHERE"; + $sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->element."')"; + $sql.= " OR"; + $sql.= " (fk_target = ".$this->id." AND targettype = '".$this->element."')"; dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG); if ($this->db->query($sql)) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index ac3e018c411..8d5fb4ffabd 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -235,7 +235,13 @@ class Conf $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; // If multicompany module is enabled, we redefine the root of data - if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1) $rootfordata.='/'.$this->entity; + if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1) + { + $rootfordata.='/'.$this->entity; + var_dump($mc->sharings); + //var_dump($mc->referent); + var_dump($mc->entities); + } // For backward compatibility // TODO Replace this->xxx->enabled by this->modulename->enabled to remove this code diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index cd105ecc066..b9ef43a31ba 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -35,322 +35,320 @@ /** - * Class to manage generation of HTML components - * Only common components must be here. + * \class Form + * \brief Class to manage generation of HTML components + * \remarks Only common components must be here. */ class Form { - var $db; - var $error; + var $db; + var $error; - // Cache arrays - var $cache_types_paiements=array(); - var $cache_conditions_paiements=array(); - var $cache_availability=array(); - var $cache_demand_reason=array(); - var $cache_type_fees=array(); + // Cache arrays + var $cache_types_paiements=array(); + var $cache_conditions_paiements=array(); + var $cache_availability=array(); + var $cache_demand_reason=array(); + var $cache_type_fees=array(); - var $tva_taux_value; - var $tva_taux_libelle; + var $tva_taux_value; + var $tva_taux_libelle; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Output key field for an editable field - * - * @param string $text Text of label or key to translate - * @param string $htmlname Name of select field - * @param string $preselected Name of Value to show/edit (not used in this function) - * @param object $object Object - * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) - * @return string HTML edit field - */ - function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string') - { - global $conf,$langs; + /** + * Output key field for an editable field + * + * @param string $text Text of label or key to translate + * @param string $htmlname Name of select field + * @param string $preselected Name of Value to show/edit (not used in this function) + * @param object $object Object + * @param boolean $perm Permission to allow button to edit parameter + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) + * @return string HTML edit field + */ + function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string') + { + global $conf,$langs; - $ret=''; + $ret=''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) - { - if ($perm) - { - $tmp=explode(':',$typeofdata); - $ret.= '
'; - $ret.= $langs->trans($text); - $ret.= '
'."\n"; - } - else - { - $ret.= $langs->trans($text); - } - } - else - { - $ret.=''; - if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; - $ret.='
'; - $ret.=$langs->trans($text); - $ret.='id.'">'.img_edit($langs->trans('Edit'),1).'
'; - } + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + { + if ($perm) + { + $tmp=explode(':',$typeofdata); + $ret.= '
'; + $ret.= $langs->trans($text); + $ret.= '
'."\n"; + } + else + { + $ret.= $langs->trans($text); + } + } + else + { + $ret.=''; + if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; + $ret.='
'; + $ret.=$langs->trans($text); + $ret.='id.'">'.img_edit($langs->trans('Edit'),1).'
'; + } - return $ret; - } + return $ret; + } - /** - * Output val field for an editable field - * - * @param string $text Text of label (not used in this function) - * @param string $htmlname Name of select field - * @param string $value Value to show/edit - * @param object $object Object - * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) - * @param string $editvalue When in edit mode, use this value as $value instead of value - * @param object $extObject External object - * @param string $success Success message - * @return string HTML edit field - */ - function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=null,$success=null) - { - global $conf,$langs,$db; + /** + * Output val field for an editable field + * + * @param string $text Text of label (not used in this function) + * @param string $htmlname Name of select field + * @param string $value Value to show/edit + * @param object $object Object + * @param boolean $perm Permission to allow button to edit parameter + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) + * @param string $editvalue When in edit mode, use this value as $value instead of value + * @param object $extObject External object + * @return string HTML edit field + */ + function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=false) + { + global $conf,$langs,$db; - $ret=''; + $ret=''; - // When option to edit inline is activated - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) - { - $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject, $success); - } - else - { - if (GETPOST('action') == 'edit'.$htmlname) - { - $ret.="\n"; - $ret.='
'; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; - $ret.='
'; - if (preg_match('/^(string|email|numeric)/',$typeofdata)) - { - $tmp=explode(':',$typeofdata); - $ret.=''; - } - else if ($typeofdata == 'text' || $typeofdata == 'textarea' || $typeofdata == 'note') - { - $ret.=''; - } - else if ($typeofdata == 'day' || $typeofdata == 'datepicker') - { - $ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname); - } - else if (preg_match('/^ckeditor/',$typeofdata)) - { - $tmp=explode(':',$typeofdata); - require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true); - $ret.=$doleditor->Create(1); - } - $ret.='
'."\n"; - $ret.='
'."\n"; - } - else - { - if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); - elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); - elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); - else if (preg_match('/^ckeditor/',$typeofdata)) - { - $tmpcontent=dol_htmlentitiesbr($value); - $firstline=preg_replace('/
.*/','',$tmpcontent); - $firstline=preg_replace('/[\n\r].*/','',$firstline); - $ret.=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); - } - else $ret.=$value; - } - } - return $ret; - } + // When option to edit inline is activated + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + { + $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject); + } + else + { + if (GETPOST('action') == 'edit'.$htmlname) + { + $ret.="\n"; + $ret.='
'; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.=''; + if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; + $ret.='
'; + if (preg_match('/^(string|email|numeric)/',$typeofdata)) + { + $tmp=explode(':',$typeofdata); + $ret.=''; + } + else if ($typeofdata == 'text' || $typeofdata == 'textarea' || $typeofdata == 'note') + { + $ret.=''; + } + else if ($typeofdata == 'day' || $typeofdata == 'datepicker') + { + $ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname); + } + else if (preg_match('/^ckeditor/',$typeofdata)) + { + $tmp=explode(':',$typeofdata); + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true); + $ret.=$doleditor->Create(1); + } + $ret.='
'."\n"; + $ret.='
'."\n"; + } + else + { + if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); + elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); + elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); + else if (preg_match('/^ckeditor/',$typeofdata)) + { + $tmpcontent=dol_htmlentitiesbr($value); + $firstline=preg_replace('/
.*/','',$tmpcontent); + $firstline=preg_replace('/[\n\r].*/','',$firstline); + $ret.=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); + } + else $ret.=$value; + } + } + return $ret; + } - /** - * Output edit in place form - * + /** + * Output edit in place form + * * @param object $object Object * @param string $value Value to show/edit * @param string $htmlname DIV ID (field name) * @param int $condition Condition to edit * @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx') * @param object $extObject External object - * @param string $success Success message * @return string HTML edit in place */ - private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=null, $success=null) - { - global $conf; + private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=false) + { + global $conf; - $out=''; + $out=''; - // Check parameters - if ($inputType == 'textarea') $value = dol_nl2br($value); - else if (preg_match('/^numeric/',$inputType)) $value = price($value); - else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); + // Check parameters + if ($inputType == 'textarea') $value = dol_nl2br($value); + else if (preg_match('/^numeric/',$inputType)) $value = price($value); + else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); - if ($condition) - { - $element = false; - $table_element = false; - $fk_element = false; - $loadmethod = false; - $savemethod = false; - $ext_element = false; - //$ext_table_element = false; - //$ext_fk_element = false; + if ($condition) + { + $element = false; + $table_element = false; + $fk_element = false; + $loadmethod = false; + $savemethod = false; + $ext_element = false; + //$ext_table_element = false; + //$ext_fk_element = false; - if (is_object($object)) - { - $element = $object->element; - $table_element = $object->table_element; - $fk_element = $object->id; - } + if (is_object($object)) + { + $element = $object->element; + $table_element = $object->table_element; + $fk_element = $object->id; + } - if (is_object($extObject)) - { - $ext_element = $extObject->element; - //$ext_table_element = $extObject->table_element; - //$ext_fk_element = $extObject->id; - } + if (is_object($extObject)) + { + $ext_element = $extObject->element; + //$ext_table_element = $extObject->table_element; + //$ext_fk_element = $extObject->id; + } - if (preg_match('/^(string|email|numeric)/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; - } - else if (preg_match('/^datepicker/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; + if (preg_match('/^(string|email|numeric)/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; + } + if (preg_match('/^datepicker/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; - $out.= ''."\n"; // Use for timestamp format - } - else if (preg_match('/^select/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $loadmethod=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; - } - else if (preg_match('/^ckeditor/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $toolbar=$tmp[1]; - if (! empty($tmp[2])) $width=$tmp[2]; - if (! empty($tmp[3])) $heigth=$tmp[3]; - if (! empty($tmp[4])) $savemethod=$tmp[4]; + $out.= ''."\n"; // Use for timestamp format + } + else if (preg_match('/^select/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $loadmethod=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; + } + else if (preg_match('/^ckeditor/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $toolbar=$tmp[1]; + if (! empty($tmp[2])) $width=$tmp[2]; + if (! empty($tmp[3])) $heigth=$tmp[3]; + if (! empty($tmp[4])) $savemethod=$tmp[4]; - if (! empty($conf->fckeditor->enabled)) - { - $out.= ''."\n"; - } - else - { - $inputType = 'textarea'; - } - } + if (! empty($conf->fckeditor->enabled)) + { + $out.= ''."\n"; + } + else + { + $inputType = 'textarea'; + } + } - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - if (! empty($success)) $out.= ''."\n"; - //$out.= ''."\n"; - //$out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + //$out.= ''."\n"; + //$out.= ''."\n"; - $out.= '
'.$value.'
'."\n"; - } - else - { - $out = $value; - } + $out.= '
'.$value.'
'."\n"; + } + else + { + $out = $value; + } - return $out; - } + return $out; + } - /** - * Show a text and picto with tooltip on text or picto - * - * @param string $text Text to show - * @param string $htmltext Content html of tooltip. Must be HTML/UTF8 encoded. - * @param int $tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2 - * @param int $direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres - * @param string $img Code img du picto (use img_xxx() function to get it) - * @param string $extracss Add a CSS style to td tags - * @param int $notabs Do not include table and tr tags - * @param string $incbefore Include code before the text - * @param int $noencodehtmltext Do not encode into html entity the htmltext - * @return string Code html du tooltip (texte+picto) - * @see Use function textwithpicto if you can. - */ - function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0) - { - global $conf; + /** + * Show a text and picto with tooltip on text or picto + * + * @param string $text Text to show + * @param string $htmltext Content html of tooltip. Must be HTML/UTF8 encoded. + * @param int $tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2 + * @param int $direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres + * @param string $img Code img du picto (use img_xxx() function to get it) + * @param string $extracss Add a CSS style to td tags + * @param int $notabs Do not include table and tr tags + * @param string $incbefore Include code before the text + * @param int $noencodehtmltext Do not encode into html entity the htmltext + * @return string Code html du tooltip (texte+picto) + * @see Use function textwithpicto if you can. + */ + function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0) + { + global $conf; - if ($incbefore) $text = $incbefore.$text; - if (! $htmltext) return $text; + if ($incbefore) $text = $incbefore.$text; + if (! $htmltext) return $text; - // Sanitize tooltip - $htmltext=str_replace("\\","\\\\",$htmltext); - $htmltext=str_replace("\r","",$htmltext); - $htmltext=str_replace("\n","",$htmltext); + // Sanitize tooltip + $htmltext=str_replace("\\","\\\\",$htmltext); + $htmltext=str_replace("\r","",$htmltext); + $htmltext=str_replace("\n","",$htmltext); - $htmltext=str_replace('"',""",$htmltext); - if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip - else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag - if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip - else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag + $htmltext=str_replace('"',""",$htmltext); + if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip + else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag + if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip + else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag - $s=""; - if (empty($notabs)) $s.=''; - if ($direction > 0) - { - if ($text != '') - { - $s.=''.$text; - if ($direction) $s.=' '; - $s.=''; - } - if ($direction) $s.=''.$img.''; - } - else - { - if ($direction) $s.=''.$img.''; - if ($text != '') - { - $s.=''; - if ($direction) $s.=' '; - $s.=$text.''; - } - } - if (empty($notabs)) $s.='
'; + $s=""; + if (empty($notabs)) $s.=''; + if ($direction > 0) + { + if ($text != '') + { + $s.=''.$text; + if ($direction) $s.=' '; + $s.=''; + } + if ($direction) $s.=''.$img.''; + } + else + { + if ($direction) $s.=''.$img.''; + if ($text != '') + { + $s.=''; + if ($direction) $s.=' '; + $s.=$text.''; + } + } + if (empty($notabs)) $s.='
'; - return $s; - } + return $s; + } /** * Show a text with a picto and a tooltip on picto @@ -374,8 +372,7 @@ class Form if (empty($conf->use_javascript_ajax)) { if ($type == 'info' || $type == 'help') return $text; - else { $alt=$htmltext; $htmltext=''; - } + else { $alt=$htmltext; $htmltext=''; } } // If info or help with smartphone, show only text if (! empty($conf->browser->phone)) @@ -394,25 +391,24 @@ class Form } /** - * Return combo list of activated countries, into language of user + * Return combo list of activated countries, into language of user * - * @param string $selected Id or Code or Label of preselected country - * @param string $htmlname Name of html select object - * @param string $htmloption Options html on select object - * @return void + * @param selected Id or Code or Label of preselected country + * @param htmlname Name of html select object + * @param htmloption Options html on select object */ function select_pays($selected='',$htmlname='pays_id',$htmloption='') { - print $this->select_country($selected,$htmlname,$htmloption); + print $this->select_country($selected,$htmlname,$htmloption); } /** - * Return combo list of activated countries, into language of user + * Return combo list of activated countries, into language of user * - * @param string $selected Id or Code or Label of preselected country - * @param string $htmlname Name of html select object - * @param string $htmloption Options html on select object - * @return string HTML string with select + * @param selected Id or Code or Label of preselected country + * @param htmlname Name of html select object + * @param htmloption Options html on select object + * @return string HTML string with select */ function select_country($selected='',$htmlname='pays_id',$htmloption='') { @@ -440,13 +436,13 @@ class Form { $foundselected=false; - while ($i < $num) - { + while ($i < $num) + { $obj = $this->db->fetch_object($resql); $countryArray[$i]['rowid'] = $obj->rowid; $countryArray[$i]['code_iso'] = $obj->code_iso; $countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:'')); - $label[$i] = $countryArray[$i]['label']; + $label[$i] = $countryArray[$i]['label']; $i++; } @@ -454,10 +450,10 @@ class Form foreach ($countryArray as $row) { - //print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'
'; - if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) ) - { - $foundselected=true; + //print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'
'; + if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) ) + { + $foundselected=true; $out.= ''; + print ''; } print ''; @@ -610,15 +711,29 @@ class Form } /** - * Output html form to select a third party + * Output html form to select a third party * - * @param string $selected Preselected type - * @param string $htmlname Name of field in form - * @param string $filter Optionnal filters criteras - * @param int $showempty Add an empty field - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) - * @param int $forcecombo Force to use combo box - * @return string HTML string with + * @param selected Preselected type + * @param htmlname Name of field in form + * @param filter Optionnal filters criteras + * @param showempty Add an empty field + * @param showtype Show third party type in combolist (customer, prospect or supplier) + * @param forcecombo Force to use combo box + */ + function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) + { + print $this->select_company($selected,$htmlname,$filter,$showempty,$showtype,$forcecombo); + } + + /** + * Output html form to select a third party + * + * @param selected Preselected type + * @param htmlname Name of field in form + * @param filter Optionnal filters criteras + * @param showempty Add an empty field + * @param showtype Show third party type in combolist (customer, prospect or supplier) + * @param forcecombo Force to use combo box */ function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) { @@ -635,7 +750,7 @@ class Form if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " ORDER BY nom ASC"; - dol_syslog(get_class($this)."::select_company sql=".$sql); + dol_syslog("Form::select_societes sql=".$sql); $resql=$this->db->query($sql); if ($resql) { @@ -643,7 +758,7 @@ class Form { //$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); - $out.= ajax_combobox($htmlname); + $out.= ajax_combobox($htmlname); } $out.= ''; - if ($show_empty) $out.= ''."\n"; + $out.= ''; - $out.= ''; + $out.= ''; } @@ -1000,13 +1115,13 @@ class Form if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) { - if ($selected && empty($selected_input_value)) - { - require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); - $product = new Product($this->db); - $product->fetch($selected); - $selected_input_value=$product->ref; - } + if ($selected && empty($selected_input_value)) + { + require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); + $product = new Product($this->db); + $product->fetch($selected); + $selected_input_value=$product->ref; + } // mode=1 means customers products print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajaxproducts.php', 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); if (! $hidelabel) print $langs->trans("RefOrLabel").' : '; @@ -1069,18 +1184,18 @@ class Form // Add criteria on ref/label if ($filterkey && $filterkey != '') { - if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index - { - $sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'"; - if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '".$filterkey."%'"; - $sql.=")"; - } - else - { - $sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'"; - if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '%".$filterkey."%'"; - $sql.=")"; - } + if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index + { + $sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'"; + if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '".$filterkey."%'"; + $sql.=")"; + } + else + { + $sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'"; + if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '%".$filterkey."%'"; + $sql.=")"; + } } $sql.= $db->order("p.ref"); $sql.= $db->plimit($limit); @@ -1096,7 +1211,7 @@ class Form $num = $this->db->num_rows($result); $outselect.=''; + print ''; + $num = $this->db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + if ($selected == $obj->id) + { + print ''; + $i++; + } + } + print ''; + } + else + { + dol_print_error($this->db); + } + } + + /** * Return a HTML select list of bank accounts * @@ -2029,7 +2204,7 @@ class Form return $output; } - /** + /** * Show a confirmation HTML form or AJAX popup * * @param page Url of page to call if confirmation is OK @@ -2044,7 +2219,7 @@ class Form */ function form_confirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500) { - print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width); + print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width); } /** @@ -2070,65 +2245,65 @@ class Form if (is_array($formquestion) && count($formquestion) > 0) { - $more.=''."\n"; + $more.='
'."\n"; $more.=''."\n"; foreach ($formquestion as $key => $input) { - if (is_array($input)) - { - if ($input['type'] == 'text') - { - $more.=''."\n"; - } - else if ($input['type'] == 'password') - { - $more.=''."\n"; - } - else if ($input['type'] == 'select') - { - $more.=''."\n"; - } - else if ($input['type'] == 'checkbox') - { - $more.=''; - $more.=''; - if ($i==0) $more.=''; - else $more.=''; - $more.=''."\n"; - } - array_push($inputarray,$input['name']); - } + if (is_array($input)) + { + if ($input['type'] == 'text') + { + $more.=''."\n"; + } + else if ($input['type'] == 'password') + { + $more.=''."\n"; + } + else if ($input['type'] == 'select') + { + $more.=''."\n"; + } + else if ($input['type'] == 'checkbox') + { + $more.=''; + $more.=''; + if ($i==0) $more.=''; + else $more.=''; + $more.=''."\n"; + } + array_push($inputarray,$input['name']); + } } $more.='
'.$formquestion['text'].'
'.$input['label'].'
'.$input['label'].'
'; - if (! empty($input['label'])) $more.=$input['label'].''; - $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1); - $more.='
'.$input['label'].' '; - $more.=' $selval) - { - $more.='
'.$input['label'].' '; - $more.=$input['value']; - $more.='
'.$input['label'].'
'.$input['label'].'
'; + if (! empty($input['label'])) $more.=$input['label'].''; + $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1); + $more.='
'.$input['label'].' '; + $more.=' $selval) + { + $more.='
'.$input['label'].' '; + $more.=$input['value']; + $more.='
'."\n"; } @@ -2137,15 +2312,15 @@ class Form if ($useajax && $conf->use_javascript_ajax) { - $autoOpen=true; - $dialogconfirm='dialog-confirm'; - if (! is_int($useajax)) - { - $button=$useajax; - $useajax=1; - $autoOpen=false; - $dialogconfirm.='-'.$button; - } + $autoOpen=true; + $dialogconfirm='dialog-confirm'; + if (! is_int($useajax)) + { + $button=$useajax; + $useajax=1; + $autoOpen=false; + $dialogconfirm.='-'.$button; + } $pageyes=$page.'&action='.$action.'&confirm=yes'; $pageno=($useajax == 2?$page.'&confirm=no':''); @@ -2334,14 +2509,14 @@ class Form } } - /** - * Show a form to select a delivery delay + /** + * Show a form to select a delivery delay * - * @param int $page Page - * @param string $selected Id condition pre-selectionne - * @param string $htmlname Name of select html field - * @param int $addempty Ajoute entree vide - * @return void + * @param page Page + * @param selected Id condition pre-selectionne + * @param htmlname Name of select html field + * @param addempty Ajoute entree vide + * @return void */ function form_availability($page, $selected='', $htmlname='availability', $addempty=0) { @@ -2370,7 +2545,7 @@ class Form } } - /** + /** * Show a select form to select origin * * @param page Page @@ -2636,12 +2811,12 @@ class Form } } - /** - * Output html select to select thirdparty +/** + * Affiche formulaire de selection des tiers * - * @param string $page Page - * @param string $selected Id preselected - * @param string $htmlname Name of HTML select + * @param page Page + * @param selected Id contact pre-selectionne + * @param htmlname Nom du formulaire select * @return void */ function form_thirdparty($page, $selected='', $htmlname='socid') @@ -2655,7 +2830,7 @@ class Form print ''; print ''; print ''; print ''; print '
'; - print $this->select_company($selected , $htmlname); + $num=$this->select_societes($selected , $htmlname); print '
'; @@ -2668,6 +2843,48 @@ class Form $soc = new Societe($this->db); $soc->fetch($selected); print $soc->getNomUrl($langs); + } else { + print " "; + } + } + } + + /** + * Show form to select addresse + * + * @param page Page + * @param selected Id condition pre-selectionne + * @param htmlname Nom du formulaire select + * @param origin Origine de l'appel pour pouvoir creer un retour + * @param originid Id de l'origine + * @return void + * @deprecated + */ + function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='') + { + global $langs,$conf; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + $this->select_address($selected, $socid, $htmlname, 1); + print ''; + $langs->load("companies"); + print '   '.$langs->trans("AddAddress").''; + print '
'; + } + else + { + if ($selected) + { + require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php"); + $address=new Address($this->db); + $result=$address->fetch_address($selected); + print ''.$address->label.''; } else { @@ -2685,7 +2902,7 @@ class Form */ function select_currency($selected='',$htmlname='currency_id') { - print $this->selectcurrency($selected,$htmlname); + print $this->selectcurrency($selected,$htmlname); } /** @@ -2725,14 +2942,14 @@ class Form $obj = $this->db->fetch_object($resql); $currencyArray[$i]['code_iso'] = $obj->code_iso; $currencyArray[$i]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); - $label[$i] = $currencyArray[$i]['label']; + $label[$i] = $currencyArray[$i]['label']; $i++; } array_multisort($label, SORT_ASC, $currencyArray); foreach ($currencyArray as $row) { - if ($selected && $selected == $row['code_iso']) { + if ($selected && $selected == $row['code_iso']) { $foundselected=true; $out.= '\n"; @@ -3414,21 +3628,21 @@ class Form * Return a HTML area with the reference of object and a navigation bar for a business object * To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria. * - * @param Object $object Object to show - * @param int $paramid Name of parameter to use to name the id into the URL link - * @param string $morehtml More html content to output just before the nav bar - * @param int $shownav Show Condition (navigation is shown if value is 1) - * @param int $fieldid Nom du champ en base a utiliser pour select next et previous - * @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous - * @param string $morehtmlref Code html supplementaire a afficher apres ref - * @param string $moreparam More param to add in nav link url. - * @return tring Portion HTML avec ref + boutons nav + * @param object Object to show + * @param paramid Name of parameter to use to name the id into the URL link + * @param morehtml More html content to output just before the nav bar + * @param shownav Show Condition (navigation is shown if value is 1) + * @param fieldid Nom du champ en base a utiliser pour select next et previous + * @param fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous + * @param morehtmlref Code html supplementaire a afficher apres ref + * @param moreparam More param to add in nav link url. + * @return string Portion HTML avec ref + boutons nav */ function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='') { $ret=''; - //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; + //print "$paramid,$morehtml,$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid); $previous_ref = $object->ref_previous?''.img_previous().'':''; $next_ref = $object->ref_next?''.img_next().'':''; @@ -3439,17 +3653,14 @@ class Form } $ret.=$object->$fieldref; - if ($morehtmlref) - { + if ($morehtmlref) { $ret.=' '.$morehtmlref; } - if ($morehtml) - { + if ($morehtml) { $ret.=''.$morehtml; } - if ($shownav && ($previous_ref || $next_ref)) - { + if ($shownav && ($previous_ref || $next_ref)) { $ret.=''.$previous_ref.''; $ret.=''.$next_ref; } @@ -3462,12 +3673,12 @@ class Form /** - * Return HTML code to output a barcode - * - * @param Object &$object Object containing data to retrieve file name - * @param int $width Width of photo - * @return string HTML code to output barcode - */ + * Return HTML code to output a barcode + * + * @param Object &$object Object containing data to retrieve file name + * @param int $width Width of photo + * @return string HTML code to output barcode + */ function showbarcode(&$object,$width=100) { global $conf; @@ -3556,27 +3767,27 @@ class Form else dol_print_error('','Call of showphoto with wrong parameters'); /* Disabled. lightbox seems to not work. I don't know why. - $ret.="\n\n"; + $ret.="\n\n"; $ret.="\n\n"; + jQuery(function() { + jQuery('.photologo').lightBox({ + overlayBgColor: '#FFF', + overlayOpacity: 0.6, + imageLoading: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-ico-loading.gif', + imageBtnClose: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-close.gif', + imageBtnPrev: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-prev.gif', + imageBtnNext: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-next.gif', + containerResizeSpeed: 350, + txtImage: 'Imagem', + txtOf: 'de' + }); + }); + \n"; */ return $ret; @@ -3610,7 +3821,7 @@ class Form $sql = "SELECT ug.rowid, ug.nom "; if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity) { - $sql.= ", e.label"; + $sql.= ", e.label"; } $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as ug "; if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity) @@ -3621,11 +3832,11 @@ class Form } else { - $sql.= " WHERE ug.entity IN (0,".$conf->entity.")"; + $sql.= " WHERE ug.entity IN (0,".$conf->entity.")"; } if (is_array($exclude) && $excludeGroups) $sql.= " AND ug.rowid NOT IN ('".$excludeGroups."')"; if (is_array($include) && $includeGroups) $sql.= " AND ug.rowid IN ('".$includeGroups."')"; - $sql.= " ORDER BY ug.nom ASC"; + $sql.= " ORDER BY ug.nom ASC"; dol_syslog("Form::select_dolgroups sql=".$sql); $resql=$this->db->query($sql); @@ -3635,8 +3846,8 @@ class Form $i = 0; if ($num) { - $out.= ''; + if ($show_empty) $out.= ''."\n"; while ($i < $num) { @@ -3655,7 +3866,7 @@ class Form $out.= $obj->nom; if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) { - $out.= " (".$obj->label.")"; + $out.= " (".$obj->label.")"; } $out.= ''; @@ -3664,8 +3875,8 @@ class Form } else { - $out.= ''; + $out.= ''; } $out.= ''; } diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 2635d3b99fc..3acdd83fb1e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2011 Juanjo Menent +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2006-2011 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,11 +51,11 @@ class ProductFournisseur extends Product /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ - function ProductFournisseur($DB) + function __construct($db) { - $this->db = $DB; + $this->db = $db; } @@ -324,15 +324,14 @@ class ProductFournisseur extends Product function list_product_fournisseur_price($prodid) { global $conf; - - // Suppliers list + $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn,"; $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " ON pfp.fk_soc = s.rowid"; - $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE pfp.entity IN (".getEntity('product', 1).")"; + $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND pfp.fk_product = ".$prodid; $sql.= " ORDER BY s.nom, pfp.quantity, pfp.price"; diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 65160f9cbb2..45533e043cb 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -34,6 +34,8 @@ $langs->load("bills"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); @@ -52,22 +54,22 @@ $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->ser if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - if ($_GET["id"]) + if ($id) { $product = new Product($db); - $result = $product->fetch($_GET["id"]); + $result = $product->fetch($id); $result = $product->add_photo($dir, $_FILES['userfile']); } } -if ($_REQUEST["action"] == 'confirm_delete' && $_GET["file"] && $_REQUEST['confirm'] == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) +if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) { $product = new Product($db); $product->delete_photo($dir."/".$_GET["file"]); } -if ($_GET["action"] == 'addthumb' && $_GET["file"]) +if ($action == 'addthumb' && $_GET["file"]) { $product = new Product($db); $product->add_thumb($dir."/".$_GET["file"]); @@ -80,12 +82,11 @@ if ($_GET["action"] == 'addthumb' && $_GET["file"]) $form = new Form($db); -if ($_GET["id"] || $_GET["ref"]) +if ($id > 0 || ! empty($ref)) { $product = new Product($db); - if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); - if ($_GET["id"]) $result = $product->fetch($_GET["id"]); + $result = $product->fetch($id, $ref); llxHeader("","",$langs->trans("CardProduct".$product->type)); @@ -151,7 +152,7 @@ if ($_GET["id"] || $_GET["ref"]) { if (! empty($conf->global->MAIN_UPLOAD_DOC)) { - print ''; + print 'id.'">'; print $langs->trans("AddPhoto").''; } else @@ -166,15 +167,15 @@ if ($_GET["id"] || $_GET["ref"]) /* * Add a photo */ - if ($_GET["action"] == 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer) && ! empty($conf->global->MAIN_UPLOAD_DOC)) + if ($action == 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer) && ! empty($conf->global->MAIN_UPLOAD_DOC)) { // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1); + $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$product->id,$langs->trans("AddPhoto"),1); } // Affiche photos - if ($_GET["action"] != 'ajout_photo') + if ($action != 'ajout_photo') { $nbphoto=0; $nbbyrow=5; @@ -201,8 +202,7 @@ else } +llxFooter(); $db->close(); - -llxFooter(); ?>