Works on paypal module

New: possibility to use the price defined in paypal instead dolibarr price
This commit is contained in:
Regis Houssin 2011-05-25 06:06:55 +00:00
parent 60ff4318d8
commit 8f8da6b4f0
4 changed files with 53 additions and 6 deletions

View File

@ -31,6 +31,7 @@ OrderIsCreated=Order created
InvoiceIsCreated=Invoice created
PaypalCreateOrderEnabled=Enable the ability to create customer orders
PaypalCreateInvoiceEnabled=Enable the ability to create customer invoices
UseThePriceDefinedInPaypal=Use the price defined in Paypal instead of the one defined in Dolibarr
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.

View File

@ -31,6 +31,7 @@ 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.
UseThePriceDefinedInPaypal=Utiliser le prix défini dans Paypal au lieu de celui défini dans Dolibarr
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.

View File

@ -203,6 +203,33 @@ if ($conf->facture->enabled)
print '</td></tr>';
}
// Invoice
if ($conf->facture->enabled)
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("UseThePriceDefinedInPaypal").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="100">';
if ($conf->use_javascript_ajax)
{
print ajax_constantonoff('PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL');
}
else
{
if($conf->global->PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL == 0)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
else if($conf->global->PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL == 1)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_PAYPAL_PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL">'.img_picto($langs->trans("Enabled"),'on').'</a>';
}
}
print '</td></tr>';
}
// Shipping costs
$var=!$var;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -176,9 +176,27 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
if ($ret > 0)
{
$qty=$_SESSION[$_GET['transaction_id']]["L_QTY".$i];
if ($conf->global->PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL)
{
if ($_SESSION[$_GET['transaction_id']]["L_AMT".$i])
{
$amount_ht = ($_SESSION[$_GET['transaction_id']]["L_AMT".$i] - $_SESSION[$_GET['transaction_id']]["L_SHIPPINGAMT".$i]);
}
else
{
$amount_ht = ($_SESSION[$_GET['transaction_id']]["AMT"] - $_SESSION[$_GET['transaction_id']]["SHIPAMOUNT"] - $_SESSION[$_GET['transaction_id']]["L_TAXAMT".$i]);
}
$unitprice_ht = ($amount_ht / $qty);
}
else
{
$unitprice_ht = $product->price;
}
if ($subelement == 'commande') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,$product->price_base_type,0,'','',$product->product_type);
if ($subelement == 'facture') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,$product->price_base_type,0,$product->product_type);
if ($subelement == 'commande') $fields = array($object_id,$product->description,$unitprice_ht,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,$product->price_base_type,0,'','',$product->product_type);
if ($subelement == 'facture') $fields = array($object_id,$product->description,$unitprice_ht,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,$product->price_base_type,0,$product->product_type);
$result = $object->addline($fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5],$fields[6],$fields[7],$fields[8],$fields[9],$fields[10],$fields[11],$fields[12],$fields[13],$fields[14],$fields[15],$fields[16]);
@ -357,14 +375,14 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
if ($_SESSION[$_GET['transaction_id']]["L_AMT".$i])
{
$amount_ht = ($_SESSION[$_GET['transaction_id']]["L_AMT".$i] - $_SESSION[$_GET['transaction_id']]["L_SHIPPINGAMT".$i]);
$unitprice_ht = ($amount_ht / $qty);
}
else
{
$amount_ht = ($_SESSION[$_GET['transaction_id']]["AMT"] - $_SESSION[$_GET['transaction_id']]["SHIPAMOUNT"] - $_SESSION[$_GET['transaction_id']]["L_TAXAMT".$i]);
$unitprice_ht = ($amount_ht / $qty);
}
$unitprice_ht = ($amount_ht / $qty);
$return_arr['contents'].= '<tr '.$bc[$var].'>';
$return_arr['contents'].= '<td>'.$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i].'</td>';
$return_arr['contents'].= '<td>'.$_SESSION[$_GET['transaction_id']]["L_NAME".$i].'</td>';
@ -423,13 +441,13 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
$return_arr['contents'].= '</table>';
}
/*
/*
$return_arr['contents'].= '<br />';
foreach ($_SESSION[$_GET['transaction_id']] as $key => $value)
{
$return_arr['contents'].= $key.': '.$value.'<br />';
}
*/
*/
echo json_encode($return_arr);
}