Add option capture on input file for photo

This commit is contained in:
Laurent Destailleur 2018-09-05 16:03:10 +02:00
parent ab8155f170
commit cb89942bfb

View File

@ -6674,16 +6674,17 @@ class Form
* @param string $imagesize 'mini', 'small' or '' (original)
* @param int $addlinktofullsize Add link to fullsize image
* @param int $cache 1=Accept to use image in cache
* @param string $forcecapture Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if empty.
* @return string HTML code to output photo
*/
static function showphoto($modulepart, $object, $width=100, $height=0, $caneditfield=0, $cssclass='photowithmargin', $imagesize='', $addlinktofullsize=1, $cache=0)
static function showphoto($modulepart, $object, $width=100, $height=0, $caneditfield=0, $cssclass='photowithmargin', $imagesize='', $addlinktofullsize=1, $cache=0, $forcecapture='')
{
global $conf,$langs;
$entity = (! empty($object->entity) ? $object->entity : $conf->entity);
$id = (! empty($object->id) ? $object->id : $object->rowid);
$ret='';$dir='';$file='';$originalfile='';$altfile='';$email='';
$ret='';$dir='';$file='';$originalfile='';$altfile='';$email='';$capture='';
if ($modulepart=='societe')
{
$dir=$conf->societe->multidir_output[$entity];
@ -6707,6 +6708,7 @@ class Form
$originalfile=get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo;
}
$email=$object->email;
$capture='user';
}
else if ($modulepart=='userphoto')
{
@ -6720,6 +6722,7 @@ class Form
}
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email;
$capture='user';
}
else if ($modulepart=='memberphoto')
{
@ -6733,6 +6736,7 @@ class Form
}
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email;
$capture='user';
}
else
{
@ -6749,6 +6753,8 @@ class Form
$email=$object->email;
}
if ($forcecapture) $capture = $forcecapture;
if ($dir)
{
if ($file && file_exists($dir."/".$file))
@ -6805,7 +6811,7 @@ class Form
if ($object->photo) $ret.="<br>\n";
$ret.='<table class="nobordernopadding centpercent">';
if ($object->photo) $ret.='<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
$ret.='<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput"></td></tr>';
$ret.='<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput"'.($capture?' capture="'.$capture.'"':'').'></td></tr>';
$ret.='</table>';
}