From 250e8aacafea4257b0de9c408f32367794c1475b Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 2 Aug 2014 09:58:23 +0200 Subject: [PATCH 1/7] Update company.lib.php --- htdocs/core/lib/company.lib.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index bd5f19e2401..88443ba2ad5 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -64,13 +64,21 @@ function societe_prepare_head($object) $h++; } - if (($object->localtax1_assuj || $object->localtax2_assuj) && (isset($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL > 0) ) - { - $head[$h][0] = DOL_URL_ROOT.'/societe/localtaxes.php?socid='.$object->id; - $head[$h][1] = $langs->trans("LocalTaxes"); - $head[$h][2] = 'localtaxes'; - $h++; - } + if (! empty($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES)) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Contact"); + $head[$h][2] = 'contact'; + $h++; + } + + if (($object->localtax1_assuj || $object->localtax2_assuj) && (isset($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL > 0) ) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/localtaxes.php?socid='.$object->id; + $head[$h][1] = $langs->trans("LocalTaxes"); + $head[$h][2] = 'localtaxes'; + $h++; + } if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { From 83b27c33d8a9989a087cbdc0e44dd7face3f7a39 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 2 Aug 2014 10:03:53 +0200 Subject: [PATCH 2/7] add contact tabs on company appair only if MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES is enabled display on tabs adherent list of company --- htdocs/societe/societecontact.php | 325 ++++++++++++++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 htdocs/societe/societecontact.php diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php new file mode 100644 index 00000000000..f02a0cb0b0a --- /dev/null +++ b/htdocs/societe/societecontact.php @@ -0,0 +1,325 @@ + + * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Philippe Grand + * Copyright (C) 2014 Charles-Fr Benke + * + * 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 3 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/societecontact.php + * \ingroup societe + * \brief Onglet de gestion des contacts additionnel d'une société + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + +$langs->load("orders"); +$langs->load("companies"); + +$id=GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'societe', $id,''); + +$object = new Societe($db); + +/* + * Ajout d'un nouveau contact + */ + +if ($action == 'addcontact' && $user->rights->societe->creer) +{ + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } +} + +// bascule du statut d'un contact +else if ($action == 'swapstatut' && $user->rights->societe->creer) +{ + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } +} + +// Efface un contact +else if ($action == 'deletecontact' && $user->rights->societe->creer) +{ + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } +} + +else if ($action == 'setaddress' && $user->rights->societe->creer) +{ + $object->fetch($id); + $result=$object->setDeliveryAddress($_POST['fk_address']); + if ($result < 0) dol_print_error($db,$object->error); +} + +/* + * View + */ + +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('',$langs->trans("ThirdParty"),$help_url); + + +$form = new Form($db); +$formcompany = new FormCompany($db); +$formother = new FormOther($db); +$contactstatic=new Contact($db); +$userstatic=new User($db); + + +/* *************************************************************************** */ +/* */ +/* Mode vue et edition */ +/* */ +/* *************************************************************************** */ +dol_htmloutput_mesg($mesg); + +if ($id > 0 || ! empty($ref)) +{ + $langs->trans("OrderCard"); + + if ($object->fetch($id, $ref) > 0) + { + $soc = new Societe($db); + $soc->fetch($object->socid); + + $head = societe_prepare_head($object); + dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"),0,'company'); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } + + if ($object->client) + { + print ''; + } + + if ($object->fournisseur) + { + print ''; + } + print '
'.$langs->trans('ThirdPartyName').''; + print $form->showrefnav($object,'id','',($user->societe_id?0:1),'rowid','nom'); + print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; + print $langs->trans('CustomerCode').''; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; + print '
'; + print $langs->trans('SupplierCode').''; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print '
'; + print '
'; + + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); + foreach($dirtpls as $reldir) + { + $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; + } + + // additionnal list with adherents of company + if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + + $membertypestatic=new AdherentType($db); + $memberstatic=new Adherent($db); + + $langs->load("members"); + $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; + $sql.= " d.datefin,"; + $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; + $sql.= " t.libelle as type, t.cotisation"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; + $sql.= " WHERE d.fk_soc=".$id; + + dol_syslog("get list sql=".$sql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + if ($num > 0 ) + { + $titre=$langs->trans("MembersListOfTiers"); + print '
'; + + print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,''); + + print ""; + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"t.libelle",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); + print "\n"; + + $var=True; + $i=0; + while ($i < $num && $i < $conf->liste_limit) + { + $objp = $db->fetch_object($resql); + + $datefin=$db->jdate($objp->datefin); + $memberstatic->id=$objp->rowid; + $memberstatic->ref=$objp->rowid; + $memberstatic->lastname=$objp->lastname; + $memberstatic->firstname=$objp->firstname; + + $companyname=$objp->company; + + $var=!$var; + print ""; + + // Ref + print "\n"; + + // Lastname + print "\n"; + + // Login + print "\n"; + + // Type + $membertypestatic->id=$objp->type_id; + $membertypestatic->libelle=$objp->type; + print ''; + + // Moral/Physique + print "\n"; + + // EMail + print "\n"; + + // Statut + print '"; + + // End of subscription date + if ($datefin) + { + print ''; + } + else + { + print ''; + } + + print "\n"; + $i++; + } + print "
"; + print $memberstatic->getNomUrl(1); + print "rowid\">"; + print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : ''); + print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : ''); + print (! empty($companyname) ? dol_trunc($companyname, 32) : ''); + print "".$objp->login."'; + print $membertypestatic->getNomUrl(1,32); + print '".$memberstatic->getmorphylib($objp->morphy)."".dol_print_email($objp->email,0,0,1)."'; + print $memberstatic->LibStatut($objp->statut,$objp->cotisation,$datefin,2); + print "'; + print dol_print_date($datefin,'day'); + if ($datefin < ($now - $conf->adherent->cotisation->warning_delay) && $objp->statut > 0) print " ".img_warning($langs->trans("SubscriptionLate")); + print ''; + if ($objp->cotisation == 'yes') + { + print $langs->trans("SubscriptionNotReceived"); + if ($objp->statut > 0) print " ".img_warning(); + } + else + { + print ' '; + } + print '
\n"; + } + } + } + } + else + { + // Contrat non trouve + print "ErrorRecordNotFound"; + } +} + + +$db->close(); +llxFooter(); +?> \ No newline at end of file From f4738dc1d49e3c1253bed21b27820d3d47b101b6 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 2 Aug 2014 10:21:00 +0200 Subject: [PATCH 3/7] Update societecontact.php --- htdocs/societe/societecontact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index f02a0cb0b0a..42519bb13e1 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -22,7 +22,7 @@ /** * \file htdocs/societe/societecontact.php * \ingroup societe - * \brief Onglet de gestion des contacts additionnel d'une société + * \brief Onglet de gestion des contacts additionnel d'une société */ require '../main.inc.php'; @@ -322,4 +322,4 @@ if ($id > 0 || ! empty($ref)) $db->close(); llxFooter(); -?> \ No newline at end of file +?> From 21168308af4c030944ba08699b2c78890a04609e Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 2 Aug 2014 10:53:19 +0200 Subject: [PATCH 4/7] Update societecontact.php --- htdocs/societe/societecontact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 42519bb13e1..c473bd27d32 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -319,7 +319,7 @@ if ($id > 0 || ! empty($ref)) } } - $db->close(); llxFooter(); -?> + +?> From bc478a75ee571404371d155bc15f90c7d674d885 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 2 Aug 2014 11:34:29 +0200 Subject: [PATCH 5/7] Update societecontact.php --- htdocs/societe/societecontact.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index c473bd27d32..60e114be6a5 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -321,5 +321,3 @@ if ($id > 0 || ! empty($ref)) $db->close(); llxFooter(); - -?> From 5d81eca1a3b2a629d2d9e8907632b759b18c8c34 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Thu, 14 Aug 2014 10:47:28 +0200 Subject: [PATCH 6/7] change option name replace MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES by MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES --- htdocs/admin/dict.php | 2 +- htdocs/core/lib/company.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 7075b601877..4efd1d31ae1 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -421,7 +421,7 @@ if ($id == 11) 'fichinter' => $langs->trans('InterventionCard'), 'agenda' => $langs->trans('Agenda') ); - if (! empty($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); + if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); $sourceList = array( 'internal' => $langs->trans('Internal'), 'external' => $langs->trans('External') diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 88443ba2ad5..176df3a7e37 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -64,7 +64,7 @@ function societe_prepare_head($object) $h++; } - if (! empty($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES)) + if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) { $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; $head[$h][1] = $langs->trans("Contact"); From e713c8dadc3d9ec30eb70edf1dde7f6f26e90d8c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 17 Aug 2014 15:12:20 +0200 Subject: [PATCH 7/7] Fix: broken feature: add param for use only "disabled" with delConstant and "enabled" with setConstant --- htdocs/core/js/lib_head.js | 21 ++++++++++++--------- htdocs/core/lib/ajax.lib.php | 10 ++++++---- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/htdocs/core/js/lib_head.js b/htdocs/core/js/lib_head.js index a5e1410d503..40b1473698e 100644 --- a/htdocs/core/js/lib_head.js +++ b/htdocs/core/js/lib_head.js @@ -1,5 +1,5 @@ // Copyright (C) 2005-2014 Laurent Destailleur -// Copyright (C) 2005-2012 Regis Houssin +// Copyright (C) 2005-2014 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 @@ -633,7 +633,7 @@ function hideMessage(fieldId,message) { /* * TODO Used by admin page only ? */ -function setConstant(url, code, input, entity) { +function setConstant(url, code, input, entity, strict) { $.get( url, { action: "set", name: code, @@ -644,7 +644,7 @@ function setConstant(url, code, input, entity) { $("#del_" + code).show(); $.each(input, function(type, data) { // Enable another element - if (type == "disabled") { + if (type == "disabled" && strict != 1) { $.each(data, function(key, value) { var newvalue=((value.search("^#") < 0 && value.search("^\.") < 0) ? "#" : "") + value; $(newvalue).removeAttr("disabled"); @@ -656,7 +656,10 @@ function setConstant(url, code, input, entity) { } else if (type == "enabled") { $.each(data, function(key, value) { var newvalue=((value.search("^#") < 0 && value.search("^\.") < 0) ? "#" : "") + value; - $(newvalue).attr("disabled", true); + if (strict == 1) + $(newvalue).removeAttr("disabled"); + else + $(newvalue).attr("disabled", true); if ($(newvalue).hasClass("butAction") == true) { $(newvalue).removeClass("butAction"); $(newvalue).addClass("butActionRefused"); @@ -688,7 +691,7 @@ function setConstant(url, code, input, entity) { /* * TODO Used by admin page only ? */ -function delConstant(url, code, input, entity) { +function delConstant(url, code, input, entity, strict) { $.get( url, { action: "del", name: code, @@ -708,7 +711,7 @@ function delConstant(url, code, input, entity) { $(newvalue).addClass("butActionRefused"); } }); - } else if (type == "enabled") { + } else if (type == "enabled" && strict != 1) { $.each(data, function(key, value) { var newvalue=((value.search("^#") < 0 && value.search("^\.") < 0) ? "#" : "") + value; $(newvalue).removeAttr("disabled"); @@ -742,7 +745,7 @@ function delConstant(url, code, input, entity) { /* * TODO Used by admin page only ? */ -function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton) { +function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict) { var boxConfirm = box; $("#confirm_" + code) .attr("title", boxConfirm.title) @@ -758,9 +761,9 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, text : yesButton, click : function() { if (action == "set") { - setConstant(url, code, input, entity); + setConstant(url, code, input, entity, strict); } else if (action == "del") { - delConstant(url, code, input, entity); + delConstant(url, code, input, entity, strict); } // Close dialog $(this).dialog("close"); diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 47363ac8d06..e68fe78bc87 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007-2012 Regis Houssin + * Copyright (C) 2007-2014 Regis Houssin * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -391,9 +391,10 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0) * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param int $entity Entity to set * @param int $revertonoff Revert on/off + * @param bool $strict Use only "disabled" with delConstant and "enabled" with setConstant * @return void */ -function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0) +function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0) { global $conf, $langs; @@ -413,6 +414,7 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0) var url = \''.DOL_URL_ROOT.'/core/ajax/constantonoff.php\'; var code = \''.$code.'\'; var entity = \''.$entity.'\'; + var strict = \''.$strict.'\'; var yesButton = "'.dol_escape_js($langs->transnoentities("Yes")).'"; var noButton = "'.dol_escape_js($langs->transnoentities("No")).'"; @@ -421,7 +423,7 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0) if (input.alert && input.alert.set) { if (input.alert.set.yesButton) yesButton = input.alert.set.yesButton; if (input.alert.set.noButton) noButton = input.alert.set.noButton; - confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton); + confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton, strict); } else { setConstant(url, code, input, entity); } @@ -432,7 +434,7 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0) if (input.alert && input.alert.del) { if (input.alert.del.yesButton) yesButton = input.alert.del.yesButton; if (input.alert.del.noButton) noButton = input.alert.del.noButton; - confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton); + confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton, strict); } else { delConstant(url, code, input, entity); }