From 3f87b0c2255d8dd781d44e55176f17a23b101b54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Aug 2016 00:04:24 +0200 Subject: [PATCH] NEW Show photo of contacts on thirdparty card. --- htdocs/contact/class/contact.class.php | 25 +++++++++++++++++------ htdocs/core/lib/company.lib.php | 28 +++++++++++++++++++++----- htdocs/societe/soc.php | 7 +++++-- htdocs/theme/eldy/style.css.php | 9 ++++++++- htdocs/theme/md/style.css.php | 7 +++++++ 5 files changed, 62 insertions(+), 14 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ee057bbb00f..8566b4e5585 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -41,7 +41,8 @@ class Contact extends CommonObject public $table_element='socpeople'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - var $civility_id; // In fact we store civility_code + var $civility_id; // In fact we store civility_code + var $civility_code; var $address; var $zip; var $town; @@ -612,6 +613,7 @@ class Contact extends CommonObject $this->ref = $obj->rowid; $this->ref_ext = $obj->ref_ext; $this->civility_id = $obj->civility_id; + $this->civility_code = $obj->civility_id; $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; $this->address = $obj->address; @@ -659,11 +661,7 @@ class Contact extends CommonObject $this->import_key = $obj->import_key; // Define gender according to civility - if(in_array($this->civility_id, array('MR'))) { - $this->gender = 'man'; - } else if(in_array($this->civility_id, array('MME','MLE'))) { - $this->gender = 'woman'; - } + $this->setGenderFromCivility(); // Search Dolibarr user linked to this contact $sql = "SELECT u.rowid "; @@ -735,6 +733,21 @@ class Contact extends CommonObject } + /** + * Set property ->gender from property ->civility_id + * + * @return void + */ + function setGenderFromCivility() + { + unset($this->gender); + if (in_array($this->civility_id, array('MR'))) { + $this->gender = 'man'; + } else if(in_array($this->civility_id, array('MME','MLE'))) { + $this->gender = 'woman'; + } + } + /** * Load number of elements the contact is used as a link for * ref_facturation diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2ef445bcac3..0f427381d15 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -653,6 +653,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $colspan=9; print ''; + print_liste_field_titre(''); print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"p.lastname","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Poste"),$_SERVER["PHP_SELF"],"p.poste","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); @@ -668,8 +669,8 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print "\n"; - $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays as country_id, p.civility, p.poste, p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.email, p.skype, p.statut "; - $sql .= ", p.civility as civility_id, p.address, p.zip, p.town"; + $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays as country_id, p.civility, p.poste, p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.email, p.skype, p.statut, p.photo,"; + $sql .= " p.civility as civility_id, p.address, p.zip, p.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".$object->id; if ($search_status!='' && $search_status != '-1') $sql .= " AND p.statut = ".$db->escape($search_status); @@ -687,6 +688,10 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') { print ''; + // Photo + print ''; + print ''; + // Name - Position print ''; print ''; @@ -732,6 +737,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $contactstatic->lastname = $obj->lastname; $contactstatic->firstname = $obj->firstname; $contactstatic->civility_id = $obj->civility_id; + $contactstatic->civility_code = $obj->civility_id; $contactstatic->poste = $obj->poste; $contactstatic->address = $obj->address; $contactstatic->zip = $obj->zip; @@ -742,15 +748,27 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $contactstatic->email = $obj->email; $contactstatic->web = $obj->web; $contactstatic->skype = $obj->skype; + $contactstatic->photo = $obj->photo; $country_code = getCountry($obj->country_id, 2); $contactstatic->country_code = $country_code; + + $contactstatic->setGenderFromCivility(); print ""; - print ''; - print $contactstatic->getNomUrl(1,'',0,'&backtopage='.urlencode($backtopage)); - print ''; + // Photo + print ''; + print $form->showphoto('contact',$contactstatic,0,0,0,'photorefnoborder','small',1,0,1); + print ''; + + // Name + print ''; + print $contactstatic->getNomUrl(0,'',0,'&backtopage='.urlencode($backtopage)); + print ''; + + // Job position + print ''; if ($obj->poste) print $obj->poste; print ''; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b7813eadac4..0eecd8e6b92 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -2537,8 +2537,11 @@ else print '

'; // Subsidiaries list - $result=show_subsidiaries($conf,$langs,$db,$object); - + if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) + { + $result=show_subsidiaries($conf,$langs,$db,$object); + } + // Contacts list if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index be38ec586b4..eed6e5792ca 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -913,7 +913,14 @@ img.photoref { padding: 4px; height: 80px; width: 80px; - object-fit: contain + object-fit: contain; +} +img.photorefnoborder { + padding: 2px; + height: 48px; + width: 48px; + object-fit: contain; + border: 1px solid #CCC; } .underrefbanner { } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 452640ddd9c..16dce1c5206 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -955,6 +955,13 @@ img.photoref { -webkit-box-shadow: 3px 3px 4px #DDD; box-shadow: 3px 3px 4px #DDD; } +img.photorefnoborder { + padding: 2px; + height: 48px; + width: 48px; + object-fit: contain; + border: 1px solid #CCC; +} .underrefbanner { } .underbanner {