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
|
||||
* @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;
|
||||
|
||||
$result='';
|
||||
|
||||
$file = '/commande/fiche.php';
|
||||
if ($conf->expedition->enabled && ($option == 1 || $option == 2)) $file = '/expedition/shipment.php';
|
||||
if ($conf->expedition->enabled && ($option == 1 || $option == 2)) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id;
|
||||
else $url = DOL_URL_ROOT.'/commande/fiche.php?id='.$this->id;
|
||||
|
||||
$url = DOL_URL_ROOT.$file.'?id='.$this->id;
|
||||
if ($short) return $url;
|
||||
|
||||
$linkstart = '<a href="'.$url.'">';
|
||||
|
||||
@ -151,6 +151,7 @@ class Facture extends CommonObject
|
||||
$this->note=trim($this->note);
|
||||
$this->note_public=trim($this->note_public);
|
||||
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;
|
||||
$this->brouillon = 1;
|
||||
|
||||
@ -605,22 +606,19 @@ class Facture extends CommonObject
|
||||
* @param max Maxlength of ref
|
||||
* @return string String with URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0,$option='',$max=0)
|
||||
function getNomUrl($withpicto=0,$option='',$max=0,$short=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result='';
|
||||
|
||||
if ($option == 'withdraw')
|
||||
{
|
||||
$lien = '<a href="'.DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id.'">';
|
||||
$lienfin='</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lien = '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$this->id.'">';
|
||||
$lienfin='</a>';
|
||||
}
|
||||
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;
|
||||
|
||||
if ($short) return $url;
|
||||
|
||||
$linkstart='<a href="'.$url.'">';
|
||||
$linkend='</a>';
|
||||
|
||||
$picto='bill';
|
||||
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 == 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 != 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;
|
||||
}
|
||||
|
||||
|
||||
@ -78,4 +78,5 @@ ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Setup
|
||||
ErrorBadMask=Error on mask
|
||||
ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number
|
||||
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>
|
||||
PaypalTransactionDesc=This options allows you to import Paypal payments in Dolibarr as orders, invoices, etc ...
|
||||
PaypalEnableThisTool=Enable this functionnality
|
||||
Verified=Verified
|
||||
Unverified=Unverified
|
||||
Confirmed=Confirmed
|
||||
Unconfirmed=Unconfirmed
|
||||
GrossAmount=Gross amount
|
||||
FeeAmount=Fee amount
|
||||
|
||||
@ -79,4 +79,5 @@ ErrorModuleSetupNotComplete=La configuration du module semble incomplète. Aller
|
||||
ErrorBadMask=Erreur sur le masque
|
||||
ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence
|
||||
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>
|
||||
PaypalTransactionDesc=Ces options permettent d'importer des paiements Paypal dans Dolibarr en tant que commandes, factures, etc...
|
||||
PaypalEnableThisTool=Activer ces fonctionnalités
|
||||
Verified=Vérifié
|
||||
Unverified=Non vérifié
|
||||
Confirmed=Confirmée
|
||||
Unconfirmed=Non confirmée
|
||||
GrossAmount=Montant brut
|
||||
FeeAmount=Frais Paypal
|
||||
|
||||
@ -64,6 +64,9 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
|
||||
$error=0;
|
||||
$return_arr = array();
|
||||
|
||||
// Create customer if not exists
|
||||
$ret = $soc->fetchObjectFromRefExt($soc->table_element,$_SESSION[$_GET['transaction_id']]['PAYERID']);
|
||||
if ($ret < 0)
|
||||
@ -116,27 +119,34 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
||||
$contact->priv=0;
|
||||
|
||||
$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();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$langs->load("errors");
|
||||
echo $langs->trans($contact->error);
|
||||
echo $langs->trans($soc->error);
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
$element = $subelement = $_GET['element'];
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$_GET['element'],$regs))
|
||||
@ -146,6 +156,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
||||
}
|
||||
// For compatibility
|
||||
if ($element == 'order') { $element = $subelement = 'commande'; }
|
||||
if ($element == 'invoice') { $element = 'compta/facture'; $subelement = 'facture'; }
|
||||
|
||||
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||
|
||||
@ -173,63 +184,52 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
||||
|
||||
if ($ret > 0)
|
||||
{
|
||||
$qty=$_SESSION[$_GET['transaction_id']]["L_QTY".$i];
|
||||
$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 ($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);
|
||||
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);
|
||||
|
||||
$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]);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$return_arr['error'] = ucfirst($subelement).'::addline '.$langs->trans($object->error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$return_arr['error'].= $langs->trans('ErrorProductWithRefNotExist', $_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]).'<br />';
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Insert default contacts
|
||||
/*
|
||||
if ($contact->id > 0)
|
||||
{
|
||||
$result=$object->add_contact($contact->id,'CUSTOMER','external');
|
||||
if ($result < 0) $error++;
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$return_arr['error'] = ucfirst($subelement).'::create '.$langs->trans($object->error);
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
if ($object_id > 0 && ! $error)
|
||||
{
|
||||
$db->commit();
|
||||
$return_arr['elementurl'] = $object->getNomUrl(0,'',0,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($return_arr);
|
||||
|
||||
// Return element id
|
||||
echo $object->getNomUrl(0,0,1);
|
||||
/*
|
||||
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>';
|
||||
|
||||
$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;
|
||||
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']);
|
||||
$var=!$var;
|
||||
|
||||
@ -148,27 +148,53 @@ if (empty($conf->global->PAYPAL_API_USER) || empty($conf->global->PAYPAL_API_PAS
|
||||
modal: true,
|
||||
width: 500,
|
||||
buttons: {
|
||||
'<?php
|
||||
<?php
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
$langs->load("orders");
|
||||
echo $langs->transnoentities('CreateOrder'); ?>': function() {
|
||||
$.get( "<?php echo DOL_URL_ROOT; ?>/paypal/ajaxtransaction.php", {
|
||||
$langs->load("orders"); ?>
|
||||
'<?php echo $langs->transnoentities('CreateOrder'); ?>': function() {
|
||||
$.getJSON( "<?php echo DOL_URL_ROOT; ?>/paypal/ajaxtransaction.php", {
|
||||
action: 'add',
|
||||
element: 'order',
|
||||
transaction_id: id_value
|
||||
},
|
||||
function(elementurl) {
|
||||
if ($.jnotify) {
|
||||
$.jnotify("<?php echo $langs->trans('PleaseBePatient'); ?>", 500);
|
||||
}
|
||||
$( "div #paypal-details" ).dialog( "close" );
|
||||
location.href=elementurl;
|
||||
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;
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
'<?php
|
||||
}
|
||||
echo $langs->transnoentities('Cancel'); ?>': function() {
|
||||
<?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;
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
<?php } ?>
|
||||
'<?php echo $langs->transnoentities('Cancel'); ?>': function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user