dolibarr 24.0.0-beta
payout.php
1<?php
2/* Copyright (C) 2018-2023 Thibault FOUCART <support@ptibogxiv.net>
3 * Copyright (C) 2019-2026 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';
32require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
33require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
34require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
35//require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
37require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
38require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
39if (isModEnabled('accounting')) {
40 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
41}
42
43// Load translation files required by the page
44$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
45
46// Security check
47$socid = GETPOSTINT("socid");
48if ($user->socid) {
49 $socid = $user->socid;
50}
51//restrictedArea($user, 'salaries', '', '', '');
52
53$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
54$rowid = GETPOST("rowid", 'alpha');
55$sortfield = GETPOST('sortfield', 'aZ09comma');
56$sortorder = GETPOST('sortorder', 'aZ09comma');
57$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
58if (empty($page) || $page == -1) {
59 $page = 0;
60} // If $page is not defined, or '' or -1
61$offset = $limit * $page;
62$pageprev = $page - 1;
63$pagenext = $page + 1;
64$optioncss = GETPOST('optioncss', 'alpha');
65$param = "";
66$num = 0;
67
68$result = restrictedArea($user, 'banque');
69
70
71/*
72 * View
73 */
74
75$form = new Form($db);
76$acc = new Account($db);
77$stripe = new Stripe($db);
78
79llxHeader('', $langs->trans("StripePayoutList"));
80
81if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE')/* || GETPOST('forcesandbox', 'alpha') */)) {
82 $service = 'StripeTest';
83 $servicestatus = '0';
84 dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), [], 'warning');
85} else {
86 $service = 'StripeLive';
87 $servicestatus = '1';
88}
89
90$stripeacc = $stripe->getStripeAccount($service);
91/*if (empty($stripeaccount))
92{
93 print $langs->trans('ErrorStripeAccountNotDefined');
94}*/
95
96$moreforfilter = '';
97$totalnboflines = -1;
98
99if (!$rowid) {
100 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
101 if ($optioncss != '') {
102 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
103 }
104 print '<input type="hidden" name="token" value="'.newToken().'">';
105 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
106 print '<input type="hidden" name="action" value="list">';
107 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
108 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
109 print '<input type="hidden" name="page" value="'.$page.'">';
110
111 $title = $langs->trans("StripePayoutList");
112 $title .= $form->textwithpicto('', $stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)');
113
114 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit);
115
116 print '<div class="div-table-responsive">';
117 print '<table class="tagtable noborder liste'.(!empty($moreforfilter) ? " listwithfilterbefore" : "").'">'."\n";
118
119 print '<tr class="liste_titre">';
120 print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
121 print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center ');
122 print_liste_field_titre("DateOperation", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center ');
123 print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'left ');
124 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right ');
125 print_liste_field_titre("", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right '); // For info links
126 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'center ');
127 print "</tr>\n";
128
129 print "</tr>\n";
130
131 try {
132 if ($stripeacc) {
133 $payout_all = \Stripe\Payout::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
134 } else {
135 $payout_all = \Stripe\Payout::all(array("limit" => $limit));
136 }
137 '@phan-var-force \Stripe\Payout $payout_all'; // TStripeObject suggested, but is a template
138
139 foreach ($payout_all->data as $payout) {
140 '@phan-var-force \Stripe\Payout $payout'; // TStripeObject suggested, but is a template
141 print '<tr class="oddeven">';
142
143 // Ref
144 if (!empty($stripeacc)) {
145 $connect = $stripeacc.'/';
146 } else {
147 $connect = null;
148 }
149
150 $url = 'https://dashboard.stripe.com/'.$connect.'test/payouts/'.$payout->id;
151 if ($servicestatus) {
152 $url = 'https://dashboard.stripe.com/'.$connect.'payouts/'.$payout->id;
153 }
154
155 print '<td><a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe')." ".dolPrintHTML($payout->id)."</a></td>\n";
156
157 // Date payment
158 print '<td class="center">'.dol_print_date($payout->created, 'dayhour')."</td>\n";
159 // Date payment
160 print '<td class="center">'.dol_print_date($payout->arrival_date, 'dayhour')."</td>\n";
161 // Type
162 print '<td>'.dolPrintHTML($payout->description).'</td>';
163 // Amount
164 print '<td class="right"><span class="amount">'.price(($payout->amount) / 100, 0, '', 1, -1, -1, strtoupper($payout->currency))."</span></td>";
165 // Info links
166 print '<td>';
167 print '<span class="small">';
168 // TODO Add missing link to bank transfer for the num_chq = $payout->id
169 print '</span>';
170 print "</td>";
171 // Status
172 print '<td class="center">';
173 if ($payout->status == 'paid') {
174 print img_picto($langs->trans($payout->status), 'statut4');
175 } elseif ($payout->status == 'pending') {
176 print img_picto($langs->trans($payout->status), 'statut7');
177 } elseif ($payout->status == 'in_transit') {
178 print img_picto($langs->trans($payout->status), 'statut7');
179 } elseif ($payout->status == 'failed') {
180 print img_picto($langs->trans($payout->status), 'statut7');
181 } elseif ($payout->status == 'canceled') {
182 print img_picto($langs->trans($payout->status), 'statut8');
183 }
184 print '</td>';
185 print "</tr>\n";
186 }
187 } catch (Exception $e) {
188 print '<tr><td colspan="6">'.$e->getMessage().'</td></td>';
189 }
190 print "</table>";
191 print '</div>';
192 print '</form>';
193}
194
195// End of page
196llxFooter();
197$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage bank accounts.
Class to manage generation of HTML components Only common components must be here.
Stripe class @TODO No reason to extend CommonObject.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $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, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.