Update transaction.php

This commit is contained in:
ptibogxiv
2018-09-19 18:59:32 +02:00
committed by GitHub
parent 0770d8e56e
commit 7e0bad97eb

View File

@@ -26,7 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
if (! empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
@@ -68,7 +70,7 @@ if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GET
}
else
{
$service = 'StripeLive';
$service = 'StripeLive';
$servicestatus = '1';
}
@@ -81,8 +83,9 @@ $stripeaccount = $stripe->getStripeAccount($service);
if (! $rowid) {
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
if ($optioncss != '')
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
}
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@@ -123,6 +126,32 @@ if (! $rowid) {
foreach ($txn->data as $txn)
{
//$charge = $txn;
//var_dump($txn);
// The metadata FULLTAG is defined by the online payment page
/*$FULLTAG=$charge->metadata->FULLTAG;
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG,'.','=');
// Load origin object according to metadata
if (! empty($tmparray['CUS']))
{
$societestatic->fetch($tmparray['CUS']);
}
else
{
$societestatic->id = 0;
}
if (! empty($tmparray['MEM']))
{
$memberstatic->fetch($tmparray['MEM']);
}
else
{
$memberstatic->id = 0;
}*/
$societestatic->fetch($charge->metadata->idcustomer);
$societestatic->id = $charge->metadata->idcustomer;
$societestatic->lastname = $obj->lastname;
@@ -135,26 +164,52 @@ if (! $rowid) {
print '<tr class="oddeven">';
// Ref
if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/';
// Ref
if (preg_match('/po_/i', $txn->source)){
$origin="payouts";
} elseif (preg_match('/fee_/i', $txn->source)) {
$origin="connect/application_fees";
} else {
$origin="payments";
}
if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/';
$url='https://dashboard.stripe.com/'.$connect.'test/'.$origin.'/'.$txn->source;
if ($servicestatus)
{
$url='https://dashboard.stripe.com/'.$connect.$origin.'/'.$txn->source;
}
if ($txn->type == 'stripe_fee' || $txn->type == 'reserve_transaction') {
print "<td>".$txn->type."</td>";
} else print "<td><a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')." " . $txn->source . "</a></td>\n";
if (preg_match('/po_/i', $txn->source)){
$origin="payouts";
} elseif (preg_match('/fee_/i', $txn->source)) {
$origin="connect/application_fees";
} else {
$origin="payments";
}
$url='https://dashboard.stripe.com/'.$connect.'test/'.$origin.'/'.$txn->source;
if ($servicestatus)
{
$url='https://dashboard.stripe.com/'.$connect.$origin.'/'.$txn->source;
}
if ($txn->type == 'stripe_fee' || $txn->type == 'reserve_transaction') {
print "<td>".$txn->type."</td>";
} else print "<td><a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')." " . $txn->source . "</a></td>\n";
// Stripe customer
//print "<td>".$charge->customer."</td>\n";
// Link
/*print "<td>";
if ($societestatic->id > 0)
{
print $societestatic->getNomUrl(1);
}
if ($memberstatic->id > 0)
{
print $memberstatic->getNomUrl(1);
}
print "</td>\n";*/
// Origine
//print "<td>";
////if ($charge->metadata->dol_type=="order"){
// $object = new Commande($db);
// $object->fetch($charge->metadata->dol_id);
// print "<A href='".DOL_URL_ROOT."/commande/card.php?id=".$charge->metadata->dol_id."'>".img_picto('', 'object_order')." ".$object->ref."</A>";
//} elseif ($charge->metadata->dol_type=="invoice"){
// $object = new Facture($db);
// $object->fetch($charge->metadata->dol_id);
// print "<A href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</A>";
//}
//print "</td>\n";
// Date payment
print '<td align="center">' . dol_print_date($txn->created, '%d/%m/%Y %H:%M') . "</td>\n";
// Type
@@ -164,12 +219,13 @@ if (! $rowid) {
print "<td align=\"right\">" . price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)) . "</td>";
// Status
print "<td align='right'>";
if ($txn->status=='available')
{print img_picto($langs->trans("".$txn->status.""),'statut4');}
elseif ($txn->status=='pending')
{print img_picto($langs->trans("".$txn->status.""),'statut7');}
elseif ($txn->status=='failed')
{print img_picto($langs->trans("".$txn->status.""),'statut8');}
if ($txn->status=='available') {
print img_picto($langs->trans("".$txn->status.""),'statut4');
} elseif ($txn->status=='pending') {
print img_picto($langs->trans("".$txn->status.""),'statut7');
} elseif ($txn->status=='failed') {
print img_picto($langs->trans("".$txn->status.""),'statut8');
}
print '</td>';
print "</tr>\n";
}