From e7d3d9496c426a54f8e971cd7a1bef295686fe68 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Sep 2012 12:15:55 +0200 Subject: [PATCH] first step for extrafield for contact/address --- htdocs/core/lib/company.lib.php | 10 +- .../install/mysql/migration/3.2.0-3.3.0.sql | 12 + .../tables/llx_socpeople_extrafields.key.sql | 20 ++ .../tables/llx_socpeople_extrafields.sql | 26 +++ htdocs/langs/en_US/admin.lang | 2 + htdocs/langs/en_US/companies.lang | 10 +- htdocs/langs/fr_FR/admin.lang | 2 + htdocs/societe/admin/contact_extrafields.php | 212 ++++++++++++++++++ 8 files changed, 288 insertions(+), 6 deletions(-) create mode 100755 htdocs/install/mysql/tables/llx_socpeople_extrafields.key.sql create mode 100755 htdocs/install/mysql/tables/llx_socpeople_extrafields.sql create mode 100755 htdocs/societe/admin/contact_extrafields.php diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index c4e5509cf3d..00ff7db6ddd 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -193,10 +193,18 @@ function societe_admin_prepare_head($object) complete_head_from_modules($conf,$langs,$object,$head,$h,'company_admin'); $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][1] = $langs->trans("ExtraFieldsThirdParties"); $head[$h][2] = 'attributes'; $h++; + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/admin/contact_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsContacts"); + $head[$h][2] = 'attributes_contacts'; + $h++; + } + complete_head_from_modules($conf,$langs,$object,$head,$h,'company_admin','remove'); return $head; diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index bb10f9a7cb7..16d77a581ad 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -226,3 +226,15 @@ ALTER TABLE llx_propaldet MODIFY COLUMN localtax2_type varchar(1); -- END TASK #204 ALTER TABLE llx_menu MODIFY COLUMN enabled varchar(255) NULL default '1'; + + +create table llx_socpeople_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_socpeople_extrafields ADD INDEX idx_socpeople_extrafields (fk_object); + diff --git a/htdocs/install/mysql/tables/llx_socpeople_extrafields.key.sql b/htdocs/install/mysql/tables/llx_socpeople_extrafields.key.sql new file mode 100755 index 00000000000..ca2dc93360f --- /dev/null +++ b/htdocs/install/mysql/tables/llx_socpeople_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2011 Laurent Destailleur +-- +-- 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 +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + + +ALTER TABLE llx_socpeople_extrafields ADD INDEX idx_socpeople_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_socpeople_extrafields.sql b/htdocs/install/mysql/tables/llx_socpeople_extrafields.sql new file mode 100755 index 00000000000..b70546202e6 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_socpeople_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2011 Laurent Destailleur +-- +-- 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 +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +create table llx_socpeople_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 74f7ca3b7d9..3a4e3cc151a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -895,6 +895,8 @@ MAIN_PROXY_USER=Login to use the proxy server MAIN_PROXY_PASS=Password to use the proxy server DefineHereComplementaryAttributes=Define here all atributes, not already available by default, and that you want to be supported for %s. ExtraFields=Complementary attributes +ExtraFieldsThirdParties=Complementary attributes (thirdparty) +ExtraFieldsContacts=Complementary attributes (contact/address) ExtraFieldHasWrongValue=Attribut %s has a wrong value. AlphaNumOnlyCharsAndNoSpace=only alphanumericals characters without space SendingMailSetup=Setup of sendings by email diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 763a05b8dfe..e176b08e935 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -6,7 +6,7 @@ ErrorSetACountryFirst=Set the country first SelectThirdParty=Select a third party DeleteThirdParty=Delete a third party ConfirmDeleteCompany=Are you sure you want to delete this company and all inherited information ? -DeleteContact=Delete a contact +DeleteContact=Delete a contact/address ConfirmDeleteContact=Are you sure you want to delete this contact and all inherited information ? MenuNewThirdParty=New third party MenuNewCompany=New company @@ -24,10 +24,10 @@ SocGroup=Group of companies IdThirdParty=Id third party IdCompany=Company Id IdContact=Contact Id -Contacts=Contacts +Contacts=Contacts/Addresses ThirdPartyContacts=Third party contacts -ThirdPartyContact=Third party contact -StatusContactValidated=Status of contact +ThirdPartyContact=Third party contact/address +StatusContactValidated=Status of contact/address Company=Company CompanyName=Company name Companies=Companies @@ -254,7 +254,7 @@ EditContactAddress=Edit contact/address Contact=Contact ContactsAddresses=Contacts/Addresses NoContactDefined=No contact defined for this third party -DefaultContact=Default contact +DefaultContact=Default contact/address AddCompany=Add company AddThirdParty=Add third party DeleteACompany=Delete a company diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index ad7f9b2a7b6..f0b7708c540 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -904,6 +904,8 @@ MAIN_PROXY_USER=Login pour passer le serveur proxy mandataire MAIN_PROXY_PASS=Mot de passe pour passer le serveur proxy mandataire DefineHereComplementaryAttributes=Définissez ici la liste des attributs supplémentaires, non disponibles en standard, et que vous voulez voir gérer sur les %s. ExtraFields=Attributs suplémentaires +ExtraFieldsThirdParties=Attributs suplémentaires (tiers) +ExtraFieldsContacts=Attributs suplémentaires (contacts/adresses) ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte. AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace SendingMailSetup=Configuration de l'envoi par mail diff --git a/htdocs/societe/admin/contact_extrafields.php b/htdocs/societe/admin/contact_extrafields.php new file mode 100755 index 00000000000..4a67f92f320 --- /dev/null +++ b/htdocs/societe/admin/contact_extrafields.php @@ -0,0 +1,212 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/societe/admin/contact_extrafields.php + * \ingroup societe + * \brief Page to setup extra fields of contact + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("companies"); +$langs->load("admin"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=getStaticMember(get_class($extrafields),'type2label'); +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='contact'; + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("ContactsAddresses"); + +$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; +llxHeader('',$langs->trans("CompanySetup"),$help_url); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("CompanySetup"),$linkback,'setup'); + + +$head = societe_admin_prepare_head(null); + +dol_fiche_head($head, 'attributes_contacts', $langs->trans("ThirdParties"), 0, 'company'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +dol_htmloutput_errors($mesg); + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print ""; + // $i++; +} + +print "
'.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").' 
".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + +/* + * Barre d'actions + * + */ +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel + /* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + print '
'; + print ''; + print ''; + + print ''; + + // Label + print ''; + // Code + print ''; + // Type + print ''; + // Size + print ''; + + print "
'.$langs->trans("Label").'
'.$langs->trans("AttributeCode").' ('.$langs->trans("AlphaNumOnlyCharsAndNoSpace").')
'.$langs->trans("Type").''; + print $form->selectarray('type',$type2label,GETPOST('type')); + print '
'.$langs->trans("Size").'
\n"; + + print '

  '; + print '
'; + + print "
\n"; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + /* + * formulaire d'edition + */ + print '
'; + print ''; + print ''; + print ''; + print ''; + + // Label + print ''; + print ''; + print ''; + // Code + print ''; + print ''; + print ''; + print ''; + // Type + $type=$extrafields->attribute_type[$attrname]; + $size=$extrafields->attribute_size[$attrname]; + print ''; + print ''; + // Size + print ''; + + print '
'.$langs->trans("Label").'
'.$langs->trans("AttributeCode").''.$attrname.' 
'.$langs->trans("Type").''; + print $type2label[$type]; + print ''; + print '
'.$langs->trans("Size").'
'; + + print '

  '; + print '
'; + + print "
"; + +} + +llxFooter(); + +$db->close(); +?>