Works on paypal module

Fix: enable/disable create object
Fix: defined default bank account for paypal
This commit is contained in:
Regis Houssin 2011-05-24 16:31:54 +00:00
parent 14cf987a35
commit 2663005150
4 changed files with 100 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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 '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
print '</tr>';
// Order
if ($conf->commande->enabled)
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("PaypalCreateOrderEnabled").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="100">';
if ($conf->use_javascript_ajax)
{
print ajax_constantonoff('PAYPAL_CREATE_ORDER_ENABLED');
}
else
{
if($conf->global->PAYPAL_CREATE_ORDER_ENABLED == 0)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_PAYPAL_CREATE_ORDER_ENABLED">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
else if($conf->global->PAYPAL_CREATE_ORDER_ENABLED == 1)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_PAYPAL_CREATE_ORDER_ENABLED">'.img_picto($langs->trans("Enabled"),'on').'</a>';
}
}
print '</td></tr>';
}
// Invoice
if ($conf->facture->enabled)
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("PaypalCreateInvoiceEnabled").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="100">';
if ($conf->use_javascript_ajax)
{
print ajax_constantonoff('PAYPAL_CREATE_INVOICE_ENABLED');
}
else
{
if($conf->global->PAYPAL_CREATE_INVOICE_ENABLED == 0)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_PAYPAL_CREATE_INVOICE_ENABLED">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
else if($conf->global->PAYPAL_CREATE_INVOICE_ENABLED == 1)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_PAYPAL_CREATE_INVOICE_ENABLED">'.img_picto($langs->trans("Enabled"),'on').'</a>';
}
}
print '</td></tr>';
}
// Shipping costs
$var=!$var;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setproductshippingcosts">';
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("DefaultProductShippingCosts").'</td>';
print '<td width="60" align="center">';
print '<td width="60" align="right">';
$form->select_produits($conf->global->PAYPAL_PRODUCT_SHIPPING_COSTS,'idprod','',$conf->product->limit_size,1,1,1,'',1);
print '</td>';
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr>';
print '</form>';
// Bank
if ($conf->banque->enabled)
{
$var=!$var;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setpaypalaccount">';
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("DefaultPaypalAccount").'</td>';
print '<td width="60" align="right">';
$form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT,'accountid',0,'',1);
print '</td>';
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr>';
print '</form>';
}
print '</table>';
$db->close();

View File

@ -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 = <?php echo ($conf->commande->enabled ? 'true' : 'false'); ?>;
var $invoice_enabled = <?php echo ($conf->facture->enabled ? 'true' : 'false'); ?>;
var $order_enabled = <?php echo (($conf->commande->enabled && $conf->global->PAYPAL_CREATE_ORDER_ENABLED) ? 'true' : 'false'); ?>;
var $invoice_enabled = <?php echo (($conf->facture->enabled && $conf->global->PAYPAL_CREATE_INVOICE_ENABLED) ? 'true' : 'false'); ?>;
var $element_created = false;
$.each(details, function(key,value) {