dolibarr 21.0.0-alpha
payout.php
1<?php
2/* Copyright (C) 2018-2023 Thibault FOUCART <support@ptibogxiv.net>
3 * Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20// Put here all includes required by your class file
21
22// Load Dolibarr environment
23require '../main.inc.php';
24require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
25require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
26require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
27//require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
29require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
30require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
31if (isModEnabled('accounting')) {
32 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
33}
34
35// Load translation files required by the page
36$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
37
38// Security check
39$socid = GETPOSTINT("socid");
40if ($user->socid) {
41 $socid = $user->socid;
42}
43//$result = restrictedArea($user, 'salaries', '', '', '');
44
45$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
46$rowid = GETPOST("rowid", 'alpha');
47$sortfield = GETPOST('sortfield', 'aZ09comma');
48$sortorder = GETPOST('sortorder', 'aZ09comma');
49$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
50if (empty($page) || $page == -1) {
51 $page = 0;
52} // If $page is not defined, or '' or -1
53$offset = $limit * $page;
54$pageprev = $page - 1;
55$pagenext = $page + 1;
56$optioncss = GETPOST('optioncss', 'alpha');
57$param = "";
58$num = 0;
59
60$result = restrictedArea($user, 'banque');
61
62
63/*
64 * View
65 */
66
67$form = new Form($db);
68$acc = new Account($db);
69$stripe = new Stripe($db);
70
71llxHeader('', $langs->trans("StripePayoutList"));
72
73if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha'))) {
74 $service = 'StripeTest';
75 $servicestatus = '0';
76 dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), [], 'warning');
77} else {
78 $service = 'StripeLive';
79 $servicestatus = '1';
80}
81
82$stripeacc = $stripe->getStripeAccount($service);
83/*if (empty($stripeaccount))
84{
85 print $langs->trans('ErrorStripeAccountNotDefined');
86}*/
87
88$moreforfilter = '';
89$totalnboflines = -1;
90
91if (!$rowid) {
92 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
93 if ($optioncss != '') {
94 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
95 }
96 print '<input type="hidden" name="token" value="'.newToken().'">';
97 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
98 print '<input type="hidden" name="action" value="list">';
99 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
100 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
101 print '<input type="hidden" name="page" value="'.$page.'">';
102
103 $title = $langs->trans("StripePayoutList");
104 $title .= ($stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)');
105
106 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit);
107
108 print '<div class="div-table-responsive">';
109 print '<table class="tagtable liste'.(!empty($moreforfilter) ? " listwithfilterbefore" : "").'">'."\n";
110
111 print '<tr class="liste_titre">';
112 print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
113 print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center ');
114 print_liste_field_titre("DateOperation", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center ');
115 print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'left ');
116 print_liste_field_titre("Paid", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right ');
117 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right ');
118 print "</tr>\n";
119
120 print "</tr>\n";
121
122 try {
123 if ($stripeacc) {
124 $payout_all = \Stripe\Payout::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
125 } else {
126 $payout_all = \Stripe\Payout::all(array("limit" => $limit));
127 }
128 '@phan-var-force \Stripe\Payout $payout_all'; // TStripeObject suggested, but is a template
129
130 foreach ($payout_all->data as $payout) {
131 '@phan-var-force \Stripe\Payout $payout'; // TStripeObject suggested, but is a template
132 print '<tr class="oddeven">';
133
134 // Ref
135 if (!empty($stripeacc)) {
136 $connect = $stripeacc.'/';
137 } else {
138 $connect = null;
139 }
140
141 $url = 'https://dashboard.stripe.com/'.$connect.'test/payouts/'.$payout->id;
142 if ($servicestatus) {
143 $url = 'https://dashboard.stripe.com/'.$connect.'payouts/'.$payout->id;
144 }
145
146 print "<td><a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$payout->id."</a></td>\n";
147
148 // Date payment
149 print '<td class="center">'.dol_print_date($payout->created, 'dayhour')."</td>\n";
150 // Date payment
151 print '<td class="center">'.dol_print_date($payout->arrival_date, 'dayhour')."</td>\n";
152 // Type
153 print '<td>'.$payout->description.'</td>';
154 // Amount
155 print '<td class="right"><span class="amount">'.price(($payout->amount) / 100, 0, '', 1, -1, -1, strtoupper($payout->currency))."</span></td>";
156 // Status
157 print "<td class='right'>";
158 if ($payout->status == 'paid') {
159 print img_picto($langs->trans($payout->status), 'statut4');
160 } elseif ($payout->status == 'pending') {
161 print img_picto($langs->trans($payout->status), 'statut7');
162 } elseif ($payout->status == 'in_transit') {
163 print img_picto($langs->trans($payout->status), 'statut7');
164 } elseif ($payout->status == 'failed') {
165 print img_picto($langs->trans($payout->status), 'statut7');
166 } elseif ($payout->status == 'canceled') {
167 print img_picto($langs->trans($payout->status), 'statut8');
168 }
169 print '</td>';
170 print "</tr>\n";
171 }
172 } catch (Exception $e) {
173 print '<tr><td colspan="6">'.$e->getMessage().'</td></td>';
174 }
175 print "</table>";
176 print '</div>';
177 print '</form>';
178}
179
180// End of page
181llxFooter();
182$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage bank accounts.
Class to manage generation of HTML components Only common components must be here.
Stripe class @TODO No reason to extends CommonObject.
llxFooter()
Footer empty.
Definition document.php:107
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.