diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index ce4ba172583..53c8777d404 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -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').' '; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index d0e15307be5..71d32404c94 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -201,27 +201,27 @@ if ($action == 'valide') print ''; // Ref -print ''; +print ''; // Date payment -print ''; // 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 ''; +print ''; // Payment numero -print ''; // Amount -print ''; +print ''; // Note -print ''; @@ -250,7 +250,8 @@ if (! empty($conf->banque->enabled)) print ''; print ''; - 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); diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index e53aec7bfea..0b7b3ed0c57 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -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 ''; print '
'; - $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 '\n"; print '\n"; print '\n"; + print '\n"; + print '\n"; print ''; @@ -491,7 +501,34 @@ if ($action == 'new') print '\n"; print '\n"; print '\n"; - print ''; + print ''; + + // Link to payment + print ''; + // Link to bank transaction + print ''; + print '' ; @@ -644,6 +681,7 @@ else print '
'.$langs->trans('Ref').''.$object->id.'
'.$langs->trans('Ref').''.$object->id.'
'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).''; +print '
'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).''; print $form->editfieldval("Date",'datep',$object->date,$object,$user->rights->facture->paiement,'datepicker','',null,$langs->trans('PaymentDateUpdateSucceeded')); print '
'.$langs->trans('PaymentMode').''.$labeltype.'
'.$langs->trans('PaymentMode').''.$labeltype.'
'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).''; +print '
'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).''; print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded')); print '
'.$langs->trans('Amount').''.price($object->montant,'',$langs,0,0,-1,$conf->currency).'
'.$langs->trans('Amount').''.price($object->montant,'',$langs,0,0,-1,$conf->currency).'
'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->facture->paiement).''; +print '
'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->facture->paiement).''; print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea'); print '
'.$langs->trans("CheckTransmitter")."'.$langs->trans("Bank")."'.$langs->trans("Amount")."'.$langs->trans("Payment")."'.$langs->trans("LineRecord")."'.$langs->trans("Select")."
"; if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; print '
'.$value["numero"]."'.$value["emetteur"]."'.$value["banque"]."'.price($value["amount"]).''.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; + $paymentstatic->id=$value["paymentid"]; + $paymentstatic->ref=$value["paymentid"]; + if ($paymentstatic->id) + { + print $paymentstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + $accountlinestatic->rowid=$value["id"]; + if ($accountlinestatic->rowid) + { + print $accountlinestatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; print ''; print '
'; $param="&id=".$object->id; + print ''; 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 "\n"; $i=1; $var=false; @@ -670,17 +709,7 @@ else print ''; print ''; print ''; - print ''; + // Link to payment print ''; + // Link to bank transaction + print ''; + // Action button + print ''; + print 'rowid.'">'.img_delete().''; } - else if($objp->statut == 2) { - print ''; + if ($object->statut == 1 && $objp->statut != 2) + { + print '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 3ed2ad7711c..a95a7ce8756 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -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; } } 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 '
'.dol_trunc($objp->emetteur,24).''.dol_trunc($objp->banque,24).''.price($objp->amount).''; - $accountlinestatic->rowid=$objp->rowid; - if ($accountlinestatic->rowid) - { - print $accountlinestatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; $paymentstatic->id=$objp->pid; $paymentstatic->ref=$objp->pid; @@ -693,14 +722,33 @@ else print ' '; } print ''; + $accountlinestatic->rowid=$objp->rowid; + if ($accountlinestatic->rowid) + { + print $accountlinestatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; if ($object->statut == 0) { - print 'rowid.'">'.img_delete().''; - print 'rowid.'">'.img_picto($langs->trans("RejectCheck"),'disable').''.img_picto($langs->trans('CheckRejected'),'statut8').'
'; print ''; 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 ''; // Date - print ''; + print ''; // TODO Use date hour // Bank print '
'.dol_print_date($db->jdate($objp->dp),'day').''.dol_print_date($db->jdate($objp->dp),'day').''; 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/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 98250ab0db1..400eb934e26 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -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) { 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 27756a5b0c2..2a3f43e32cc 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/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8778314c460..32d8dbf5a05 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -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); 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 e5390bcdfee..0bd4fa7431b 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 diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 7f6609d5fe6..5f14e6387f1 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -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'); } }