Works on paypal module
Fix: uniformize code
This commit is contained in:
parent
9421ff4969
commit
e0fe945afd
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
|
||||
*
|
||||
* 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
|
||||
@ -582,6 +582,9 @@ class Commande extends CommonObject
|
||||
}
|
||||
if (! $remise) $remise=0;
|
||||
if (! $this->fk_project) $this->fk_project = 0;
|
||||
|
||||
// $date_commande is deprecated
|
||||
$date = ($this->date_commande ? $this->date_commande : $this->date);
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
@ -593,7 +596,7 @@ class Commande extends CommonObject
|
||||
$sql.= ", entity";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES ('(PROV)',".$this->socid.", ".$this->db->idate(gmmktime()).", ".$user->id.", ".$this->fk_project;
|
||||
$sql.= ", ".$this->db->idate($this->date_commande);
|
||||
$sql.= ", ".$this->db->idate($date);
|
||||
$sql.= ", ".($this->source>=0 && $this->source != '' ?$this->source:'null');
|
||||
$sql.= ", '".$this->db->escape($this->note)."'";
|
||||
$sql.= ", '".$this->db->escape($this->note_public)."'";
|
||||
@ -2402,7 +2405,7 @@ class Commande extends CommonObject
|
||||
function LibStatut($statut,$facturee,$mode)
|
||||
{
|
||||
global $langs;
|
||||
print 'x'.$statut.'-'.$facturee;
|
||||
//print 'x'.$statut.'-'.$facturee;
|
||||
if ($mode == 0)
|
||||
{
|
||||
if ($statut==-1) return $langs->trans('StatusOrderCanceled');
|
||||
|
||||
@ -351,14 +351,10 @@ if ($action == 'add' && $user->rights->commande->creer)
|
||||
{
|
||||
$result=$object->add_contact($_POST["contactidp"],'CUSTOMER','external');
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$error=0;
|
||||
}
|
||||
else
|
||||
if ($result < 0)
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
|
||||
$error=1;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -60,9 +60,11 @@ dol_syslog(join(',',$_GET));
|
||||
|
||||
if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transaction_id']) && ! empty($_GET['transaction_id']) )
|
||||
{
|
||||
if ($_GET['action'] == 'create')
|
||||
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)
|
||||
{
|
||||
@ -130,8 +132,11 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
||||
}
|
||||
}
|
||||
|
||||
// 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))
|
||||
@ -152,7 +157,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
||||
|
||||
$db->begin();
|
||||
|
||||
$object->date_commande = dol_now();
|
||||
$object->date = dol_now();
|
||||
$object->ref_ext = $_SESSION[$_GET['transaction_id']]['SHIPTOCITY'];
|
||||
$object->contactid = $contact->id;
|
||||
|
||||
@ -160,28 +165,64 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
||||
if ($object_id > 0)
|
||||
{
|
||||
$i=0;
|
||||
while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i]))
|
||||
|
||||
// Add element lines
|
||||
while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i]))
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch('',$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]);
|
||||
$ret = $product->fetch('',$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]);
|
||||
|
||||
//$_SESSION[$_GET['transaction_id']]["L_QTY".$i];
|
||||
echo 'ref='.$product->ref.' label='.$product->libelle.'<br>';
|
||||
if ($ret > 0)
|
||||
{
|
||||
$product_type=($product->product_type?$product->product_type:0);
|
||||
|
||||
$result = $object->addline(
|
||||
$object_id,
|
||||
$product->description,
|
||||
$product->price,
|
||||
$_SESSION[$_GET['transaction_id']]["L_QTY".$i],
|
||||
$product->tva_tx,
|
||||
$product->localtax1_tx,
|
||||
$product->localtax2_tx,
|
||||
$product->id,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
'HT',
|
||||
0,
|
||||
'',
|
||||
'',
|
||||
$product_type
|
||||
);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$error++;
|
||||
}
|
||||
|
||||
if ($object_id > 0 && ! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
// Return element id
|
||||
echo 'socid='.$soc->id;
|
||||
|
||||
// Create element (order or bill)
|
||||
/*
|
||||
foreach ($_SESSION[$_GET['transaction_id']] as $key => $value)
|
||||
{
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/paypal/ajaxtransactiondetails.php
|
||||
* \brief File to return Ajax response on paypal transaction details
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
||||
|
||||
require('../main.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php");
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
//header('Cache-Control: Public, must-revalidate');
|
||||
//header('Pragma: public');
|
||||
|
||||
//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
|
||||
top_httphead();
|
||||
|
||||
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||
|
||||
//print '<body class="nocellnopadd">'."\n";
|
||||
|
||||
dol_syslog(join(',',$_GET));
|
||||
|
||||
if (isset($_GET['transaction_id']) && ! empty($_GET['transaction_id']))
|
||||
{
|
||||
$resArray = GetTransactionDetails($_GET['transaction_id']);
|
||||
|
||||
foreach($resArray as $key => $value) {
|
||||
echo $key.': '.$value.'<br />';
|
||||
}
|
||||
|
||||
//print json_encode($resArray);
|
||||
}
|
||||
|
||||
//print "</body>";
|
||||
//print "</html>";
|
||||
?>
|
||||
@ -127,7 +127,7 @@ llxHeader();
|
||||
buttons: {
|
||||
'<?php echo $langs->transnoentities('Create'); ?>': function() {
|
||||
$.get( "<?php echo DOL_URL_ROOT; ?>/paypal/ajaxtransaction.php", {
|
||||
action: 'create',
|
||||
action: 'add',
|
||||
element: 'order',
|
||||
transaction_id: id_value
|
||||
},
|
||||
|
||||
@ -1019,46 +1019,47 @@ class Product extends CommonObject
|
||||
{
|
||||
$result = $this->db->fetch_array($result);
|
||||
|
||||
$this->id = $result["rowid"];
|
||||
$this->ref = $result["ref"];
|
||||
$this->libelle = $result["label"];
|
||||
$this->description = $result["description"];
|
||||
$this->note = $result["note"];
|
||||
$this->customcode = $result["customcode"];
|
||||
$this->country_id = $result["fk_country"];
|
||||
$this->country_code = getCountry($this->country_id,2,$this->db);
|
||||
$this->price = $result["price"];
|
||||
$this->price_ttc = $result["price_ttc"];
|
||||
$this->price_min = $result["price_min"];
|
||||
$this->price_min_ttc = $result["price_min_ttc"];
|
||||
$this->price_base_type = $result["price_base_type"];
|
||||
$this->tva_tx = $result["tva_tx"];
|
||||
$this->id = $result["rowid"];
|
||||
$this->ref = $result["ref"];
|
||||
$this->libelle = $result["label"]; // TODO deprecated
|
||||
$this->label = $result["label"];
|
||||
$this->description = $result["description"];
|
||||
$this->note = $result["note"];
|
||||
$this->customcode = $result["customcode"];
|
||||
$this->country_id = $result["fk_country"];
|
||||
$this->country_code = getCountry($this->country_id,2,$this->db);
|
||||
$this->price = $result["price"];
|
||||
$this->price_ttc = $result["price_ttc"];
|
||||
$this->price_min = $result["price_min"];
|
||||
$this->price_min_ttc = $result["price_min_ttc"];
|
||||
$this->price_base_type = $result["price_base_type"];
|
||||
$this->tva_tx = $result["tva_tx"];
|
||||
//! French VAT NPR
|
||||
$this->tva_npr = $result["tva_npr"];
|
||||
$this->tva_npr = $result["tva_npr"];
|
||||
//! Spanish local taxes
|
||||
$this->localtax1_tx = $result["localtax1_tx"];
|
||||
$this->localtax2_tx = $result["localtax2_tx"];
|
||||
$this->localtax1_tx = $result["localtax1_tx"];
|
||||
$this->localtax2_tx = $result["localtax2_tx"];
|
||||
|
||||
$this->type = $result["fk_product_type"];
|
||||
$this->status = $result["tosell"];
|
||||
$this->status_buy = $result["tobuy"];
|
||||
$this->finished = $result["finished"];
|
||||
$this->hidden = $result["hidden"];
|
||||
$this->duration = $result["duration"];
|
||||
$this->duration_value = substr($result["duration"],0,dol_strlen($result["duration"])-1);
|
||||
$this->duration_unit = substr($result["duration"],-1);
|
||||
$this->seuil_stock_alerte = $result["seuil_stock_alerte"];
|
||||
$this->canvas = $result["canvas"];
|
||||
$this->weight = $result["weight"];
|
||||
$this->weight_units = $result["weight_units"];
|
||||
$this->length = $result["length"];
|
||||
$this->length_units = $result["length_units"];
|
||||
$this->surface = $result["surface"];
|
||||
$this->surface_units = $result["surface_units"];
|
||||
$this->volume = $result["volume"];
|
||||
$this->volume_units = $result["volume_units"];
|
||||
$this->barcode = $result["barcode"];
|
||||
$this->barcode_type = $result["fk_barcode_type"];
|
||||
$this->type = $result["fk_product_type"];
|
||||
$this->status = $result["tosell"];
|
||||
$this->status_buy = $result["tobuy"];
|
||||
$this->finished = $result["finished"];
|
||||
$this->hidden = $result["hidden"];
|
||||
$this->duration = $result["duration"];
|
||||
$this->duration_value = substr($result["duration"],0,dol_strlen($result["duration"])-1);
|
||||
$this->duration_unit = substr($result["duration"],-1);
|
||||
$this->seuil_stock_alerte = $result["seuil_stock_alerte"];
|
||||
$this->canvas = $result["canvas"];
|
||||
$this->weight = $result["weight"];
|
||||
$this->weight_units = $result["weight_units"];
|
||||
$this->length = $result["length"];
|
||||
$this->length_units = $result["length_units"];
|
||||
$this->surface = $result["surface"];
|
||||
$this->surface_units = $result["surface_units"];
|
||||
$this->volume = $result["volume"];
|
||||
$this->volume_units = $result["volume_units"];
|
||||
$this->barcode = $result["barcode"];
|
||||
$this->barcode_type = $result["fk_barcode_type"];
|
||||
|
||||
$this->accountancy_code_buy = $result["accountancy_code_buy"];
|
||||
$this->accountancy_code_sell= $result["accountancy_code_sell"];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user