Fix: optimize code
This commit is contained in:
parent
b6be7472c3
commit
d3c2d950a6
@ -29,11 +29,20 @@ require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php");
|
|||||||
|
|
||||||
$langs->load("paypal");
|
$langs->load("paypal");
|
||||||
|
|
||||||
$action = GETPOST('action');
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
//$result=restrictedArea($user,'paypal');
|
//$result=restrictedArea($user,'paypal');
|
||||||
|
|
||||||
|
$action = GETPOST('action');
|
||||||
|
$page = GETPOST("page",'int');
|
||||||
|
$startDateStr=GETPOST('startDateStr');
|
||||||
|
$endDateStr=GETPOST('endDateStr');
|
||||||
|
$transactionID=urlencode(GETPOST('transactionID'));
|
||||||
|
|
||||||
|
if ($page == -1) { $page = 0; }
|
||||||
|
$offset = $conf->liste_limit * $page;
|
||||||
|
$pageprev = $page - 1;
|
||||||
|
$pagenext = $page + 1;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -47,38 +56,32 @@ $action = GETPOST('action');
|
|||||||
|
|
||||||
$nvpStr='';
|
$nvpStr='';
|
||||||
|
|
||||||
$startDateStr=GETPOST('startDateStr');
|
if(isset($startDateStr) && ! empty($startDateStr)) {
|
||||||
$endDateStr=GETPOST('endDateStr');
|
$start_date_str = $startDateStr;
|
||||||
$transactionID=urlencode(GETPOST('transactionID'));
|
$start_time = dol_stringtotime($start_date_str);
|
||||||
|
} else {
|
||||||
if(isset($endDateStr) && ! empty($startDateStr)) {
|
$start_time = dol_now()-86400;
|
||||||
$start_time = dol_stringtotime($startDateStr);
|
$start_date_str = dol_print_date($start_time,'day');
|
||||||
$iso_start = dol_print_date($start_time,'dayhourrfc');
|
|
||||||
$nvpStr="&STARTDATE=$iso_start";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$iso_start = dol_print_date($start_time,'dayhourrfc');
|
||||||
|
$nvpStr.="&STARTDATE=$iso_start";
|
||||||
|
|
||||||
if(isset($endDateStr) && ! empty($endDateStr)) {
|
if(isset($endDateStr) && ! empty($endDateStr)) {
|
||||||
$end_time = dol_stringtotime($endDateStr);
|
$end_date_str = $endDateStr;
|
||||||
$iso_end = dol_print_date($end_time,'dayhourrfc');
|
$end_time = dol_stringtotime($end_date_str);
|
||||||
$nvpStr.="&ENDDATE=$iso_end";
|
} else {
|
||||||
|
$end_time = dol_now();
|
||||||
|
$end_date_str = dol_print_date($end_time,'day');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$iso_end = dol_print_date($end_time,'dayhourrfc');
|
||||||
|
$nvpStr.="&ENDDATE=$iso_end";
|
||||||
|
|
||||||
if(isset($transactionID) && ! empty($transactionID)) {
|
if(isset($transactionID) && ! empty($transactionID)) {
|
||||||
$nvpStr=$nvpStr."&TRANSACTIONID=$transactionID";
|
$nvpStr.="&TRANSACTIONID=$transactionID";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($startDateStr) && ! empty($startDateStr)) {
|
|
||||||
$start_date_str = $startDateStr;
|
|
||||||
} else {
|
|
||||||
$yesterdayDate = dol_now()-86400;
|
|
||||||
$start_date_str = dol_print_date($yesterdayDate,'day');
|
|
||||||
}
|
|
||||||
if (isset($endDateStr) && ! empty($startDateStr)) {
|
|
||||||
$end_date_str = $endDateStr;
|
|
||||||
} else {
|
|
||||||
$currentDate = dol_now();
|
|
||||||
$end_date_str = dol_print_date($currentDate,'day');
|
|
||||||
}
|
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
@ -110,6 +113,8 @@ llxHeader();
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
print_barre_liste($langs->trans('PaypalTransaction'), $page, $_SERVER['PHP_SELF']);
|
||||||
|
|
||||||
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
|
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
|
||||||
@ -138,6 +143,7 @@ print '</table>';
|
|||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
|
|
||||||
|
// Call Paypal API
|
||||||
if (! empty($nvpStr))
|
if (! empty($nvpStr))
|
||||||
{
|
{
|
||||||
$resArray=hash_call("TransactionSearch",$nvpStr);
|
$resArray=hash_call("TransactionSearch",$nvpStr);
|
||||||
@ -155,59 +161,56 @@ if (! empty($nvpStr))
|
|||||||
header("Location: $location");
|
header("Location: $location");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
print_barre_liste($title, $_GET['page'], $_SERVER['PHP_SELF'],'',$sortfield,$sortorder,'',$num);
|
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print_liste_field_titre($langs->trans('ID'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'width="25%"',$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'align="center"',$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'align="center"',$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans('ThirdPartyName'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans('GrossAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans('FeeAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans('NetAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
if(! isset($resArray["L_TRANSACTIONID0"]))
|
|
||||||
{
|
|
||||||
print '<tr>';
|
|
||||||
print '<td colspan="6">'.$langs->trans("NoTransactionSelected").'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$i=0;
|
|
||||||
|
|
||||||
while (isset($resArray["L_TRANSACTIONID".$i]))
|
|
||||||
{
|
|
||||||
$transactionID = $resArray["L_TRANSACTIONID".$i];
|
|
||||||
$timeStamp = dol_stringtotime($resArray["L_TIMESTAMP".$i]);
|
|
||||||
$payerName = $resArray["L_NAME".$i];
|
|
||||||
$amount = $resArray["L_AMT".$i];
|
|
||||||
$feeamount = $resArray["L_FEEAMT".$i];
|
|
||||||
$netamount = $resArray["L_NETAMT".$i];
|
|
||||||
$currency = $resArray["L_CURRENCYCODE".$i];
|
|
||||||
$status = $resArray["L_STATUS".$i];
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td><a id="transactiondetailslink'.$i.'" href="details.php?transactionID='.$transactionID.'">'.$transactionID.'</a></td>';
|
|
||||||
print '<td align="center">'.dol_print_date($timeStamp,'dayhour').'</td>';
|
|
||||||
print '<td align="center">'.$status.'</td>';
|
|
||||||
print '<td align="right">'.$payerName.'</td>';
|
|
||||||
print '<td align="right">'.$amount.' '.$currency.'</td>';
|
|
||||||
print '<td align="right">'.$feeamount.' '.$currency.'</td>';
|
|
||||||
print '<td align="right">'.$netamount.' '.$currency.'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print_liste_field_titre($langs->trans('ID'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'width="25%"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'align="center"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'align="center"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans('ThirdPartyName'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans('GrossAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans('FeeAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans('NetAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
if(! isset($resArray["L_TRANSACTIONID0"]))
|
||||||
|
{
|
||||||
|
print '<tr>';
|
||||||
|
print '<td colspan="6">'.$langs->trans("NoTransactionSelected").'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$i=0;
|
||||||
|
|
||||||
|
while (isset($resArray["L_TRANSACTIONID".$i]))
|
||||||
|
{
|
||||||
|
$transactionID = $resArray["L_TRANSACTIONID".$i];
|
||||||
|
$timeStamp = dol_stringtotime($resArray["L_TIMESTAMP".$i]);
|
||||||
|
$payerName = $resArray["L_NAME".$i];
|
||||||
|
$amount = $resArray["L_AMT".$i];
|
||||||
|
$feeamount = $resArray["L_FEEAMT".$i];
|
||||||
|
$netamount = $resArray["L_NETAMT".$i];
|
||||||
|
$currency = $resArray["L_CURRENCYCODE".$i];
|
||||||
|
$status = $resArray["L_STATUS".$i];
|
||||||
|
|
||||||
|
print '<tr>';
|
||||||
|
print '<td><a id="transactiondetailslink'.$i.'" href="details.php?transactionID='.$transactionID.'">'.$transactionID.'</a></td>';
|
||||||
|
print '<td align="center">'.dol_print_date($timeStamp,'dayhour').'</td>';
|
||||||
|
print '<td align="center">'.$status.'</td>';
|
||||||
|
print '<td align="right">'.$payerName.'</td>';
|
||||||
|
print '<td align="right">'.$amount.' '.$currency.'</td>';
|
||||||
|
print '<td align="right">'.$feeamount.' '.$currency.'</td>';
|
||||||
|
print '<td align="right">'.$netamount.' '.$currency.'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$');
|
llxFooter('$Date$ - $Revision$');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user