Fix: optimize code

This commit is contained in:
Regis Houssin 2011-05-04 09:34:21 +00:00
parent b6be7472c3
commit d3c2d950a6

View File

@ -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,39 +56,33 @@ $action = GETPOST('action');
$nvpStr=''; $nvpStr='';
$startDateStr=GETPOST('startDateStr');
$endDateStr=GETPOST('endDateStr');
$transactionID=urlencode(GETPOST('transactionID'));
if(isset($endDateStr) && ! empty($startDateStr)) {
$start_time = dol_stringtotime($startDateStr);
$iso_start = dol_print_date($start_time,'dayhourrfc');
$nvpStr="&STARTDATE=$iso_start";
}
if(isset($endDateStr) && ! empty($endDateStr)) {
$end_time = dol_stringtotime($endDateStr);
$iso_end = dol_print_date($end_time,'dayhourrfc');
$nvpStr.="&ENDDATE=$iso_end";
}
if(isset($transactionID) && ! empty($transactionID)) {
$nvpStr=$nvpStr."&TRANSACTIONID=$transactionID";
}
if(isset($startDateStr) && ! empty($startDateStr)) { if(isset($startDateStr) && ! empty($startDateStr)) {
$start_date_str = $startDateStr; $start_date_str = $startDateStr;
$start_time = dol_stringtotime($start_date_str);
} else { } else {
$yesterdayDate = dol_now()-86400; $start_time = dol_now()-86400;
$start_date_str = dol_print_date($yesterdayDate,'day'); $start_date_str = dol_print_date($start_time,'day');
} }
if (isset($endDateStr) && ! empty($startDateStr)) {
$iso_start = dol_print_date($start_time,'dayhourrfc');
$nvpStr.="&STARTDATE=$iso_start";
if(isset($endDateStr) && ! empty($endDateStr)) {
$end_date_str = $endDateStr; $end_date_str = $endDateStr;
$end_time = dol_stringtotime($end_date_str);
} else { } else {
$currentDate = dol_now(); $end_time = dol_now();
$end_date_str = dol_print_date($currentDate,'day'); $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)) {
$nvpStr.="&TRANSACTIONID=$transactionID";
}
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,9 +161,7 @@ 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 '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -206,7 +210,6 @@ if (! empty($nvpStr))
} }
print '</table>'; print '</table>';
}
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');