Qual: Debug and clean notification module

This commit is contained in:
Laurent Destailleur 2011-06-12 18:05:30 +00:00
parent d53cb49bf9
commit e1094fc293
17 changed files with 434 additions and 282 deletions

View File

@ -68,6 +68,7 @@ For users:
- Fix: Better Postgresql compatibility. - Fix: Better Postgresql compatibility.
- Fix: Numbering module for invoices use same number for invoice - Fix: Numbering module for invoices use same number for invoice
and credit note if mask is same. and credit note if mask is same.
- Fix: Debug and clean withdraw module.
For developers: For developers:
- New: External modules can add tabs on agenda views. - New: External modules can add tabs on agenda views.

View File

@ -2463,7 +2463,7 @@ else
} }
print '</td></tr>'; print '</td></tr>';
// Montants // Amount
print '<tr><td>'.$langs->trans('AmountHT').'</td>'; print '<tr><td>'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2" nowrap>'.price($object->total_ht).'</td>'; print '<td align="right" colspan="2" nowrap>'.price($object->total_ht).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';

View File

@ -75,42 +75,208 @@ if ($id > 0 || ! empty($ref))
$author->fetch($object->user_author); $author->fetch($object->user_author);
} }
$head = facture_prepare_head($object); $head = facture_prepare_head($object);
dol_fiche_head($head, 'preview', $langs->trans("InvoiceCustomer"), 0, 'bill'); dol_fiche_head($head, 'preview', $langs->trans("InvoiceCustomer"), 0, 'bill');
$totalpaye = $object->getSommePaiement();
/* /*
* Facture * Facture
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$rowspan=3; $rowspan=3;
// Reference // Reference
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$object->ref.'</td></tr>'; print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$object->ref.'</td></tr>';
// Societe // Societe
print '<tr><td>'.$langs->trans("Company").'</td>'; print '<tr><td>'.$langs->trans("Company").'</td>';
print '<td colspan="5">'.$soc->getNomUrl(1,'compta').'</td>'; print '<td colspan="5">'.$soc->getNomUrl(1,'compta').'</td>';
print '</tr>'; print '</tr>';
// Dates // Type
print '<tr><td>'.$langs->trans("Date").'</td>'; print '<tr><td>'.$langs->trans('Type').'</td><td colspan="5">';
print '<td colspan="3">'.dol_print_date($object->date,"daytext").'</td>'; print $object->getLibType();
print '<td>'.$langs->trans("DateMaxPayment").'</td><td>' . dol_print_date($object->date_lim_reglement,"daytext"); if ($object->type == 1)
if ($object->paye == 0 && $object->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late")); {
print "</td></tr>"; $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 $facidavoir=$object->getListIdAvoirFromInvoice();
print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">'; if (sizeof($facidavoir) > 0)
$html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->cond_reglement_id,"none"); {
print '</td>'; print ' ('.$langs->transnoentities("InvoiceHasAvoir");
print '<td width="25%">'.$langs->trans("PaymentMode").'</td><td width="25%">'; $i=0;
$html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->mode_reglement_id,"none"); 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 '</td></tr>'; print '</td></tr>';
// Remise globale // Relative and absolute discounts
print '<tr><td>'.$langs->trans('GlobalDiscount').'</td>'; $addabsolutediscount=' <a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$soc->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("AddGlobalDiscount").'</a>';
print '<td colspan="3">'.$object->remise_percent.'%</td>'; $addcreditnote=' <a href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$soc->id.'&type=2&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("AddCreditNote").'</a>';
print '<tr><td>'.$langs->trans('Discounts');
print '</td><td colspan="5">';
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 '<br>'.$text.'.<br>';
}
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 '<br>';
$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.'<br>';
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 '<br>';
$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.'<br>';
else print '. ';
}
/*if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
{
if (! $absolute_discount && ! $absolute_creditnote) print '<br>';
//print ' &nbsp; - &nbsp; ';
print $addabsolutediscount;
//print ' &nbsp; - &nbsp; '.$addcreditnote; // We disbale link to credit note
}*/
print '</td></tr>';
// Dates
print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="5">'.dol_print_date($object->date,"daytext").'</td>';
print "</tr>";
// Date payment term
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateMaxPayment');
print '</td>';
if ($object->type != 2 && $action != 'editpaymentterm' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editpaymentterm&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="5">';
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 '&nbsp;';
}
print '</td></tr>';
// Conditions reglement
print '<tr><td>'.$langs->trans("PaymentConditionsShort").'</td><td colspan="5">';
$html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->cond_reglement_id,"none");
print '</td>';
print '</td></tr>';
// Mode de reglement
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
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 '</td>';
$nbrows=5; $nbrows=5;
if ($conf->projet->enabled) $nbrows++; if ($conf->projet->enabled) $nbrows++;
@ -121,7 +287,7 @@ if ($id > 0 || ! empty($ref))
*/ */
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->facture->dir_output . "/"; $dir_output = $conf->facture->dir_output . "/";
$filepath = $dir_output . $objectref . "/"; $filepath = $dir_output . $objectref . "/";
$file = $filepath . $objectref . ".pdf"; $file = $filepath . $objectref . ".pdf";
$filedetail = $filepath . $objectref . "-detail.pdf"; $filedetail = $filepath . $objectref . "-detail.pdf";
$relativepath = $objectref.'/'.$objectref.'.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 // Conversion du PDF en image png si fichier png non existant
if (! file_exists($fileimage) && ! file_exists($fileimagebis)) if (! file_exists($fileimage) && ! file_exists($fileimagebis))
{ {
if (class_exists("Imagick")) if (class_exists("Imagick"))
{ {
$ret = dol_convert_file($file); $ret = dol_convert_file($file);
if ($ret < 0) $error++; if ($ret < 0) $error++;
} }
else else
{ {
$langs->load("other"); $langs->load("other");
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>'; print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
} }
} }
} }
@ -182,19 +348,19 @@ if ($id > 0 || ! empty($ref))
print '<td align="right" colspan="2"><b>'.price($object->total_ht).'</b></td>'; print '<td align="right" colspan="2"><b>'.price($object->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($object->total_tva).'</td>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($object->total_tva).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($object->total_ttc).'</td>'; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($object->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans('Status').'</td><td align="left" colspan="3">'.($object->getLibStatut()).'</td></tr>'; print '<tr><td>'.$langs->trans('Status').'</td><td align="left" colspan="3">'.($object->getLibStatut(4,$totalpaye)).'</td></tr>';
// Projet // Projet
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
$langs->load("projects"); $langs->load("projects");
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Project").'</td><td colspan="3">'; print '<td>'.$langs->trans("Project").'</td><td colspan="3">';
if ($object->fk_project > 0) if ($object->fk_project > 0)
{ {
@ -206,7 +372,7 @@ if ($id > 0 || ! empty($ref))
{ {
print '&nbsp;'; print '&nbsp;';
} }
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
@ -223,22 +389,22 @@ if ($id > 0 || ! empty($ref))
// Si fichier png PDF d'1 page trouve // Si fichier png PDF d'1 page trouve
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">'; print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">';
} }
// Si fichier png PDF de plus d'1 page trouve // Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis)) elseif (file_exists($fileimagebis))
{ {
$multiple = preg_replace('/\.png/','',$relativepath) . "-"; $multiple = preg_replace('/\.png/','',$relativepath) . "-";
for ($i = 0; $i < 20; $i++) for ($i = 0; $i < 20; $i++)
{ {
$preview = $multiple.$i.'.png'; $preview = $multiple.$i.'.png';
if (file_exists($dir_output.$preview)) if (file_exists($dir_output.$preview))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($preview).'"><p>'; print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($preview).'"><p>';
} }
} }
} }

View File

@ -2207,14 +2207,65 @@ class Facture extends CommonObject
} }
else else
{ {
$this->error=$this->lasterror(); $this->error=$this->db->lasterror();
return -1; return -1;
} }
} }
/** /**
* \brief Return amount (with tax) of all credit notes and deposits invoices used by invoice * Return list of payments
* \return int <0 if KO, Sum of credit notes and deposits amount otherwise * @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() function getSumCreditNotesUsed()
{ {
@ -2234,8 +2285,8 @@ class Facture extends CommonObject
} }
/** /**
* \brief Return amount (with tax) of all deposits invoices used by invoice * Return amount (with tax) of all deposits invoices used by invoice
* \return int <0 if KO, Sum of deposits amount otherwise * @return int <0 if KO, Sum of deposits amount otherwise
*/ */
function getSumDepositsUsed() function getSumDepositsUsed()
{ {
@ -2902,9 +2953,9 @@ class Facture extends CommonObject
} }
/** /**
* \brief Supprime une demande de prelevement * Supprime une demande de prelevement
* \param user utilisateur creant la demande * @param user utilisateur creant la demande
* \param did id de la demande a supprimer * @param did id de la demande a supprimer
*/ */
function demande_prelevement_delete($user, $did) function demande_prelevement_delete($user, $did)
{ {

View File

@ -400,6 +400,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
dol_fiche_end(); dol_fiche_end();
/* /*
* Withdrawal request * Withdrawal request
*/ */
@ -443,6 +444,9 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print "</div><br>\n"; print "</div><br>\n";
print $langs->trans("DoStandingOrdersBeforePayments").'<br>';
/* /*
* Withdrawals * Withdrawals
*/ */

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
@ -285,7 +285,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '</script>'."\n"; print '</script>'."\n";
} }
print '<form name="add_paiement" action="paiement.php" method="post">'; print '<form name="add_paiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add_paiement">'; print '<input type="hidden" name="action" value="add_paiement">';
print '<input type="hidden" name="facid" value="'.$facture->id.'">'; print '<input type="hidden" name="facid" value="'.$facture->id.'">';
@ -634,6 +634,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
{ {
// print '<tr><td colspan="3" align="center">'; // print '<tr><td colspan="3" align="center">';
print '<center><br><input type="checkbox" checked="checked" name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically"); print '<center><br><input type="checkbox" checked="checked" name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically");
/*if ($conf->prelevement->enabled)
{
$langs->load("withdrawals");
if ($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS) print '<br>'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed");
}*/
print '<br><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>'; print '<br><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
// print '</td></tr>'; // print '</td></tr>';
} }

View File

@ -185,12 +185,25 @@ class Paiement extends CommonObject
$deposits=$invoice->getSumDepositsUsed(); $deposits=$invoice->getSumDepositsUsed();
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
// If there is withdrawals request to do and not done yet, we wait before closing.
if ($remaintopay == 0) $mustwait=0;
$listofpayments=$invoice->getListOfPayments();
foreach($listofpayments as $paym)
{ {
$result=$invoice->set_paid($user,'',''); // This payment might be this one or a previous one
if ($paym['type']=='PRE')
{
if ($conf->prelevement->enabled)
{
// TODO Check if this payment has a withdraw request
// if not, $mustwait++; // This will disable automatic close on invoice to allow to process
}
}
} }
else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing.");
if ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more.");
else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more.");
else $result=$invoice->set_paid($user,'','');
} }
} }
else else
@ -282,7 +295,7 @@ class Paiement extends CommonObject
} }
} }
// Efface la ligne de paiement (dans paiement_facture et paiement) // Delete payment (into paiement_facture and paiement)
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement_facture'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement_facture';
$sql.= ' WHERE fk_paiement = '.$this->id; $sql.= ' WHERE fk_paiement = '.$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);

View File

@ -416,8 +416,6 @@ class BonPrelevement extends CommonObject
$subject = $langs->trans("InfoCreditSubject", $this->ref); $subject = $langs->trans("InfoCreditSubject", $this->ref);
$message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date,'dayhour')); $message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date,'dayhour'));
$this->Notify($user, "cr", $subject, $message);
//Add payment of withdrawal into bank //Add payment of withdrawal into bank
$bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; $bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
$facs = array(); $facs = array();
@ -538,7 +536,7 @@ class BonPrelevement extends CommonObject
$message = $langs->trans("InfoTransMessage", $this->ref, $user->prenom, $user->nom); $message = $langs->trans("InfoTransMessage", $this->ref, $user->prenom, $user->nom);
$message .=$langs->trans("InfoTransData", price($this->amount), $this->methodes_trans[$this->method_trans], dol_print_date($date,'day')); $message .=$langs->trans("InfoTransData", price($this->amount), $this->methodes_trans[$this->method_trans], dol_print_date($date,'day'));
$this->Notify($user,"tr", $subject, $message, 1); // TODO Call trigger to create a notification using notification module
} }
else else
{ {
@ -573,66 +571,6 @@ class BonPrelevement extends CommonObject
} }
} }
/**
* Notify withdrawal actions
* @param user id of user
* @param action notify action
* @param subject message subject
* @param message message
* @param joinfile files joineds
* @return int >0 if OK, <0 if KO
*/
function Notify($user, $action, $subject, $message, $joinfile=0)
{
global $conf,$langs;
$message .= "\n\n--\n";
$message .= $langs->trans("InfoFoot"); //"Ceci est un message automatique envoye par Dolibarr";
$sql = "SELECT u.name, u.firstname, u.email";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " , ".MAIN_DB_PREFIX."prelevement_notifications as pn";
$sql.= " WHERE pn.action = '".$action."'";
$sql.= " AND u.rowid = pn.fk_user";
$sql.= " AND u.entity IN (0,".$conf->entity.")";
dol_syslog("BonPrelevement::Notify: ".$sql, LOG_CRIT);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
$sendto = $obj->firstname . " " .$obj->name . "<".$obj->email.">";
$from = $user->prenom . " " .$user->nom . "<".$user->email.">";
$arr_file = array();
$arr_mime = array();
$arr_name = array();
$msgishtml=0;
if ($joinfile == 1)
{
$arr_file = array($conf->prelevement->dir_output.'/receipts/'.$this->ref.'.ps');
$arr_mime = array("application/ps");
$arr_name = array($this->ref.".ps");
}
$mailfile = new CMailFile($subject,$sendto,$from,$message,
$arr_file,$arr_mime,$arr_name,
'', '', 0, $msgishtml);
$result=$mailfile->sendfile();
$i++;
}
$this->db->free($resql);
}
}
/** /**
* Get invoice list * Get invoice list
* @return array id of invoices * @return array id of invoices

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
@ -76,7 +76,9 @@ print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("NbOfInvoiceToWithdraw").'</td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("NbOfInvoiceToWithdraw").'</td>';
print '<td align="right">'; print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/demandes.php?status=0&mainmenu=bank">';
print $bprev->NbFactureAPrelever(); print $bprev->NbFactureAPrelever();
print '</a>';
print '</td></tr>'; print '</td></tr>';
$var=!$var; $var=!$var;
print '<tr class="liste_total"><td>'.$langs->trans("AmountToWithdraw").'</td>'; print '<tr class="liste_total"><td>'.$langs->trans("AmountToWithdraw").'</td>';
@ -86,6 +88,57 @@ print '</td></tr></table><br>';
print '</td><td valign="top" width="70%">'; print '</td><td valign="top" width="70%">';
/*
* Withdraw receipts
*/
$limit=5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec";
$sql .= " ,p.statut ";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " ORDER BY datec DESC LIMIT ".$limit;
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$var=True;
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("LastWithdrawalReceipt",$limit).'</td>';
print '<td>'.$langs->trans("Date").'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '</tr>';
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<img border="0" src="./img/statut'.$obj->statut.'.png"></a>&nbsp;';
print '<a href="fiche.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
print '<td>'.dol_print_date($db->jdate($obj->datec),"dayhour")."</td>\n";
print '<td align="right">'.price($obj->amount)."</td>\n";
print "</tr>\n";
$i++;
}
print "</table><br>";
$db->free($result);
}
else
{
dol_print_error($db);
}
/* /*
* Invoices waiting for withdraw * Invoices waiting for withdraw
*/ */
@ -163,56 +216,6 @@ else
} }
/*
* Withdraw receipts
*/
$limit=5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec";
$sql .= " ,p.statut ";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " ORDER BY datec DESC LIMIT ".$limit;
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$var=True;
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("LastWithdrawalReceipt",$limit).'</td>';
print '<td>'.$langs->trans("Date").'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '</tr>';
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<img border="0" src="./img/statut'.$obj->statut.'.png"></a>&nbsp;';
print '<a href="fiche.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
print '<td>'.dol_print_date($db->jdate($obj->datec),"dayhour")."</td>\n";
print '<td align="right">'.price($obj->amount)."</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($result);
}
else
{
dol_print_error($db);
}
print '</td></tr></table>'; print '</td></tr></table>';
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');

View File

@ -44,7 +44,7 @@ $result = restrictedArea($user, 'prelevement','','','bons');
llxHeader('',$langs->trans("WithdrawStatistics")); llxHeader('',$langs->trans("WithdrawStatistics"));
print_fiche_titre($langs->trans("WithdrawStatistics")); print_fiche_titre($langs->trans("Statistics"));
// Define total and nbtotal // Define total and nbtotal
$sql = "SELECT sum(pl.amount), count(pl.amount)"; $sql = "SELECT sum(pl.amount), count(pl.amount)";
@ -70,6 +70,10 @@ if ($resql)
/* /*
* Stats * Stats
*/ */
print '<br>';
print_titre($langs->trans("WithdrawStatistics"));
$ligne=new LignePrelevement($db,$user); $ligne=new LignePrelevement($db,$user);
$sql = "SELECT sum(pl.amount), count(pl.amount), pl.statut"; $sql = "SELECT sum(pl.amount), count(pl.amount), pl.statut";
@ -140,6 +144,7 @@ else
print '<br>'; print '<br>';
print_titre($langs->trans("WithdrawRejectStatistics")); print_titre($langs->trans("WithdrawRejectStatistics"));
// Define total and nbtotal // Define total and nbtotal
$sql = "SELECT sum(pl.amount), count(pl.amount)"; $sql = "SELECT sum(pl.amount), count(pl.amount)";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";

View File

@ -207,7 +207,6 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk
-- Withdrawal -- Withdrawal
insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled', __HANDLER__, 'left', 2500__+MAX_llx_menu__, 'accountancy', '', 14__+MAX_llx_menu__, '/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank', 'StandingOrders', 0, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 9, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled', __HANDLER__, 'left', 2500__+MAX_llx_menu__, 'accountancy', '', 14__+MAX_llx_menu__, '/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank', 'StandingOrders', 0, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 9, __ENTITY__);
insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2502__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/create.php?leftmenu=withdraw', 'NewStandingOrder', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2502__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/create.php?leftmenu=withdraw', 'NewStandingOrder', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 0, __ENTITY__);
insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2501__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/demandes.php?status=0&amp;leftmenu=withdraw', 'StandingOrderToProcess', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2503__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/bons.php?leftmenu=withdraw', 'WithdrawalsReceipts', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 2, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2503__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/bons.php?leftmenu=withdraw', 'WithdrawalsReceipts', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 2, __ENTITY__);
insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2504__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/liste.php?leftmenu=withdraw', 'WithdrawalsLines', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 3, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2504__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/liste.php?leftmenu=withdraw', 'WithdrawalsLines', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 3, __ENTITY__);
insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2506__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/rejets.php?leftmenu=withdraw', 'Rejects', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 5, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2506__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/rejets.php?leftmenu=withdraw', 'Rejects', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 5, __ENTITY__);

View File

@ -1025,11 +1025,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
{ {
$newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank",$langs->trans("StandingOrders"),0,$user->rights->prelevement->bons->lire); $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank",$langs->trans("StandingOrders"),0,$user->rights->prelevement->bons->lire);
//if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/demandes.php?status=0&amp;mainmenu=bank",$langs->trans("StandingOrderToProcess"),1,$user->rights->prelevement->bons->lire);
if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/create.php?mainmenu=bank",$langs->trans("NewStandingOrder"),1,$user->rights->prelevement->bons->creer); if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/create.php?mainmenu=bank",$langs->trans("NewStandingOrder"),1,$user->rights->prelevement->bons->creer);
//if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/demandes.php",$langs->trans("StandingOrder"),1,$user->rights->prelevement->bons->lire);
if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/demandes.php?status=0&amp;mainmenu=bank",$langs->trans("StandingOrderToProcess"),1,$user->rights->prelevement->bons->lire);
//if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/demandes.php?status=1",$langs->trans("StandingOrderProcessed"),2,$user->rights->prelevement->bons->lire);
if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/bons.php?mainmenu=bank",$langs->trans("WithdrawalsReceipts"),1,$user->rights->prelevement->bons->lire); if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/bons.php?mainmenu=bank",$langs->trans("WithdrawalsReceipts"),1,$user->rights->prelevement->bons->lire);
if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/liste.php?mainmenu=bank",$langs->trans("WithdrawalsLines"),1,$user->rights->prelevement->bons->lire); if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/liste.php?mainmenu=bank",$langs->trans("WithdrawalsLines"),1,$user->rights->prelevement->bons->lire);

View File

@ -10,6 +10,8 @@
-- To change type of field: ALTER TABLE llx_table MODIFY name varchar(60); -- To change type of field: ALTER TABLE llx_table MODIFY name varchar(60);
-- --
DROP table llx_prelevement_notifications;
-- Fix corrupted data -- Fix corrupted data
update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01'; update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01';
@ -376,3 +378,4 @@ update llx_actioncomm set elementtype='contract' where elementtype='contrat';
alter table llx_propal add column tms timestamp after fk_projet; alter table llx_propal add column tms timestamp after fk_projet;

View File

@ -1,36 +0,0 @@
-- ===================================================================
-- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
-- $Id$
-- ===================================================================
--
-- Utilisateur a notifier
--
-- actions :
-- 'NOTIFY_EMT_WITHDRAW' emission d'un bon
-- 'NOTIFY_TRN_WITHDRAW' tranmission d'un bon
-- 'NOTIFY_CRD_WITHDRAW' credit du bon par la banque
create table llx_prelevement_notifications
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_user integer NOT NULL,
action varchar(32)
)ENGINE=innodb;

View File

@ -79,6 +79,8 @@ BankToReceiveWithdraw=Bank account to receive withdraws
CreditDate=Credit on CreditDate=Credit on
WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country
ShowWithdraw=Show Withdraw ShowWithdraw=Show Withdraw
IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one withdrawal payment not yet processed, it won't be set as payed to allow to manage withdrawal before.
DoStandingOrdersBeforePayments=This tabs allows you to request for a standing order. Once it will be finished, you can type the payment to close the invoice.
### Notifications ### Notifications
InfoCreditSubject=Payment of standing order %s by the bank InfoCreditSubject=Payment of standing order %s by the bank

View File

@ -79,6 +79,8 @@ BankToReceiveWithdraw=Compte bancaire recevant les prélèvements
CreditDate=Crédité le CreditDate=Crédité le
WithdrawalFileNotCapable=Impossible de generer fichier de bon de prelevements pour votre pays WithdrawalFileNotCapable=Impossible de generer fichier de bon de prelevements pour votre pays
ShowWithdraw=Voir prélèvement ShowWithdraw=Voir prélèvement
IfInvoiceNeedOnWithdrawPaymentWontBeClosed=Toutefois, si la facture a au moins un paiement par prélèvement non traité, elle ne le sera pas afin de permettre la gestion du prélèvement d'abord.
DoStandingOrdersBeforePayments=Cet onglet permet de faire une demande de pélèvement bancaire. Une fois terminé, vous pourrez saisir le payement sur la facture pour la clore.
### Notifications ### Notifications
InfoCreditSubject=Credit prélèvement %s a la banque InfoCreditSubject=Credit prélèvement %s a la banque

View File

@ -91,13 +91,10 @@ function prelevement_prepare_head($object)
function prelevement_check_config() function prelevement_check_config()
{ {
global $conf; global $conf;
if(empty($conf->global->PRELEVEMENT_USER)) return -1;
if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1; if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
if(empty($conf->global->PRELEVEMENT_CODE_BANQUE)) return -1;
if(empty($conf->global->PRELEVEMENT_CODE_GUICHET)) return -1;
if(empty($conf->global->PRELEVEMENT_NUMERO_COMPTE)) return -1;
if(empty($conf->global->PRELEVEMENT_NUMBER_KEY)) return -1;
if(empty($conf->global->PRELEVEMENT_RAISON_SOCIALE)) return -1;
if(empty($conf->global->PRELEVEMENT_NUMERO_NATIONAL_EMETTEUR)) return -1; if(empty($conf->global->PRELEVEMENT_NUMERO_NATIONAL_EMETTEUR)) return -1;
return 0; return 0;
} }
?> ?>