diff --git a/ChangeLog b/ChangeLog index ee7f01a682c..610307c12d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -68,6 +68,7 @@ For users: - Fix: Better Postgresql compatibility. - Fix: Numbering module for invoices use same number for invoice and credit note if mask is same. +- Fix: Debug and clean withdraw module. For developers: - New: External modules can add tabs on agenda views. diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index a8d0e384c5a..1717f7700c7 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2463,7 +2463,7 @@ else } print ''; - // Montants + // Amount print '
| '.$langs->trans('Ref').' | '.$object->ref.' | |||||||
| '.$langs->trans("Company").' | '; print ''.$soc->getNomUrl(1,'compta').' | '; print '|||||||
| '.$langs->trans("Date").' | '; - print ''.dol_print_date($object->date,"daytext").' | '; - print ''.$langs->trans("DateMaxPayment").' | ' . dol_print_date($object->date_lim_reglement,"daytext"); - if ($object->paye == 0 && $object->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late")); - print " | |||||
| '.$langs->trans('Type').' | '; + print $object->getLibType(); + if ($object->type == 1) + { + $facreplaced=new Facture($db); + $facreplaced->fetch($object->fk_facture_source); + print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; + } + if ($object->type == 2) + { + $facusing=new Facture($db); + $facusing->fetch($object->fk_facture_source); + print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')'; + } - // Conditions et modes de reglement - print ' | |||||||
| '.$langs->trans("PaymentConditions").' | '; - $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->cond_reglement_id,"none"); - print ' | '; - print ''.$langs->trans("PaymentMode").' | '; - $html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->mode_reglement_id,"none"); + $facidavoir=$object->getListIdAvoirFromInvoice(); + if (sizeof($facidavoir) > 0) + { + print ' ('.$langs->transnoentities("InvoiceHasAvoir"); + $i=0; + foreach($facidavoir as $id) + { + if ($i==0) print ' '; + else print ','; + $facavoir=new Facture($db); + $facavoir->fetch($id); + print $facavoir->getNomUrl(1); + } + print ')'; + } + if ($objectidnext > 0) + { + $facthatreplace=new Facture($db); + $facthatreplace->fetch($objectidnext); + print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; + } print ' | |||||
| '.$langs->trans('GlobalDiscount').' | '; - print ''.$object->remise_percent.'% | '; + // Relative and absolute discounts + $addabsolutediscount=' id.'">'.$langs->trans("AddGlobalDiscount").''; + $addcreditnote=' id.'">'.$langs->trans("AddCreditNote").''; + + print '|||||||
| '.$langs->trans('Discounts'); + print ' | ';
+ if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
+ else print $langs->trans("CompanyHasNoRelativeDiscount");
+
+ if ($absolute_discount > 0)
+ {
+ print '. ';
+ if ($object->statut > 0 || $object->type == 2 || $object->type == 3)
+ {
+ if ($object->statut == 0)
+ {
+ print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie));
+ print '. ';
+ }
+ else
+ {
+ if ($object->statut < 1 || $object->type == 2 || $object->type == 3)
+ {
+ $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie));
+ print ' '.$text.'. '; + } + else + { + $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie)); + $text2=$langs->trans("AbsoluteDiscountUse"); + print $html->textwithpicto($text,$text2); + } + } + } + else + { + // Remise dispo de type remise fixe (not credit note) + $filter='fk_facture_source IS NULL'; + print ' '; + $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id',$soc->id, $absolute_discount, $filter, $resteapayer, ' - '.$addabsolutediscount); + } + } + else + { + if ($absolute_creditnote > 0) // If not linke will be added later + { + if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' - '.$addabsolutediscount.' '; + else print '.'; + } + else print '. '; + } + if ($absolute_creditnote > 0) + { + // If validated, we show link "add credit note to payment" + if ($object->statut != 1 || $object->type == 2 || $object->type == 3) + { + if ($object->statut == 0 && $object->type != 3) + { + $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->monnaie)); + print $html->textwithpicto($text,$langs->trans("CreditNoteDepositUse")); + } + else + { + print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->monnaie)).'.'; + } + } + else + { + // Remise dispo de type avoir + $filter='fk_facture_source IS NOT NULL'; + if (! $absolute_discount) print ' '; + $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filter, $resteapayer); + } + } + if (! $absolute_discount && ! $absolute_creditnote) + { + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' - '.$addabsolutediscount.' '; + else print '. '; + } + /*if ($object->statut == 0 && $object->type != 2 && $object->type != 3) + { + if (! $absolute_discount && ! $absolute_creditnote) print ' '; + //print ' - '; + print $addabsolutediscount; + //print ' - '.$addcreditnote; // We disbale link to credit note + }*/ + print ' | |||||||
| '.$langs->trans("Date").' | '; + print ''.dol_print_date($object->date,"daytext").' | '; + print "|||||||
';
+ print '
| '; + if ($object->type != 2) + { + if ($action == 'editpaymentterm') + { + $html->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date_lim_reglement,'paymentterm'); + } + else + { + print dol_print_date($object->date_lim_reglement,'daytext'); + if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! $object->am) print img_warning($langs->trans('Late')); + } + } + else + { + print ' '; + } + print ' | |||||||
| '.$langs->trans("PaymentConditionsShort").' | '; + $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->cond_reglement_id,"none"); + print ' | '; + print '|||||||
';
+ print '
| '; + if ($action == 'editmode') + { + $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); + } + else + { + $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'none'); + } + print ' | '; $nbrows=5; if ($conf->projet->enabled) $nbrows++; @@ -121,7 +287,7 @@ if ($id > 0 || ! empty($ref)) */ $objectref = dol_sanitizeFileName($object->ref); $dir_output = $conf->facture->dir_output . "/"; - $filepath = $dir_output . $objectref . "/"; + $filepath = $dir_output . $objectref . "/"; $file = $filepath . $objectref . ".pdf"; $filedetail = $filepath . $objectref . "-detail.pdf"; $relativepath = $objectref.'/'.$objectref.'.pdf'; @@ -164,15 +330,15 @@ if ($id > 0 || ! empty($ref)) // Conversion du PDF en image png si fichier png non existant if (! file_exists($fileimage) && ! file_exists($fileimagebis)) { - if (class_exists("Imagick")) - { - $ret = dol_convert_file($file); - if ($ret < 0) $error++; + if (class_exists("Imagick")) + { + $ret = dol_convert_file($file); + if ($ret < 0) $error++; } else { - $langs->load("other"); - print ''.$langs->trans("ErrorNoImagickReadimage").''; + $langs->load("other"); + print ''.$langs->trans("ErrorNoImagickReadimage").''; } } } @@ -182,19 +348,19 @@ if ($id > 0 || ! empty($ref)) print ''.price($object->total_ht).' | '; print ''.$langs->trans("Currency".$conf->monnaie).' | |||||
| '.$langs->trans('AmountVAT').' | '.price($object->total_tva).' | '; - print ''.$langs->trans('Currency'.$conf->monnaie).' | ||||||
| '.$langs->trans('AmountTTC').' | '.price($object->total_ttc).' | '; - print ''.$langs->trans('Currency'.$conf->monnaie).' | ||||||
| '.$langs->trans('AmountVAT').' | '.price($object->total_tva).' | '; + print ''.$langs->trans('Currency'.$conf->monnaie).' | ||||||
| '.$langs->trans('AmountTTC').' | '.price($object->total_ttc).' | '; + print ''.$langs->trans('Currency'.$conf->monnaie).' | ||||||
| '.$langs->trans('Status').' | '.($object->getLibStatut()).' | |||||||
| '.$langs->trans('Status').' | '.($object->getLibStatut(4,$totalpaye)).' | |||||||
| '.$langs->trans("Project").' | '; if ($object->fk_project > 0) { @@ -206,7 +372,7 @@ if ($id > 0 || ! empty($ref)) { print ' '; } - print ' | |||||||
';
- }
- }
+ if (file_exists($dir_output.$preview))
+ {
+ print '
';
+ }
+ }
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 4247c1f8eb2..781750c8d62 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2207,14 +2207,65 @@ class Facture extends CommonObject
}
else
{
- $this->error=$this->lasterror();
+ $this->error=$this->db->lasterror();
return -1;
}
}
/**
- * \brief Return amount (with tax) of all credit notes and deposits invoices used by invoice
- * \return int <0 if KO, Sum of credit notes and deposits amount otherwise
+ * Return list of payments
+ * @return Array with list of payments
+ */
+ function getListOfPayments($filtertype='')
+ {
+ $retarray=array();
+
+ $table='paiement_facture';
+ $table2='paiement';
+ $field='fk_facture';
+ $field2='fk_paiement';
+ if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
+ {
+ $table='paiementfourn_facturefourn';
+ $table2='paiementfourn';
+ $field='fk_facturefourn';
+ $field2='fk_paiementfourn';
+ }
+
+ $sql = 'SELECT pf.amount, p.fk_paiement, p.datep, t.code';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t';
+ $sql.= ' WHERE pf.'.$field.' = '.$this->id;
+ $sql.= ' AND pf.'.$field2.' = p.rowid';
+ $sql.= ' AND p.fk_paiement = t.rowid';
+ if ($filtertype) $sql.=" AND t.code='PRE'";
+
+ dol_syslog("Facture::getListOfPayments sql=".$sql, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i=0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep);
+ $i++;
+ }
+ $this->db->free($resql);
+ return $retarray;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ dol_print_error($this->db);
+ return array();
+ }
+ }
+
+
+ /**
+ * Return amount (with tax) of all credit notes and deposits invoices used by invoice
+ * @return int <0 if KO, Sum of credit notes and deposits amount otherwise
*/
function getSumCreditNotesUsed()
{
@@ -2234,8 +2285,8 @@ class Facture extends CommonObject
}
/**
- * \brief Return amount (with tax) of all deposits invoices used by invoice
- * \return int <0 if KO, Sum of deposits amount otherwise
+ * Return amount (with tax) of all deposits invoices used by invoice
+ * @return int <0 if KO, Sum of deposits amount otherwise
*/
function getSumDepositsUsed()
{
@@ -2902,9 +2953,9 @@ class Facture extends CommonObject
}
/**
- * \brief Supprime une demande de prelevement
- * \param user utilisateur creant la demande
- * \param did id de la demande a supprimer
+ * Supprime une demande de prelevement
+ * @param user utilisateur creant la demande
+ * @param did id de la demande a supprimer
*/
function demande_prelevement_delete($user, $did)
{
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index 421fdfaab91..f3ec34fdd2a 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -400,6 +400,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
dol_fiche_end();
+
/*
* Withdrawal request
*/
@@ -443,6 +444,9 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print "
\n";
+ print $langs->trans("DoStandingOrdersBeforePayments").'
';
+
+
/*
* Withdrawals
*/
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index f602b5e0316..3e77bdfab70 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2010 Laurent Destailleur