Works on paypal module
Fix: better error management
This commit is contained in:
parent
975012c6cf
commit
6d56cc196b
@ -2469,16 +2469,15 @@ class Commande extends CommonObject
|
|||||||
* @param option Where point the link
|
* @param option Where point the link
|
||||||
* @return string String with URL
|
* @return string String with URL
|
||||||
*/
|
*/
|
||||||
function getNomUrl($withpicto=0,$option=0,$short=0)
|
function getNomUrl($withpicto=0,$option=0,$max=0,$short=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$result='';
|
$result='';
|
||||||
|
|
||||||
$file = '/commande/fiche.php';
|
if ($conf->expedition->enabled && ($option == 1 || $option == 2)) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id;
|
||||||
if ($conf->expedition->enabled && ($option == 1 || $option == 2)) $file = '/expedition/shipment.php';
|
else $url = DOL_URL_ROOT.'/commande/fiche.php?id='.$this->id;
|
||||||
|
|
||||||
$url = DOL_URL_ROOT.$file.'?id='.$this->id;
|
|
||||||
if ($short) return $url;
|
if ($short) return $url;
|
||||||
|
|
||||||
$linkstart = '<a href="'.$url.'">';
|
$linkstart = '<a href="'.$url.'">';
|
||||||
|
|||||||
@ -151,6 +151,7 @@ class Facture extends CommonObject
|
|||||||
$this->note=trim($this->note);
|
$this->note=trim($this->note);
|
||||||
$this->note_public=trim($this->note_public);
|
$this->note_public=trim($this->note_public);
|
||||||
if (! $this->remise) $this->remise = 0;
|
if (! $this->remise) $this->remise = 0;
|
||||||
|
if (! $this->cond_reglement_id) $this->cond_reglement_id = 0;
|
||||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||||
$this->brouillon = 1;
|
$this->brouillon = 1;
|
||||||
|
|
||||||
@ -605,22 +606,19 @@ class Facture extends CommonObject
|
|||||||
* @param max Maxlength of ref
|
* @param max Maxlength of ref
|
||||||
* @return string String with URL
|
* @return string String with URL
|
||||||
*/
|
*/
|
||||||
function getNomUrl($withpicto=0,$option='',$max=0)
|
function getNomUrl($withpicto=0,$option='',$max=0,$short=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$result='';
|
$result='';
|
||||||
|
|
||||||
if ($option == 'withdraw')
|
if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id;
|
||||||
{
|
else $url = DOL_URL_ROOT.'/compta/facture.php?facid='.$this->id;
|
||||||
$lien = '<a href="'.DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id.'">';
|
|
||||||
$lienfin='</a>';
|
if ($short) return $url;
|
||||||
}
|
|
||||||
else
|
$linkstart='<a href="'.$url.'">';
|
||||||
{
|
$linkend='</a>';
|
||||||
$lien = '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$this->id.'">';
|
|
||||||
$lienfin='</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$picto='bill';
|
$picto='bill';
|
||||||
if ($this->type == 1) $picto.='r'; // Replacement invoice
|
if ($this->type == 1) $picto.='r'; // Replacement invoice
|
||||||
@ -632,9 +630,9 @@ class Facture extends CommonObject
|
|||||||
if ($this->type == 2) $label=$langs->trans("ShowInvoiceAvoir").': '.$this->ref;
|
if ($this->type == 2) $label=$langs->trans("ShowInvoiceAvoir").': '.$this->ref;
|
||||||
if ($this->type == 3) $label=$langs->trans("ShowInvoiceDeposit").': '.$this->ref;
|
if ($this->type == 3) $label=$langs->trans("ShowInvoiceDeposit").': '.$this->ref;
|
||||||
|
|
||||||
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
|
if ($withpicto) $result.=($linkstart.img_object($label,$picto).$linkend);
|
||||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||||
if ($withpicto != 2) $result.=$lien.($max?dol_trunc($this->ref,$max):$this->ref).$lienfin;
|
if ($withpicto != 2) $result.=$linkstart.($max?dol_trunc($this->ref,$max):$this->ref).$linkend;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -79,3 +79,4 @@ ErrorBadMask=Error on mask
|
|||||||
ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number
|
ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number
|
||||||
ErrorBadMaskBadRazMonth=Error, bad reset value
|
ErrorBadMaskBadRazMonth=Error, bad reset value
|
||||||
ErrorSelectAtLeastOne=Error. Select at least one entry.
|
ErrorSelectAtLeastOne=Error. Select at least one entry.
|
||||||
|
ErrorProductWithRefNotExist=Product with reference '<i>%s</i>' don't exist
|
||||||
@ -18,7 +18,9 @@ PAYPAL_CSS_URL=Optionnal Url of CSS style sheet on payment page
|
|||||||
ThisIsTransactionId=This is id of transaction: <b>%s</b>
|
ThisIsTransactionId=This is id of transaction: <b>%s</b>
|
||||||
PaypalTransactionDesc=This options allows you to import Paypal payments in Dolibarr as orders, invoices, etc ...
|
PaypalTransactionDesc=This options allows you to import Paypal payments in Dolibarr as orders, invoices, etc ...
|
||||||
PaypalEnableThisTool=Enable this functionnality
|
PaypalEnableThisTool=Enable this functionnality
|
||||||
|
Verified=Verified
|
||||||
Unverified=Unverified
|
Unverified=Unverified
|
||||||
|
Confirmed=Confirmed
|
||||||
Unconfirmed=Unconfirmed
|
Unconfirmed=Unconfirmed
|
||||||
GrossAmount=Gross amount
|
GrossAmount=Gross amount
|
||||||
FeeAmount=Fee amount
|
FeeAmount=Fee amount
|
||||||
|
|||||||
@ -80,3 +80,4 @@ ErrorBadMask=Erreur sur le masque
|
|||||||
ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence
|
ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence
|
||||||
ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro
|
ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro
|
||||||
ErrorSelectAtLeastOne=Erreur. Sélectionnez au moins une entrée.
|
ErrorSelectAtLeastOne=Erreur. Sélectionnez au moins une entrée.
|
||||||
|
ErrorProductWithRefNotExist=La référence produit '<i>%s</i>' n'existe pas
|
||||||
@ -18,7 +18,9 @@ PAYPAL_CSS_URL=Url optionnelle de la feuille de style CSS de la page de paiement
|
|||||||
ThisIsTransactionId=Voici l'identifiant de la transaction: <b>%s</b>
|
ThisIsTransactionId=Voici l'identifiant de la transaction: <b>%s</b>
|
||||||
PaypalTransactionDesc=Ces options permettent d'importer des paiements Paypal dans Dolibarr en tant que commandes, factures, etc...
|
PaypalTransactionDesc=Ces options permettent d'importer des paiements Paypal dans Dolibarr en tant que commandes, factures, etc...
|
||||||
PaypalEnableThisTool=Activer ces fonctionnalités
|
PaypalEnableThisTool=Activer ces fonctionnalités
|
||||||
|
Verified=Vérifié
|
||||||
Unverified=Non vérifié
|
Unverified=Non vérifié
|
||||||
|
Confirmed=Confirmée
|
||||||
Unconfirmed=Non confirmée
|
Unconfirmed=Non confirmée
|
||||||
GrossAmount=Montant brut
|
GrossAmount=Montant brut
|
||||||
FeeAmount=Frais Paypal
|
FeeAmount=Frais Paypal
|
||||||
|
|||||||
@ -64,6 +64,9 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
{
|
{
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
$return_arr = array();
|
||||||
|
|
||||||
// Create customer if not exists
|
// Create customer if not exists
|
||||||
$ret = $soc->fetchObjectFromRefExt($soc->table_element,$_SESSION[$_GET['transaction_id']]['PAYERID']);
|
$ret = $soc->fetchObjectFromRefExt($soc->table_element,$_SESSION[$_GET['transaction_id']]['PAYERID']);
|
||||||
if ($ret < 0)
|
if ($ret < 0)
|
||||||
@ -116,27 +119,34 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
$contact->priv=0;
|
$contact->priv=0;
|
||||||
|
|
||||||
$result=$contact->create($user);
|
$result=$contact->create($user);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$return_arr['error'] = 'Contact::create '.$langs->trans($contact->error);
|
||||||
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$return_arr['error'] = 'Societe::create '.$langs->trans($soc->error);
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if ($result >= 0)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
$langs->load("errors");
|
|
||||||
echo $langs->trans($contact->error);
|
|
||||||
echo $langs->trans($soc->error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add element (order, bill, etc.)
|
// Add element (order, bill, etc.)
|
||||||
if ($soc->id > 0 && isset($_GET['element']) && ! empty($_GET['element']))
|
if (! $error && $soc->id > 0 && isset($_GET['element']) && ! empty($_GET['element']))
|
||||||
{
|
{
|
||||||
$error=0;
|
|
||||||
|
|
||||||
// Parse element/subelement (ex: project_task)
|
// Parse element/subelement (ex: project_task)
|
||||||
$element = $subelement = $_GET['element'];
|
$element = $subelement = $_GET['element'];
|
||||||
if (preg_match('/^([^_]+)_([^_]+)/i',$_GET['element'],$regs))
|
if (preg_match('/^([^_]+)_([^_]+)/i',$_GET['element'],$regs))
|
||||||
@ -146,6 +156,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
}
|
}
|
||||||
// For compatibility
|
// For compatibility
|
||||||
if ($element == 'order') { $element = $subelement = 'commande'; }
|
if ($element == 'order') { $element = $subelement = 'commande'; }
|
||||||
|
if ($element == 'invoice') { $element = 'compta/facture'; $subelement = 'facture'; }
|
||||||
|
|
||||||
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||||
|
|
||||||
@ -173,54 +184,43 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
|
|
||||||
if ($ret > 0)
|
if ($ret > 0)
|
||||||
{
|
{
|
||||||
|
$qty=$_SESSION[$_GET['transaction_id']]["L_QTY".$i];
|
||||||
$product_type=($product->product_type?$product->product_type:0);
|
$product_type=($product->product_type?$product->product_type:0);
|
||||||
|
|
||||||
$result = $object->addline(
|
if ($subelement == 'commande') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,'HT',0,'','',$product_type);
|
||||||
$object_id,
|
if ($subelement == 'facture') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,'HT',0,$product_type);
|
||||||
$product->description,
|
|
||||||
$product->price,
|
$result = $object->addline($fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5],$fields[6],$fields[7],$fields[8],$fields[9],$fields[10],$fields[11],$fields[12],$fields[13],$fields[14],$fields[15],$fields[16]);
|
||||||
$_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)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
|
$langs->load("errors");
|
||||||
|
$return_arr['error'] = ucfirst($subelement).'::addline '.$langs->trans($object->error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$langs->load("errors");
|
||||||
|
$return_arr['error'].= $langs->trans('ErrorProductWithRefNotExist', $_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]).'<br />';
|
||||||
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert default contacts
|
|
||||||
/*
|
|
||||||
if ($contact->id > 0)
|
|
||||||
{
|
|
||||||
$result=$object->add_contact($contact->id,'CUSTOMER','external');
|
|
||||||
if ($result < 0) $error++;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$return_arr['error'] = ucfirst($subelement).'::create '.$langs->trans($object->error);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($object_id > 0 && ! $error)
|
if ($object_id > 0 && ! $error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
$return_arr['elementurl'] = $object->getNomUrl(0,'',0,1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -228,8 +228,8 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return element id
|
echo json_encode($return_arr);
|
||||||
echo $object->getNomUrl(0,0,1);
|
|
||||||
/*
|
/*
|
||||||
foreach ($_SESSION[$_GET['transaction_id']] as $key => $value)
|
foreach ($_SESSION[$_GET['transaction_id']] as $key => $value)
|
||||||
{
|
{
|
||||||
@ -267,9 +267,14 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Date').'</td><td>'.dol_print_date(dol_stringtotime($_SESSION[$_GET['transaction_id']]['ORDERTIME']),'dayhour').'</td>';
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Date').'</td><td>'.dol_print_date(dol_stringtotime($_SESSION[$_GET['transaction_id']]['ORDERTIME']),'dayhour').'</td>';
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('PAYERSTATUS').'</td><td>'.$langs->trans(ucfirst($_SESSION[$_GET['transaction_id']]['PAYERSTATUS'])).'</td>';
|
$payerstatus=strtolower($_SESSION[$_GET['transaction_id']]['PAYERSTATUS']);
|
||||||
|
$img_payerstatus=($payerstatus=='verified' ? img_tick($langs->trans(ucfirst($payerstatus))) : img_warning($langs->trans(ucfirst($payerstatus))) );
|
||||||
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('PAYERSTATUS').'</td><td>'.$img_payerstatus.'</td>';
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('ADDRESSSTATUS').'</td><td>'.$langs->trans(ucfirst($_SESSION[$_GET['transaction_id']]['ADDRESSSTATUS'])).'</td>';
|
$addressstatus=strtolower($_SESSION[$_GET['transaction_id']]['ADDRESSSTATUS']);
|
||||||
|
$img_addressstatus=($addressstatus=='confirmed' ? img_tick($langs->trans(ucfirst($addressstatus))) : img_warning($langs->trans(ucfirst($addressstatus))) );
|
||||||
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('ADDRESSSTATUS').'</td><td>'.$img_addressstatus.'</td>';
|
||||||
|
|
||||||
$shipamount=($_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']?$_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']:$_SESSION[$_GET['transaction_id']]['SHIPAMOUNT']);
|
$shipamount=($_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']?$_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']:$_SESSION[$_GET['transaction_id']]['SHIPAMOUNT']);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|||||||
@ -148,27 +148,53 @@ if (empty($conf->global->PAYPAL_API_USER) || empty($conf->global->PAYPAL_API_PAS
|
|||||||
modal: true,
|
modal: true,
|
||||||
width: 500,
|
width: 500,
|
||||||
buttons: {
|
buttons: {
|
||||||
'<?php
|
<?php
|
||||||
if ($conf->commande->enabled)
|
if ($conf->commande->enabled)
|
||||||
{
|
{
|
||||||
$langs->load("orders");
|
$langs->load("orders"); ?>
|
||||||
echo $langs->transnoentities('CreateOrder'); ?>': function() {
|
'<?php echo $langs->transnoentities('CreateOrder'); ?>': function() {
|
||||||
$.get( "<?php echo DOL_URL_ROOT; ?>/paypal/ajaxtransaction.php", {
|
$.getJSON( "<?php echo DOL_URL_ROOT; ?>/paypal/ajaxtransaction.php", {
|
||||||
action: 'add',
|
action: 'add',
|
||||||
element: 'order',
|
element: 'order',
|
||||||
transaction_id: id_value
|
transaction_id: id_value
|
||||||
},
|
},
|
||||||
function(elementurl) {
|
function(response) {
|
||||||
if ($.jnotify) {
|
$.each(response, function(key,value) {
|
||||||
|
if (key == 'error') {
|
||||||
|
$.jnotify(value, "error", true);
|
||||||
|
} else {
|
||||||
$.jnotify("<?php echo $langs->trans('PleaseBePatient'); ?>", 500);
|
$.jnotify("<?php echo $langs->trans('PleaseBePatient'); ?>", 500);
|
||||||
}
|
|
||||||
$( "div #paypal-details" ).dialog( "close" );
|
$( "div #paypal-details" ).dialog( "close" );
|
||||||
location.href=elementurl;
|
location.href=value;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'<?php
|
<?php } ?>
|
||||||
|
<?php
|
||||||
|
if ($conf->facture->enabled)
|
||||||
|
{
|
||||||
|
$langs->load("bills"); ?>
|
||||||
|
'<?php echo $langs->transnoentities('CreateBill'); ?>': function() {
|
||||||
|
$.getJSON( "<?php echo DOL_URL_ROOT; ?>/paypal/ajaxtransaction.php", {
|
||||||
|
action: 'add',
|
||||||
|
element: 'invoice',
|
||||||
|
transaction_id: id_value
|
||||||
|
},
|
||||||
|
function(response) {
|
||||||
|
$.each(response, function(key,value) {
|
||||||
|
if (key == 'error') {
|
||||||
|
$.jnotify(value, "error", true);
|
||||||
|
} else {
|
||||||
|
$.jnotify("<?php echo $langs->trans('PleaseBePatient'); ?>", 500);
|
||||||
|
$( "div #paypal-details" ).dialog( "close" );
|
||||||
|
location.href=value;
|
||||||
}
|
}
|
||||||
echo $langs->transnoentities('Cancel'); ?>': function() {
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
<?php } ?>
|
||||||
|
'<?php echo $langs->transnoentities('Cancel'); ?>': function() {
|
||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user