New: Can create a third party from a member.

This commit is contained in:
Laurent Destailleur 2009-02-02 02:04:26 +00:00
parent 6ba8bd8303
commit ce317d6084
13 changed files with 388 additions and 215 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -19,10 +19,10 @@
*/ */
/** /**
\file htdocs/adherents/fiche.php * \file htdocs/adherents/fiche.php
\ingroup adherent * \ingroup adherent
\brief Page d'ajout, edition, suppression d'une fiche adherent * \brief Page d'ajout, edition, suppression d'une fiche adherent
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -67,7 +67,7 @@ $typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"];
* Actions * Actions
*/ */
// Create user from a memeber // Create user from a member
if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer) if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
{ {
// Recuperation contact actuel // Recuperation contact actuel
@ -92,6 +92,30 @@ if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $
} }
} }
// Create third party from a member
if ($_POST["action"] == 'confirm_create_thirdparty' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer)
{
$adh = new Adherent($db);
$result = $adh->fetch($_GET["rowid"]);
if ($result > 0)
{
// Creation user
$company = new Societe($db);
$result=$company->create_from_member($adh,$_POST["name"]);
if ($result < 0)
{
$langs->load("errors");
$msg=$langs->trans($company->error);
}
}
else
{
$msg=$adh->error;
}
}
if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes')
{ {
$adh->id = $rowid; $adh->id = $rowid;
@ -826,7 +850,30 @@ if ($rowid && $action != 'edit')
$formquestion=array( $formquestion=array(
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)); array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login));
$html->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$adh->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion); $html->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$adh->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateLogin"),"confirm_create_user",$formquestion);
print '<br>';
}
// Confirm create third party
if ($_GET["action"] == 'create_thirdparty')
{
$name =$adh->nom;
if ($adh->nom && $adh->prenom) $name.=' ';
$name.=$adh->prenom;
if (! empty($name))
{
if ($adh->societe) $name.=' ('.$adh->societe.')';
}
else
{
$name=$adh->societe;
}
// Create a form array
$formquestion=array(
array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name));
$html->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$adh->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion);
print '<br>'; print '<br>';
} }
@ -837,7 +884,7 @@ if ($rowid && $action != 'edit')
print '<br>'; print '<br>';
} }
// Confirm validate memeber // Confirm validate member
if ($action == 'valid') if ($action == 'valid')
{ {
// Cree un tableau formulaire // Cree un tableau formulaire
@ -930,32 +977,32 @@ if ($rowid && $action != 'edit')
// Morphy // Morphy
print '<tr><td>'.$langs->trans("Person").'</td><td class="valeur">'.$adh->getmorphylib().'</td></tr>'; print '<tr><td>'.$langs->trans("Person").'</td><td class="valeur">'.$adh->getmorphylib().'</td></tr>';
// Tiers // Company
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$adh->societe.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$adh->societe.'</td></tr>';
// Adresse // Adresse
print '<tr><td>'.$langs->trans("Address").'</td><td class="valeur">'.nl2br($adh->adresse).'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Address").'</td><td class="valeur">'.nl2br($adh->adresse).'</td></tr>';
// CP / Ville // CP / Ville
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'</td></tr>';
// Pays // Pays
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.getCountryLabel($adh->pays_id).'</td></tr>'; print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.getCountryLabel($adh->pays_id).'</td></tr>';
// Tel pro. // Tel pro.
print '<tr><td>'.$langs->trans("PhonePro").'</td><td class="valeur">'.dol_print_phone($adh->phone,$adh->pays_code).'</td></tr>'; print '<tr><td>'.$langs->trans("PhonePro").'</td><td class="valeur">'.dol_print_phone($adh->phone,$adh->pays_code,0,$adh->fk_soc,1).'</td></tr>';
// Tel perso // Tel perso
print '<tr><td>'.$langs->trans("PhonePerso").'</td><td class="valeur">'.dol_print_phone($adh->phone_perso,$adh->pays_code).'</td></tr>'; print '<tr><td>'.$langs->trans("PhonePerso").'</td><td class="valeur">'.dol_print_phone($adh->phone_perso,$adh->pays_code,0,$adh->fk_soc,1).'</td></tr>';
// Tel mobile // Tel mobile
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td class="valeur">'.dol_print_phone($adh->phone_mobile,$adh->pays_code).'</td></tr>'; print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td class="valeur">'.dol_print_phone($adh->phone_mobile,$adh->pays_code,0,$adh->fk_soc,1).'</td></tr>';
// EMail // EMail
print '<tr><td>'.$langs->trans("EMail").'</td><td class="valeur">'.dol_print_email($adh->email,0,0,1).'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("EMail").'</td><td class="valeur">'.dol_print_email($adh->email,0,$adh->fk_soc,1).'</td></tr>';
// Date naissance // Date naissance
print '<tr><td>'.$langs->trans("Birthday").'</td><td class="valeur">'.dolibarr_print_date($adh->naiss,'day').'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Birthday").'</td><td class="valeur">'.dolibarr_print_date($adh->naiss,'day').'</td></tr>';
// Public // Public
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($adh->public).'</td></tr>'; print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($adh->public).'</td></tr>';
@ -975,6 +1022,22 @@ if ($rowid && $action != 'edit')
else print $langs->trans("NoDolibarrAccess"); else print $langs->trans("NoDolibarrAccess");
print '</td></tr>'; print '</td></tr>';
// Third party Dolibarr
if ($conf->societe->enabled)
{
print '<tr><td>'.$langs->trans("ThirdPartyDolibarr").'</td><td class="valeur">';
if ($adh->fk_soc)
{
$company=new Societe($db);
$result=$company->fetch($adh->fk_soc);
print $company->getNomUrl(1);
}
else
{
print $langs->trans("NoThirdPartyAssociatedToMember");
}
print '</td></tr>';
}
// Other attributs // Other attributs
foreach($adho->attribute_label as $key=>$value) foreach($adho->attribute_label as $key=>$value)
@ -1069,6 +1132,19 @@ if ($rowid && $action != 'edit')
} }
} }
// Create third party
if ($conf->societe->enabled && ! $adh->fk_soc)
{
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="fiche.php?rowid='.$adh->id.'&amp;action=create_thirdparty">'.$langs->trans("CreateDolibarrThirdParty").'</a>';
}
else
{
print "<font class=\"butActionRefused\" href=\"#\">".$langs->trans("CreateDolibarrThirdParty")."</font>";
}
}
// Supprimer // Supprimer
if ($user->rights->adherent->supprimer) if ($user->rights->adherent->supprimer)
{ {

View File

@ -19,9 +19,9 @@
*/ */
/** /**
\file htdocs/adherents/index.php * \file htdocs/adherents/index.php
\ingroup adherent * \ingroup adherent
\brief Page accueil module adherents * \brief Page accueil module adherents
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -42,22 +42,8 @@ print_fiche_titre($langs->trans("MembersArea"));
print '<table border="0" width="100%" class="notopnoleftnoright">'; print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="100%" colspan="2" class="notopnoleft">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align=right>'.$langs->trans("MembersStatusToValid").'</td>';
print '<td align=right>'.$langs->trans("MenuMembersNotUpToDate").'</td>';
print '<td align=right>'.$langs->trans("MenuMembersUpToDate").'</td>';
print '<td align=right>'.$langs->trans("MembersStatusResiliated").'</td>';
print "</tr>\n";
$var=True; $var=True;
$Adherents=array(); $Adherents=array();
$AdherentsAValider=array(); $AdherentsAValider=array();
$AdherentsResilies=array(); $AdherentsResilies=array();
@ -96,13 +82,14 @@ if ($result)
} }
else else
{ {
$Cotisants[$objp->rowid]=0; // Calculé plus loin $Cotisants[$objp->rowid]=0; // Calcule plus loin
} }
$i++; $i++;
} }
$db->free($result); $db->free($result);
} }
# Liste les cotisants a jour # Liste les cotisants a jour
$sql = "SELECT count(*) as somme , d.fk_adherent_type"; $sql = "SELECT count(*) as somme , d.fk_adherent_type";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
@ -121,13 +108,50 @@ if ($result)
$i++; $i++;
} }
$db->free(); $db->free();
} }
print '<tr><td width="30%" class="notopnoleft" valign="top">';
// Formulaire recherche adherent
print '<form action="liste.php" method="post">';
print '<input type="hidden" name="action" value="search">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("SearchAMember").'</td>';
print "</tr>\n";
$var=false;
print "<tr $bc[$var]>";
print '<td>';
print $langs->trans("Name").':</td><td><input type="text" name="search" class="flat" size="16">';
print '</td><td rowspan="2"><input class="button" type="submit" value="'.$langs->trans("Search").'"></td></tr>';
print "<tr $bc[$var]>";
print '<td>';
print $langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="16">';
print '</td></tr>';
print "</table></form>";
print '</td><td class="notopnoleftnoright" valign="top">';
$var=true;
$SommeA=0; $SommeA=0;
$SommeB=0; $SommeB=0;
$SommeC=0; $SommeC=0;
$SommeD=0; $SommeD=0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align=right>'.$langs->trans("MembersStatusToValid").'</td>';
print '<td align=right>'.$langs->trans("MenuMembersNotUpToDate").'</td>';
print '<td align=right>'.$langs->trans("MenuMembersUpToDate").'</td>';
print '<td align=right>'.$langs->trans("MembersStatusResiliated").'</td>';
print "</tr>\n";
foreach ($AdherentType as $key => $adhtype) foreach ($AdherentType as $key => $adhtype)
{ {
$var=!$var; $var=!$var;
@ -152,38 +176,10 @@ print '<td align="right"><b>'.$SommeD.' '.$staticmember->LibStatut(0,$adhtype->c
print '</tr>'; print '</tr>';
print "</table>\n"; print "</table>\n";
print "<br>\n";
print '<br>';
print '</td></tr>';
print '<tr><td width="30%" class="notopnoleft" valign="top">';
// Formulaire recherche adhérent
print '<form action="liste.php" method="post">';
print '<input type="hidden" name="action" value="search">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("SearchAMember").'</td>';
print "</tr>\n";
$var=false;
print "<tr $bc[$var]>";
print '<td>';
print $langs->trans("Name").':</td><td><input type="text" name="search" class="flat" size="16">';
print '</td><td rowspan="2"><input class="button" type="submit" value="'.$langs->trans("Search").'"></td></tr>';
print "<tr $bc[$var]>";
print '<td>';
print $langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="16">';
print '</td></tr>';
print "</table></form>";
print '</td><td class="notopnoleftnoright" valign="top">';
/* /*
* Dernières adherent * Dernieres adherent
*/ */
$max=5; $max=5;
@ -233,7 +229,7 @@ else
// Tableau résumé par an // Tableau r<EFBFBD>sum<EFBFBD> par an
$Total=array(); $Total=array();
$Number=array(); $Number=array();
$tot=0; $tot=0;

View File

@ -23,21 +23,21 @@
/** /**
\file htdocs/includes/modules/societe/modules_societe.class.php \file htdocs/includes/modules/societe/modules_societe.class.php
\ingroup societe \ingroup societe
\brief Fichier contenant la classe mère de module de generation societes \brief Fichier contenant la classe m<EFBFBD>re de module de generation societes
\version $Id$ \version $Id$
*/ */
/** /**
\class ModeleThirdPartyCode \class ModeleThirdPartyCode
\brief Classe mère des modèles de numérotation des codes tiers \brief Classe m<EFBFBD>re des mod<EFBFBD>les de num<EFBFBD>rotation des codes tiers
*/ */
class ModeleThirdPartyCode class ModeleThirdPartyCode
{ {
var $error=''; var $error='';
/** \brief Renvoi la description par defaut du modele de numérotation /** \brief Renvoi la description par defaut du modele de num<EFBFBD>rotation
* \return string Texte descripif * \return string Texte descripif
*/ */
function info($langs) function info($langs)
@ -55,7 +55,7 @@ class ModeleThirdPartyCode
} }
/** \brief Renvoi un exemple de numérotation /** \brief Renvoi un exemple de num<EFBFBD>rotation
* \return string Example * \return string Example
*/ */
function getExample($langs) function getExample($langs)
@ -64,8 +64,8 @@ class ModeleThirdPartyCode
return $langs->trans("NoExample"); return $langs->trans("NoExample");
} }
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de /** \brief Test si les num<EFBFBD>ros d<EFBFBD>j<EFBFBD> en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numérotation de fonctionner. * de conflits qui empechera cette num<EFBFBD>rotation de fonctionner.
* \return boolean false si conflit, true si ok * \return boolean false si conflit, true si ok
*/ */
function canBeActivated() function canBeActivated()
@ -73,7 +73,7 @@ class ModeleThirdPartyCode
return true; return true;
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Renvoi prochaine valeur attribu<EFBFBD>e
* \return string Valeur * \return string Valeur
*/ */
function getNextValue($objsoc=0,$type=-1) function getNextValue($objsoc=0,$type=-1)
@ -98,7 +98,7 @@ class ModeleThirdPartyCode
} }
/** /**
* \brief Renvoi la liste des modèles actifs * \brief Renvoi la liste des mod<EFBFBD>les actifs
* \param db Handler de base * \param db Handler de base
*/ */
function liste_modeles($db) function liste_modeles($db)
@ -142,12 +142,12 @@ class ModeleThirdPartyCode
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>'; $s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0) $s.=$langs->trans("RequiredIfCustomer").': '.yn(!$this->code_null,1,1).'<br>'; if ($type == 0) $s.=$langs->trans("RequiredIfCustomer").': '.yn(!$this->code_null,1,2).'<br>';
if ($type == 1) $s.=$langs->trans("RequiredIfSupplier").': '.yn(!$this->code_null,1,1).'<br>'; if ($type == 1) $s.=$langs->trans("RequiredIfSupplier").': '.yn(!$this->code_null,1,2).'<br>';
if ($type == -1) $s.=$langs->trans("Required").': '.yn(!$this->code_null,1,1).'<br>'; if ($type == -1) $s.=$langs->trans("Required").': '.yn(!$this->code_null,1,2).'<br>';
$s.=$langs->trans("CanBeModifiedIfOk").': '.yn($this->code_modifiable,1,1).'<br>'; $s.=$langs->trans("CanBeModifiedIfOk").': '.yn($this->code_modifiable,1,2).'<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,1).'<br>'; $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,1).'<br>'; $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
$s.='<br>'; $s.='<br>';
if ($type == 0 || $type == -1) $s.=$langs->trans("NextValue").': <b>'.$this->getNextValue($soc,0).'</b><br>'; if ($type == 0 || $type == -1) $s.=$langs->trans("NextValue").': <b>'.$this->getNextValue($soc,0).'</b><br>';
if ($type == 1 || $type == -1) $s.=$langs->trans("NextValue").': <b>'.$this->getNextValue($soc,1).'</b>'; if ($type == 1 || $type == -1) $s.=$langs->trans("NextValue").': <b>'.$this->getNextValue($soc,1).'</b>';
@ -164,14 +164,14 @@ class ModeleThirdPartyCode
/** /**
\class ModeleAccountancyCode \class ModeleAccountancyCode
\brief Classe mère des modèles de numérotation des codes compta \brief Classe m<EFBFBD>re des mod<EFBFBD>les de num<EFBFBD>rotation des codes compta
*/ */
class ModeleAccountancyCode class ModeleAccountancyCode
{ {
var $error=''; var $error='';
/** \brief Renvoi la description par defaut du modele de numérotation /** \brief Renvoi la description par defaut du modele de num<EFBFBD>rotation
* \return string Texte descripif * \return string Texte descripif
*/ */
function info($langs) function info($langs)
@ -180,7 +180,7 @@ class ModeleAccountancyCode
return $langs->trans("NoDescription"); return $langs->trans("NoDescription");
} }
/** \brief Renvoi un exemple de numérotation /** \brief Renvoi un exemple de num<EFBFBD>rotation
* \return string Example * \return string Example
*/ */
function getExample($langs) function getExample($langs)
@ -189,8 +189,8 @@ class ModeleAccountancyCode
return $langs->trans("NoExample"); return $langs->trans("NoExample");
} }
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de /** \brief Test si les num<EFBFBD>ros d<EFBFBD>j<EFBFBD> en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numérotation de fonctionner. * de conflits qui empechera cette num<EFBFBD>rotation de fonctionner.
* \return boolean false si conflit, true si ok * \return boolean false si conflit, true si ok
*/ */
function canBeActivated() function canBeActivated()
@ -198,7 +198,7 @@ class ModeleAccountancyCode
return true; return true;
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Renvoi prochaine valeur attribu<EFBFBD>e
* \return string Valeur * \return string Valeur
*/ */
function getNextValue($langs) function getNextValue($langs)

View File

@ -134,3 +134,5 @@ DescADHERENT_CARD_TEXT=Text printed on member cards
DescADHERENT_CARD_FOOTER_TEXT=Text printed on bottom of member cards DescADHERENT_CARD_FOOTER_TEXT=Text printed on bottom of member cards
ShowTypeCard=Show type '%s' ShowTypeCard=Show type '%s'
HTPasswordExport=htpassword file generation HTPasswordExport=htpassword file generation
NoThirdPartyAssociatedToMember=No third party associated to this member
ThirdPartyDolibarr=Dolibarr third party

View File

@ -70,6 +70,7 @@ UsersToAdd=Users to add to this group
GroupsToAdd=Groups to add to this user GroupsToAdd=Groups to add to this user
NoLogin=No login NoLogin=No login
CreateDolibarrLogin=Create Dolibarr account CreateDolibarrLogin=Create Dolibarr account
CreateDolibarrThirdParty=Create third party
LoginAccountDisable=Account disabled, put a new login to activate it. LoginAccountDisable=Account disabled, put a new login to activate it.
LoginAccountDisableInDolibarr=Account disabled in Dolibarr. LoginAccountDisableInDolibarr=Account disabled in Dolibarr.
LoginAccountDisableInLdap=Account disabled in the domain. LoginAccountDisableInLdap=Account disabled in the domain.
@ -94,5 +95,8 @@ UserDeleted=User %s removed
NewGroupCreated=Group %s created NewGroupCreated=Group %s created
GroupModified=Group %s modified GroupModified=Group %s modified
GroupDeleted=Group %s removed GroupDeleted=Group %s removed
ConfirmCreateContact=Are you sure yu want to create a Dolibarr account for this contact ? ConfirmCreateContact=Are you sure you want to create a Dolibarr account for this contact ?
ConfirmCreateLogin=Are you sure you want to create a Dolibarr account for this member ?
ConfirmCreateThirdParty=Are you sure you want to create a third party for this member ?
LoginToCreate=Login to create LoginToCreate=Login to create
NameToCreate=Name of third party to create

View File

@ -134,3 +134,5 @@ DescADHERENT_CARD_TEXT=Texte imprimé sur les cartes adhérents
DescADHERENT_CARD_FOOTER_TEXT=Texte imprimé sur le bas des cartes adhérents DescADHERENT_CARD_FOOTER_TEXT=Texte imprimé sur le bas des cartes adhérents
ShowTypeCard=Voir type '%s' ShowTypeCard=Voir type '%s'
HTPasswordExport=Generation fichier htpassword HTPasswordExport=Generation fichier htpassword
NoThirdPartyAssociatedToMember=Pas de tiers associé à cet adhérent
ThirdPartyDolibarr=Tiers Dolibarr

View File

@ -70,6 +70,7 @@ UsersToAdd=Utilisateur à ajouter à ce groupe
GroupsToAdd=Groupes à ajouter pour cet utilisateur GroupsToAdd=Groupes à ajouter pour cet utilisateur
NoLogin=Pas de login NoLogin=Pas de login
CreateDolibarrLogin=Créer un compte Dolibarr CreateDolibarrLogin=Créer un compte Dolibarr
CreateDolibarrThirdParty=Créer un tiers
LoginAccountDisable=Le compte est désactivé, mettre un nouveau login pour l'activer. LoginAccountDisable=Le compte est désactivé, mettre un nouveau login pour l'activer.
LoginAccountDisableInDolibarr=Le compte est désactivé sur Dolibarr. LoginAccountDisableInDolibarr=Le compte est désactivé sur Dolibarr.
LoginAccountDisableInLdap=Le compte est désactivé sur le domaine. LoginAccountDisableInLdap=Le compte est désactivé sur le domaine.
@ -95,4 +96,7 @@ NewGroupCreated=Création groupe %s
GroupModified=Modification groupe %s GroupModified=Modification groupe %s
GroupDeleted=Suppression groupe %s GroupDeleted=Suppression groupe %s
ConfirmCreateContact=Etes vous sur de vouloir créer un compte Dolibarr pour ce contact ? ConfirmCreateContact=Etes vous sur de vouloir créer un compte Dolibarr pour ce contact ?
ConfirmCreateLogin=Etes vous sur de vouloir créer un compte Dolibarr pour cet adhérent ?
ConfirmCreateThirdParty=Etes vous sur de vouloir créer un tiers pour cet adhérent ?
LoginToCreate=Login à créer LoginToCreate=Login à créer
NameToCreate=Nom du tiers à créer

View File

@ -789,11 +789,12 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=
$newphone='<a href="'.$url.'">'.$newphone.'</a>'; $newphone='<a href="'.$url.'">'.$newphone.'</a>';
} }
if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create) //if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create)
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
{ {
$type='AC_TEL'; $type='AC_TEL';
if ($addlink == 'AC_FAX') $type='AC_FAX'; if ($addlink == 'AC_FAX') $type='AC_FAX';
$link='<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;backtopage=1&amp;actioncode='.$type.'&amp;contactid='.$cid.'&amp;socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>'; $link='<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;backtopage=1&amp;actioncode='.$type.($cid?'&amp;contactid='.$cid:'').($socid?'&amp;socid='.$socid:'').'">'.img_object($langs->trans("AddAction"),"calendar").'</a>';
$newphone='<table class="nobordernopadding"><tr><td>'.$newphone.' </td><td>&nbsp;'.$link.'</td></tr></table>'; $newphone='<table class="nobordernopadding"><tr><td>'.$newphone.' </td><td>&nbsp;'.$link.'</td></tr></table>';
} }
} }
@ -2265,10 +2266,10 @@ function get_default_npr($societe_vendeuse, $societe_acheteuse, $taux_produit)
/** /**
\brief Renvoie oui ou non dans la langue choisie * \brief Renvoie oui ou non dans la langue choisie
\param yesno Variable pour test si oui ou non * \param yesno Variable pour test si oui ou non
\param case 1=Yes/No, 0=yes/no * \param case 1=Yes/No, 0=yes/no
\param color 0=texte only, 1=Text is format with a color font style * \param color 0=texte only, 1=Text is formated with a color font style (red or blue), 2=Text is formated with blue color.
*/ */
function yn($yesno, $case=1, $color=0) function yn($yesno, $case=1, $color=0)
{ {
@ -2282,7 +2283,8 @@ function yn($yesno, $case=1, $color=0)
elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false')
{ {
$result=($case?$langs->trans("No"):$langs->trans("no")); $result=($case?$langs->trans("No"):$langs->trans("no"));
$class='error'; if ($color == 2) $class='ok';
else $class='error';
} }
if ($color) return '<font class="'.$class.'">'.$result.'</font>'; if ($color) return '<font class="'.$class.'">'.$result.'</font>';
return $result; return $result;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2003 Brian Fraval <brian@fraval.org> * Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@ -688,7 +688,7 @@ class Societe extends CommonObject
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
dolibarr_syslog("Societe::Delete"); dolibarr_syslog("Societe::Delete", LOG_DEBUG);
$sqr = 0; $sqr = 0;
// Check if third party can be deleted // Check if third party can be deleted
@ -746,6 +746,7 @@ class Societe extends CommonObject
// Remove contacts // Remove contacts
$sql = "DELETE from ".MAIN_DB_PREFIX."socpeople"; $sql = "DELETE from ".MAIN_DB_PREFIX."socpeople";
$sql.= " WHERE fk_soc = " . $id; $sql.= " WHERE fk_soc = " . $id;
dolibarr_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$sqr++; $sqr++;
@ -756,8 +757,24 @@ class Societe extends CommonObject
dolibarr_syslog("Societe::Delete erreur -1 ".$this->error); dolibarr_syslog("Societe::Delete erreur -1 ".$this->error);
} }
// Update link in member table
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
$sql.= " SET fk_soc = NULL where fk_soc = " . $id;
dolibarr_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= $this->db->lasterror();
dolibarr_syslog("Societe::Delete erreur -1 ".$this->error);
}
// Remove ban
$sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib"; $sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib";
$sql.= " WHERE fk_soc = " . $id; $sql.= " WHERE fk_soc = " . $id;
dolibarr_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$sqr++; $sqr++;
@ -768,8 +785,10 @@ class Societe extends CommonObject
dolibarr_syslog("Societe::Delete erreur -2 ".$this->error); dolibarr_syslog("Societe::Delete erreur -2 ".$this->error);
} }
// Remove third party
$sql = "DELETE from ".MAIN_DB_PREFIX."societe"; $sql = "DELETE from ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE rowid = " . $id; $sql.= " WHERE rowid = " . $id;
dolibarr_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$sqr++; $sqr++;
@ -780,7 +799,7 @@ class Societe extends CommonObject
dolibarr_syslog("Societe::Delete erreur -3 ".$this->error); dolibarr_syslog("Societe::Delete erreur -3 ".$this->error);
} }
if ($sqr == 3) if ($sqr == 4)
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
@ -1935,6 +1954,68 @@ class Societe extends CommonObject
print '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">'; print '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">';
} }
/**
* \brief Cree en base un utilisateur depuis l'objet adherent
* \param member Objet adherent source
* \param login Login to force
* \return int Si erreur <0, si ok renvoie id compte cree
*/
function create_from_member($member,$login='')
{
global $conf,$user,$langs;
$name=$member->societe;
if (empty($name)) $name=strtolower($member->nom.' '.$member->prenom);
// Positionne parametres
$this->email = $member->email;
$this->nom = $name;
$this->code_client = -1;
$this->code_fournisseur = -1;
$this->adresse=$member->adresse;
$this->cp=$member->cp;
$this->ville=$member->ville;
$this->pays_code=$member->pays_code;
$this->pays_id=$member->pays_id;
$this->tel=$member->phone; // Prof phone
$this->db->begin();
// Cree et positionne $this->id
$result=$this->create($user);
if ($result >= 0)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
$sql.= " SET fk_soc=".$this->id;
$sql.= " WHERE rowid=".$member->id;
dolibarr_syslog("Societe::create_from_member sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->db->commit();
return $this->id;
}
else
{
$this->error=$this->db->error();
dolibarr_syslog("Societe::create_from_member - 1 - ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
else
{
// $this->error deja positionne
dolibarr_syslog("Societe::create_from_member - 2 - ".$this->error, LOG_ERR);
$this->db->rollback();
return $result;
}
}
} }
?> ?>

View File

@ -868,9 +868,9 @@ class User extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql.= " SET fk_member=".$member->id; $sql.= " SET fk_member=".$member->id;
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
$resql=$this->db->query($sql);
dolibarr_syslog("User::create_from_member sql=".$sql, LOG_DEBUG); dolibarr_syslog("User::create_from_member sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->db->commit(); $this->db->commit();
@ -878,8 +878,8 @@ class User extends CommonObject
} }
else else
{ {
$this->error=$this->db->error()." - ".$sql; $this->error=$this->db->error();
dolibarr_syslog("User::create_from_member - ".$this->error, LOG_ERR); dolibarr_syslog("User::create_from_member - 1 - ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;

View File

@ -41,7 +41,10 @@ ALTER TABLE llx_product drop column stock_commande;
ALTER TABLE llx_adherent drop index login; ALTER TABLE llx_adherent drop index login;
ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login); ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login);
ALTER TABLE llx_adherent add column fk_soc integer NULL after societe; ALTER TABLE llx_adherent add column fk_soc integer NULL after societe;
ALTER TABLE llx_adherent ADD INDEX idx_adherent_fk_soc (fk_soc);
ALTER TABLE llx_adherent ADD CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_societe drop column rubrique; ALTER TABLE llx_societe drop column rubrique;

View File

@ -20,3 +20,6 @@
ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login); ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login);
ALTER TABLE llx_adherent ADD INDEX idx_adherent_fk_soc (fk_soc);
ALTER TABLE llx_adherent ADD CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);