From 264df5d3a67c42f3549b4b8fa4e87d3d53d44e5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2010 18:56:13 +0000 Subject: [PATCH] Error management --- htdocs/adherents/card_subscriptions.php | 771 ++++++++++++------------ 1 file changed, 389 insertions(+), 382 deletions(-) diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 31a1cdf0603..fc8b9e78437 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -47,9 +47,9 @@ $errmsg=''; $defaultdelay=1; $defaultdelayunit='y'; -$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; -$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; -$typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"]; +$action=GETPOST('action'); +$rowid=GETPOST('rowid'); +$typeid=GETPOST('typeid'); if (! $user->rights->adherent->cotisation->lire) accessforbidden(); @@ -233,406 +233,413 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio * View */ -llxHeader('',$langs->trans("Subscriptions"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); - $html = new Form($db); -$adh->id = $rowid; -$result=$adh->fetch($rowid); -$result=$adh->fetch_optionals($rowid); +llxHeader('',$langs->trans("Subscriptions"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); -$adht->fetch($adh->typeid); - -// fetch optionals attributes and labels -$adho->fetch_optionals(); - - -$head = member_prepare_head($adh); - -dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user'); - -print '
'; -print ''; -print ''; - -// Ref -print ''; -print ''; - -// Nom -print ''; -print ''; - -// Prenom -print ''; -print ''; - -// Login -print ''; - -// Type -print '\n"; - -// Status -print ''; - - -print "
'.$langs->trans("Ref").''; -print $html->showrefnav($adh,'rowid'); -print '
'.$langs->trans("Lastname").''.$adh->nom.' 
'.$langs->trans("Firstname").''.$adh->prenom.' 
'.$langs->trans("Login").''.$adh->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Status").''.$adh->getLibStatut(4).'
\n"; -print '
'; - -dol_fiche_end(); - - -if ($errmsg) +if ($rowid) { - if (preg_match('/^Error/i',$errmsg)) - { - $langs->load("errors"); - $errmsg=$langs->trans($errmsg); - } - print '
'.$errmsg.'
'."\n"; -} + $adh->id = $rowid; + $result=$adh->fetch($rowid); + $result=$adh->fetch_optionals($rowid); + + $adht->fetch($adh->typeid); + + // fetch optionals attributes and labels + $adho->fetch_optionals(); -/* - * Barre d'actions - */ + $head = member_prepare_head($adh); -print '
'; + dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user'); -// Lien nouvelle cotisation si non brouillon et non resilie -if ($user->rights->adherent->cotisation->creer) -{ - if ($action != 'addsubscription') - { - if ($adh->statut > 0) print "".$langs->trans("AddSubscription").""; - else print ''.$langs->trans("AddSubscription").''; + print '
'; + print ''; + print ''; - print "
\n"; - } -} -print ''; + // Ref + print ''; + print ''; + + // Nom + print ''; + print ''; + + // Prenom + print ''; + print ''; + + // Login + print ''; + + // Type + print '\n"; + + // Status + print ''; + print "
'.$langs->trans("Ref").''; + print $html->showrefnav($adh,'rowid'); + print '
'.$langs->trans("Lastname").''.$adh->nom.' 
'.$langs->trans("Firstname").''.$adh->prenom.' 
'.$langs->trans("Login").''.$adh->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Status").''.$adh->getLibStatut(4).'
\n"; + print '
'; -// Date fin cotisation -print "\n"; -print ''; -print ''; + //print '
'.$langs->trans("SubscriptionEndDate"); -print ''; -if ($adh->datefin) -{ - if ($adh->datefin < time()) + dol_fiche_end(); + + + if ($errmsg) { - print dol_print_date($adh->datefin,'day'); + if (preg_match('/^Error/i',$errmsg)) + { + $langs->load("errors"); + $errmsg=$langs->trans($errmsg); + } + print '
'.$errmsg.'
'."\n"; + } + + + /* + * Barre d'actions + */ + + print '
'; + + // Lien nouvelle cotisation si non brouillon et non resilie + if ($user->rights->adherent->cotisation->creer) + { + if ($action != 'addsubscription') + { + if ($adh->statut > 0) print "".$langs->trans("AddSubscription").""; + else print ''.$langs->trans("AddSubscription").''; + + print "
\n"; + } + } + print '
'; + + + + // Date fin cotisation + print "\n"; + print ''; + print ''; -print ''; -print '
'.$langs->trans("SubscriptionEndDate"); + print ''; + 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'); + } + } + 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 } - 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 '
'; -print '
'; - - -/* - * 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 "\n"; - - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->banque->enabled) - { - print ''; - } - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - $cotisationstatic->ref=$objp->crowid; - $cotisationstatic->id=$objp->crowid; - print ''; - print '\n"; - print '\n"; - print ''; - if ($conf->banque->enabled) - { - print ''; - } - print ""; - $i++; - } - print "
'.$langs->trans("Ref").''.$langs->trans("DateSubscription").''.$langs->trans("DateEnd").''.$langs->trans("Amount").''.$langs->trans("Account").'
'.$cotisationstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->dateadh),'day')."'.dol_print_date($db->jdate($objp->datef),'day')."'.price($objp->cotisation).''; - if ($objp->bid) - { - $accountstatic->label=$objp->label; - $accountstatic->id=$objp->baid; - print $accountstatic->getNomUrl(1); - } - else - { - print ' '; - } - print '
"; - } - else - { - dol_print_error($db); - } -} - - - -/* - * Add new subscription form - */ -if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer) -{ - print '
'; - - 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\n"; - - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; - } - - print '
'; - print ''; - print ''; - print ''; - print "\n"; - - $today=mktime(); - $datefrom=0; - $dateto=0; - - // Date start subscription - print '"; - - // Date end subscription - if ($_POST["endday"]) - { - $dateto=dol_mktime(0,0,0,$_POST["endmonth"],$_POST["endday"],$_POST["endyear"]); - } - if (! $dateto) - { - //$dateto=dol_time_plus_duree(dol_time_plus_duree($datefrom,$defaultdelay,$defaultdelayunit),-1,'d'); - $dateto=-1; // By default, no date is suggested - } - print '"; - - if ($adht->cotisation) - { - // Amount - print ''; - - // Label - print ''; - print ''; - - // Bank account transaction - if ($conf->banque->enabled || $conf->facture->enabled) - { - $company=new Societe($db); - if ($adh->fk_soc) - { - $result=$company->fetch($adh->fk_soc); - } - - // Title payments - //print ''; - - // Define a way to write payment - print ''; - print ''; - - // Bank account - print '\n"; - - // Payment mode - print '\n"; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - } - } - - print ''; - - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("DateSubscription").''; - if ($_POST["reday"]) - { - $datefrom=dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); - } - if (! $datefrom) - { - if ($adh->datefin > 0) - { - $datefrom=dol_time_plus_duree($adh->datefin,1,'d'); - } - else - { - $datefrom=mktime(); - } - } - $html->select_date($datefrom,'','','','',"cotisation"); - print "
'.$langs->trans("DateEndSubscription").''; - $html->select_date($dateto,'end','','','',"cotisation"); - print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("Label").'
'.$langs->trans("Payment").'
'.$langs->trans('MoreActions'); - print ''; - print ' '.$langs->trans("None").'
'; - if ($conf->banque->enabled) - { - print ' '.$langs->trans("MoreActionBankDirect").'
'; - } - if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled) - { - print '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 '
'; - } - if ($conf->societe->enabled && $conf->facture->enabled) - { - print '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 '
'; - } - print '
'.$langs->trans("FinancialAccount").''; - $html->select_comptes($_POST["accountid"],'accountid',0,'',1); - print "
'.$langs->trans("PaymentMode").''; - $html->select_types_paiements($_POST["operation"],'operation'); - print "
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
'.$langs->trans('CheckTransmitter'); - print ' ('.$langs->trans("ChequeMaker").')'; - print '
'.$langs->trans('Bank'); - print ' ('.$langs->trans("ChequeBank").')'; - print '
 
'.$langs->trans("SendAcknowledgementByMail").''; - if (! $adh->email) - { - print $langs->trans("NoEMail"); - } - else - { - $adht = new AdherentType($db); - $adht->fetch($adh->typeid); - - $subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); - $texttosend=$adh->makeSubstitution($adht->getMailOnSubscription()); - - $tmp='global->ADHERENT_DEFAULT_SENDINFOBYMAIL?' checked="true"':'').'>'; - $helpcontent=''; - $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; - $helpcontent.=''.$langs->trans("MailRecipient").': '.$adh->email.'
'."\n"; - $helpcontent.=''.$langs->trans("Subject").':
'."\n"; - $helpcontent.=$subjecttosend."\n"; - $helpcontent.="
"; - $helpcontent.=''.$langs->trans("Content").':
'; - $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; - - print $html->textwithpicto($tmp,$helpcontent,1,'help'); - } - print '
'; print '
'; - print '
'; - print ''; - print '     '; - print ''; - print '
'; - print '
'; + /* + * 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; - print "\n\n\n"; + $result = $db->query($sql); + if ($result) + { + $cotisationstatic=new Cotisation($db); + $accountstatic=new Account($db); + + $num = $db->num_rows($result); + $i = 0; + + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->banque->enabled) + { + print ''; + } + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + $cotisationstatic->ref=$objp->crowid; + $cotisationstatic->id=$objp->crowid; + print ''; + print '\n"; + print '\n"; + print ''; + if ($conf->banque->enabled) + { + print ''; + } + print ""; + $i++; + } + print "
'.$langs->trans("Ref").''.$langs->trans("DateSubscription").''.$langs->trans("DateEnd").''.$langs->trans("Amount").''.$langs->trans("Account").'
'.$cotisationstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->dateadh),'day')."'.dol_print_date($db->jdate($objp->datef),'day')."'.price($objp->cotisation).''; + if ($objp->bid) + { + $accountstatic->label=$objp->label; + $accountstatic->id=$objp->baid; + print $accountstatic->getNomUrl(1); + } + else + { + print ' '; + } + print '
"; + } + else + { + dol_print_error($db); + } + } + + + + /* + * Add new subscription form + */ + if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer) + { + print '
'; + + 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\n"; + + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + + print '
'; + print ''; + print ''; + print ''; + print "\n"; + + $today=mktime(); + $datefrom=0; + $dateto=0; + + // Date start subscription + print '"; + + // Date end subscription + if ($_POST["endday"]) + { + $dateto=dol_mktime(0,0,0,$_POST["endmonth"],$_POST["endday"],$_POST["endyear"]); + } + if (! $dateto) + { + //$dateto=dol_time_plus_duree(dol_time_plus_duree($datefrom,$defaultdelay,$defaultdelayunit),-1,'d'); + $dateto=-1; // By default, no date is suggested + } + print '"; + + if ($adht->cotisation) + { + // Amount + print ''; + + // Label + print ''; + print ''; + + // Bank account transaction + if ($conf->banque->enabled || $conf->facture->enabled) + { + $company=new Societe($db); + if ($adh->fk_soc) + { + $result=$company->fetch($adh->fk_soc); + } + + // Title payments + //print ''; + + // Define a way to write payment + print ''; + print ''; + + // Bank account + print '\n"; + + // Payment mode + print '\n"; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + } + } + + print ''; + + print ''; + print ''; + print '
'.$langs->trans("DateSubscription").''; + if ($_POST["reday"]) + { + $datefrom=dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); + } + if (! $datefrom) + { + if ($adh->datefin > 0) + { + $datefrom=dol_time_plus_duree($adh->datefin,1,'d'); + } + else + { + $datefrom=mktime(); + } + } + $html->select_date($datefrom,'','','','',"cotisation"); + print "
'.$langs->trans("DateEndSubscription").''; + $html->select_date($dateto,'end','','','',"cotisation"); + print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("Label").'
'.$langs->trans("Payment").'
'.$langs->trans('MoreActions'); + print ''; + print ' '.$langs->trans("None").'
'; + if ($conf->banque->enabled) + { + print ' '.$langs->trans("MoreActionBankDirect").'
'; + } + if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled) + { + print '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 '
'; + } + if ($conf->societe->enabled && $conf->facture->enabled) + { + print '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 '
'; + } + print '
'.$langs->trans("FinancialAccount").''; + $html->select_comptes($_POST["accountid"],'accountid',0,'',1); + print "
'.$langs->trans("PaymentMode").''; + $html->select_types_paiements($_POST["operation"],'operation'); + print "
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans('CheckTransmitter'); + print ' ('.$langs->trans("ChequeMaker").')'; + print '
'.$langs->trans('Bank'); + print ' ('.$langs->trans("ChequeBank").')'; + print '
 
'.$langs->trans("SendAcknowledgementByMail").''; + if (! $adh->email) + { + print $langs->trans("NoEMail"); + } + else + { + $adht = new AdherentType($db); + $adht->fetch($adh->typeid); + + $subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); + $texttosend=$adh->makeSubstitution($adht->getMailOnSubscription()); + + $tmp='global->ADHERENT_DEFAULT_SENDINFOBYMAIL?' checked="true"':'').'>'; + $helpcontent=''; + $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent.=''.$langs->trans("MailRecipient").': '.$adh->email.'
'."\n"; + $helpcontent.=''.$langs->trans("Subject").':
'."\n"; + $helpcontent.=$subjecttosend."\n"; + $helpcontent.="
"; + $helpcontent.=''.$langs->trans("Content").':
'; + $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; + + print $html->textwithpicto($tmp,$helpcontent,1,'help'); + } + print '
'; + print '
'; + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print '
'; + + print "\n\n\n"; + } + + //print '
'; +} +else +{ + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); } - -//print ''; -//print ''; - $db->close();