Qual: Uniformisation du code. Les dates de paiements dans les objets sont gérées au format timestamp

Qual: Ajout de controles sur la saisie d'une transaction bancaire
This commit is contained in:
Laurent Destailleur 2007-02-04 21:23:58 +00:00
parent 05b9c19c8b
commit 7d7c1e8dc1
22 changed files with 268 additions and 157 deletions

View File

@ -788,7 +788,7 @@ class Adherent
{ {
$acct=new Account($this->db,$accountid); $acct=new Account($this->db,$accountid);
$dateop=strftime("%Y%m%d",time()); $dateop=time();
$insertid=$acct->addline($dateop, $operation, $label, $montant, $num_chq, '', $user); $insertid=$acct->addline($dateop, $operation, $label, $montant, $num_chq, '', $user);
if ($insertid > 0) if ($insertid > 0)

View File

@ -59,7 +59,7 @@ if ($_POST["action"] == '2bank' && $_POST["rowid"] !='')
// \todo Créer une facture et enregistrer son paiement // \todo Créer une facture et enregistrer son paiement
$dateop=strftime("%Y%m%d",time()); $dateop=time();
$sql="SELECT cotisation FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid=".$_POST["rowid"]." "; $sql="SELECT cotisation FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid=".$_POST["rowid"]." ";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)

View File

@ -308,7 +308,7 @@ if ($_POST["action"] == 'add')
// insertion dans la gestion banquaire si configure pour // insertion dans la gestion banquaire si configure pour
if ($global->conf->ADHERENT_BANK_USE) if ($global->conf->ADHERENT_BANK_USE)
{ {
$dateop=strftime("%Y%m%d",time()); $dateop=time();
$amount=$cotisation; $amount=$cotisation;
$acct=new Account($db,$_POST["accountid"]); $acct=new Account($db,$_POST["accountid"]);
$insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"], '', $user); $insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"], '', $user);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -69,7 +69,7 @@ print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Value").'</td>'; print '<td>'.$langs->trans("Value").'</td>';
print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Note").'</td>'; print '<td>'.$langs->trans("Note").'</td>';
print '<td>'.$langs->trans("Action").'</td>'; print '<td align="center">'.$langs->trans("Action").'</td>';
print "</tr>\n"; print "</tr>\n";
@ -82,21 +82,17 @@ print '<form action="const.php" method="POST">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print "<tr $bc[$var] class=value><td><input type=\"text\" class=\"flat\" size=\"24\" name=\"constname\" value=\"\"></td>\n"; print "<tr $bc[$var] class=value><td><input type=\"text\" class=\"flat\" size=\"24\" name=\"constname\" value=\"\"></td>\n";
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="30" name="constvalue" value="">'; print '<input type="text" class="flat" size="32" name="constvalue" value="">';
print '</td><td>'; print '</td><td>';
$form->select_array('consttype',array('yesno','texte','chaine'),2); $form->select_array('consttype',array('yesno','texte','chaine'),2);
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat" size="24" name="constnote" value="">';
print '<input type="text" class="flat" size="15" name="constnote" value="">'; print '</td><td align="center">';
print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="Button"><br>'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="Button"><br>';
print "</td>\n"; print "</td>\n";
print '</tr>'; print '</tr>';
print '</form>'; print '</form>';
@ -143,15 +139,15 @@ if ($result)
} }
else else
{ {
print '<input type="text" class="flat" size="30" name="constvalue" value="'.stripslashes($obj->value).'">'; print '<input type="text" class="flat" size="32" name="constvalue" value="'.stripslashes($obj->value).'">';
print '</td><td>'; print '</td><td>';
$form->select_array('consttype',array('yesno','texte','chaine'),2); $form->select_array('consttype',array('yesno','texte','chaine'),2);
} }
print '</td><td>'; print '</td><td>';
// Note // Note
print '<input type="text" class="flat" size="15" name="constnote" value="'.stripslashes(nl2br($obj->note)).'">'; print '<input type="text" class="flat" size="24" name="constnote" value="'.stripslashes(nl2br($obj->note)).'">';
print '</td><td>'; print '</td><td align="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="button"> &nbsp; '; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="button"> &nbsp; ';
print '<a href="const.php?rowid='.$obj->rowid.'&action=delete">'.img_delete().'</a>'; print '<a href="const.php?rowid='.$obj->rowid.'&action=delete">'.img_delete().'</a>';
print "</td></tr>\n"; print "</td></tr>\n";

View File

@ -191,13 +191,32 @@ class Account
/** /**
\brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank \brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
\return int rowid de l'entrée ajoutée, <0 si erreur \param $date Date TMS opération
\param $oper 1,2,3,4...
\param $label Descripton
\param $amount Montant
\param $num_chq Numero cheque ou virement
\param $categorie Categorie optionnelle
\param $user Utilisateur qui crée
\param $emetteur Nom emetteur
\param $banque Banque emettrice
\return int Rowid de l'entrée ajoutée, <0 si erreur
*/ */
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user='',$emetteur='',$banque='') function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user, $emetteur='',$banque='')
{ {
// Nettoyage parametres
$emetteur=trim($emetteur);
$banque=trim($banque);
dolibarr_syslog("Account::Addline: date=".$date.", oper=".$oper.", label=".$label.", amount=".$amount.", num_chq=".$num_chq.", categorie=".$categorie.", user=".$user->id); dolibarr_syslog("Account::Addline: date=".$date.", oper=".$oper.", label=".$label.", amount=".$amount.", num_chq=".$num_chq.", categorie=".$categorie.", user=".$user->id);
if ($this->rowid)
// Verififcation parametres
if (! $this->rowid)
{ {
$this->error="Account::addline rowid not defined";
return -1;
}
$this->db->begin(); $this->db->begin();
switch ($oper) switch ($oper)
@ -228,9 +247,10 @@ class Account
$datev = $date; $datev = $date;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, dateo, datev, label, amount, fk_user_author, num_chq, fk_account, fk_type,emetteur,banque)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, dateo, datev, label, amount, fk_user_author, num_chq, fk_account, fk_type,emetteur,banque)";
$sql.= " VALUES (now(),'".$date."','$datev','".addslashes($label)."','" . price2num($amount)."','".$user->id."','$num_chq','".$this->rowid."', '$oper'"; $sql.= " VALUES (now(),'".$this->db->idate($date)."','".$this->db->idate($datev)."',";
$sql.= ",'".addslashes(trim($emetteur))."'"; $sql.= "'".addslashes($label)."','" . price2num($amount)."','".$user->id."','$num_chq','".$this->rowid."', '$oper'";
$sql.= ",'".addslashes(trim($banque))."');"; $sql.= ",'".addslashes($emetteur)."'";
$sql.= ",'".addslashes($banque)."');";
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -256,12 +276,6 @@ class Account
return -2; return -2;
} }
} }
else
{
$this->error="Account::addline rowid not defined";
return -1;
}
}
/* /*
* \brief Creation du compte bancaire en base * \brief Creation du compte bancaire en base

View File

@ -43,6 +43,8 @@ $vline=isset($_GET["vline"])?$_GET["vline"]:$_POST["vline"];
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
$page=isset($_GET["page"])?$_GET["page"]:0; $page=isset($_GET["page"])?$_GET["page"]:0;
$mesg='';
/* /*
* Action * Action
@ -50,6 +52,7 @@ $page=isset($_GET["page"])?$_GET["page"]:0;
if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->banque->modifier)
{ {
if ($_POST["credit"] > 0) if ($_POST["credit"] > 0)
{ {
$amount = $_POST["credit"]; $amount = $_POST["credit"];
@ -59,13 +62,18 @@ if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]) && $user-
$amount = - $_POST["debit"]; $amount = - $_POST["debit"];
} }
$dateop = $_POST["dateoy"].$_POST["dateo"]; $dateop = dolibarr_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]);
$operation=$_POST["operation"];
$label=$_POST["label"];
$operation=$_POST["operation"]; $operation=$_POST["operation"];
$num_chq=$_POST["num_chq"]; $num_chq=$_POST["num_chq"];
$label=$_POST["label"];
$cat1=$_POST["cat1"]; $cat1=$_POST["cat1"];
if (! $dateop) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Date"));
if (! $operation) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Type"));
if (! $amount) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount"));
if (! $mesg)
{
$acct=new Account($db,$account); $acct=new Account($db,$account);
$insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
@ -78,6 +86,11 @@ if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]) && $user-
{ {
dolibarr_print_error($db,$acct->error); dolibarr_print_error($db,$acct->error);
} }
}
else
{
$_GET["action"]='addline';
}
} }
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"]=='yes' && $user->rights->banque->modifier) if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"]=='yes' && $user->rights->banque->modifier)
{ {
@ -194,25 +207,28 @@ if ($account > 0)
dolibarr_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0); dolibarr_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0);
if ($mesg) print '<div class="error">'.$mesg.'</div>';
/** /**
* Bandeau recherche * Bandeau recherche
*/ */
$mesg=''; $navig='';
$nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total $nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total
if ($limitsql > $viewline) if ($limitsql > $viewline)
{ {
$mesg.='<a href="account.php?account='.$acct->id.'&amp;page='.($page+1).'">'.img_previous().'</a>'; $navig.='<a href="account.php?account='.$acct->id.'&amp;page='.($page+1).'">'.img_previous().'</a>';
} }
$mesg.= ' Page '.($nbpage-$page).'/'.$nbpage.' '; $navig.= ' Page '.($nbpage-$page).'/'.$nbpage.' ';
if ($total_lines > $limitsql ) if ($total_lines > $limitsql )
{ {
$mesg.= '<a href="account.php?account='.$acct->id.'&amp;page='.($page-1).'">'.img_next().'</a>'; $navig.= '<a href="account.php?account='.$acct->id.'&amp;page='.($page-1).'">'.img_next().'</a>';
} }
if (! $_GET["action"]=='addline' && ! $_GET["action"]=='delete') if (! $_GET["action"]=='addline' && ! $_GET["action"]=='delete')
{ {
$titre=$langs->trans("FinancialAccount")." : ".$acct->label; $titre=$langs->trans("FinancialAccount")." : ".$acct->label;
print_fiche_titre($titre,$mesg); print_fiche_titre($titre,$navig);
} }
if ($_GET["action"]=='delete') if ($_GET["action"]=='delete')
@ -226,11 +242,6 @@ if ($account > 0)
print '<table class="notopnoleftnoright" width="100%">'; print '<table class="notopnoleftnoright" width="100%">';
/*
* Affiche tableau des transactions bancaires
*
*/
// Formulaire de saisie d'une opération hors factures // Formulaire de saisie d'une opération hors factures
if ($user->rights->banque->modifier && $_GET["action"]=='addline') if ($user->rights->banque->modifier && $_GET["action"]=='addline')
{ {
@ -246,16 +257,21 @@ if ($account > 0)
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td><small>YYYY MMDD</small></td><td colspan="2">'.$langs->trans("Type").'</td><td>'.$langs->trans("Description").'</td><td align=right>'.$langs->trans("Debit").'</td><td align=right>'.$langs->trans("Credit").'</td>'; print '<td>'.$langs->trans("Date").'</td>';
print '<td colspan="2" align="center">&nbsp;'; print '<td>&nbsp;</td>';
print '</td></tr>'; print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align=right>'.$langs->trans("Debit").'</td>';
print '<td align=right>'.$langs->trans("Credit").'</td>';
print '<td colspan="2" align="center">&nbsp;</td>';
print '</tr>';
print '<tr '.$bc[false].'>'; print '<tr '.$bc[false].'>';
print '<td nowrap>'; print '<td nowrap="nowrap" colspan="2">';
print '<input name="dateoy" class="flat" type="text" size="2" value="'.strftime("%Y",time()).'" maxlength="4">'; $html->select_date(-1,'op',0,0,0,'transaction');
print '<input name="dateo" class="flat" type="text" size="2" maxlength="4"></td>'; print '</td>';
print '<td colspan="2" nowrap>'; print '<td nowrap="nowrap">';
$html->select_types_paiements('','operation','1,2',1); $html->select_types_paiements('','operation','1,2',1,1);
print '<input name="num_chq" class="flat" type="text" size="4"></td>'; print '<input name="num_chq" class="flat" type="text" size="4"></td>';
print '<td>'; print '<td>';
print '<input name="label" class="flat" type="text" size="40">'; print '<input name="label" class="flat" type="text" size="40">';
@ -275,6 +291,11 @@ if ($account > 0)
print "<tr class=\"noborder\"><td colspan=\"8\">&nbsp;</td></tr>\n"; print "<tr class=\"noborder\"><td colspan=\"8\">&nbsp;</td></tr>\n";
} }
/*
* Affiche tableau des transactions bancaires
*
*/
// Ligne de titre tableau des acritures // Ligne de titre tableau des acritures
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Value").'</td><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Value").'</td><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Description").'</td>';

View File

@ -56,10 +56,10 @@ if ($_POST['action'] == 'add_paiement' || $_POST['action'] == 'confirm_paiement'
{ {
$error = 0; $error = 0;
$datepaye = $db->idate(mktime(12, 0 , 0, $datepaye = dolibarr_mktime(12, 0 , 0,
$_POST['remonth'], $_POST['remonth'],
$_POST['reday'], $_POST['reday'],
$_POST['reyear'])); $_POST['reyear']);
$paiement_id = 0; $paiement_id = 0;
// Verifie si des paiements sont supérieurs au montant facture // Verifie si des paiements sont supérieurs au montant facture

View File

@ -48,7 +48,7 @@ $mesg='';
* Actions * Actions
*/ */
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->facture->creer) if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement)
{ {
$db->begin(); $db->begin();
@ -68,7 +68,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user-
} }
} }
if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->facture->creer) if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement)
{ {
$db->begin(); $db->begin();
@ -129,7 +129,7 @@ dolibarr_fiche_head($head, $hselected, $langs->trans("Payment").": ".$paiement->
*/ */
if ($_GET['action'] == 'delete') if ($_GET['action'] == 'delete')
{ {
$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), 'Etes-vous sûr de vouloir supprimer ce paiement ?', 'confirm_delete'); $html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete');
print '<br>'; print '<br>';
} }
@ -262,13 +262,18 @@ print '<div class="tabsAction">';
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '') if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
{ {
print '<a class="tabAction" href="fiche.php?id='.$_GET['id'].'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>'; if ($user->rights->facture->paiement)
} {
print '<a class="butAction" href="fiche.php?id='.$_GET['id'].'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
}
}
if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '') if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '')
{ {
print '<a class="butDelete" href="fiche.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>'; if ($user->rights->facture->paiement)
{
print '<a class="butActionDelete" href="fiche.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
} }
print '</div>'; print '</div>';

View File

@ -32,7 +32,7 @@
require('./pre.inc.php'); require('./pre.inc.php');
require('./paiementfourn.class.php'); require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
$langs->load('companies'); $langs->load('companies');
$langs->load('bills'); $langs->load('bills');
@ -61,10 +61,10 @@ if ($action == 'add_paiement')
{ {
$error = 0; $error = 0;
$datepaye = $db->idate(mktime(12, 0 , 0, $datepaye = dolibarr_mktime(12, 0 , 0,
$_POST['remonth'], $_POST['remonth'],
$_POST['reday'], $_POST['reday'],
$_POST['reyear'])); $_POST['reyear']);
$paiement_id = 0; $paiement_id = 0;
$total = 0; $total = 0;
// Génère tableau des montants amounts // Génère tableau des montants amounts

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -21,7 +21,7 @@
* $Source$ * $Source$
*/ */
/*! /**
\file htdocs/fourn/facture/paiementfourn.class.php \file htdocs/fourn/facture/paiementfourn.class.php
\ingroup fournisseur, facture \ingroup fournisseur, facture
\brief Page de création de paiement factures fournisseurs \brief Page de création de paiement factures fournisseurs
@ -140,7 +140,7 @@ class PaiementFourn
if ($this->total <> 0) // On accepte les montants négatifs if ($this->total <> 0) // On accepte les montants négatifs
{ {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author)'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author)';
$sql .= ' VALUES (now(), '.$this->datepaye.', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')'; $sql .= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')';
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -309,6 +309,8 @@ class PaiementFourn
function valide() function valide()
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn SET statut = 1 WHERE rowid = '.$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn SET statut = 1 WHERE rowid = '.$this->id;
dolibarr_syslog("PaiementFourn::valide sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -316,7 +318,8 @@ class PaiementFourn
} }
else else
{ {
dolibarr_syslog('Paiement::Valide Error -1'); $this->error='Paiement::Valide Error -1 '.$this->db->error();
dolibarr_syslog('PaiementFourn::valide error '.$this->error);
return -1; return -1;
} }
} }
@ -331,6 +334,7 @@ class PaiementFourn
$sql .= ', '.$this->db->pdate('tms').' as tms'; $sql .= ', '.$this->db->pdate('tms').' as tms';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c';
$sql .= ' WHERE c.rowid = '.$id; $sql .= ' WHERE c.rowid = '.$id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -397,5 +401,57 @@ class PaiementFourn
} }
} }
/**
* \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
* \return string Libelle
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->statut,$mode);
}
/**
* \brief Renvoi le libellé d'un statut donne
* \param status Statut
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
* \return string Libellé du statut
*/
function LibStatut($status,$mode=0)
{
global $langs; // TODO Renvoyer le libellé anglais et faire traduction a affichage
$langs->load('compta');
if ($mode == 0)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 1)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 3)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 4)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 5)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
return $langs->trans('Unknown');
}
} }
?> ?>

View File

@ -35,10 +35,12 @@ require('./pre.inc.php');
require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php'); require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
$user->getrights('facture'); $user->getrights('facture');
$user->getrights('fournisseur');
$langs->load('bills'); $langs->load('bills');
$langs->load('banks'); $langs->load('banks');
$langs->load('companies'); $langs->load('companies');
$langs->load("suppliers");
$mesg=''; $mesg='';
@ -47,7 +49,7 @@ $mesg='';
* Actions * Actions
*/ */
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->facture->creer) if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer)
{ {
$db->begin(); $db->begin();
@ -67,7 +69,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user-
} }
} }
if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->facture->creer) if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider)
{ {
$db->begin(); $db->begin();
@ -110,7 +112,7 @@ $head[$h][1] = $langs->trans('Info');
$h++; $h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Payment').': '.$paiement->ref); dolibarr_fiche_head($head, $hselected, $langs->trans('SupplierPayment'));
/* /*
* Confirmation de la suppression du paiement * Confirmation de la suppression du paiement
@ -162,13 +164,13 @@ if ($paiement->numero)
print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>'; print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>';
} }
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans('Status').'</td><td colspan="3">'.$paiement->getLibStatut(4).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
print '</table>'; print '</table>';
/* /**
* * Liste des factures
*
*/ */
$allow_delete = 1 ; $allow_delete = 1 ;
$sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.idp'; $sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.idp';
@ -234,15 +236,21 @@ print '</div>';
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '') if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
{ {
if ($user->rights->fournisseur->facture->valider)
{
print '<a class="tabAction" href="fiche.php?id='.$_GET['id'].'&amp;action=valide">'.$langs->trans('Valid').'</a>'; print '<a class="tabAction" href="fiche.php?id='.$_GET['id'].'&amp;action=valide">'.$langs->trans('Valid').'</a>';
}
}
}
if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '') if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '')
{ {
if ($user->rights->fournisseur->facture->supprimer)
{
print '<a class="butDelete" href="fiche.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>'; print '<a class="butDelete" href="fiche.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
} }
print '</div>'; print '</div>';

View File

@ -31,6 +31,7 @@ require("./pre.inc.php");
require(DOL_DOCUMENT_ROOT."/fourn/facture/paiementfourn.class.php"); require(DOL_DOCUMENT_ROOT."/fourn/facture/paiementfourn.class.php");
$langs->load("bills"); $langs->load("bills");
$langs->load("suppliers");
$langs->load("companies"); $langs->load("companies");
llxHeader(); llxHeader();
@ -45,7 +46,7 @@ $head[$h][1] = $langs->trans("Info");
$hselected = $h; $hselected = $h;
$h++; $h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Payment").": ".$_GET["id"]); dolibarr_fiche_head($head, $hselected, $langs->trans("SupplierPayment"));
/* /*

View File

@ -1144,8 +1144,9 @@ class Form
* \param htmlname Nom de la zone select * \param htmlname Nom de la zone select
* \param filtertype Pour filtre * \param filtertype Pour filtre
* \param format 0=id+libelle, 1=code+code, 2=code+libelle * \param format 0=id+libelle, 1=code+code, 2=code+libelle
* \param empty 1=peut etre vide, 0 sinon
*/ */
function select_types_paiements($selected='',$htmlname='paiementtype',$filtertype='',$format=0) function select_types_paiements($selected='',$htmlname='paiementtype',$filtertype='',$format=0, $empty=0)
{ {
global $langs; global $langs;
@ -1159,6 +1160,7 @@ class Form
$this->load_cache_types_paiements(); $this->load_cache_types_paiements();
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
if ($empty) print '<option value="">&nbsp;</option>';
foreach($this->cache_types_paiements_code as $id => $code) foreach($this->cache_types_paiements_code as $id => $code)
{ {
// On passe si on a demandé de filtrer sur des modes de paiments particulièrs // On passe si on a demandé de filtrer sur des modes de paiments particulièrs

View File

@ -38,6 +38,8 @@ SupplierBills=suppliers invoices
BillContacts=Invoice contacts BillContacts=Invoice contacts
Payment=Payment Payment=Payment
Payments=Payments Payments=Payments
DeletePayment=Delete payment
ConfirmDeletePayment=Are you sure you want to delete this payment ?
ReceivedPayments=Received payments ReceivedPayments=Received payments
ReceivedCustomersPayments=Payments received from customers ReceivedCustomersPayments=Payments received from customers
ReceivedCustomersPaymentsToValid=Received customers payments to validate ReceivedCustomersPaymentsToValid=Received customers payments to validate

View File

@ -78,6 +78,8 @@ InvoiceValidatedInDolibarr=Invoice %s validated in Dolibarr
InvoicePayedInDolibarr=Invoice %s changed to payed in Dolibarr InvoicePayedInDolibarr=Invoice %s changed to payed in Dolibarr
InvoiceCanceledInDolibarr=Invoice %s canceled in Dolibarr InvoiceCanceledInDolibarr=Invoice %s canceled in Dolibarr
PaymentDoneInDolibarr=Payment %s done in Dolibarr PaymentDoneInDolibarr=Payment %s done in Dolibarr
CustomerPaymentDoneInDolibarr=Customer payment %s done in Dolibarr
SupplierPaymentDoneInDolibarr=Supplier payment %s done in Dolibarr
##### Export ##### ##### Export #####
ExportsArea=Exports area ExportsArea=Exports area
AvailableFormats=Available formats AvailableFormats=Available formats

View File

@ -17,3 +17,4 @@ ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier
ErrorSupplierCountryIsNotDefined=Country for this supplier is not defined. Correct this first. ErrorSupplierCountryIsNotDefined=Country for this supplier is not defined. Correct this first.
ProductHasAlreadyReferenceInThisSupplier=This product has already a reference in this supplier ProductHasAlreadyReferenceInThisSupplier=This product has already a reference in this supplier
NoRecordedSuppliers=No suppliers recorded NoRecordedSuppliers=No suppliers recorded
SupplierPayment=Supplier payment

View File

@ -38,6 +38,8 @@ SupplierBills=Factures fournisseurs
BillContacts=Contacts facture BillContacts=Contacts facture
Payment=Réglement Payment=Réglement
Payments=Réglements Payments=Réglements
DeletePayment=Supprimer le paiement
ConfirmDeletePayment=Etes vous sur de vouloir supprimer ce paiement ?
ReceivedPayments=Réglements reçus ReceivedPayments=Réglements reçus
ReceivedCustomersPayments=Réglements reçus du client ReceivedCustomersPayments=Réglements reçus du client
ReceivedCustomersPaymentsToValid=Réglements clients reçus à valider ReceivedCustomersPaymentsToValid=Réglements clients reçus à valider

View File

@ -17,3 +17,4 @@ ErrorQtyTooLowForThisSupplier=Quantit
ErrorSupplierCountryIsNotDefined=Le pays de ce fournisseur n'est pas défini. Corriger sur sa fiche. ErrorSupplierCountryIsNotDefined=Le pays de ce fournisseur n'est pas défini. Corriger sur sa fiche.
ProductHasAlreadyReferenceInThisSupplier=Ce produit a déjà une référence chez ce fournisseur ProductHasAlreadyReferenceInThisSupplier=Ce produit a déjà une référence chez ce fournisseur
NoRecordedSuppliers=Pas de fournisseurs enregistrés NoRecordedSuppliers=Pas de fournisseurs enregistrés
SupplierPayment=Paiement fournisseur

View File

@ -441,7 +441,7 @@ class DoliDb
} }
/** /**
\brief Formatage (par PHP) d'une date au format texte pour insertion dans champ date. \brief Formatage (par PHP) d'une date vers format texte pour insertion dans champ date.
Fonction à utiliser pour générer les INSERT. Fonction à utiliser pour générer les INSERT.
\param param Date TMS à convertir \param param Date TMS à convertir
\return date Date au format texte YYYYMMDDHHMMSS. \return date Date au format texte YYYYMMDDHHMMSS.

View File

@ -436,7 +436,7 @@ class DoliDb
} }
/** /**
\brief Formatage (par PHP) de la date en texte qui s'insere dans champ date. \brief Formatage (par PHP) d'une date vers format texte pour insertion dans champ date.
Fonction à utiliser pour générer les INSERT. Fonction à utiliser pour générer les INSERT.
\param param Date tms à convertir \param param Date tms à convertir
\return date Date au format text YYYYMMDDHHMMSS. \return date Date au format text YYYYMMDDHHMMSS.

View File

@ -137,7 +137,7 @@ class Paiement
if ($this->total <> 0) // On accepte les montants négatifs pour les rejets de prélèvement if ($this->total <> 0) // On accepte les montants négatifs pour les rejets de prélèvement
{ {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)';
$sql .= ' VALUES (now(), '.$this->datepaye.', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')'; $sql .= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')';
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -238,7 +238,7 @@ class Tva
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/account.class.php'); require_once(DOL_DOCUMENT_ROOT.'/compta/bank/account.class.php');
$acc = new Account($this->db, $this->accountid); $acc = new Account($this->db, $this->accountid);
$bank_line_id = $acc->addline($this->db->idate($this->datep), $this->paymenttype, $this->label, -abs($this->amount), '', '', $user); $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
// Mise a jour fk_bank dans llx_paiementtva. On connait ainsi la ligne de tva qui a généré l'écriture bancaire // Mise a jour fk_bank dans llx_paiementtva. On connait ainsi la ligne de tva qui a généré l'écriture bancaire
if ($bank_line_id) { if ($bank_line_id) {