|
@@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
|
|
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
|
@@ -277,12 +278,72 @@ if (empty($reshook))
|
|
|
$action = 'edit';
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if (! $error)
|
|
|
{
|
|
|
$contactid=GETPOST("contactid",'int');
|
|
|
|
|
|
$object->fetch($contactid);
|
|
|
|
|
|
+ // Photo save
|
|
|
+ $dir = $conf->societe->dir_output."/contact/".$object->id."/photos";
|
|
|
+ $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
|
|
+ if ($file_OK)
|
|
|
+ {
|
|
|
+ if (GETPOST('deletephoto'))
|
|
|
+ {
|
|
|
+ $fileimg=$dir.'/'.$object->photo;
|
|
|
+ $dirthumbs=$dir.'/thumbs';
|
|
|
+ dol_delete_file($fileimg);
|
|
|
+ dol_delete_dir_recursive($dirthumbs);
|
|
|
+ $object->photo = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (image_format_supported($_FILES['photo']['name']) > 0)
|
|
|
+ {
|
|
|
+ dol_mkdir($dir);
|
|
|
+
|
|
|
+ if (@is_dir($dir))
|
|
|
+ {
|
|
|
+ $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
|
|
|
+ $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
|
|
|
+
|
|
|
+ if (! $result > 0)
|
|
|
+ {
|
|
|
+ $errors[] = "ErrorFailedToSaveFile";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
|
|
+ // Create small thumbs for company (Ratio is near 16/9)
|
|
|
+ // Used on logon for example
|
|
|
+ $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
|
|
+
|
|
|
+ // Create mini thumbs for company (Ratio is near 16/9)
|
|
|
+ // Used on menu or for setup page for example
|
|
|
+ $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $errors[] = "ErrorBadImageFormat";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ switch($_FILES['photo']['error'])
|
|
|
+ {
|
|
|
+ case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
|
|
|
+ case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
|
|
|
+ $errors[] = "ErrorFileSizeTooLarge";
|
|
|
+ break;
|
|
|
+ case 3: //uploaded file was only partially uploaded
|
|
|
+ $errors[] = "ErrorFilePartiallyUploaded";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$object->oldcopy = clone$object;
|
|
|
|
|
|
$object->old_lastname = GETPOST("old_lastname");
|
|
@@ -699,7 +760,7 @@ else
|
|
|
print '</script>'."\n";
|
|
|
}
|
|
|
|
|
|
- print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" name="formsoc">';
|
|
|
+ print '<form enctype="multipart/form-data" method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" name="formsoc">';
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
print '<input type="hidden" name="id" value="'.$id.'">';
|
|
|
print '<input type="hidden" name="action" value="update">';
|
|
@@ -906,6 +967,23 @@ else
|
|
|
else print $langs->trans("NoDolibarrAccess");
|
|
|
print '</td></tr>';
|
|
|
|
|
|
+ // Photo
|
|
|
+ print '<tr class="hideonsmartphone">';
|
|
|
+ print '<td>'.fieldLabel('Photo','photoinput').'</td>';
|
|
|
+ print '<td colspan="3">';
|
|
|
+ if ($object->photo) {
|
|
|
+ print $form->showphoto('contact',$object);
|
|
|
+ print "<br>\n";
|
|
|
+ }
|
|
|
+ print '<table class="nobordernopadding">';
|
|
|
+ if ($object->photo) print '<tr><td><input type="checkbox" class="flat" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
|
|
+ //print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
|
|
+ print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
|
|
+ print '</table>';
|
|
|
+
|
|
|
+ print '</td>';
|
|
|
+ print '</tr>';
|
|
|
+
|
|
|
print '</table>';
|
|
|
|
|
|
print dol_fiche_end();
|
|
@@ -973,12 +1051,12 @@ else
|
|
|
|
|
|
// Name
|
|
|
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
|
|
|
- print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
|
|
|
+ print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td>';
|
|
|
|
|
|
// Company
|
|
|
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
|
|
{
|
|
|
- print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
|
|
|
+ print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="2">';
|
|
|
if ($object->socid > 0)
|
|
|
{
|
|
|
$objsoc->fetch($object->socid);
|
|
@@ -988,30 +1066,44 @@ else
|
|
|
{
|
|
|
print $langs->trans("ContactNotLinkedToCompany");
|
|
|
}
|
|
|
- print '</td></tr>';
|
|
|
+ print '</td>';
|
|
|
+ }
|
|
|
+
|
|
|
+ // Photo
|
|
|
+ if ($object->photo)
|
|
|
+ {
|
|
|
+ print '<td rowspan="6" style="text-align: center;" width="25%">';
|
|
|
+ print $form->showphoto('contact',$object);
|
|
|
+ print '</td>';
|
|
|
+ } else {
|
|
|
+ print '<td rowspan="6" style="text-align: center;" width="25%">';
|
|
|
+ print ' ';
|
|
|
+ print '</td>';
|
|
|
}
|
|
|
|
|
|
+ print '</tr>';
|
|
|
+
|
|
|
// Civility
|
|
|
- print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
|
|
+ print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="2">';
|
|
|
print $object->getCivilityLabel();
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Role
|
|
|
- print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3">'.$object->poste.'</td>';
|
|
|
+ print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="2">'.$object->poste.'</td>';
|
|
|
|
|
|
// Address
|
|
|
- print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">';
|
|
|
+ print '<tr><td>'.$langs->trans("Address").'</td><td colspan="2">';
|
|
|
dol_print_address($object->address,'gmap','contact',$object->id);
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Zip/Town
|
|
|
- print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">';
|
|
|
+ print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="2">';
|
|
|
print $object->zip;
|
|
|
if ($object->zip) print ' ';
|
|
|
print $object->town.'</td></tr>';
|
|
|
|
|
|
// Country
|
|
|
- print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
|
|
|
+ print '<tr><td>'.$langs->trans("Country").'</td><td colspan="2">';
|
|
|
$img=picto_from_langcode($object->country_code);
|
|
|
if ($img) print $img.' ';
|
|
|
print $object->country;
|
|
@@ -1020,7 +1112,7 @@ else
|
|
|
// State
|
|
|
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
|
|
{
|
|
|
- print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$object->state.'</td>';
|
|
|
+ print '<tr><td>'.$langs->trans('State').'</td><td colspan="2">'.$object->state.'</td>';
|
|
|
}
|
|
|
|
|
|
// Phone
|