Add a right navigation on list of stripe charges

This commit is contained in:
Laurent Destailleur 2020-03-30 15:56:14 +02:00
parent a886629d08
commit 39fba83f26
3 changed files with 58 additions and 22 deletions

View File

@ -80,6 +80,28 @@ $stripeacc = $stripe->getStripeAccount($service);
if (!$rowid)
{
$option = array('limit' => $limit + 1);
if (GETPOSTISSET('starting_after_'.$page)) $option['starting_after'] = GETPOST('starting_after_'.$page, 'alphanohtml');
if ($stripeacc)
{
$list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc));
}
else
{
$list = \Stripe\Charge::all($option);
}
$num = count($list->data);
$totalnboflines = '';
$param = '';
//if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
$param.='&starting_after_'.($page+1).'='.$list->data[($limit-1)]->id;
//$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id;
$moreforfilter = '';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -92,7 +114,7 @@ if (!$rowid)
$title = $langs->trans("StripeChargeList");
$title .= ($stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)');
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', 'hidepaginationprevious', $limit);
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
@ -108,29 +130,23 @@ if (!$rowid)
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right ');
print "</tr>\n";
print "</tr>\n";
if ($stripeacc)
{
$list=\Stripe\Charge::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
}
else
{
$list=\Stripe\Charge::all(array("limit" => $limit));
}
//print $list;
$i = 0;
foreach ($list->data as $charge)
{
if ($i >= $limit) {
break;
}
if ($charge->refunded=='1') {
$status = img_picto($langs->trans("refunded"), 'statut6');
} elseif ($charge->paid=='1') {
$status = img_picto($langs->trans("".$charge->status.""), 'statut4');
$status = img_picto($langs->trans((string) $charge->status), 'statut4');
} else {
$label="Message: ".$charge->failure_message."<br>";
$label.="Réseau: ".$charge->outcome->network_status."<br>";
$label.="Statut: ".$langs->trans("".$charge->outcome->seller_message."");
$status = $form->textwithpicto(img_picto($langs->trans("".$charge->status.""), 'statut8'), $label, 1);
$label = $langs->trans("Message").": ".$charge->failure_message."<br>";
$label.= $langs->trans("Network").": ".$charge->outcome->network_status."<br>";
$label.= $langs->trans("Status").": ".$langs->trans((string) $charge->outcome->seller_message);
$status = $form->textwithpicto(img_picto($langs->trans((string) $charge->status), 'statut8'), $label, -1);
}
if ($charge->payment_method_details->type=='card') {
@ -145,13 +161,14 @@ if (!$rowid)
$type = $langs->trans("iDEAL");
}
if (! empty($charge->payment_intent)) {
// Why this ?
/*if (! empty($charge->payment_intent)) {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent);
} else {
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent, array("stripe_account" => $stripeacc));
}
}
}*/
// The metadata FULLTAG is defined by the online payment page
$FULLTAG = $charge->metadata->FULLTAG;
@ -192,7 +209,9 @@ if (!$rowid)
}
print "<td>";
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id."</a>";
if ($charge->payment_intent) print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>';
print "</td>\n";
// Stripe customer
print "<td>";
if (!empty($conf->stripe->enabled) && !empty($stripeacc)) $connect = $stripeacc.'/';
@ -206,6 +225,7 @@ if (!$rowid)
print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.'</a>';
}
print "</td>\n";
// Link
print "<td>";
if ($societestatic->id > 0)
@ -217,7 +237,8 @@ if (!$rowid)
print $memberstatic->getNomUrl(1);
}
print "</td>\n";
// Origine
// Origin
print "<td>";
if ($charge->metadata->dol_type=="order" || $charge->metadata->dol_type=="commande") {
$object = new Commande($db);
@ -228,6 +249,7 @@ if (!$rowid)
print $FULLTAG;
}
} elseif ($charge->metadata->dol_type=="invoice" || $charge->metadata->dol_type=="facture") {
print $charge->metadata->dol_type.' '.$charge->metadata->dol_id.' - ';
$object = new Facture($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
@ -239,6 +261,7 @@ if (!$rowid)
print $FULLTAG;
}
print "</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($charge->created, '%d/%m/%Y %H:%M')."</td>\n";
// Type
@ -253,8 +276,9 @@ if (!$rowid)
print "</td>\n";
print "</tr>\n";
$i++;
}
} else {
}
// End of page

View File

@ -3161,7 +3161,12 @@ div.pagination li.paginationafterarrows {
.paginationatbottom {
margin-top: 9px;
}
table.hidepaginationprevious .paginationprevious {
display: none;
}
table.hidepaginationnext .paginationnext {
display: none;
}

View File

@ -3149,6 +3149,13 @@ div.pagination li.paginationafterarrows {
.paginationatbottom {
margin-top: 9px;
}
table.hidepaginationprevious .paginationprevious {
display: none;
}
table.hidepaginationnext .paginationnext {
display: none;
}
/* Prepare to remove class pair - impair
.noborder > tbody > tr:nth-child(even) td {