21 require
'../main.inc.php';
22 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
23 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
24 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
29 if (!empty($conf->accounting->enabled)) {
30 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
34 $langs->loadLangs(array(
'compta',
'salaries',
'bills',
'hrm',
'stripe'));
37 $socid =
GETPOST(
"socid",
"int");
39 $socid = $user->socid;
43 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
44 $rowid =
GETPOST(
"rowid",
'alpha');
45 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
46 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
48 if (empty($page) || $page == -1) {
51 $offset = $limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
54 $optioncss =
GETPOST(
'optioncss',
'alpha');
64 $societestatic =
new Societe($db);
69 llxHeader(
'', $langs->trans(
"StripeTransactionList"));
71 if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'alpha'))) {
72 $service =
'StripeTest';
74 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
76 $service =
'StripeLive';
79 $stripeacc = $stripe->getStripeAccount($service);
86 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
87 if ($optioncss !=
'') {
88 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
90 print
'<input type="hidden" name="token" value="'.newToken().
'">';
91 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
92 print
'<input type="hidden" name="action" value="list">';
93 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
94 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
95 print
'<input type="hidden" name="page" value="'.$page.
'">';
97 $title = $langs->trans(
"StripeTransactionList");
98 $title .= ($stripeaccount ?
' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.
')' :
' (Stripe connection with keys from Stripe module setup)');
100 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $totalnboflines,
'title_accountancy.png', 0,
'',
'', $limit);
102 print
'<div class="div-table-responsive">';
103 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
105 print
'<tr class="liste_titre">';
110 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"",
"",
"",
'', $sortfield, $sortorder,
'center ');
119 $txn = \Stripe\BalanceTransaction::all(array(
"limit" => $limit), array(
"stripe_account" => $stripeacc));
121 $txn = \Stripe\BalanceTransaction::all(array(
"limit" => $limit));
124 foreach ($txn->data as $txn) {
151 $societestatic->fetch($charge->metadata->idcustomer);
152 $societestatic->id = $charge->metadata->idcustomer;
153 $societestatic->lastname = $obj->lastname;
154 $societestatic->firstname = $obj->firstname;
155 $societestatic->admin = $obj->admin;
156 $societestatic->login = $obj->login;
157 $societestatic->email = $obj->email;
158 $societestatic->societe_id = $obj->fk_soc;
160 print
'<tr class="oddeven">';
163 if (!empty($stripeacc)) {
164 $connect = $stripeacc.
'/';
168 if (preg_match(
'/po_/i', $txn->source)) {
170 } elseif (preg_match(
'/fee_/i', $txn->source)) {
171 $origin =
"connect/application_fees";
173 $origin =
"payments";
176 $url =
'https://dashboard.stripe.com/'.$connect.
'test/'.$origin.
'/'.$txn->source;
177 if ($servicestatus) {
178 $url =
'https://dashboard.stripe.com/'.$connect.$origin.
'/'.$txn->source;
180 if ($txn->type ==
'stripe_fee' || $txn->type ==
'reserve_transaction') {
181 print
"<td>".$txn->type.
"</td>";
183 print
"<td><a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
" ".$txn->source.
"</a></td>\n";
210 print
'<td class="center">'.dol_print_date($txn->created,
'dayhour').
"</td>\n";
212 print
'<td>'.$txn->type.
'</td>';
214 print
'<td class="right"><span class="amount">'.price(($txn->amount) / 100, 0,
'', 1, - 1, - 1, strtoupper($txn->currency)).
"</span></td>";
215 print
'<td class="right"><span class="amount">'.price(($txn->fee) / 100, 0,
'', 1, - 1, - 1, strtoupper($txn->currency)).
"</span></td>";
217 print
"<td class='right'>";
218 if ($txn->status ==
'available') {
219 print
img_picto($langs->trans(
"".$txn->status.
""),
'statut4');
220 } elseif ($txn->status ==
'pending') {
221 print
img_picto($langs->trans(
"".$txn->status.
""),
'statut7');
222 } elseif ($txn->status ==
'failed') {
223 print
img_picto($langs->trans(
"".$txn->status.
""),
'statut8');
229 print
'<tr><td colspan="6">'.$e->getMessage().
'</td></td>';