';
-print '| '.$langs->trans("ThisIsInformationOnPayment").' : |
'."\n";
-
-$found=false;
-$error=0;
-$var=false;
-
-
-
-// Free payment
-if (! GETPOST("source") && $valid)
-{
- $found=true;
- $tag=GETPOST("tag");
- $fulltag=$tag;
-
- // Creditor
-
- print '| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
- // Amount
-
- print '| '.$langs->trans("Amount");
- if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
- print ' | ';
- if (empty($amount) || ! is_numeric($amount))
- {
- print '';
- print '';
- }
- else {
- print ''.price($amount).'';
- print '';
- print '';
- }
-
- // Currency
- print ' '.$langs->trans("Currency".$currency).'';
- print '';
- print ' |
'."\n";
-
- // Tag
-
- print '| '.$langs->trans("PaymentCode");
- print ' | '.$fulltag.'';
- print '';
- print '';
- print ' |
'."\n";
-
- // EMail
-
- print '| '.$langs->trans("YourEMail");
- print ' ('.$langs->trans("ToComplete").')';
- print ' | |
'."\n";
-}
-
-
-// Payment on customer order
-if (GETPOST("source") == 'order' && $valid)
-{
- $found=true;
- $langs->load("orders");
-
- require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
-
- $order=new Commande($db);
- $result=$order->fetch('',$ref);
- if ($result < 0)
- {
- $mesg=$order->error;
- $error++;
- }
- else
- {
- $result=$order->fetch_thirdparty($order->socid);
- }
-
- $amount=$order->total_ttc;
- if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
- $amount=price2num($amount);
-
- $fulltag='IR='.$order->ref.'.TPID='.$order->thirdparty->id;
- //$fulltag.='.TP='.strtr($order->thirdparty->name,"-"," "); We disable this because url that will contains FULLTAG must be lower than 150
- if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; }
- $fulltag=dol_string_unaccent($fulltag);
-
- // Creditor
-
- print '| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
- // Debitor
-
- print '| '.$langs->trans("ThirdParty");
- print ' | '.$order->thirdparty->name.'';
-
- // Object
-
- $text=''.$langs->trans("PaymentOrderRef",$order->ref).'';
- print ' |
| '.$langs->trans("Designation");
- print ' | '.$text;
- print '';
- print '';
- print ' |
'."\n";
-
- // Amount
-
- print '| '.$langs->trans("Amount");
- if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
- print ' | ';
- if (empty($amount) || ! is_numeric($amount))
- {
- print '';
- print '';
- }
- else {
- print ''.price($amount).'';
- print '';
- print '';
- }
- // Currency
- print ' '.$langs->trans("Currency".$currency).'';
- print '';
- print ' |
'."\n";
-
- // Tag
-
- print '| '.$langs->trans("PaymentCode");
- print ' | '.$fulltag.'';
- print '';
- print '';
- print ' |
'."\n";
-
- // EMail
-
- print '| '.$langs->trans("YourEMail");
- print ' ('.$langs->trans("ToComplete").')';
- $email=$order->thirdparty->email;
- $email=(GETPOST("email")?GETPOST("email"):(isValidEmail($email)?$email:''));
- print ' | |
'."\n";
-}
-
-
-// Payment on customer invoice
-if (GETPOST("source") == 'invoice' && $valid)
-{
- $found=true;
- $langs->load("bills");
-
- require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-
- $invoice=new Facture($db);
- $result=$invoice->fetch('',$ref);
- if ($result < 0)
- {
- $mesg=$invoice->error;
- $error++;
- }
- else
- {
- $result=$invoice->fetch_thirdparty($invoice->socid);
- }
-
- $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement());
- if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
- $amount=price2num($amount);
-
- $fulltag='IR='.$invoice->ref.'.TPID='.$invoice->thirdparty->id;
- //$fulltag.='.TP='.strtr($invoice->thirdparty->name,"-"," "); We disable this because url that will contains FULLTAG must be lower than 150
- if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; }
- $fulltag=dol_string_unaccent($fulltag);
-
- // Creditor
-
- print '| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
- // Debitor
-
- print '| '.$langs->trans("ThirdParty");
- print ' | '.$invoice->thirdparty->name.'';
-
- // Object
-
- $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).'';
- print ' |
| '.$langs->trans("Designation");
- print ' | '.$text;
- print '';
- print '';
- print ' |
'."\n";
-
- // Amount
-
- print '| '.$langs->trans("Amount");
- if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
- print ' | ';
- if (empty($amount) || ! is_numeric($amount))
- {
- print '';
- print '';
- }
- else {
- print ''.price($amount).'';
- print '';
- print '';
- }
- // Currency
- print ' '.$langs->trans("Currency".$currency).'';
- print '';
- print ' |
'."\n";
-
- // Tag
-
- print '| '.$langs->trans("PaymentCode");
- print ' | '.$fulltag.'';
- print '';
- print '';
- print ' |
'."\n";
-
- // EMail
-
- print '| '.$langs->trans("YourEMail");
- print ' ('.$langs->trans("ToComplete").')';
- $email=$invoice->thirdparty->email;
- $email=(GETPOST("email")?GETPOST("email"):(isValidEmail($email)?$email:''));
- print ' | |
'."\n";
-}
-
-// Payment on contract line
-if (GETPOST("source") == 'contractline' && $valid)
-{
- $found=true;
- $langs->load("contracts");
-
- require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
-
- $contractline=new ContratLigne($db);
- $result=$contractline->fetch('',$ref);
- if ($result < 0)
- {
- $mesg=$contractline->error;
- $error++;
- }
- else
- {
- if ($contractline->fk_contrat > 0)
- {
- $contract=new Contrat($db);
- $result=$contract->fetch($contractline->fk_contrat);
- if ($result > 0)
- {
- $result=$contract->fetch_thirdparty($contract->socid);
- }
- else
- {
- $mesg=$contract->error;
- $error++;
- }
- }
- else
- {
- $mesg='ErrorRecordNotFound';
- $error++;
- }
- }
-
- $amount=$contractline->total_ttc;
- if ($contractline->fk_product)
- {
- $product=new Product($db);
- $result=$product->fetch($contractline->fk_product);
-
- // We define price for product (TODO Put this in a method in product class)
- if (! empty($conf->global->PRODUIT_MULTIPRICES))
- {
- $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
- $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
- $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
- }
- else
- {
- $pu_ht = $product->price;
- $pu_ttc = $product->price_ttc;
- $price_base_type = $product->price_base_type;
- }
-
- $amount=$pu_ttc;
- if (empty($amount))
- {
- dol_print_error('','ErrorNoPriceDefinedForThisProduct');
- exit;
- }
- }
- if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
- $amount=price2num($amount);
-
- $fulltag='CLR='.$contractline->ref.'.CR='.$contract->ref.'.TPID='.$contract->thirdparty->id;
- //$fulltag.='.TP='.strtr($contract->thirdparty->name,"-"," "); We disable this because url that will contains FULLTAG must be lower than 150
- if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; }
- $fulltag=dol_string_unaccent($fulltag);
-
- $qty=1;
- if (GETPOST('qty')) $qty=GETPOST('qty');
-
- // Creditor
-
- print '| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
- // Debitor
-
- print '| '.$langs->trans("ThirdParty");
- print ' | '.$contract->thirdparty->name.'';
-
- // Object
-
- $text=''.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).'';
- if ($contractline->fk_product)
- {
- $text.=' '.$product->ref.($product->label?' - '.$product->label:'');
- }
- if ($contractline->description) $text.=' '.dol_htmlentitiesbr($contractline->description);
- //if ($contractline->date_fin_validite) {
- // $text.=' '.$langs->trans("DateEndPlanned").': ';
- // $text.=dol_print_date($contractline->date_fin_validite);
- //}
- if ($contractline->date_fin_validite)
- {
- $text.=' '.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite);
- }
-
- print ' |
| '.$langs->trans("Designation");
- print ' | '.$text;
- print '';
- print '';
- print ' |
'."\n";
-
- // Quantity
-
- $label=$langs->trans("Quantity");
- $qty=1;
- $duration='';
- if ($contractline->fk_product)
- {
- if ($product->isService() && $product->duration_value > 0)
- {
- $label=$langs->trans("Duration");
-
- // TODO Put this in a global method
- if ($product->duration_value > 1)
- {
- $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("DurationDays"),"w"=>$langs->trans("DurationWeeks"),"m"=>$langs->trans("DurationMonths"),"y"=>$langs->trans("DurationYears"));
- }
- else
- {
- $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("DurationDay"),"w"=>$langs->trans("DurationWeek"),"m"=>$langs->trans("DurationMonth"),"y"=>$langs->trans("DurationYear"));
- }
- $duration=$product->duration_value.' '.$dur[$product->duration_unit];
- }
- }
- print '| '.$label.' | ';
- print ''.($duration?$duration:$qty).'';
- print '';
- print ' |
'."\n";
-
- // Amount
-
- print '| '.$langs->trans("Amount");
- if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
- print ' | ';
- if (empty($amount) || ! is_numeric($amount))
- {
- print '';
- print '';
- }
- else {
- print ''.price($amount).'';
- print '';
- print '';
- }
- // Currency
- print ' '.$langs->trans("Currency".$currency).'';
- print '';
- print ' |
'."\n";
-
- // Tag
-
- print '| '.$langs->trans("PaymentCode");
- print ' | '.$fulltag.'';
- print '';
- print '';
- print ' |
'."\n";
-
- // EMail
-
- print '| '.$langs->trans("YourEMail");
- print ' ('.$langs->trans("ToComplete").')';
- $email=$contract->thirdparty->email;
- $email=(GETPOST("email")?GETPOST("email"):(isValidEmail($email)?$email:''));
- print ' | |
'."\n";
-
-}
-
-// Payment on member subscription
-if (GETPOST("source") == 'membersubscription' && $valid)
-{
- $found=true;
- $langs->load("members");
-
- require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
- require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
-
- $member=new Adherent($db);
- $result=$member->fetch('',$ref);
- if ($result < 0)
- {
- $mesg=$member->error;
- $error++;
- }
- else
- {
- $subscription=new Subscription($db);
- }
-
- $amount=$subscription->total_ttc;
- if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
- $amount=price2num($amount);
-
- $fulltag='MID='.$member->id;
- //$fulltag.='.M='.dol_trunc(strtr($member->getFullName($langs),"-"," "),12); We disable this because url that will contains FULLTAG must be lower than 150
- if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; }
- $fulltag=dol_string_unaccent($fulltag);
-
- // Creditor
-
- print '| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
- // Debitor
-
- print '| '.$langs->trans("Member");
- print ' | ';
- if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe;
- else print $member->getFullName($langs);
- print '';
-
- // Object
-
- $text=''.$langs->trans("PaymentSubscription").'';
- print ' |
| '.$langs->trans("Designation");
- print ' | '.$text;
- print '';
- print '';
- print ' |
'."\n";
-
- if ($member->last_subscription_date || $member->last_subscription_amount)
- {
- // Last subscription date
-
- print '| '.$langs->trans("LastSubscriptionDate");
- print ' | '.dol_print_date($member->last_subscription_date,'day');
- print ' |
'."\n";
-
- // Last subscription amount
-
- print '| '.$langs->trans("LastSubscriptionAmount");
- print ' | '.price($member->last_subscription_amount);
- print ' |
'."\n";
-
- if (empty($amount) && ! GETPOST('newamount','alpha')) $_GET['newamount']=$member->last_subscription_amount;
- }
-
- // Amount
-
- print '| '.$langs->trans("Amount");
- if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
- print ' | ';
- $valtoshow='';
- if (empty($amount) || ! is_numeric($amount))
- {
- $valtoshow=price2num(GETPOST("newamount",'alpha'),'MT');
- // force default subscription amount to value defined into constant...
- if (empty($valtoshow))
- {
- if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
- if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
- $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT;
- }
- }
- else {
- if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
- $amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
- }
- }
- }
- }
- if (empty($amount) || ! is_numeric($amount))
- {
- //$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT');
- if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow);
- print '';
- print '';
- }
- else {
- $valtoshow=$amount;
- if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow);
- print ''.price($valtoshow).'';
- print '';
- print '';
- }
- // Currency
- print ' '.$langs->trans("Currency".$currency).'';
- print '';
- print ' |
'."\n";
-
- // Tag
-
- print '| '.$langs->trans("PaymentCode");
- print ' | '.$fulltag.'';
- print '';
- print '';
- print ' |
'."\n";
-
- // EMail
-
- print '| '.$langs->trans("YourEMail");
- $email=$member->email;
- $email=(GETPOST("email")?GETPOST("email"):(isValidEmail($email)?$email:''));
- if (empty($email)) print ' ('.$langs->trans("ToComplete").')';
- print ' | |
'."\n";
-}
-
-
-
-
-if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters");
-
-if ($mesg) print '
'.$mesg.' |
'."\n";
-
-print '
'."\n";
-print "\n";
-
-if ($found && ! $error) // We are in a management option and no error
-{
- print '