';
+ if ($object->statut == 1 && $objp->statut != 2)
+ {
+ print 'id.'&action=reject_check&lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"),'disable').'';
+ }
+ if ($objp->statut == 2)
+ {
+ print ' '.img_picto($langs->trans('CheckRejected'),'statut8').'';
}
+ print '';
print '';
$var=!$var;
$i++;
diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
index df401f4c35d..c7fc00c9d2e 100644
--- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
@@ -661,23 +661,38 @@ class RemiseCheque extends CommonObject
}
/**
- * Check rejection management
- * Reopen linked invoices and saves a new negative payment
+ * Check return management
+ * Reopen linked invoices and create a new negative payment.
*
- * @param int $bank_id Id of bank line concerned
- * @param date $rejection_date Date to use on the negative payment
- * @return int
+ * @param int $bank_id Id of bank transaction line concerned
+ * @param date $rejection_date Date to use on the negative payment
+ * @return int Id of negative payment line created
*/
- function reject_check($bank_id, $rejection_date)
+ function rejectCheck($bank_id, $rejection_date)
{
global $db, $user;
$payment = new Paiement($db);
$payment->fetch(0,0,$bank_id);
+ $bankline = new AccountLine($db);
+ $bankline->fetch($bank_id);
+
+ /* Conciliation is allowed because when check is returned, a new line is created onto bank transaction log.
+ if ($bankline->rappro)
+ {
+ $this->error='ActionRefusedLineAlreadyConciliated';
+ return -1;
+ }*/
+
+ $this->db->begin();
+
+ // Not conciliated, we can delete it
+ //$bankline->delete($user); // We delete
+
$bankaccount = $payment->fk_account;
- // Get invoice list to reopen them
+ // Get invoices list to reopen them
$sql = 'SELECT pf.fk_facture, pf.amount';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
$sql.= ' WHERE pf.fk_paiement = '.$payment->id;
@@ -700,27 +715,45 @@ class RemiseCheque extends CommonObject
$rejectedPayment->amounts[$obj->fk_facture] = price2num($obj->amount) * -1;
}
- if ($rejectedPayment->create($user) > 0)
+ $result = $rejectedPayment->create($user);
+ if ($result > 0)
{
- $result=$rejectedPayment->addPaymentToBank($user,'payment','(CheckRejected)',$bankaccount,'','');
+ // We created a negative payment, we also add the line as bank transaction
+ $result=$rejectedPayment->addPaymentToBank($user,'payment','(CheckRejected)',$bankaccount,'','');
if ($result > 0)
{
- $payment->reject();
- return $rejectedPayment->id;
+ $result = $payment->reject();
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return $rejectedPayment->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
}
else
{
+ $this->error = $rejectedPayment->error;
+ $this->errors = $rejectedPayment->errors;
+ $this->db->rollback();
return -1;
}
}
else
{
+ $this->error = $rejectedPayment->error;
+ $this->errors = $rejectedPayment->errors;
+ $this->db->rollback();
return -1;
}
}
else
{
- $this->error=$this->db->error();
+ $this->error=$this->db->lasterror();
+ $this->db->rollback();
return -1;
}
}
diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php
index 8f1e4cbb0ef..d44aef51dce 100644
--- a/htdocs/compta/paiement/cheque/list.php
+++ b/htdocs/compta/paiement/cheque/list.php
@@ -120,7 +120,7 @@ if ($resql)
print '
';
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index e45d0936bcc..9baa15a417f 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -697,9 +697,11 @@ class Paiement extends CommonObject
}
}
- /*
- * \brief Information sur l'objet
- * \param id id du paiement dont il faut afficher les infos
+ /**
+ * Information sur l'objet
+ *
+ * @param int $id id du paiement dont il faut afficher les infos
+ * @return void
*/
function info($id)
{
diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php
index 15057d6f3d7..9624bf66341 100644
--- a/htdocs/core/menus/standard/auguria.lib.php
+++ b/htdocs/core/menus/standard/auguria.lib.php
@@ -61,17 +61,19 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0)
if ($showmode == 1)
{
$url = $shorturl = $newTabMenu[$i]['url'];
+
if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
{
$tmp=explode('?',$newTabMenu[$i]['url'],2);
$url = $shorturl = $tmp[0];
$param = (isset($tmp[1])?$tmp[1]:'');
- if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
+ if (! preg_match('/mainmenu/i',$param) || ! preg_match('/leftmenu/i',$param)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
$url = dol_buildpath($url,1).($param?'?'.$param:'');
$shorturl = $shorturl.($param?'?'.$param:'');
}
+
$url=preg_replace('/__LOGIN__/',$user->login,$url);
$shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl);
$url=preg_replace('/__USERID__/',$user->id,$url);
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 33e9a745665..f316fb47980 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -275,7 +275,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0)
$url = $shorturl = $tmp[0];
$param = (isset($tmp[1])?$tmp[1]:'');
- if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
+ if (! preg_match('/mainmenu/i',$param) || ! preg_match('/leftmenu/i',$param)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
$url = dol_buildpath($url,1).($param?'?'.$param:'');
$shorturl = $shorturl.($param?'?'.$param:'');
diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang
index f98f02ccef0..a1e05481be9 100644
--- a/htdocs/langs/en_US/banks.lang
+++ b/htdocs/langs/en_US/banks.lang
@@ -165,8 +165,8 @@ DeleteARib=Delete BAN record
ConfirmDeleteRib=Are you sure you want to delete this BAN record ?
StartDate=Start date
EndDate=End date
-RejectCheck=Check rejection
+RejectCheck=Check returned
ConfirmRejectCheck=Are you sure you want to mark this check as rejected ?
-RejectCheckDate=Check rejection date
-CheckRejected=Check rejected
-CheckRejectedAndInvoicesReopened=Check rejected and invoices reopened
+RejectCheckDate=Date the check was returned
+CheckRejected=Check returned
+CheckRejectedAndInvoicesReopened=Check returned and invoices reopened
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 6b4bef7e8d2..404801c5335 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -705,7 +705,7 @@ PublicUrl=Public URL
AddBox=Add box
SelectElementAndClickRefresh=Select an element and click Refresh
PrintFile=Print File %s
-ShowTransaction=Show transaction
+ShowTransaction=Show transaction on bank account
GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide.
Deny=Deny
Denied=Denied