Merge pull request #9507 from frederic34/stripetransac

clean code indentation completely broken
This commit is contained in:
Laurent Destailleur 2018-09-15 17:27:20 +02:00 committed by GitHub
commit 8ceee52d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 210 additions and 196 deletions

View File

@ -9,6 +9,7 @@
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 ThibaultFOUCART <support@ptibogxiv.net> * Copyright (C) 2018 ThibaultFOUCART <support@ptibogxiv.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -218,13 +219,10 @@ if (empty($reshook))
/* /*
* Action add_paiement * Action add_paiement
*/ */
if ($action == 'add_paiement') if ($action == 'add_paiement') {
{ if ($error) {
if ($error)
{
$action = 'create'; $action = 'create';
if (!$source) if (!$source) {
{
setEventMessages($langs->transnoentities('NoSource'), null, 'errors'); setEventMessages($langs->transnoentities('NoSource'), null, 'errors');
} }
$error++; $error++;
@ -410,12 +408,10 @@ $form=new Form($db);
llxHeader(); llxHeader();
if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) {
{
$service = 'StripeLive'; $service = 'StripeLive';
$servicestatus = 0; $servicestatus = 0;
} } else {
else {
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
} }
@ -627,7 +623,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<tr>'; print '<tr>';
print '<td align="center" width="20" '; print '<td align="center" width="20" ';
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
print'class="opacitymedium"';
}
print '><input type="radio" id="source_id" class="flat" name="source_id" value="'.$src->id.'"'; print '><input type="radio" id="source_id" class="flat" name="source_id" value="'.$src->id.'"';
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
print ' disabled'; print ' disabled';
@ -637,62 +635,61 @@ if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source'
print '></td>'; print '></td>';
print '<td '; print '<td ';
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
print'class="opacitymedium"';
}
print' >'; print' >';
if ($src->object=='card') if ($src->object=='card') {
{
print img_credit_card($src->brand); print img_credit_card($src->brand);
} } elseif ($src->object=='source' && $src->type=='card') {
elseif ($src->object=='source' && $src->type=='card')
{
print img_credit_card($src->card->brand); print img_credit_card($src->card->brand);
} } elseif ($src->object=='source' && $src->type=='sepa_debit') {
elseif ($src->object=='source' && $src->type=='sepa_debit')
{
print '<span class="fa fa-university fa-2x fa-fw"></span>'; print '<span class="fa fa-university fa-2x fa-fw"></span>';
} }
print '</td>'; print '</td>';
print '<td '; print '<td ';
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
print'class="opacitymedium"';
}
print' >'; print' >';
if ($src->object=='card') { if ($src->object=='card') {
print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.'';
print '</td><td>'; print '</td><td>';
if ($src->country) if ($src->country) {
{
$img = picto_from_langcode($src->country); $img = picto_from_langcode($src->country);
print $img?$img.' ':''; print $img?$img.' ':'';
print getCountry($src->country,1); print getCountry($src->country,1);
} else {
print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
} }
else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; } elseif ($src->object=='source' && $src->type=='card') {
}
elseif ($src->object=='source' && $src->type=='card'){
print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
print '</td><td>'; print '</td><td>';
if ($src->card->country) if ($src->card->country) {
{
$img = picto_from_langcode($src->card->country); $img = picto_from_langcode($src->card->country);
print $img?$img.' ':''; print $img?$img.' ':'';
print getCountry($src->card->country,1); print getCountry($src->card->country,1);
} else {
print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
} }
else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; } elseif ($src->object=='source' && $src->type=='sepa_debit') {
}
elseif ($src->object=='source' && $src->type=='sepa_debit'){
print 'info sepa'; print 'info sepa';
print '</td><td>'; print '</td><td>';
if ($src->sepa_debit->country) if ($src->sepa_debit->country) {
{
$img = picto_from_langcode($src->sepa_debit->country); $img = picto_from_langcode($src->sepa_debit->country);
print $img?$img.' ':''; print $img?$img.' ':'';
print getCountry($src->sepa_debit->country,1); print getCountry($src->sepa_debit->country,1);
} else {
print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
} }
else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
} }
print '</td>'; print '</td>';
// Default // Default
print '<td align="center" width="50" '; print '<td align="center" width="50" ';
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) {
print'class="opacitymedium"';
}
print'>'; print'>';
if (($customerstripe->default_source==$src->id)) { if (($customerstripe->default_source==$src->id)) {
print "<SPAN class=' fa fa-star fa-2x'></SPAN>"; print "<SPAN class=' fa fa-star fa-2x'></SPAN>";
@ -709,7 +706,9 @@ print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td align="center" width="20" '; print '<td align="center" width="20" ';
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) {
print'class="opacitymedium"';
}
print'><input type="radio" id="source_id" class="flat" name="source_id" value="'.$conf->global->STRIPE_EXTERNAL_ACCOUNT.'"'; print'><input type="radio" id="source_id" class="flat" name="source_id" value="'.$conf->global->STRIPE_EXTERNAL_ACCOUNT.'"';
if ((empty($input) && $action != 'add_paiement') or ($source==$conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { if ((empty($input) && $action != 'add_paiement') or ($source==$conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) {
print ' checked'; print ' checked';
@ -717,20 +716,28 @@ print '</tr>';
print ' disabled'; print ' disabled';
} }
print '></td><td '; print '></td><td ';
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) {
print'class="opacitymedium"';
}
print '><span class="fa fa-cc-stripe fa-3x fa-fw"></span></td>'; print '><span class="fa fa-cc-stripe fa-3x fa-fw"></span></td>';
print '<td '; print '<td ';
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) {
print'class="opacitymedium"';
}
print'>'.$langs->trans('sold'); print'>'.$langs->trans('sold');
print'</td><td '; print'</td><td ';
if ($action == 'add_paiement' && $src->id!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $src->id!=$source) {
print'class="opacitymedium"';
}
print'>'; print'>';
print '</td>'; print '</td>';
// Default // Default
print '<td align="center" width="50" '; print '<td align="center" width="50" ';
if ($action == 'add_paiement' && $src->id!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $src->id!=$source) {
print'class="opacitymedium"';
}
print'>'; print'>';
//if (($customer->default_source!=$src->id)) { //if (($customer->default_source!=$src->id)) {
// print img_picto($langs->trans("Disabled"),'off'); // print img_picto($langs->trans("Disabled"),'off');
@ -740,8 +747,7 @@ print '</tr>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) {
{
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>'; print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
} }
@ -1023,9 +1029,10 @@ print '</tr>';
$preselectedchoice=$addwarning?'no':'yes'; $preselectedchoice=$addwarning?'no':'yes';
print '<br>'; print '<br>';
if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); if (!empty($totalpayment)) {
if (!empty($multicurrency_totalpayment)) $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency));
{ }
if (!empty($multicurrency_totalpayment)) {
$text.='<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); $text.='<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency"));
} }
if (GETPOST('closepaidinvoices')) if (GETPOST('closepaidinvoices'))

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2018 PtibogXIV <support@ptibogxiv.net> /* Copyright (C) 2018 PtibogXIV <support@ptibogxiv.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,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.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.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 // Load translation files required by the page
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
@ -77,25 +80,26 @@ $stripeaccount = $stripe->getStripeAccount($service);
if (! $rowid) { if (! $rowid) {
print '<FORM method="POST" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
if ($optioncss != '') if ($optioncss != '') {
print '<INPUT type="hidden" name="optioncss" value="' . $optioncss . '">'; print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
print '<INPUT type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; }
print '<INPUT type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<INPUT type="hidden" name="action" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<INPUT type="hidden" name="sortfield" value="' . $sortfield . '">'; print '<input type="hidden" name="action" value="list">';
print '<INPUT type="hidden" name="sortorder" value="' . $sortorder . '">'; print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
print '<INPUT type="hidden" name="page" value="' . $page . '">'; print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
print '<input type="hidden" name="page" value="' . $page . '">';
$title=$langs->trans("StripeTransactionList"); $title=$langs->trans("StripeTransactionList");
$title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeaccount.')':' (Stripe connection with keys from Stripe module setup)'); $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeaccount.')':' (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, '', '', $limit);
print '<DIV class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<TABLE class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n"; print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
print '<TR class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
//print_liste_field_titre("StripeCustomerId",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); //print_liste_field_titre("StripeCustomerId",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
//print_liste_field_titre("CustomerId", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); //print_liste_field_titre("CustomerId", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
@ -105,9 +109,9 @@ if (! $rowid) {
print_liste_field_titre("Paid", $_SERVER["PHP_SELF"], "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Paid", $_SERVER["PHP_SELF"], "", "", "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Fee", $_SERVER["PHP_SELF"], "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Fee", $_SERVER["PHP_SELF"], "", "", "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", 'align="right"'); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", 'align="right"');
print "</TR>\n"; print "</tr>\n";
print "</TR>\n"; print "</tr>\n";
if ($stripeaccount) if ($stripeaccount)
{ {
@ -155,14 +159,14 @@ if (! $rowid) {
$societestatic->email = $obj->email; $societestatic->email = $obj->email;
$societestatic->societe_id = $obj->fk_soc; $societestatic->societe_id = $obj->fk_soc;
print '<TR class="oddeven">'; print '<tr class="oddeven">';
// Ref // Ref
print "<TD><A href='" . DOL_URL_ROOT . "/stripe/transaction.php?rowid=" . $txn->source . "'>" . $txn->source . "</A></TD>\n"; print "<td><a href='" . DOL_URL_ROOT . "/stripe/transaction.php?rowid=" . $txn->source . "'>" . $txn->source . "</A></td>\n";
// Stripe customer // Stripe customer
//print "<TD>".$charge->customer."</TD>\n"; //print "<td>".$charge->customer."</td>\n";
// Link // Link
/*print "<TD>"; /*print "<td>";
if ($societestatic->id > 0) if ($societestatic->id > 0)
{ {
print $societestatic->getNomUrl(1); print $societestatic->getNomUrl(1);
@ -171,8 +175,9 @@ if (! $rowid) {
{ {
print $memberstatic->getNomUrl(1); print $memberstatic->getNomUrl(1);
} }
print "</TD>\n";*/ print "</td>\n";*/
// Origine // Origine
//print "<TD>"; //print "<TD>";
////if ($charge->metadata->dol_type=="order"){ ////if ($charge->metadata->dol_type=="order"){
// $object = new Commande($db); // $object = new Commande($db);
@ -185,27 +190,29 @@ if (! $rowid) {
//} //}
//print "</TD>\n"; //print "</TD>\n";
// Date payment // Date payment
print '<TD align="center">' . dol_print_date($txn->created, '%d/%m/%Y %H:%M') . "</TD>\n"; print '<td align="center">' . dol_print_date($txn->created, '%d/%m/%Y %H:%M') . "</td>\n";
// Type // Type
print '<TD>' . $txn->type . '</TD>'; print '<td>' . $txn->type . '</td>';
// Amount // Amount
print "<TD align=\"right\">" . price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)) . "</TD>"; print "<td align=\"right\">" . price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)) . "</td>";
print "<TD align=\"right\">" . price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)) . "</TD>"; print "<td align=\"right\">" . price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)) . "</td>";
// Status // Status
print "<TD align='right'>"; print "<td align='right'>";
if ($txn->status=='available') if ($txn->status=='available')
{print img_picto($langs->trans("".$txn->status.""),'statut4');} {
print img_picto($langs->trans("".$txn->status.""),'statut4');}
elseif ($txn->status=='pending') elseif ($txn->status=='pending')
{print img_picto($langs->trans("".$txn->status.""),'statut7');} {print img_picto($langs->trans("".$txn->status.""),'statut7');}
elseif ($txn->status=='failed') elseif ($txn->status=='failed')
{print img_picto($langs->trans("".$txn->status.""),'statut8');} {
print '</TD>'; print img_picto($langs->trans("".$txn->status.""),'statut8');}
print "</TR>\n"; print '</td>';
print "</tr>\n";
}
print "</table>";
print '</div>';
print '</form>';
} }
print "</TABLE>";
print '</DIV>';
print '</FORM>';
} else {}
// End of page // End of page
llxFooter(); llxFooter();