From 266300515041911500cc853269b6e14f7adc7e84 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 24 May 2011 16:31:54 +0000 Subject: [PATCH] Works on paypal module Fix: enable/disable create object Fix: defined default bank account for paypal --- htdocs/langs/en_US/paypal.lang | 4 ++ htdocs/langs/fr_FR/paypal.lang | 4 ++ htdocs/paypal/admin/import.php | 94 ++++++++++++++++++++++++++++++++-- htdocs/paypal/transaction.php | 4 +- 4 files changed, 100 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index 6c9dd0da851..42a95d8002b 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -29,6 +29,10 @@ CustomerDetails=Customer details NewTransaction=New transaction OrderIsCreated=Order created InvoiceIsCreated=Invoice created +PaypalCreateOrderEnabled=Enable the ability to create customer orders +PaypalCreateInvoiceEnabled=Enable the ability to create customer invoices +DefaultProductShippingCosts=Select the product to be used for adding shipping costs. +DefaultPaypalAccount=Select the bank account to be used as a Paypal account, this will deduct the Paypal fee when adding a payment. # Paypal transaction fields PAYERID=Payer ID diff --git a/htdocs/langs/fr_FR/paypal.lang b/htdocs/langs/fr_FR/paypal.lang index 6d4bd8d2db6..6a73994a273 100644 --- a/htdocs/langs/fr_FR/paypal.lang +++ b/htdocs/langs/fr_FR/paypal.lang @@ -29,6 +29,10 @@ CustomerDetails=Détail du client NewTransaction=Nouveau paiement OrderIsCreated=Commande créée InvoiceIsCreated=Facture créée +PaypalCreateOrderEnabled=Activer la possibilité de créer des commandes clients. +PaypalCreateInvoiceEnabled=Activer la possibilité de créer des factures clients. +DefaultProductShippingCosts=Sélectionnez le produit qui sera utilisé pour l'ajout des frais de port. +DefaultPaypalAccount=Sélectionner le compte bancaire qui sera utilisé comme compte Paypal, ceci permettra de déduire les frais Paypal lors de l'ajout d'un paiement. # Paypal transaction fields PAYERID=ID du payeur diff --git a/htdocs/paypal/admin/import.php b/htdocs/paypal/admin/import.php index d1dc27d7fe4..fda11b0fb64 100755 --- a/htdocs/paypal/admin/import.php +++ b/htdocs/paypal/admin/import.php @@ -33,8 +33,9 @@ if (!$user->admin) $langs->load("paypal"); $langs->load("admin"); -$action=GETPOST('action'); -$idprod=GETPOST('idprod'); +$action = GETPOST('action'); +$idprod = GETPOST('idprod'); +$accountid = GETPOST('accountid'); /* @@ -81,6 +82,19 @@ if ($action == 'setproductshippingcosts') } } +if ($action == 'setpaypalaccount') +{ + if (dolibarr_set_const($db, 'PAYPAL_BANK_ACCOUNT', $accountid, 'chaine', 0, '', $conf->entity) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + /* * View */ @@ -135,19 +149,91 @@ print ' '; print ''.$langs->trans("Value").''."\n"; print ''; +// Order +if ($conf->commande->enabled) +{ + $var=!$var; + print ''; + print ''.$langs->trans("PaypalCreateOrderEnabled").''; + print ' '; + + print ''; + if ($conf->use_javascript_ajax) + { + print ajax_constantonoff('PAYPAL_CREATE_ORDER_ENABLED'); + } + else + { + if($conf->global->PAYPAL_CREATE_ORDER_ENABLED == 0) + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + else if($conf->global->PAYPAL_CREATE_ORDER_ENABLED == 1) + { + print ''.img_picto($langs->trans("Enabled"),'on').''; + } + } + print ''; +} + +// Invoice +if ($conf->facture->enabled) +{ + $var=!$var; + print ''; + print ''.$langs->trans("PaypalCreateInvoiceEnabled").''; + print ' '; + + print ''; + if ($conf->use_javascript_ajax) + { + print ajax_constantonoff('PAYPAL_CREATE_INVOICE_ENABLED'); + } + else + { + if($conf->global->PAYPAL_CREATE_INVOICE_ENABLED == 0) + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + else if($conf->global->PAYPAL_CREATE_INVOICE_ENABLED == 1) + { + print ''.img_picto($langs->trans("Enabled"),'on').''; + } + } + print ''; +} + +// Shipping costs $var=!$var; print '
'; print ''; print ''; print ''; print ''.$langs->trans("DefaultProductShippingCosts").''; -print ''; +print ''; $form->select_produits($conf->global->PAYPAL_PRODUCT_SHIPPING_COSTS,'idprod','',$conf->product->limit_size,1,1,1,'',1); print ''; -print ''; +print ''; print ''; print '
'; +// Bank +if ($conf->banque->enabled) +{ + $var=!$var; + print '
'; + print ''; + print ''; + print ''; + print ''.$langs->trans("DefaultPaypalAccount").''; + print ''; + $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT,'accountid',0,'',1); + print ''; + print ''; + print ''; + print '
'; +} + print ''; $db->close(); diff --git a/htdocs/paypal/transaction.php b/htdocs/paypal/transaction.php index cef7f1878ec..a2a11177817 100644 --- a/htdocs/paypal/transaction.php +++ b/htdocs/paypal/transaction.php @@ -145,8 +145,8 @@ if (empty($conf->global->PAYPAL_API_USER) || empty($conf->global->PAYPAL_API_PAS transaction_id: id_value }, function(details) { - var $order_enabled = commande->enabled ? 'true' : 'false'); ?>; - var $invoice_enabled = facture->enabled ? 'true' : 'false'); ?>; + var $order_enabled = commande->enabled && $conf->global->PAYPAL_CREATE_ORDER_ENABLED) ? 'true' : 'false'); ?>; + var $invoice_enabled = facture->enabled && $conf->global->PAYPAL_CREATE_INVOICE_ENABLED) ? 'true' : 'false'); ?>; var $element_created = false; $.each(details, function(key,value) {