* Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro * * 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 * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/adherents/subscription.php * \ingroup member * \brief Onglet d'ajout, edition, suppression des adhesions d'un adherent */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->load("companies"); $langs->load("bills"); $langs->load("members"); $langs->load("users"); $langs->load("mails"); $langs->load('other'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $rowid=GETPOST('rowid','int'); $typeid=GETPOST('typeid','int'); // Security check $result=restrictedArea($user,'adherent',$rowid,'','cotisation'); $object = new Adherent($db); $extrafields = new ExtraFields($db); $adht = new AdherentType($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $errmsg=''; $errmsgs=array(); $defaultdelay=1; $defaultdelayunit='y'; if ($rowid) { // Load member $result = $object->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 ($object->user_id) { // $user est le user qui edite, $object->user_id est l'id de l'utilisateur lies au membre edite $caneditfielduser=( (($user->id == $object->user_id) && $user->rights->user->self->creer) || (($user->id != $object->user_id) && $user->rights->user->user->creer) ); $caneditpassworduser=( (($user->id == $object->user_id) && $user->rights->user->self->password) || (($user->id != $object->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; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('subscription')); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); /* * Actions */ // Create third party from a member if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { if ($result > 0) { // Creation user $company = new Societe($db); $result=$company->create_from_member($object,$_POST["companyname"]); if ($result < 0) { $langs->load("errors"); setEventMessages($company->error, $company->errors, 'errors'); } else { $action='addsubscription'; } } else { setEventMessages($object->error, $object->errors, 'errors'); } } 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 { if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) { $error++; setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); } } if (! $error) { if ($_POST["userid"] != $object->user_id) // If link differs from currently in database { $result=$object->setUserId($_POST["userid"]); if ($result < 0) dol_print_error('',$object->error); $_POST['action']=''; $action=''; } } } if ($action == 'setsocid') { $error=0; if (! $error) { if (GETPOST('socid','int') != $object->fk_soc) // If link differs from currently in database { $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; $sql.=" WHERE fk_soc = '".GETPOST('socid','int')."'"; $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','int')); $error++; setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), null, 'errors'); } } if (! $error) { $result=$object->setThirdPartyId(GETPOST('socid','int')); if ($result < 0) dol_print_error('',$object->error); $_POST['action']=''; $action=''; } } } } if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $_POST["cancel"]) { $error=0; $langs->load("banks"); $result=$object->fetch($rowid); $result=$adht->fetch($object->typeid); // Subscription informations $datesubscription=0; $datesubend=0; $paymentdate=0; if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"]) { $datesubscription=dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"]) { $datesubend=dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); } if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"]) { $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); } $subscription=price2num(GETPOST("subscription",'alpha')); // Amount of subscription $label=$_POST["label"]; // Payment informations $accountid=$_POST["accountid"]; $operation=$_POST["operation"]; // Payment mode $num_chq=$_POST["num_chq"]; $emetteur_nom=$_POST["chqemetteur"]; $emetteur_banque=$_POST["chqbank"]; $option=$_POST["paymentsave"]; if (empty($option)) $option='none'; // Check parameters if (! $datesubscription) { $error++; $langs->load("errors"); $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateSubscription")); setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } if (GETPOST('end') && ! $datesubend) { $error++; $langs->load("errors"); $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateEndSubscription")); setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } if (! $datesubend) { $datesubend=dol_time_plus_duree(dol_time_plus_duree($datesubscription,$defaultdelay,$defaultdelayunit),-1,'d'); } if (($option == 'bankviainvoice' || $option == 'bankdirect') && ! $paymentdate) { $error++; $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } $amount = price2num(GETPOST("subscription",'alpha')); // Check if a payment is mandatory or not if (! $error && $adht->subscription) // Member type need subscriptions { if (! is_numeric($amount)) { // If field is '' or not a numeric value $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")); setEventMessages($errmsg, null, 'errors'); $error++; $action='addsubscription'; } else { if (! empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { if ($_POST["subscription"]) { if (! $_POST["label"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["operation"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["accountid"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("FinancialAccount")); } else { if ($_POST["accountid"]) $errmsg=$langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); } if ($errmsg) { setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } } } } if (! $error && $action=='subscription') { $db->begin(); // Create subscription $crowid=$object->subscription($datesubscription, $subscription, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); if ($crowid <= 0) { $error++; $errmsg=$object->error; setEventMessages($object->error,$object->errors, 'errors'); } if (! $error) { // Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect' if ($option == 'bankdirect' && $accountid) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acct=new Account($db); $result=$acct->fetch($accountid); $dateop=$paymentdate; $insertid=$acct->addline($dateop, $operation, $label, $subscription, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); if ($insertid > 0) { $inserturlid=$acct->add_url_line($insertid, $object->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $object->getFullname($langs), 'member'); if ($inserturlid > 0) { // Update table subscription $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; $sql.=" WHERE rowid=".$crowid; dol_syslog("subscription::subscription", LOG_DEBUG); $resql = $db->query($sql); if (! $resql) { $error++; $errmsg=$db->lasterror(); setEventMessages($errmsg, null, 'errors'); } } else { $error++; $errmsg=$acct->error; $errmsgs=$acct->errors; setEventMessages($errmsg, $errmsgs, 'errors'); } } else { $error++; $errmsg=$acct->error; $errmsgs=$acct->errors; setEventMessages($errmsg, $errmsgs, 'errors'); } } // If option choosed, we create invoice if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; $invoice=new Facture($db); $customer=new Societe($db); if (! $error) { if (! ($object->fk_soc > 0)) { $langs->load("errors"); $errmsg=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); setEventMessages($errmsg, null, 'errors'); $error++; } } if (! $error) { $result=$customer->fetch($object->fk_soc); if ($result <= 0) { $errmsg=$customer->error; $errmsgs=$acct->errors; setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } if (! $error) { // Create draft invoice $invoice->type= Facture::TYPE_STANDARD; $invoice->cond_reglement_id=$customer->cond_reglement_id; if (empty($invoice->cond_reglement_id)) { $paymenttermstatic=new PaymentTerm($db); $invoice->cond_reglement_id=$paymenttermstatic->getDefaultId(); if (empty($invoice->cond_reglement_id)) { $error++; $errmsg='ErrorNoPaymentTermRECEPFound'; setEventMessages($errmsg, null, 'errors'); } } $invoice->socid=$object->fk_soc; $invoice->date=$datesubscription; // Possibility to add external linked objects with hooks $invoice->linked_objects['subscription'] = $crowid; if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) { $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); } $result=$invoice->create($user); if ($result <= 0) { $errmsg=$invoice->error; $errmsgs=$invoice->errors; setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } if (! $error) { // Add line to draft invoice $idprodsubscription=0; if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS; $vattouse=0; if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') { $vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription); } //print xx".$vattouse." - ".$mysoc." - ".$customer;exit; $result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datesubscription,$datesubend,0,0,'','TTC',$subscription,1); if ($result <= 0) { $errmsg=$invoice->error; setEventMessages($errmsg, null, 'errors'); $error++; } } if (! $error) { // Validate invoice $result=$invoice->validate($user); if ($result <= 0) { $errmsg=$invoice->error; $errmsgs=$invoice->errors; setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } // Add payment onto invoice if ($option == 'bankviainvoice' && $accountid) { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; $amounts[$invoice->id] = price2num($subscription); $paiement = new Paiement($db); $paiement->datepaye = $paymentdate; $paiement->amounts = $amounts; $paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement'); $paiement->num_paiement = $num_chq; $paiement->note = $label; if (! $error) { // Create payment line for invoice $paiement_id = $paiement->create($user); if (! $paiement_id > 0) { $errmsg=$paiement->error; $errmsgs=$paiement->errors; setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } if (! $error) { // Add transaction into bank account $bank_line_id=$paiement->addPaymentToBank($user,'payment','(SubscriptionPayment)',$accountid,$emetteur_nom,$emetteur_banque); if (! ($bank_line_id > 0)) { $errmsg=$paiement->error; $errmsgs=$paiement->errors; setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; } } if (! $error) { // Update fk_bank into subscription table $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id; $sql.= ' WHERE rowid='.$crowid; $result = $db->query($sql); if (! $result) { $error++; } } if (! $error) { // Set invoice as paid $invoice->set_paid($user); } if (! $error) { // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $customer->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) $invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } } if (! $error) { $db->commit(); } else { $db->rollback(); $action = 'addsubscription'; } // Send email if (! $error) { // Send confirmation Email if ($object->email && $_POST["sendmail"]) { $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); $texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); $result=$object->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1); if ($result < 0) { $errmsg=$object->error; setEventMessages($errmsg, null, 'errors'); } } $_POST["subscription"]=''; $_POST["accountid"]=''; $_POST["operation"]=''; $_POST["label"]=''; $_POST["num_chq"]=''; } } } /* * View */ $form = new Form($db); $now=dol_now(); $title=$langs->trans("Member") . " - " . $langs->trans("Subscriptions"); $helpurl="EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros"; llxHeader("",$title,$helpurl); if ($rowid > 0) { $res=$object->fetch($rowid); if ($res < 0) { dol_print_error($db,$object->error); exit; } $adht->fetch($object->typeid); $head = member_prepare_head($object); $rowspan=10; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; print '
'; print ''; print ''; dol_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'rowid', $linkback); print '
'; print '
'; print '
'; print ''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } // Type print '\n"; // Morphy print ''; print ''; // Company print ''; // Civility print ''; print ''; // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Nature").''.$object->getmorphylib().'
'.$langs->trans("Company").''.$object->societe.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("Password").''.preg_replace('/./i','*',$object->pass); if ((! empty($object->pass) || ! empty($object->pass_crypted)) && empty($object->user_id)) { $langs->load("errors"); $htmltext=$langs->trans("WarningPasswordSetWithNoAccount"); print ' '.$form->textwithpicto('', $htmltext,1,'warning'); } print '
'; print '
'; print '
'; print '
'; print ''; // Birthday print ''; // Public print ''; // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { print ''; print ''; } // Other attributes $cols=2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Date end subscription print ''; // Third party Dolibarr if (! empty($conf->societe->enabled)) { print ''; } // Login Dolibarr print ''; print "
'.$langs->trans("Birthday").''.dol_print_date($object->birth,'day').'
'.$langs->trans("Public").''.yn($object->public).'
' . $langs->trans("Categories") . ''; print $form->showCategories($object->id, 'member', 1); print '
'.$langs->trans("SubscriptionEndDate").''; if ($object->datefin) { print dol_print_date($object->datefin,'day'); if ($object->hasDelay()) { print " ".img_warning($langs->trans("Late")); } } else { if (! $adht->subscription) { print $langs->trans("SubscriptionNotRecorded"); if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie } else { print $langs->trans("SubscriptionNotReceived"); if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie } } print '
'; print ''; if ($action != 'editthirdparty' && $user->rights->adherent->creer) print ''; print '
'; print $langs->trans("LinkedToDolibarrThirdParty"); print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'
'; print '
'; if ($action == 'editthirdparty') { $htmlname='socid'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'; print $form->select_company($object->fk_soc,'socid','',1); print '
'; } else { if ($object->fk_soc) { $company=new Societe($db); $result=$company->fetch($object->fk_soc); print $company->getNomUrl(1); } else { print $langs->trans("NoThirdPartyAssociatedToMember"); } } print '
'; print ''; if ($action != 'editlogin' && $user->rights->adherent->creer) { print ''; } print '
'; print $langs->trans("LinkedToDolibarrUser"); print ''; if ($user->rights->user->user->creer) { print 'id.'">'.img_edit($langs->trans('SetLinkToUser'),1).''; } print '
'; print '
'; if ($action == 'editlogin') { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid',''); } else { if ($object->user_id) { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none'); } else print $langs->trans("NoDolibarrAccess"); } print '
\n"; print "
\n"; print '
'; dol_fiche_end(); print ''; /* * Hotbar */ // Button to create a new subscription if member no draft neither resiliated if ($user->rights->adherent->cotisation->creer) { if ($action != 'addsubscription' && $action != 'create_thirdparty') { print '
'; if ($object->statut > 0) print '"; else print ''; print "
\n"; print '
'; print '
'; } } /* * List of subscriptions */ if ($action != 'addsubscription' && $action != 'create_thirdparty') { $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,"; $sql.= " c.rowid as crowid, c.subscription,"; $sql.= " c.datec,"; $sql.= " c.dateadh as dateh,"; $sql.= " c.datef,"; $sql.= " c.fk_bank,"; $sql.= " b.rowid as bid,"; $sql.= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription 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) { $subscriptionstatic=new Subscription($db); $num = $db->num_rows($result); $i = 0; print ''."\n"; print ''; print ''; print ''; print ''; print ''; print ''; if (! empty($conf->banque->enabled)) { print ''; } print "\n"; $accountstatic=new Account($db); while ($i < $num) { $objp = $db->fetch_object($result); print ''; $subscriptionstatic->ref=$objp->crowid; $subscriptionstatic->id=$objp->crowid; print ''; print '\n"; print '\n"; print '\n"; print ''; if (! empty($conf->banque->enabled)) { print ''; } print ""; $i++; } print "
'.$langs->trans("Ref").''.$langs->trans("DateCreation").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("Amount").''.$langs->trans("Account").'
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec),'dayhour')."'.dol_print_date($db->jdate($objp->dateh),'day')."'.dol_print_date($db->jdate($objp->datef),'day')."'.price($objp->subscription).''; if ($objp->bid) { $accountstatic->label=$objp->label; $accountstatic->id=$objp->baid; $accountstatic->number=$objp->number; $accountstatic->account_number=$objp->account_number; if (! empty($conf->accounting->enabled)) { $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objp->fk_accountancy_journal); $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); } $accountstatic->ref=$objp->ref; print $accountstatic->getNomUrl(1); } else { print ' '; } print '
"; } else { dol_print_error($db); } // Link for paypal payment if (! empty($conf->paypal->enabled)) { include_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; print showPaypalPaymentUrl('membersubscription',$object->ref); } // Link for stripe payment if (! empty($conf->stripe->enabled)) { include_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; print showStripePaymentUrl('membersubscription',$object->ref); } } /* * Add new subscription form */ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { print '
'; print load_fiche_titre($langs->trans("NewCotisation")); // Define default choice to select $bankdirect=0; // 1 means option by default is write to bank direct with no invoice $invoiceonly=0; // 1 means option by default is invoice only $bankviainvoice=0; // 1 means option by default is write to bank via invoice if (GETPOST('paymentsave')) { if (GETPOST('paymentsave') == 'bankdirect') $bankdirect=1; if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly=1; if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice=1; } else { if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $bankviainvoice=1; else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && ! empty($conf->banque->enabled)) $bankdirect=1; else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $invoiceonly=1; } print "\n\n\n"; if ($conf->use_javascript_ajax) { //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); print "\n".''."\n"; } // Confirm create third party if ($action == 'create_thirdparty') { $name = $object->getFullName($langs); if (! empty($name)) { if ($object->morphy == 'mor' && ! empty($object->societe)) $name=$object->societe.' ('.$name.')'; else if ($object->societe) $name.=' ('.$object->societe.')'; } else { $name=$object->societe; } // Create a form array $formquestion=array(array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); } print '
'; print ''; print ''; print ''; print ''; print ''; dol_fiche_head(''); print "\n"; print ''; $today=dol_now(); $datefrom=0; $dateto=0; $paymentdate=-1; // Date payment if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { $paymentdate=dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); } // Date start subscription print '"; // Date end subscription if (GETPOST('endday')) { $dateto=dol_mktime(0,0,0,GETPOST('endmonth'),GETPOST('endday'),GETPOST('endyear')); } if (! $dateto) { $dateto=-1; // By default, no date is suggested } print '"; if ($adht->subscription) { // Amount print ''; // Label print ''; print ''; // Complementary action if (! empty($conf->banque->enabled) || ! empty($conf->facture->enabled)) { $company=new Societe($db); if ($object->fk_soc) { $result=$company->fetch($object->fk_soc); } // Title payments //print ''; // No more action print ''; print ''; // Bank account print '\n"; // Payment mode print '\n"; // Date of payment print '\n"; print ''; print ''; print ''; print ''; print ''; print ''; } } print ''; print ''; print ''; print ''; print '
'.$langs->trans("DateSubscription").''; if (GETPOST('reday')) { $datefrom=dol_mktime(0,0,0,GETPOST('remonth'),GETPOST('reday'),GETPOST('reyear')); } if (! $datefrom) { if ($object->datefin > 0) { $datefrom=dol_time_plus_duree($object->datefin,1,'d'); } else { //$datefrom=dol_now(); $datefrom=$object->datevalid; } } print $form->select_date($datefrom,'','','','',"subscription",1,1,1); print "
'.$langs->trans("DateEndSubscription").''; print $form->select_date($dateto,'end','','','',"subscription",1,0,1); print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Label").'
'.$langs->trans("Payment").'
'.$langs->trans('MoreActions'); print ''; print ' '.$langs->trans("None").'
'; // Add entry into bank accoun if (! empty($conf->banque->enabled)) { print ' '.$langs->trans("MoreActionBankDirect").'
'; } // Add invoice with no payments if (! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) { print 'fk_soc)) print ' disabled'; print '> '.$langs->trans("MoreActionInvoiceOnly"); if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; else { print ' ('; if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); print $langs->trans("NoThirdPartyAssociatedToMember"); print ' - '; print $langs->trans("CreateDolibarrThirdParty"); print ')'; } if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0); if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) { $prodtmp=new Product($db); $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } print '
'; } // Add invoice with payments if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) { print 'fk_soc)) print ' disabled'; print '> '.$langs->trans("MoreActionBankViaInvoice"); if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; else { print ' ('; if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); print $langs->trans("NoThirdPartyAssociatedToMember"); print ' - '; print $langs->trans("CreateDolibarrThirdParty"); print ')'; } if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0); if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) { $prodtmp=new Product($db); $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } print '
'; } print '
'.$langs->trans("FinancialAccount").''; $form->select_comptes(GETPOST('accountid'),'accountid',0,'',1); print "
'.$langs->trans("PaymentMode").''; $form->select_types_paiements(GETPOST('operation'),'operation','',2); print "
'.$langs->trans("DatePayment").''; print $form->select_date(isset($paymentdate)?$paymentdate:-1,'payment',0,0,1,'subscription',1,1,1); 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 (! $object->email) { print $langs->trans("NoEMail"); } else { $adht = new AdherentType($db); $adht->fetch($object->typeid); $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); $texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); $tmp='global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>'; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent.=''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent.=''.$langs->trans("MailTopic").':
'."\n"; $helpcontent.=$subjecttosend."\n"; $helpcontent.="
"; $helpcontent.=''.$langs->trans("MailText").':
'; $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; print $form->textwithpicto($tmp,$helpcontent,1,'help'); } print '
'; dol_fiche_end(); print '
'; print ''; print '     '; print ''; print '
'; print '
'; print "\n\n\n"; } //print ''; //print ''; } else { $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); } llxFooter(); $db->close();