diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index a4a7661f712..dada4920d45 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -88,8 +88,33 @@ if ($rowid) * Actions */ +// Create third party from a member +if ($action == 'confirm_create_thirdparty' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer) +{ + if ($result > 0) + { + // Creation user + $company = new Societe($db); + $result=$company->create_from_member($adh,$_POST["companyname"]); + + if ($result < 0) + { + $langs->load("errors"); + $errmsg=$langs->trans($company->error); + $errmsgs=$company->errors; + } + else + { + $action='addsubscription'; + } + } + else + { + $errmsg=$adh->error; + } +} -if ($_POST['action'] == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) +if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { $error=0; if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only @@ -113,7 +138,7 @@ if ($_POST['action'] == 'setuserid' && ($user->rights->user->self->creer || $use } } -if ($_POST['action'] == 'setsocid') +if ($action == 'setsocid') { $error=0; if (! $error) @@ -148,7 +173,7 @@ if ($_POST['action'] == 'setsocid') } } -if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisation' && ! $_POST["cancel"]) +if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $_POST["cancel"]) { $error=0; @@ -547,15 +572,7 @@ if ($rowid) dol_fiche_end(); - if ($errmsg) - { - if (preg_match('/^Error/i',$errmsg)) - { - $langs->load("errors"); - $errmsg=$langs->trans($errmsg); - } - print '
'.$errmsg.'
'."\n"; - } + dol_htmloutput_errors($errmg,$errmsgs); /* @@ -565,11 +582,11 @@ if ($rowid) // Lien nouvelle cotisation si non brouillon et non resilie if ($user->rights->adherent->cotisation->creer) { - if ($action != 'addsubscription') + if ($action != 'addsubscription' && $action != 'create_thirdparty') { print '
'; - if ($adh->statut > 0) print "".$langs->trans("AddSubscription").""; + if ($adh->statut > 0) print ''.$langs->trans("AddSubscription").""; else print ''.$langs->trans("AddSubscription").''; print "
\n"; @@ -583,7 +600,7 @@ if ($rowid) /* * List of subscriptions */ - if ($action != 'addsubscription') + if ($action != 'addsubscription' && $action != 'create_thirdparty') { $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe,"; $sql.= " c.rowid as crowid, c.cotisation,"; @@ -662,7 +679,7 @@ if ($rowid) /* * Add new subscription form */ - if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer) + if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { print '
'; @@ -716,11 +733,34 @@ if ($rowid) print ''."\n"; } + + // Confirm create third party + if ($_GET["action"] == 'create_thirdparty') + { + $name = $adh->getFullName($langs); + 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)); + + $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$adh->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); + if ($ret == 'html') print '
'; + } + + print '
'; print ''; print ''; print ''; - print ''; + print ''; print ''; print "\n"; @@ -799,7 +839,13 @@ if ($rowid) if (empty($adh->fk_soc) || empty($bankviainvoice)) print ' disabled="true"'; print '> '.$langs->trans("MoreActionBankViaInvoice"); if ($adh->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else print ' ('.$langs->trans("NoThirdPartyAssociatedToMember").')'; + else + { + print ' ('.$langs->trans("NoThirdPartyAssociatedToMember"); + print ' - '; + print $langs->trans("CreateDolibarrThirdParty"); + print ')'; + } print '
'; } if ($conf->societe->enabled && $conf->facture->enabled) @@ -808,7 +854,13 @@ if ($rowid) if (empty($adh->fk_soc) || empty($bankviainvoice)) print ' disabled="true"'; print '> '.$langs->trans("MoreActionInvoiceOnly"); if ($adh->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else print ' ('.$langs->trans("NoThirdPartyAssociatedToMember").')'; + else + { + print ' ('.$langs->trans("NoThirdPartyAssociatedToMember"); + print ' - '; + print $langs->trans("CreateDolibarrThirdParty"); + print ')'; + } print '
'; } print ''; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index cd3c08c0853..932b81738be 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -390,7 +390,7 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer) // Check parameters if (empty($morphy) || $morphy == "-1") { $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Person"))."
\n"; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."
\n"; } // Test si le login existe deja if (empty($login)) { @@ -638,7 +638,7 @@ if ($action == 'create') // Moral-Physique $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); - print '\n"; @@ -841,7 +841,7 @@ if ($action == 'edit') // Physique-Moral $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Morale"); - print '"; @@ -1155,7 +1155,7 @@ if ($rowid && $action != 'edit') print ''; // Morphy - print ''; + print ''; // Company print ''; @@ -1375,7 +1375,7 @@ if ($rowid && $action != 'edit') { if ($user->rights->societe->creer) { - if ($adh->statut != -1) print ''.$langs->trans("CreateDolibarrThirdParty").''; + if ($adh->statut != -1) print ''.$langs->trans("CreateDolibarrThirdParty").''; else print ''.$langs->trans("CreateDolibarrThirdParty").''; } else @@ -1389,7 +1389,7 @@ if ($rowid && $action != 'edit') { if ($user->rights->user->user->creer) { - if ($adh->statut != -1) print ''.$langs->trans("CreateDolibarrLogin").''; + if ($adh->statut != -1) print ''.$langs->trans("CreateDolibarrLogin").''; else print ''.$langs->trans("CreateDolibarrLogin").''; } else
'.$langs->trans("Person")."\n"; + print '
'.$langs->trans("Nature")."\n"; print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy, 1); print "
'.$langs->trans("Person").''; + print '
'.$langs->trans("Nature").''; print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy); print "
'.$langs->trans("Person").''.$adh->getmorphylib().'
'.$langs->trans("Nature").''.$adh->getmorphylib().'
'.$langs->trans("Company").''.$adh->societe.'