diff --git a/htdocs/paypal/ajaxtransaction.php b/htdocs/paypal/ajaxtransaction.php index 4fff6d27568..51e2e07833a 100644 --- a/htdocs/paypal/ajaxtransaction.php +++ b/htdocs/paypal/ajaxtransaction.php @@ -63,7 +63,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti if ($_GET['action'] == 'add') { $soc = new Societe($db); - + // Create customer if not exists $ret = $soc->fetchObjectFromRefExt($soc->table_element,$_SESSION[$_GET['transaction_id']]['PAYERID']); if ($ret < 0) @@ -77,7 +77,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti } require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); $modCodeClient = new $module; - + // Create customer and return rowid $soc->ref_ext = $_SESSION[$_GET['transaction_id']]['PAYERID']; $soc->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_SESSION[$_GET['transaction_id']]['FIRSTNAME'].' '.$_SESSION[$_GET['transaction_id']]['LASTNAME']):trim($_SESSION[$_GET['transaction_id']]['LASTNAME'].' '.$_SESSION[$_GET['transaction_id']]['FIRSTNAME']); @@ -92,7 +92,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti $soc->tva_assuj = 1; $soc->client = 1; $soc->particulier = 1; - + $db->begin(); $result = $soc->create($user); if ($result >= 0) @@ -100,7 +100,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti if ($soc->particulier) { $contact=new Contact($db); - + $contact->civilite_id = $soc->civilite_id; $contact->name=$soc->nom_particulier; $contact->firstname=$soc->prenom; @@ -114,11 +114,11 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti $contact->status=1; $contact->email=$soc->email; $contact->priv=0; - + $result=$contact->create($user); } } - + if ($result >= 0) { $db->commit(); @@ -131,12 +131,12 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti echo $langs->trans($soc->error); } } - + // Add element (order, bill, etc.) if ($soc->id > 0 && isset($_GET['element']) && ! empty($_GET['element'])) { $error=0; - + // Parse element/subelement (ex: project_task) $element = $subelement = $_GET['element']; if (preg_match('/^([^_]+)_([^_]+)/i',$_GET['element'],$regs)) @@ -151,30 +151,31 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti $classname = ucfirst($subelement); $object = new $classname($db); - + $object->socid=$soc->id; $object->fetch_thirdparty(); - + $db->begin(); - + $object->date = dol_now(); $object->ref_ext = $_SESSION[$_GET['transaction_id']]['SHIPTOCITY']; - + $object_id = $object->create($user); if ($object_id > 0) { $i=0; - + // Add element lines while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i])) { $product = new Product($db); + $ret = $product->fetch('',$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]); if ($ret > 0) { $product_type=($product->product_type?$product->product_type:0); - + $result = $object->addline( $object_id, $product->description, @@ -193,17 +194,17 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti '', $product_type ); - + if ($result < 0) { $error++; break; } } - + $i++; } - + // Insert default contacts /* if ($contact->id > 0) @@ -217,7 +218,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti { $error++; } - + if ($object_id > 0 && ! $error) { $db->commit(); @@ -230,27 +231,27 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti // Return element id echo $object->getNomUrl(0,0,1); - + /* foreach ($_SESSION[$_GET['transaction_id']] as $key => $value) { echo $key.': '.$value.'
'; } */ - + } else if ($_GET['action'] == 'showdetails') { // For paypal request optimization if (! isset($_SESSION[$_GET['transaction_id']]) ) $_SESSION[$_GET['transaction_id']] = GetTransactionDetails($_GET['transaction_id']); - + $var=true; - + echo ''; echo ''; - echo ''; + echo ''; echo ''; - + $var=!$var; echo ''; $var=!$var; @@ -265,36 +266,36 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti echo ''; $var=!$var; echo ''; - + echo '
'.$langs->trans('CustomerDetails').''.$langs->trans('ThirdParty').'
'.$langs->trans('LastName').': '.$_SESSION[$_GET['transaction_id']]['LASTNAME'].'
'.$langs->trans('Email').': '.$_SESSION[$_GET['transaction_id']]['EMAIL'].'
'.$langs->trans('Date').': '.dol_print_date(dol_stringtotime($_SESSION[$_GET['transaction_id']]['ORDERTIME']),'dayhour').'
'; - + $i=0; - + echo ''; - + echo ''; echo ''; echo ''; echo ''; echo ''; - + while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i])) { $var=!$var; - + echo ''; echo ''; echo ''; echo ''; echo ''; - + $i++; } - + echo '
'.$langs->trans('Ref').''.$langs->trans('Label').''.$langs->trans('Qty').'
'.$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i].''.$_SESSION[$_GET['transaction_id']]["L_NAME".$i].''.$_SESSION[$_GET['transaction_id']]["L_QTY".$i].'
'; -/* +/* echo '
'; - + foreach ($_SESSION[$_GET['transaction_id']] as $key => $value) { echo $key.': '.$value.'
'; diff --git a/htdocs/paypal/transaction.php b/htdocs/paypal/transaction.php index d1e37cfbf69..f7bad49e279 100644 --- a/htdocs/paypal/transaction.php +++ b/htdocs/paypal/transaction.php @@ -24,10 +24,13 @@ */ require("../main.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/date.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'); require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php"); $langs->load("paypal"); +$langs->load("paybox"); +$langs->load("companies"); // Security check $result=restrictedArea($user,'paypal','','','transaction'); @@ -58,11 +61,13 @@ $errors=''; $nvpStr=''; +$now=dol_now(); + if(isset($startDateStr) && ! empty($startDateStr)) { $start_date_str = $startDateStr; $start_time = dol_stringtotime($start_date_str); } else { - $start_time = dol_now()-2592000; // 30 days + $start_time = dol_time_plus_duree($now,-1,'m'); // 30 days $start_date_str = dol_print_date($start_time,'day'); } @@ -71,22 +76,40 @@ $nvpStr.="&STARTDATE=$iso_start"; if(isset($endDateStr) && ! empty($endDateStr)) { $end_date_str = $endDateStr; - $end_time = dol_stringtotime($end_date_str); + $end_time = dol_stringtotime($end_date_str); } else { - $end_time = dol_now(); + $end_time = $now; $end_date_str = dol_print_date($end_time,'day'); } $iso_end = dol_print_date($end_time,'dayhourrfc'); -$nvpStr.="&ENDDATE=$iso_end"; +$nvpStr.="&ENDDATE=".$iso_end; if(isset($transactionID) && ! empty($transactionID)) { $nvpStr.="&TRANSACTIONID=$transactionID"; } + llxHeader(); +dol_htmloutput_errors('',$errors); + +print_fiche_titre(' - '.$langs->trans('PaypalTransaction'), '', 'paypal_logo@paypal'); + +print '
'; + +if (empty($conf->global->PAYPAL_API_USER) || empty($conf->global->PAYPAL_API_PASSWORD) + || empty($conf->global->PAYPAL_API_SIGNATURE)) +{ + $langs->load("errors"); + print $langs->trans("ErrorModuleSetupNotComplete"); + + llxFooter(); + exit; +} + + ?>