Merge remote-tracking branch 'origin/3.8' into develop

This commit is contained in:
Laurent Destailleur 2015-09-12 18:22:10 +02:00
commit b94fb9e1f3
13 changed files with 152 additions and 59 deletions

View File

@ -263,7 +263,7 @@ if (function_exists("ldap_connect"))
$ldap = new Ldap(); // Les parametres sont passes et recuperes via $conf
$result = $ldap->connect_bind();
if ($result)
if ($result > 0)
{
// Test ldap connect and bind
print img_picto('','info').' ';

View File

@ -201,27 +201,27 @@ if ($action == 'valide')
print '<table class="border" width="100%">';
// Ref
print '<tr><td valign="top" width="20%">'.$langs->trans('Ref').'</td><td colspan="3">'.$object->id.'</td></tr>';
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="3">'.$object->id.'</td></tr>';
// Date payment
print '<tr><td valign="top">'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).'</td><td colspan="3">';
print '<tr><td>'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).'</td><td colspan="3">';
print $form->editfieldval("Date",'datep',$object->date,$object,$user->rights->facture->paiement,'datepicker','',null,$langs->trans('PaymentDateUpdateSucceeded'));
print '</td></tr>';
// Payment type (VIR, LIQ, ...)
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle;
print '<tr><td valign="top">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
// Payment numero
print '<tr><td valign="top">'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print '<tr><td>'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
print '</td></tr>';
// Amount
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant,'',$langs,0,0,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant,'',$langs,0,0,-1,$conf->currency).'</td></tr>';
// Note
print '<tr><td valign="top">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->facture->paiement).'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->facture->paiement).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea');
print '</td></tr>';
@ -250,7 +250,8 @@ if (! empty($conf->banque->enabled))
print '</td>';
print '</tr>';
if($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) {
if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0)
{
dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php');
$bordereau = new RemiseCheque($db);
$bordereau->fetch($bankline->fk_bordereau);

View File

@ -227,16 +227,18 @@ if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->rights->ban
$rejected_check = GETPOST('bankid');
$object->fetch($id);
$paiement_id = $object->reject_check($rejected_check, $reject_date);
$paiement_id = $object->rejectCheck($rejected_check, $reject_date);
if ($paiement_id > 0)
{
setEventMessage($langs->trans("CheckRejectedAndInvoicesReopened"));
header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id);
exit;
//header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id);
//exit;
$action='';
}
else
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
}
@ -367,6 +369,9 @@ $accounts = array();
if ($action == 'new')
{
$paymentstatic=new Paiement($db);
$accountlinestatic=new AccountLine($db);
$lines = array();
$now=dol_now();
@ -402,9 +407,11 @@ if ($action == 'new')
print '</form>';
print '<br>';
$sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as chqid, ";
$sql.= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque";
$sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as transactionid, ";
$sql.= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque,";
$sql.= " p.rowid as paymentid";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
$sql.= " WHERE b.fk_type = 'CHQ'";
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
@ -426,7 +433,8 @@ if ($action == 'new')
$lines[$obj->bid][$i]["emetteur"] = $obj->emetteur;
$lines[$obj->bid][$i]["numero"] = $obj->num_chq;
$lines[$obj->bid][$i]["banque"] = $obj->banque;
$lines[$obj->bid][$i]["id"] = $obj->chqid;
$lines[$obj->bid][$i]["id"] = $obj->transactionid;
$lines[$obj->bid][$i]["paymentid"] = $obj->paymentid;
$i++;
}
@ -469,6 +477,8 @@ if ($action == 'new')
print '<td style="min-width: 200px">'.$langs->trans("CheckTransmitter")."</td>\n";
print '<td style="min-width: 200px">'.$langs->trans("Bank")."</td>\n";
print '<td align="right" width="100px">'.$langs->trans("Amount")."</td>\n";
print '<td align="center" width="100px">'.$langs->trans("Payment")."</td>\n";
print '<td align="center" width="100px">'.$langs->trans("LineRecord")."</td>\n";
print '<td align="center" width="100px">'.$langs->trans("Select")."<br>";
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
print '</td>';
@ -491,7 +501,34 @@ if ($action == 'new')
print '<td>'.$value["numero"]."</td>\n";
print '<td>'.$value["emetteur"]."</td>\n";
print '<td>'.$value["banque"]."</td>\n";
print '<td align="right">'.price($value["amount"]).'</td>';
print '<td align="right">'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).'</td>';
// Link to payment
print '<td align="center">';
$paymentstatic->id=$value["paymentid"];
$paymentstatic->ref=$value["paymentid"];
if ($paymentstatic->id)
{
print $paymentstatic->getNomUrl(1);
}
else
{
print '&nbsp;';
}
print '</td>';
// Link to bank transaction
print '<td align="center">';
$accountlinestatic->rowid=$value["id"];
if ($accountlinestatic->rowid)
{
print $accountlinestatic->getNomUrl(1);
}
else
{
print '&nbsp;';
}
print '</td>';
print '<td align="center">';
print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
print '</td>' ;
@ -644,6 +681,7 @@ else
print '<table class="noborder" width="100%">';
$param="&amp;id=".$object->id;
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Cheques"),'','','','','width="30"');
print_liste_field_titre($langs->trans("DateChequeReceived"),$_SERVER["PHP_SELF"],"b.dateo,b.rowid", "",$param,'align="center"',$sortfield,$sortorder);
@ -651,8 +689,9 @@ else
print_liste_field_titre($langs->trans("CheckTransmitter"),$_SERVER["PHP_SELF"],"b.emetteur", "",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Bank"),$_SERVER["PHP_SELF"],"b.banque", "",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"b.amount", "",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LineRecord"),$_SERVER["PHP_SELF"],"b.rowid", "",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Payment"),$_SERVER["PHP_SELF"],"p.rowid", "",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LineRecord"),$_SERVER["PHP_SELF"],"b.rowid", "",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre('');
print "</tr>\n";
$i=1;
$var=false;
@ -670,17 +709,7 @@ else
print '<td>'.dol_trunc($objp->emetteur,24).'</td>';
print '<td>'.dol_trunc($objp->banque,24).'</td>';
print '<td align="right">'.price($objp->amount).'</td>';
print '<td align="center">';
$accountlinestatic->rowid=$objp->rowid;
if ($accountlinestatic->rowid)
{
print $accountlinestatic->getNomUrl(1);
}
else
{
print '&nbsp;';
}
print '</td>';
// Link to payment
print '<td align="center">';
$paymentstatic->id=$objp->pid;
$paymentstatic->ref=$objp->pid;
@ -693,14 +722,33 @@ else
print '&nbsp;';
}
print '</td>';
// Link to bank transaction
print '<td align="center">';
$accountlinestatic->rowid=$objp->rowid;
if ($accountlinestatic->rowid)
{
print $accountlinestatic->getNomUrl(1);
}
else
{
print '&nbsp;';
}
print '</td>';
// Action button
print '<td align="right">';
if ($object->statut == 0)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=remove&amp;lineid='.$objp->rowid.'">'.img_delete().'</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reject_check&amp;lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"),'disable').'</a></td>';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=remove&amp;lineid='.$objp->rowid.'">'.img_delete().'</a>';
}
else if($objp->statut == 2) {
print '<td align="right">'.img_picto($langs->trans('CheckRejected'),'statut8').'</a></td>';
if ($object->statut == 1 && $objp->statut != 2)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reject_check&amp;lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"),'disable').'</a>';
}
if ($objp->statut == 2)
{
print ' &nbsp; '.img_picto($langs->trans('CheckRejected'),'statut8').'</a>';
}
print '</td>';
print '</tr>';
$var=!$var;
$i++;

View File

@ -668,23 +668,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;
@ -707,27 +722,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;
}
}

View File

@ -120,7 +120,7 @@ if ($resql)
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"bc.number","",$params,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"dp","",$params,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"dp","",$params,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$params,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("NbOfCheques"),$_SERVER["PHP_SELF"],"bc.nbcheque","",$params,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"bc.amount","",$params,'align="right"',$sortfield,$sortorder);
@ -164,7 +164,7 @@ if ($resql)
print '</td>';
// Date
print '<td align="center">'.dol_print_date($db->jdate($objp->dp),'day').'</td>';
print '<td align="center">'.dol_print_date($db->jdate($objp->dp),'day').'</td>'; // TODO Use date hour
// Bank
print '<td>';

View File

@ -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)
{

View File

@ -156,10 +156,17 @@ class Ldap
if (count($this->server) == 0 || empty($this->server[0]))
{
$this->error='LDAP setup (file conf.php) is not complete';
$return=-1;
dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
return -1;
}
if (! function_exists('ldap_connect'))
{
$this->error='Your PHP need extension ldap';
dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
return -1;
}
// Loop on each ldap server
foreach ($this->server as $key => $host)
{

View File

@ -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'].'&amp;leftmenu=';
if (! preg_match('/mainmenu/i',$param) || ! preg_match('/leftmenu/i',$param)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&amp;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);

View File

@ -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'].'&amp;leftmenu=';
if (! preg_match('/mainmenu/i',$param) || ! preg_match('/leftmenu/i',$param)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&amp;leftmenu=';
//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
$url = dol_buildpath($url,1).($param?'?'.$param:'');
$shorturl = $shorturl.($param?'?'.$param:'');

View File

@ -1436,7 +1436,7 @@ class FactureFournisseur extends CommonInvoice
$response = new WorkboardResponse();
$response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24;
$response->label=$langs->trans("SupplierBillsToPay");
$response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=paye:0';
$response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0';
$response->img=img_object($langs->trans("Bills"),"bill");
$facturestatic = new FactureFournisseur($this->db);

View File

@ -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

View File

@ -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

View File

@ -94,7 +94,7 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre"))
$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
//$testdate = false;
//$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
setEventMessage($langs->trans('ExpiredDate'),'warnings');
setEventMessage('ExpireDate','warnings');
}
}