From 7e0bad97ebbcc5a74c2b71e7b9dfceee97b8adea Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 19 Sep 2018 18:59:32 +0200 Subject: [PATCH] Update transaction.php --- htdocs/stripe/transaction.php | 112 +++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 28 deletions(-) diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 219846d151d..964d0463f55 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -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 '
'; - if ($optioncss != '') - print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -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 ''; // 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 "".$txn->type.""; - } else print "".img_picto($langs->trans('ShowInStripe'), 'object_globe')." " . $txn->source . "\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 "".$txn->type.""; + } else print "".img_picto($langs->trans('ShowInStripe'), 'object_globe')." " . $txn->source . "\n"; + // Stripe customer + //print "".$charge->customer."\n"; + // Link + /*print ""; + if ($societestatic->id > 0) + { + print $societestatic->getNomUrl(1); + } + if ($memberstatic->id > 0) + { + print $memberstatic->getNomUrl(1); + } + print "\n";*/ + // Origine + + //print ""; + ////if ($charge->metadata->dol_type=="order"){ + // $object = new Commande($db); + // $object->fetch($charge->metadata->dol_id); + // print "".img_picto('', 'object_order')." ".$object->ref.""; + //} elseif ($charge->metadata->dol_type=="invoice"){ + // $object = new Facture($db); + // $object->fetch($charge->metadata->dol_id); + // print "".img_picto('', 'object_invoice')." ".$object->ref.""; + //} + //print "\n"; // Date payment print '' . dol_print_date($txn->created, '%d/%m/%Y %H:%M') . "\n"; // Type @@ -164,12 +219,13 @@ if (! $rowid) { print "" . price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)) . ""; // Status print ""; -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 ''; print "\n"; }