mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Work on invoice creation when creating subscription
This commit is contained in:
parent
110e66db18
commit
bbb1db7a51
|
|
@ -39,6 +39,17 @@ $langs->load("members");
|
|||
$langs->load("users");
|
||||
$langs->load("mails");
|
||||
|
||||
// If socid provided by ajax company selector
|
||||
if (! empty($_REQUEST['socid_id']))
|
||||
{
|
||||
$_GET['socid'] = $_GET['socid_id'];
|
||||
$_POST['socid'] = $_POST['socid_id'];
|
||||
$_REQUEST['socid'] = $_REQUEST['socid_id'];
|
||||
}
|
||||
|
||||
// Security check
|
||||
if (! $user->rights->adherent->cotisation->lire) accessforbidden();
|
||||
|
||||
$adh = new Adherent($db);
|
||||
$adho = new AdherentOptions($db);
|
||||
$adht = new AdherentType($db);
|
||||
|
|
@ -51,14 +62,103 @@ $action=GETPOST('action');
|
|||
$rowid=GETPOST('rowid');
|
||||
$typeid=GETPOST('typeid');
|
||||
|
||||
if (! $user->rights->adherent->cotisation->lire)
|
||||
accessforbidden();
|
||||
if ($rowid)
|
||||
{
|
||||
// Load member
|
||||
$result = $adh->fetch($rowid);
|
||||
|
||||
// Define variables to know what current user can do on users
|
||||
$canadduser=($user->admin || $user->rights->user->user->creer);
|
||||
// Define variables to know what current user can do on properties of user linked to edited member
|
||||
if ($adh->user_id)
|
||||
{
|
||||
// $user est le user qui edite, $adh->user_id est l'id de l'utilisateur lies au membre edite
|
||||
$caneditfielduser=( (($user->id == $adh->user_id) && $user->rights->user->self->creer)
|
||||
|| (($user->id != $adh->user_id) && $user->rights->user->user->creer) );
|
||||
$caneditpassworduser=( (($user->id == $adh->user_id) && $user->rights->user->self->password)
|
||||
|| (($user->id != $adh->user_id) && $user->rights->user->user->password) );
|
||||
}
|
||||
}
|
||||
|
||||
// Define variables to know what current user can do on members
|
||||
$canaddmember=$user->rights->adherent->creer;
|
||||
// Define variables to know what current user can do on properties of a member
|
||||
if ($rowid)
|
||||
{
|
||||
$caneditfieldmember=$user->rights->adherent->creer;
|
||||
}
|
||||
|
||||
// Define size of logo small and mini (might be set into other pages)
|
||||
$maxwidthsmall=270;$maxheightsmall=150;
|
||||
$maxwidthmini=128;$maxheightmini=72;
|
||||
$quality = 80;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
|
||||
if ($_POST['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
|
||||
{
|
||||
if ($_POST["userid"] != $user->id && $_POST["userid"] != $adh->user_id)
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if ($_POST["userid"] != $adh->user_id) // If link differs from currently in database
|
||||
{
|
||||
$result=$adh->setUserId($_POST["userid"]);
|
||||
if ($result < 0) dol_print_error($adh->db,$adh->error);
|
||||
$_POST['action']='';
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'setsocid')
|
||||
{
|
||||
$error=0;
|
||||
if (! $error)
|
||||
{
|
||||
if (GETPOST("socid") != $adh->fk_soc) // If link differs from currently in database
|
||||
{
|
||||
$sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
|
||||
$sql.=" WHERE fk_soc = '".GETPOST("socid")."'";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj && $obj->rowid > 0)
|
||||
{
|
||||
$othermember=new Adherent($db);
|
||||
$othermember->fetch($obj->rowid);
|
||||
$thirdparty=new Societe($db);
|
||||
$thirdparty->fetch(GETPOST("socid"));
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->nom).'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$adh->setThirdPartyId(GETPOST("socid"));
|
||||
if ($result < 0) dol_print_error($adh->db,$adh->error);
|
||||
$_POST['action']='';
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisation' && ! $_POST["cancel"])
|
||||
{
|
||||
$error=0;
|
||||
|
|
@ -240,6 +340,7 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
|
@ -250,7 +351,6 @@ llxHeader('',$langs->trans("Subscriptions"),'EN:Module_Foundations|FR:Module_Adh
|
|||
|
||||
if ($rowid)
|
||||
{
|
||||
$adh->id = $rowid;
|
||||
$result=$adh->fetch($rowid);
|
||||
$result=$adh->fetch_optionals($rowid);
|
||||
|
||||
|
|
@ -264,8 +364,9 @@ if ($rowid)
|
|||
|
||||
dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user');
|
||||
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$adh->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
|
|
@ -292,7 +393,6 @@ if ($rowid)
|
|||
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$adh->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Date end subscription
|
||||
// Date fin cotisation
|
||||
print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
|
||||
if ($adh->datefin)
|
||||
{
|
||||
|
|
@ -313,6 +413,73 @@ if ($rowid)
|
|||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Third party Dolibarr
|
||||
if ($conf->societe->enabled)
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans("LinkedToDolibarrThirdParty");
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&rowid='.$adh->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td class="valeur">';
|
||||
if ($_GET['action'] == 'editthirdparty')
|
||||
{
|
||||
$htmlname='socid';
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$adh->id.'">';
|
||||
print '<input type="hidden" name="action" value="set'.$htmlname.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
print $html->select_societes($adh->fk_soc,'socid','',1);
|
||||
print '</td>';
|
||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
print '</tr></table></form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
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>';
|
||||
}
|
||||
|
||||
// Login Dolibarr
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans("LinkedToDolibarrUser");
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'editlogin' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlogin&rowid='.$adh->id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td class="valeur">';
|
||||
if ($_GET['action'] == 'editlogin')
|
||||
{
|
||||
/*$include=array();
|
||||
if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only
|
||||
{
|
||||
$include=array($adh->user_id,$user->id);
|
||||
}*/
|
||||
print $html->form_users($_SERVER['PHP_SELF'].'?rowid='.$adh->id,$adh->user_id,'userid','');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($adh->user_id)
|
||||
{
|
||||
print $html->form_users($_SERVER['PHP_SELF'].'?rowid='.$adh->id,$adh->user_id,'none');
|
||||
}
|
||||
else print $langs->trans("NoDolibarrAccess");
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>\n";
|
||||
print '</form>';
|
||||
|
||||
|
|
|
|||
|
|
@ -51,10 +51,7 @@ if (! empty($_REQUEST['socid_id']))
|
|||
}
|
||||
|
||||
// Security check
|
||||
if (! $user->rights->adherent->lire)
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
if (! $user->rights->adherent->lire) accessforbidden();
|
||||
|
||||
$adh = new Adherent($db);
|
||||
$adho = new AdherentOptions($db);
|
||||
|
|
@ -318,18 +315,8 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe
|
|||
}
|
||||
else
|
||||
{
|
||||
if ($adh->error)
|
||||
{
|
||||
$errmsg=$adh->error;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($adh->errors as $error)
|
||||
{
|
||||
if ($errmsg) $errmsg.='<br>';
|
||||
$errmsg.=$error;
|
||||
}
|
||||
}
|
||||
if ($adh->error) $errmsg=$adh->error;
|
||||
else $errmsgs=$adh->errors;
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
|
@ -475,7 +462,7 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer)
|
|||
$db->rollback();
|
||||
|
||||
if ($adh->error) $errmsg=$adh->error;
|
||||
else $errmsg=$adh->errors[0];
|
||||
else $errmsgs=$adh->errors;
|
||||
|
||||
$action = 'create';
|
||||
}
|
||||
|
|
@ -527,19 +514,8 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_valid' && $_P
|
|||
}
|
||||
else
|
||||
{
|
||||
// \TODO Mettre fonction qui fabrique errmsg depuis this->error||this->errors
|
||||
if ($adh->error)
|
||||
{
|
||||
$errmsg=$adh->error;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($adh->errors as $error)
|
||||
{
|
||||
if ($errmsg) $errmsg.='<br>';
|
||||
$errmsg.=$error;
|
||||
}
|
||||
}
|
||||
if ($adh->error) $errmsg=$adh->error;
|
||||
else $errmsgs=$adh->errors;
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
|
@ -571,19 +547,8 @@ if ($user->rights->adherent->supprimer && $_POST["action"] == 'confirm_resign' &
|
|||
}
|
||||
else
|
||||
{
|
||||
// \TODO Mettre fonction qui fabrique errmsg depuis this->error||this->errors
|
||||
if ($adh->error)
|
||||
{
|
||||
$errmsg=$adh->error;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($adh->errors as $error)
|
||||
{
|
||||
if ($errmsg) $errmsg.='<br>';
|
||||
$errmsg.=$error;
|
||||
}
|
||||
}
|
||||
if ($adh->error) $errmsg=$adh->error;
|
||||
else $errmsgs=$adh->errors;
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
|
@ -857,10 +822,8 @@ if ($action == 'edit')
|
|||
|
||||
dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
|
||||
|
||||
if ($errmsg)
|
||||
{
|
||||
print '<div class="error">'.$errmsg.'</div>';
|
||||
}
|
||||
dol_htmloutput_errors($errmsg,$errmsgs);
|
||||
|
||||
if ($mesg) print '<div class="ok">'.$mesg.'</div>';
|
||||
|
||||
|
||||
|
|
@ -1195,7 +1158,6 @@ if ($rowid && $action != 'edit')
|
|||
$rowspan=15+sizeof($adho->attribute_label);
|
||||
if ($conf->societe->enabled) $rowspan++;
|
||||
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
|
|
@ -1289,9 +1251,9 @@ if ($rowid && $action != 'edit')
|
|||
print '</td><td class="valeur">';
|
||||
if ($_GET['action'] == 'editthirdparty')
|
||||
{
|
||||
$page=$_SERVER['PHP_SELF'].'?rowid='.$adh->id;
|
||||
$htmlname='socid';
|
||||
print '<form method="post" action="'.$page.'" name="form'.$htmlname.'">';
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$adh->id.'">';
|
||||
print '<input type="hidden" name="action" value="set'.$htmlname.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
|
|
|
|||
|
|
@ -1636,6 +1636,7 @@ class Facture extends CommonObject
|
|||
$total_ttc = $tabprice[2];
|
||||
$total_localtax1 = $tabprice[9];
|
||||
$total_localtax2 = $tabprice[10];
|
||||
$pu_ht = $tabprice[3];
|
||||
|
||||
// Rang to use
|
||||
$rangtouse = $rang;
|
||||
|
|
|
|||
|
|
@ -2113,7 +2113,7 @@ class Form
|
|||
|
||||
if ($htmlname != "none")
|
||||
{
|
||||
print '<form method="post" action="'.$page.'" name="form'.$htmlname.'">';
|
||||
print '<form method="POST" action="'.$page.'" name="form'.$htmlname.'">';
|
||||
print '<input type="hidden" name="action" value="set'.$htmlname.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
|
|
@ -2151,7 +2151,7 @@ class Form
|
|||
global $langs;
|
||||
if ($htmlname != "none")
|
||||
{
|
||||
print '<form method="post" action="'.$page.'">';
|
||||
print '<form method="POST" action="'.$page.'">';
|
||||
print '<input type="hidden" name="action" value="setmode">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user