mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Qual: Uniformisation du code. Les dates de paiements dans les objets sont gres au format timestamp
Qual: Ajout de controles sur la saisie d'une transaction bancaire
This commit is contained in:
parent
05b9c19c8b
commit
7d7c1e8dc1
|
|
@ -788,7 +788,7 @@ class Adherent
|
|||
{
|
||||
$acct=new Account($this->db,$accountid);
|
||||
|
||||
$dateop=strftime("%Y%m%d",time());
|
||||
$dateop=time();
|
||||
|
||||
$insertid=$acct->addline($dateop, $operation, $label, $montant, $num_chq, '', $user);
|
||||
if ($insertid > 0)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ if ($_POST["action"] == '2bank' && $_POST["rowid"] !='')
|
|||
// \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"]." ";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ if ($_POST["action"] == 'add')
|
|||
// insertion dans la gestion banquaire si configure pour
|
||||
if ($global->conf->ADHERENT_BANK_USE)
|
||||
{
|
||||
$dateop=strftime("%Y%m%d",time());
|
||||
$dateop=time();
|
||||
$amount=$cotisation;
|
||||
$acct=new Account($db,$_POST["accountid"]);
|
||||
$insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"], '', $user);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* 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
|
||||
* 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("Type").'</td>';
|
||||
print '<td>'.$langs->trans("Note").'</td>';
|
||||
print '<td>'.$langs->trans("Action").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Action").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
|
|
@ -82,21 +82,17 @@ print '<form action="const.php" method="POST">';
|
|||
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 '<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>';
|
||||
|
||||
$form->select_array('consttype',array('yesno','texte','chaine'),2);
|
||||
print '</td><td>';
|
||||
|
||||
print '<input type="text" class="flat" size="15" name="constnote" value="">';
|
||||
print '</td><td>';
|
||||
|
||||
print '<input type="text" class="flat" size="24" name="constnote" value="">';
|
||||
print '</td><td align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="Button"><br>';
|
||||
print "</td>\n";
|
||||
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
|
|
@ -143,15 +139,15 @@ if ($result)
|
|||
}
|
||||
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>';
|
||||
$form->select_array('consttype',array('yesno','texte','chaine'),2);
|
||||
}
|
||||
print '</td><td>';
|
||||
|
||||
// Note
|
||||
print '<input type="text" class="flat" size="15" name="constnote" value="'.stripslashes(nl2br($obj->note)).'">';
|
||||
print '</td><td>';
|
||||
print '<input type="text" class="flat" size="24" name="constnote" value="'.stripslashes(nl2br($obj->note)).'">';
|
||||
print '</td><td align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="button"> ';
|
||||
print '<a href="const.php?rowid='.$obj->rowid.'&action=delete">'.img_delete().'</a>';
|
||||
print "</td></tr>\n";
|
||||
|
|
|
|||
|
|
@ -189,79 +189,93 @@ class Account
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
|
||||
\return int rowid de l'entrée ajoutée, <0 si erreur
|
||||
*/
|
||||
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user='',$emetteur='',$banque='')
|
||||
{
|
||||
dolibarr_syslog("Account::Addline: date=".$date.", oper=".$oper.", label=".$label.", amount=".$amount.", num_chq=".$num_chq.", categorie=".$categorie.", user=".$user->id);
|
||||
if ($this->rowid)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
switch ($oper)
|
||||
{
|
||||
case 1:
|
||||
$oper = 'TIP';
|
||||
break;
|
||||
case 2:
|
||||
$oper = 'VIR';
|
||||
break;
|
||||
case 3:
|
||||
$oper = 'PRE';
|
||||
break;
|
||||
case 4:
|
||||
$oper = 'LIQ';
|
||||
break;
|
||||
case 5:
|
||||
$oper = 'VAD';
|
||||
break;
|
||||
case 6:
|
||||
$oper = 'CB';
|
||||
break;
|
||||
case 7:
|
||||
$oper = 'CHQ';
|
||||
break;
|
||||
}
|
||||
/**
|
||||
\brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
|
||||
\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='')
|
||||
{
|
||||
// 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);
|
||||
|
||||
$datev = $date;
|
||||
// Verififcation parametres
|
||||
if (! $this->rowid)
|
||||
{
|
||||
$this->error="Account::addline rowid not defined";
|
||||
return -1;
|
||||
}
|
||||
|
||||
$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.= ",'".addslashes(trim($emetteur))."'";
|
||||
$sql.= ",'".addslashes(trim($banque))."');";
|
||||
$this->db->begin();
|
||||
|
||||
switch ($oper)
|
||||
{
|
||||
case 1:
|
||||
$oper = 'TIP';
|
||||
break;
|
||||
case 2:
|
||||
$oper = 'VIR';
|
||||
break;
|
||||
case 3:
|
||||
$oper = 'PRE';
|
||||
break;
|
||||
case 4:
|
||||
$oper = 'LIQ';
|
||||
break;
|
||||
case 5:
|
||||
$oper = 'VAD';
|
||||
break;
|
||||
case 6:
|
||||
$oper = 'CB';
|
||||
break;
|
||||
case 7:
|
||||
$oper = 'CHQ';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank");
|
||||
if ($categorie)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ('$rowid', '$categorie')";
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->error();
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
$this->db->commit();
|
||||
return $rowid;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->error();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Account::addline rowid not defined";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
$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.= " VALUES (now(),'".$this->db->idate($date)."','".$this->db->idate($datev)."',";
|
||||
$sql.= "'".addslashes($label)."','" . price2num($amount)."','".$user->id."','$num_chq','".$this->rowid."', '$oper'";
|
||||
$sql.= ",'".addslashes($emetteur)."'";
|
||||
$sql.= ",'".addslashes($banque)."');";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank");
|
||||
if ($categorie)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ('$rowid', '$categorie')";
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->error();
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
$this->db->commit();
|
||||
return $rowid;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->error();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Creation du compte bancaire en base
|
||||
|
|
|
|||
|
|
@ -43,14 +43,17 @@ $vline=isset($_GET["vline"])?$_GET["vline"]:$_POST["vline"];
|
|||
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
|
||||
$page=isset($_GET["page"])?$_GET["page"]:0;
|
||||
|
||||
$mesg='';
|
||||
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->banque->modifier)
|
||||
{
|
||||
if ($_POST["credit"] > 0)
|
||||
|
||||
if ($_POST["credit"] > 0)
|
||||
{
|
||||
$amount = $_POST["credit"];
|
||||
}
|
||||
|
|
@ -59,25 +62,35 @@ if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]) && $user-
|
|||
$amount = - $_POST["debit"];
|
||||
}
|
||||
|
||||
$dateop = $_POST["dateoy"].$_POST["dateo"];
|
||||
$operation=$_POST["operation"];
|
||||
$label=$_POST["label"];
|
||||
$dateop = dolibarr_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]);
|
||||
$operation=$_POST["operation"];
|
||||
$num_chq=$_POST["num_chq"];
|
||||
$label=$_POST["label"];
|
||||
$cat1=$_POST["cat1"];
|
||||
|
||||
$acct=new Account($db,$account);
|
||||
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);
|
||||
|
||||
$insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
|
||||
if ($insertid > 0)
|
||||
{
|
||||
Header("Location: account.php?account=" . $account);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db,$acct->error);
|
||||
}
|
||||
$insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
|
||||
if ($insertid > 0)
|
||||
{
|
||||
Header("Location: account.php?account=" . $account);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db,$acct->error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"]='addline';
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
if ($mesg) print '<div class="error">'.$mesg.'</div>';
|
||||
|
||||
|
||||
/**
|
||||
* Bandeau recherche
|
||||
*/
|
||||
$mesg='';
|
||||
$navig='';
|
||||
|
||||
$nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total
|
||||
if ($limitsql > $viewline)
|
||||
{
|
||||
$mesg.='<a href="account.php?account='.$acct->id.'&page='.($page+1).'">'.img_previous().'</a>';
|
||||
$navig.='<a href="account.php?account='.$acct->id.'&page='.($page+1).'">'.img_previous().'</a>';
|
||||
}
|
||||
$mesg.= ' Page '.($nbpage-$page).'/'.$nbpage.' ';
|
||||
$navig.= ' Page '.($nbpage-$page).'/'.$nbpage.' ';
|
||||
if ($total_lines > $limitsql )
|
||||
{
|
||||
$mesg.= '<a href="account.php?account='.$acct->id.'&page='.($page-1).'">'.img_next().'</a>';
|
||||
$navig.= '<a href="account.php?account='.$acct->id.'&page='.($page-1).'">'.img_next().'</a>';
|
||||
}
|
||||
if (! $_GET["action"]=='addline' && ! $_GET["action"]=='delete')
|
||||
{
|
||||
$titre=$langs->trans("FinancialAccount")." : ".$acct->label;
|
||||
print_fiche_titre($titre,$mesg);
|
||||
print_fiche_titre($titre,$navig);
|
||||
}
|
||||
|
||||
if ($_GET["action"]=='delete')
|
||||
|
|
@ -222,15 +238,10 @@ if ($account > 0)
|
|||
print '<br />';
|
||||
}
|
||||
|
||||
|
||||
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
|
||||
|
||||
/*
|
||||
* Affiche tableau des transactions bancaires
|
||||
*
|
||||
*/
|
||||
|
||||
// Formulaire de saisie d'une opération hors factures
|
||||
if ($user->rights->banque->modifier && $_GET["action"]=='addline')
|
||||
{
|
||||
|
|
@ -246,16 +257,21 @@ if ($account > 0)
|
|||
print '</tr>';
|
||||
|
||||
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 colspan="2" align="center"> ';
|
||||
print '</td></tr>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td> </td>';
|
||||
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"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr '.$bc[false].'>';
|
||||
print '<td nowrap>';
|
||||
print '<input name="dateoy" class="flat" type="text" size="2" value="'.strftime("%Y",time()).'" maxlength="4">';
|
||||
print '<input name="dateo" class="flat" type="text" size="2" maxlength="4"></td>';
|
||||
print '<td colspan="2" nowrap>';
|
||||
$html->select_types_paiements('','operation','1,2',1);
|
||||
print '<td nowrap="nowrap" colspan="2">';
|
||||
$html->select_date(-1,'op',0,0,0,'transaction');
|
||||
print '</td>';
|
||||
print '<td nowrap="nowrap">';
|
||||
$html->select_types_paiements('','operation','1,2',1,1);
|
||||
print '<input name="num_chq" class="flat" type="text" size="4"></td>';
|
||||
print '<td>';
|
||||
print '<input name="label" class="flat" type="text" size="40">';
|
||||
|
|
@ -275,6 +291,11 @@ if ($account > 0)
|
|||
print "<tr class=\"noborder\"><td colspan=\"8\"> </td></tr>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Affiche tableau des transactions bancaires
|
||||
*
|
||||
*/
|
||||
|
||||
// Ligne de titre tableau des acritures
|
||||
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>';
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ if ($_POST['action'] == 'add_paiement' || $_POST['action'] == 'confirm_paiement'
|
|||
{
|
||||
$error = 0;
|
||||
|
||||
$datepaye = $db->idate(mktime(12, 0 , 0,
|
||||
$datepaye = dolibarr_mktime(12, 0 , 0,
|
||||
$_POST['remonth'],
|
||||
$_POST['reday'],
|
||||
$_POST['reyear']));
|
||||
$_POST['reyear']);
|
||||
$paiement_id = 0;
|
||||
|
||||
// Verifie si des paiements sont supérieurs au montant facture
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ $mesg='';
|
|||
* 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();
|
||||
|
||||
|
|
@ -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();
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ dolibarr_fiche_head($head, $hselected, $langs->trans("Payment").": ".$paiement->
|
|||
*/
|
||||
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>';
|
||||
}
|
||||
|
||||
|
|
@ -262,13 +262,18 @@ print '<div class="tabsAction">';
|
|||
|
||||
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET['id'].'&facid='.$objp->facid.'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
if ($user->rights->facture->paiement)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$_GET['id'].'&facid='.$objp->facid.'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
|
||||
}
|
||||
}
|
||||
if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?id='.$_GET['id'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
|
||||
if ($user->rights->facture->paiement)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$_GET['id'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
|
||||
require('./pre.inc.php');
|
||||
require('./paiementfourn.class.php');
|
||||
require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
|
||||
|
||||
$langs->load('companies');
|
||||
$langs->load('bills');
|
||||
|
|
@ -61,10 +61,10 @@ if ($action == 'add_paiement')
|
|||
{
|
||||
$error = 0;
|
||||
|
||||
$datepaye = $db->idate(mktime(12, 0 , 0,
|
||||
$_POST['remonth'],
|
||||
$_POST['reday'],
|
||||
$_POST['reyear']));
|
||||
$datepaye = dolibarr_mktime(12, 0 , 0,
|
||||
$_POST['remonth'],
|
||||
$_POST['reday'],
|
||||
$_POST['reyear']);
|
||||
$paiement_id = 0;
|
||||
$total = 0;
|
||||
// Génère tableau des montants amounts
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* 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>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* $Source$
|
||||
*/
|
||||
|
||||
/*!
|
||||
/**
|
||||
\file htdocs/fourn/facture/paiementfourn.class.php
|
||||
\ingroup fournisseur, facture
|
||||
\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
|
||||
{
|
||||
$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);
|
||||
if ($resql)
|
||||
{
|
||||
|
|
@ -309,6 +309,8 @@ class PaiementFourn
|
|||
function valide()
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn SET statut = 1 WHERE rowid = '.$this->id;
|
||||
|
||||
dolibarr_syslog("PaiementFourn::valide sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
|
|
@ -316,7 +318,8 @@ class PaiementFourn
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -331,6 +334,7 @@ class PaiementFourn
|
|||
$sql .= ', '.$this->db->pdate('tms').' as tms';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c';
|
||||
$sql .= ' WHERE c.rowid = '.$id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
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');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -35,10 +35,12 @@ require('./pre.inc.php');
|
|||
require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
|
||||
|
||||
$user->getrights('facture');
|
||||
$user->getrights('fournisseur');
|
||||
|
||||
$langs->load('bills');
|
||||
$langs->load('banks');
|
||||
$langs->load('companies');
|
||||
$langs->load("suppliers");
|
||||
|
||||
$mesg='';
|
||||
|
||||
|
|
@ -47,7 +49,7 @@ $mesg='';
|
|||
* 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();
|
||||
|
||||
|
|
@ -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();
|
||||
|
||||
|
|
@ -110,7 +112,7 @@ $head[$h][1] = $langs->trans('Info');
|
|||
$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
|
||||
|
|
@ -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('Amount').'</td><td colspan="3">'.price($paiement->montant).' '.$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 '</table>';
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
/**
|
||||
* Liste des factures
|
||||
*/
|
||||
$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';
|
||||
|
|
@ -234,15 +236,21 @@ print '</div>';
|
|||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET['id'].'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
if ($user->rights->fournisseur->facture->valider)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET['id'].'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
|
||||
}
|
||||
}
|
||||
if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?id='.$_GET['id'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
if ($user->rights->fournisseur->facture->supprimer)
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?id='.$_GET['id'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
|
||||
}
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ require("./pre.inc.php");
|
|||
require(DOL_DOCUMENT_ROOT."/fourn/facture/paiementfourn.class.php");
|
||||
|
||||
$langs->load("bills");
|
||||
$langs->load("suppliers");
|
||||
$langs->load("companies");
|
||||
|
||||
llxHeader();
|
||||
|
|
@ -45,7 +46,7 @@ $head[$h][1] = $langs->trans("Info");
|
|||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Payment").": ".$_GET["id"]);
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("SupplierPayment"));
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1144,12 +1144,13 @@ class Form
|
|||
* \param htmlname Nom de la zone select
|
||||
* \param filtertype Pour filtre
|
||||
* \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;
|
||||
|
||||
dolibarr_syslog("Form::select_type_paiements $selected, $htmlname, $filtertype, $format",LOG_DEBUG);
|
||||
dolibarr_syslog("Form::select_type_paiements $selected, $htmlname, $filtertype, $format",LOG_DEBUG);
|
||||
|
||||
$filterarray=array();
|
||||
if ($filtertype == 'CRDT') $filterarray=array(0,2);
|
||||
|
|
@ -1159,6 +1160,7 @@ class Form
|
|||
$this->load_cache_types_paiements();
|
||||
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
if ($empty) print '<option value=""> </option>';
|
||||
foreach($this->cache_types_paiements_code as $id => $code)
|
||||
{
|
||||
// On passe si on a demandé de filtrer sur des modes de paiments particulièrs
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ SupplierBills=suppliers invoices
|
|||
BillContacts=Invoice contacts
|
||||
Payment=Payment
|
||||
Payments=Payments
|
||||
DeletePayment=Delete payment
|
||||
ConfirmDeletePayment=Are you sure you want to delete this payment ?
|
||||
ReceivedPayments=Received payments
|
||||
ReceivedCustomersPayments=Payments received from customers
|
||||
ReceivedCustomersPaymentsToValid=Received customers payments to validate
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ InvoiceValidatedInDolibarr=Invoice %s validated in Dolibarr
|
|||
InvoicePayedInDolibarr=Invoice %s changed to payed in Dolibarr
|
||||
InvoiceCanceledInDolibarr=Invoice %s canceled in Dolibarr
|
||||
PaymentDoneInDolibarr=Payment %s done in Dolibarr
|
||||
CustomerPaymentDoneInDolibarr=Customer payment %s done in Dolibarr
|
||||
SupplierPaymentDoneInDolibarr=Supplier payment %s done in Dolibarr
|
||||
##### Export #####
|
||||
ExportsArea=Exports area
|
||||
AvailableFormats=Available formats
|
||||
|
|
|
|||
|
|
@ -16,4 +16,5 @@ ChangeSupplierPrice=Change supplier price
|
|||
ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier
|
||||
ErrorSupplierCountryIsNotDefined=Country for this supplier is not defined. Correct this first.
|
||||
ProductHasAlreadyReferenceInThisSupplier=This product has already a reference in this supplier
|
||||
NoRecordedSuppliers=No suppliers recorded
|
||||
NoRecordedSuppliers=No suppliers recorded
|
||||
SupplierPayment=Supplier payment
|
||||
|
|
@ -38,6 +38,8 @@ SupplierBills=Factures fournisseurs
|
|||
BillContacts=Contacts facture
|
||||
Payment=Réglement
|
||||
Payments=Réglements
|
||||
DeletePayment=Supprimer le paiement
|
||||
ConfirmDeletePayment=Etes vous sur de vouloir supprimer ce paiement ?
|
||||
ReceivedPayments=Réglements reçus
|
||||
ReceivedCustomersPayments=Réglements reçus du client
|
||||
ReceivedCustomersPaymentsToValid=Réglements clients reçus à valider
|
||||
|
|
|
|||
|
|
@ -16,4 +16,5 @@ ChangeSupplierPrice=Modifier prix fournisseur
|
|||
ErrorQtyTooLowForThisSupplier=Quantité insuffisante pour ce fournisseur
|
||||
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
|
||||
NoRecordedSuppliers=Pas de fournisseurs enregistrés
|
||||
NoRecordedSuppliers=Pas de fournisseurs enregistrés
|
||||
SupplierPayment=Paiement fournisseur
|
||||
|
|
@ -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.
|
||||
\param param Date TMS à convertir
|
||||
\return date Date au format texte YYYYMMDDHHMMSS.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
\param param Date tms à convertir
|
||||
\return date Date au format text YYYYMMDDHHMMSS.
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class Paiement
|
|||
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 .= ' 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);
|
||||
if ($resql)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ class Tva
|
|||
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/account.class.php');
|
||||
|
||||
$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
|
||||
if ($bank_line_id) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user