mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Start to work on invoice/payment creation on subscription creation
This commit is contained in:
parent
f844640adf
commit
fd177b1746
|
|
@ -65,8 +65,7 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio
|
|||
|
||||
$adh->id = $rowid;
|
||||
$result=$adh->fetch($rowid);
|
||||
|
||||
$adht->fetch($adh->typeid);
|
||||
$result=$adht->fetch($adh->typeid);
|
||||
|
||||
// Subscription informations
|
||||
$datecotisation=0;
|
||||
|
|
@ -98,6 +97,8 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio
|
|||
$num_chq=$_POST["num_chq"];
|
||||
$emetteur_nom=$_POST["chqemetteur"];
|
||||
$emetteur_banque=$_POST["chqbank"];
|
||||
$option=$_POST["paymentsave"];
|
||||
if (empty($option)) $option='none';
|
||||
|
||||
// Check if a payment is mandatory or not
|
||||
if ($adht->cotisation) // Type adherent soumis a cotisation
|
||||
|
|
@ -110,9 +111,9 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio
|
|||
}
|
||||
else
|
||||
{
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
if ($conf->banque->enabled && $_POST["paymentsave"] != 'none')
|
||||
{
|
||||
if ($_POST["cotisation"])
|
||||
if ($_POST["cotisation"])
|
||||
{
|
||||
if (! $_POST["label"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
|
||||
if (! $_POST["operation"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
||||
|
|
@ -131,7 +132,7 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio
|
|||
{
|
||||
$db->begin();
|
||||
|
||||
$crowid=$adh->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
|
||||
$crowid=$adh->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $option);
|
||||
|
||||
if ($crowid > 0)
|
||||
{
|
||||
|
|
@ -181,9 +182,6 @@ $adht->fetch($adh->typeid);
|
|||
$adho->fetch_optionals();
|
||||
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = member_prepare_head($adh);
|
||||
|
||||
dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user');
|
||||
|
|
@ -219,7 +217,7 @@ print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$adh->getLib
|
|||
print "</table>\n";
|
||||
print '</form>';
|
||||
|
||||
print "</div>\n";
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
if ($errmsg)
|
||||
|
|
@ -236,7 +234,6 @@ if ($errmsg)
|
|||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
|
|
@ -253,145 +250,165 @@ print "<br>\n";
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Bandeau des cotisations
|
||||
*
|
||||
*/
|
||||
|
||||
print '<table border=0 width="100%">';
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top" width="50%">';
|
||||
|
||||
|
||||
/*
|
||||
* Liste des cotisations
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe,";
|
||||
$sql.= " c.rowid as crowid, c.cotisation,";
|
||||
$sql.= " c.dateadh,";
|
||||
$sql.= " c.datef,";
|
||||
$sql.= " c.fk_bank,";
|
||||
$sql.= " b.rowid as bid,";
|
||||
$sql.= " ba.rowid as baid, ba.label, ba.bank";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql.= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$cotisationstatic=new Cotisation($db);
|
||||
$accountstatic=new Account($db);
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateSubscription").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
{
|
||||
print '<td align="right">'.$langs->trans("Account").'</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
$cotisationstatic->ref=$objp->crowid;
|
||||
$cotisationstatic->id=$objp->crowid;
|
||||
print '<td>'.$cotisationstatic->getNomUrl(1).'</td>';
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n";
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
|
||||
print '<td align="right">'.price($objp->cotisation).'</td>';
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
{
|
||||
print '<td align="right">';
|
||||
if ($objp->bid)
|
||||
{
|
||||
$accountstatic->label=$objp->label;
|
||||
$accountstatic->id=$objp->baid;
|
||||
print $accountstatic->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '</td><td valign="top">';
|
||||
|
||||
|
||||
// Date fin cotisation
|
||||
print "<table class=\"border\" width=\"100%\">\n";
|
||||
print "<table class=\"border\" width=\"50%\">\n";
|
||||
print '<tr><td>'.$langs->trans("SubscriptionEndDate");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($adh->datefin)
|
||||
{
|
||||
if ($adh->datefin < time())
|
||||
{
|
||||
print dol_print_date($adh->datefin,'day');
|
||||
if ($adh->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
|
||||
}
|
||||
else
|
||||
{
|
||||
print dol_print_date($adh->datefin,'day');
|
||||
}
|
||||
if ($adh->datefin < time())
|
||||
{
|
||||
print dol_print_date($adh->datefin,'day');
|
||||
if ($adh->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
|
||||
}
|
||||
else
|
||||
{
|
||||
print dol_print_date($adh->datefin,'day');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("SubscriptionNotReceived");
|
||||
if ($adh->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
|
||||
print $langs->trans("SubscriptionNotReceived");
|
||||
if ($adh->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
/*
|
||||
* Add new subscription
|
||||
* List of subscriptions
|
||||
*/
|
||||
if ($action != 'addsubscription')
|
||||
{
|
||||
$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe,";
|
||||
$sql.= " c.rowid as crowid, c.cotisation,";
|
||||
$sql.= " c.dateadh,";
|
||||
$sql.= " c.datef,";
|
||||
$sql.= " c.fk_bank,";
|
||||
$sql.= " b.rowid as bid,";
|
||||
$sql.= " ba.rowid as baid, ba.label, ba.bank";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql.= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$cotisationstatic=new Cotisation($db);
|
||||
$accountstatic=new Account($db);
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateSubscription").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
print '<td align="right">'.$langs->trans("Account").'</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
$cotisationstatic->ref=$objp->crowid;
|
||||
$cotisationstatic->id=$objp->crowid;
|
||||
print '<td>'.$cotisationstatic->getNomUrl(1).'</td>';
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n";
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
|
||||
print '<td align="right">'.price($objp->cotisation).'</td>';
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
print '<td align="right">';
|
||||
if ($objp->bid)
|
||||
{
|
||||
$accountstatic->label=$objp->label;
|
||||
$accountstatic->id=$objp->baid;
|
||||
print $accountstatic->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Add new subscription form
|
||||
*/
|
||||
if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer)
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
print_fiche_titre($langs->trans("NewCotisation"));
|
||||
|
||||
$bankdirect=0; // Option to write to bank is on by default
|
||||
$bankviainvoice=0; // Option to write via invoice is on by default
|
||||
$invoiceonly=0;
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && (empty($_POST['paymentsave']) || $_POST["paymentsave"] == 'bankdirect')) $bankdirect=1;
|
||||
if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled && $adh->fk_soc) $bankviainvoice=1;
|
||||
// TODO A virer
|
||||
$bankviainvoice=0;
|
||||
|
||||
print "\n\n<!-- Form add subscription -->\n";
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print '<script type="text/javascript" language="javascript">';
|
||||
print 'jQuery(document).ready(function () {
|
||||
jQuery(".bankswitchclass").'.($bankdirect||$bankviainvoice?'show()':'hide()').';
|
||||
jQuery("#none").click(function() {
|
||||
jQuery(".bankswitchclass").hide();
|
||||
});
|
||||
jQuery("#bankdirect").click(function() {
|
||||
jQuery(".bankswitchclass").show();
|
||||
});
|
||||
jQuery("#bankdviainvoice").click(function() {
|
||||
jQuery(".bankswitchclass").show();
|
||||
});
|
||||
jQuery("#invoiceonly").click(function() {
|
||||
jQuery(".bankswitchclass").show();
|
||||
});
|
||||
});';
|
||||
print '</script>';
|
||||
}
|
||||
|
||||
print '<form name="cotisation" method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="cotisation">';
|
||||
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
||||
print "<table class=\"border\" width=\"100%\">\n";
|
||||
|
||||
// Title subscription
|
||||
print '<tr><td colspan="2"><b>'.$langs->trans("NewCotisation").'</b></td></tr>';
|
||||
|
||||
$today=mktime();
|
||||
$datefrom=0;
|
||||
$dateto=0;
|
||||
|
||||
// Date start subscription
|
||||
print '<tr><td>'.$langs->trans("DateSubscription").'</td><td>';
|
||||
print '<tr><td width="30%" class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
|
||||
if ($_POST["reday"])
|
||||
{
|
||||
$datefrom=dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
||||
|
|
@ -427,48 +444,85 @@ if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer)
|
|||
if ($adht->cotisation)
|
||||
{
|
||||
// Amount
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td><input type="text" name="cotisation" size="6" value="'.$_POST["cotisation"].'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="cotisation" size="6" value="'.$_POST["cotisation"].'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
|
||||
print '<td><input name="label" type="text" size="32" value="'.$langs->trans("Subscription").' ';
|
||||
print dol_print_date(($datefrom?$datefrom:time()),"%Y").'" ></td></tr>';
|
||||
|
||||
// Bank account
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
// Bank account transaction
|
||||
if ($conf->banque->enabled || $conf->facture->enabled)
|
||||
{
|
||||
// Title payments
|
||||
print '<tr><td colspan="2"><b>'.$langs->trans("Payment").'</b></td></tr>';
|
||||
$company=new Societe($db);
|
||||
if ($adh->fk_soc)
|
||||
{
|
||||
$result=$company->fetch($adh->fk_soc);
|
||||
}
|
||||
|
||||
// Title payments
|
||||
//print '<tr><td colspan="2"><b>'.$langs->trans("Payment").'</b></td></tr>';
|
||||
|
||||
// Define a way to write payment
|
||||
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('MoreActions');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(!$bankdirect&&!$bankviainvoice?' checked="true"':'').'> '.$langs->trans("None").'<br>';
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.($bankdirect?' checked="true"':'');
|
||||
print '> '.$langs->trans("MoreActionBankDirect").'<br>';
|
||||
}
|
||||
if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled)
|
||||
{
|
||||
print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.($bankviainvoice?' checked="true"':'');
|
||||
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").')';
|
||||
print '<br>';
|
||||
}
|
||||
if ($conf->societe->enabled && $conf->facture->enabled)
|
||||
{
|
||||
print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.($invoiceonly?' checked="true"':'');
|
||||
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").')';
|
||||
print '<br>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank account
|
||||
print '<tr><td>'.$langs->trans("FinancialAccount").'</td><td>';
|
||||
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
|
||||
$html->select_comptes($_POST["accountid"],'accountid',0,'',1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Payment mode
|
||||
print '<tr><td>'.$langs->trans("PaymentMode").'</td><td>';
|
||||
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||
$html->select_types_paiements($_POST["operation"],'operation');
|
||||
print "</td></tr>\n";
|
||||
|
||||
print '<tr><td>'.$langs->trans('Numero');
|
||||
print '<tr class="bankswitchclass"><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input name="num_chq" type="text" size="8" value="'.(empty($_POST['num_chq'])?'':$_POST['num_chq']).'"></td></tr>';
|
||||
print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(empty($_POST['num_chq'])?'':$_POST['num_chq']).'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('CheckTransmitter');
|
||||
print '<tr class="bankswitchclass"><td>'.$langs->trans('CheckTransmitter');
|
||||
print ' <em>('.$langs->trans("ChequeMaker").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input name="chqemetteur" size="32" type="text" value="'.(empty($_POST['chqemetteur'])?$facture->client->nom:$_POST['chqemetteur']).'"></td></tr>';
|
||||
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(empty($_POST['chqemetteur'])?$facture->client->nom:$_POST['chqemetteur']).'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Bank');
|
||||
print '<tr class="bankswitchclass"><td>'.$langs->trans('Bank');
|
||||
print ' <em>('.$langs->trans("ChequeBank").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input name="chqbank" size="32" type="text" value="'.(empty($_POST['chqbank'])?'':$_POST['chqbank']).'"></td></tr>';
|
||||
|
||||
print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(empty($_POST['chqbank'])?'':$_POST['chqbank']).'"></td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("SendAcknowledgementByMail").'</td>';
|
||||
print '<tr><td colspan="2"> </td>';
|
||||
|
||||
print '<tr><td width="30%">'.$langs->trans("SendAcknowledgementByMail").'</td>';
|
||||
print '<td>';
|
||||
if (! $adh->email)
|
||||
{
|
||||
|
|
@ -495,23 +549,22 @@ if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer)
|
|||
print $html->textwithpicto($tmp,$helpcontent,1,'help');
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<tr><td colspan="2" align="center">';
|
||||
print '<center>';
|
||||
print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</td></tr>';
|
||||
print '</center>';
|
||||
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
print "\n<!-- End form subscription -->\n\n";
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
//print '</td></tr>';
|
||||
//print '</table>';
|
||||
|
||||
|
||||
$db->close();
|
||||
|
|
|
|||
|
|
@ -1143,9 +1143,10 @@ class Adherent extends CommonObject
|
|||
* \param emetteur_nom Nom emetteur cheque
|
||||
* \param emetteur_banque Nom banque emetteur cheque
|
||||
* \param datesubend Date fin adhesion
|
||||
* \param option 'none'=No more action, 'bankdirect'=Add direct bank transaction, 'bankviainvoice'=Add bank transaction via invoice and payment
|
||||
* \return int rowid de l'entree ajoutee, <0 si erreur
|
||||
*/
|
||||
function cotisation($date, $montant, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0)
|
||||
function cotisation($date, $montant, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0, $option='none')
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
|
||||
|
|
@ -1174,7 +1175,6 @@ class Adherent extends CommonObject
|
|||
$cotisation->note=$label;
|
||||
|
||||
$rowid=$cotisation->create($user);
|
||||
|
||||
if ($rowid > 0)
|
||||
{
|
||||
// Update denormalized subscription end date (read database subscription to find values)
|
||||
|
|
@ -1189,7 +1189,7 @@ class Adherent extends CommonObject
|
|||
}
|
||||
|
||||
// Insertion dans la gestion bancaire si configure pour
|
||||
if ($conf->global->ADHERENT_BANK_USE && $accountid)
|
||||
if ($option == 'bankdirect' && $accountid)
|
||||
{
|
||||
$acct=new Account($this->db);
|
||||
$result=$acct->fetch($accountid);
|
||||
|
|
@ -1229,6 +1229,12 @@ class Adherent extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
// Create invoice and payment
|
||||
if ($option == 'bankviainvoice' && $accountid)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Change properties of object (used by triggers)
|
||||
$this->last_subscription_date=$dateop;
|
||||
$this->last_subscription_amount=$montant;
|
||||
|
|
|
|||
|
|
@ -48,91 +48,13 @@ $pagenext = $page + 1;
|
|||
$msg='';
|
||||
$date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
|
||||
|
||||
// Desactivation fonctions insertions en banque apres coup
|
||||
// Cette fonction me semble pas utile. Si on a fait des adhesions alors que module banque
|
||||
// pas actif c'est qu'on voulait pas d'insertion en banque.
|
||||
// si on active apres coup, on va pas modifier toutes les adhesions pour avoir une ecriture
|
||||
// en banque mais on va mettre le solde banque direct a la valeur apres toutes les adh<64>sions.
|
||||
$allowinsertbankafter=0;
|
||||
|
||||
if (! $user->rights->adherent->cotisation->lire)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// Insertion de la cotisation dans le compte banquaire
|
||||
if ($allowinsertbankafter && $_POST["action"] == '2bank' && $_POST["rowid"] !='')
|
||||
{
|
||||
if ($conf->global->ADHERENT_BANK_USE)
|
||||
{
|
||||
if (! $_POST["accountid"])
|
||||
{
|
||||
$msg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("BankAccount")).'</div>';
|
||||
}
|
||||
if (! $_POST["paymenttypeid"])
|
||||
{
|
||||
$msg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("OperationType")).'</div>';
|
||||
}
|
||||
|
||||
// Cr<43>er un tiers + facture et enregistrer son paiement ? -> Non requis avec module compta expert
|
||||
// Eventuellement offrir option a la creation adhesion
|
||||
|
||||
if (! $msg)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$dateop=time();
|
||||
|
||||
$cotisation=new Cotisation($db);
|
||||
$result=$cotisation->fetch($_POST["rowid"]);
|
||||
$adherent=new Adherent($db);
|
||||
$result=$adherent->fetch($cotisation->fk_adherent);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$amount=$cotisation->amount;
|
||||
|
||||
$acct=new Account($db);
|
||||
$acct->fetch($_POST["accountid"]);
|
||||
$insertid=$acct->addline($dateop, $_POST["paymenttypeid"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE,$user);
|
||||
if ($insertid < 0)
|
||||
{
|
||||
dol_print_error($db,$acct->error);
|
||||
}
|
||||
else
|
||||
{
|
||||
$inserturlid=$acct->add_url_line($insertid, $adherent->rowid, DOL_URL_ROOT.'/adherents/fiche.php?rowid=', $adherent->getFullname($langs), 'member');
|
||||
|
||||
// Met a jour la table cotisation
|
||||
$sql="UPDATE ".MAIN_DB_PREFIX."cotisation";
|
||||
$sql.=" SET fk_bank=".$insertid.",";
|
||||
$sql.=" note='".addslashes($_POST["label"])."'";
|
||||
$sql.=" WHERE rowid=".$_POST["rowid"];
|
||||
dol_syslog("cotisations sql=".$sql);
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
//Header("Location: cotisations.php");
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dol_print_error($db,$cotisation->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
* Actions
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -155,7 +77,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
|
|||
$sql.= " WHERE d.rowid = c.fk_adherent";
|
||||
if (isset($date_select) && $date_select != '')
|
||||
{
|
||||
$sql.= " AND dateadh LIKE '$date_select%'";
|
||||
$sql.= " AND dateadh LIKE '$date_select%'";
|
||||
}
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
$sql.= $db->plimit($conf->liste_limit+1, $offset);
|
||||
|
|
@ -169,7 +91,7 @@ if ($result)
|
|||
$title=$langs->trans("ListOfSubscriptions");
|
||||
if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')';
|
||||
$param.="&statut=$statut&date_select=$date_select";
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num);
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num);
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
|
@ -179,21 +101,21 @@ if ($result)
|
|||
print_liste_field_titre($langs->trans("Name"),"cotisations.php","d.nom",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Login"),"cotisations.php","d.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"),"cotisations.php","c.note",$param,"",'align="left"',$sortfield,$sortorder);
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
print_liste_field_titre($langs->trans("Bank"),"cotisations.php","b.fk_account",$pram,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Account"),"cotisations.php","b.fk_account",$pram,"","",$sortfield,$sortorder);
|
||||
}
|
||||
print_liste_field_titre($langs->trans("Date"),"cotisations.php","c.dateadh",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateEnd"),"cotisations.php","c.datef",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation",$param,"",'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
// Static objects
|
||||
// Static objects
|
||||
$cotisation=new Cotisation($db);
|
||||
$adherent=new Adherent($db);
|
||||
$accountstatic=new Account($db);
|
||||
|
||||
$var=true;
|
||||
$var=true;
|
||||
$total=0;
|
||||
while ($i < $num && $i < $conf->liste_limit)
|
||||
{
|
||||
|
|
@ -209,39 +131,29 @@ if ($result)
|
|||
|
||||
$var=!$var;
|
||||
|
||||
if ($allowinsertbankafter && ! $objp->fk_account && $conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && $objp->cotisation)
|
||||
{
|
||||
print "<form method=\"post\" action=\"cotisations.php\">";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
}
|
||||
if ($allowinsertbankafter && ! $objp->fk_account && $conf->banque->enabled && $objp->cotisation)
|
||||
{
|
||||
print "<form method=\"post\" action=\"cotisations.php\">";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
}
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Ref
|
||||
print '<td>'.$cotisation->getNomUrl(1).'</td>';
|
||||
// Ref
|
||||
print '<td>'.$cotisation->getNomUrl(1).'</td>';
|
||||
|
||||
// Nom
|
||||
print '<td>'.$adherent->getNomUrl(1).'</td>';
|
||||
// Nom
|
||||
print '<td>'.$adherent->getNomUrl(1).'</td>';
|
||||
|
||||
// Login
|
||||
print '<td>'.$adherent->login.'</td>';
|
||||
// Login
|
||||
print '<td>'.$adherent->login.'</td>';
|
||||
|
||||
// Libelle
|
||||
print '<td>';
|
||||
if ($allowinsertbankafter && $user->rights->banque->modifier && ! $objp->fk_account && $conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && $objp->cotisation)
|
||||
{
|
||||
print "<input name=\"label\" type=\"text\" class=\"flat\" size=\"30\" value=\"".$langs->trans("Subscriptions").' '.dol_print_date($db->jdate($objp->dateadh),"%Y")."\" >\n";
|
||||
// print "<td><input name=\"debit\" type=\"text\" size=8></td>";
|
||||
// print "<td><input name=\"credit\" type=\"text\" size=8></td>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print dol_trunc($objp->note,32);
|
||||
}
|
||||
print '</td>';
|
||||
// Libelle
|
||||
print '<td>';
|
||||
print dol_trunc($objp->note,32);
|
||||
print '</td>';
|
||||
|
||||
// Banque
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
// Banque
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
if ($objp->fk_account)
|
||||
{
|
||||
|
|
@ -252,40 +164,40 @@ if ($result)
|
|||
}
|
||||
else
|
||||
{
|
||||
print "<td>";
|
||||
print "<td>";
|
||||
if ($allowinsertbankafter && $objp->cotisation)
|
||||
{
|
||||
print '<input type="hidden" name="action" value="2bank">';
|
||||
print '<input type="hidden" name="rowid" value="'.$objp->crowid.'">';
|
||||
$html = new Form($db);
|
||||
$html->select_comptes('','accountid',0,'',1);
|
||||
print '<br>';
|
||||
$html->select_types_paiements('','paymenttypeid');
|
||||
print '<input name="num_chq" type="text" class="flat" size="5">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print "</td>\n";
|
||||
{
|
||||
print '<input type="hidden" name="action" value="2bank">';
|
||||
print '<input type="hidden" name="rowid" value="'.$objp->crowid.'">';
|
||||
$html = new Form($db);
|
||||
$html->select_comptes('','accountid',0,'',1);
|
||||
print '<br>';
|
||||
$html->select_types_paiements('','paymenttypeid');
|
||||
print '<input name="num_chq" type="text" class="flat" size="5">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Date start
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n";
|
||||
// Date start
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n";
|
||||
|
||||
// Date end
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
|
||||
// Date end
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
|
||||
|
||||
// Price
|
||||
print '<td align="right">'.price($objp->cotisation).'</td>';
|
||||
// Price
|
||||
print '<td align="right">'.price($objp->cotisation).'</td>';
|
||||
|
||||
print "</tr>";
|
||||
if ($allowinsertbankafter && ! $objp->fk_account && $conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && $objp->cotisation)
|
||||
{
|
||||
print "</form>\n";
|
||||
}
|
||||
$i++;
|
||||
if ($allowinsertbankafter && ! $objp->fk_account && $conf->banque->enabled && $objp->cotisation)
|
||||
{
|
||||
print "</form>\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Total
|
||||
|
|
@ -295,9 +207,9 @@ if ($result)
|
|||
print "<td align=\"right\"> </td>\n";
|
||||
print "<td align=\"right\"> </td>\n";
|
||||
print "<td align=\"right\"> </td>\n";
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
|
|
@ -311,7 +223,7 @@ if ($result)
|
|||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -466,39 +466,6 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer)
|
|||
$result=$adh->create($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($cotisation > 0)
|
||||
{
|
||||
$crowid=$adh->cotisation($datecotisation, $cotisation);
|
||||
|
||||
// insertion dans la gestion banquaire si configure pour
|
||||
if ($global->conf->ADHERENT_BANK_USE)
|
||||
{
|
||||
$dateop=time();
|
||||
$amount=$cotisation;
|
||||
$acct=new Account($db,$_POST["accountid"]);
|
||||
$insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"], '', $user);
|
||||
if ($insertid == '')
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
else
|
||||
{
|
||||
// met a jour la table cotisation
|
||||
$sql ="UPDATE ".MAIN_DB_PREFIX."cotisation";
|
||||
$sql.=" SET fk_bank=$insertid WHERE rowid=$crowid ";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
//Header("Location: fiche.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
$rowid=$adh->id;
|
||||
$action='';
|
||||
|
|
@ -1101,7 +1068,7 @@ if ($rowid && $action != 'edit')
|
|||
$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);
|
||||
$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 '<br>';
|
||||
}
|
||||
|
||||
|
|
@ -1132,7 +1099,7 @@ if ($rowid && $action != 'edit')
|
|||
// Cree un tableau formulaire
|
||||
$formquestion=array();
|
||||
if ($adh->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
|
||||
$ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion);
|
||||
$ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
|
|
@ -1487,21 +1454,6 @@ if ($rowid && $action != 'edit')
|
|||
print '</div>';
|
||||
print "<br>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Bandeau des cotisations
|
||||
*/
|
||||
|
||||
print '<table border=0 width="100%">';
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top" width="50%">';
|
||||
|
||||
print '</td><td valign="top">';
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1569,7 +1569,7 @@ class Form
|
|||
|
||||
$this->load_cache_types_paiements();
|
||||
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print '<select id="selectpaymenttypes" class="flat" name="'.$htmlname.'">';
|
||||
if ($empty) print '<option value=""> </option>';
|
||||
foreach($this->cache_types_paiements as $id => $arraytypes)
|
||||
{
|
||||
|
|
@ -1710,7 +1710,7 @@ class Form
|
|||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print '<select id="selectbankaccount" class="flat" name="'.$htmlname.'">';
|
||||
if ($useempty)
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'"> </option>';
|
||||
|
|
|
|||
|
|
@ -880,7 +880,7 @@ InterventionsSetup=Interventions module setup
|
|||
##### Members #####
|
||||
MembersSetup=Members module setup
|
||||
MemberMainOptions=Main options
|
||||
AddSubscriptionIntoAccount=Add subscriptions into bank or cash account, of bank module
|
||||
AddSubscriptionIntoAccount=Suggest by default to create a bank transaction, in bank module, when adding a new payed subscription
|
||||
AdherentMailRequired=EMail required to create a new member
|
||||
MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default
|
||||
##### LDAP setup #####
|
||||
|
|
|
|||
|
|
@ -150,3 +150,7 @@ HTPasswordExport=htpassword file generation
|
|||
NoThirdPartyAssociatedToMember=No third party associated to this member
|
||||
ThirdPartyDolibarr=Dolibarr third party
|
||||
MembersAndSubscriptions= Members and Suscriptions
|
||||
MoreActions=Complementary action on recording
|
||||
MoreActionBankDirect=Create a direct transaction record on account
|
||||
MoreActionBankViaInvoice=Create an invoice and payment on account
|
||||
MoreActionInvoiceOnly=Create an invoice with no payment
|
||||
|
|
|
|||
|
|
@ -892,7 +892,7 @@ FreeLegalTextOnInterventions= Mention complémentaire sur les fiches d'intervent
|
|||
##### Members #####= undefined
|
||||
MembersSetup= Configuration du module Adhérents
|
||||
MemberMainOptions= Options principales
|
||||
AddSubscriptionIntoAccount= Enregistrer cotisations dans compte bancaire ou caisse, du module banque
|
||||
AddSubscriptionIntoAccount= Proposer par défaut la création d'une écriture bancaire, dans le module banque, à l'enregistrement d'une adhésion payante
|
||||
AdherentMailRequired= EMail obligatoire pour créer un nouvel adhérent
|
||||
MemberSendInformationByMailByDefault= Case à cocher pour envoyer un mail de confirmation (validation ou nouvelle cotisation) aux adhérents. Est à oui par défaut.
|
||||
##### LDAP setup #####= undefined
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ DescADHERENT_MAIL_COTIS_SUBJECT=Sujet du mail de validation cotisation
|
|||
DescADHERENT_MAIL_COTIS=Mail de validation d'une adhésion
|
||||
DescADHERENT_MAIL_RESIL_SUBJECT=Sujet du mail de résiliation
|
||||
DescADHERENT_MAIL_RESIL=Mail de résiliation
|
||||
DescADHERENT_MAIL_FROM=Mail émetteur pour les mails automatics
|
||||
DescADHERENT_MAIL_FROM=Mail émetteur pour les mails automatiques
|
||||
DescADHERENT_ETIQUETTE_TYPE=Format pages étiquettes
|
||||
DescADHERENT_CARD_TYPE=Format pages cartes d'adhérent
|
||||
DescADHERENT_CARD_HEADER_TEXT=Texte imprimé sur le haut des cartes d'adhérent
|
||||
|
|
@ -149,4 +149,8 @@ ShowTypeCard=Voir type '%s'
|
|||
HTPasswordExport=Génération fichier htpassword
|
||||
NoThirdPartyAssociatedToMember=Pas de tiers associé à cet adhérent
|
||||
ThirdPartyDolibarr=Tiers Dolibarr
|
||||
MembersAndSubscriptions= Adhérents et Adhésions
|
||||
MembersAndSubscriptions= Adhérents et Adhésions
|
||||
MoreActions=Action complémentaire à l'enregistrement
|
||||
MoreActionBankDirect=Création transaction sur compte directement
|
||||
MoreActionBankViaInvoice=Création facture avec paiement sur compte
|
||||
MoreActionInvoiceOnly=Création facture sans paiement
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user