diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 87fc2de3b4b..eedcd5c507a 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -23,37 +23,60 @@ require("./pre.inc.php");
$acts[0] = "add";
$acts[1] = "delete";
-$actl[0] = "Ajouter";
-$actl[1] = "Enlever";
+$actl[0] = "Activer";
+$actl[1] = "Désactiver";
+$active = 1;
+
+// Mettre ici tous les caractéristiques des dictionnaires editables
$tabid[1] = "llx_c_forme_juridique";
$tabid[2] = "llx_c_departements";
$tabid[3] = "llx_c_regions";
+$tabid[4] = "llx_c_pays";
-if (!$user->admin)
+$tabnom[1] = "Formes juridiques";
+$tabnom[2] = "Départements";
+$tabnom[3] = "Régions";
+$tabnom[4] = "Pays";
+
+$tabsql[1] = "SELECT code, libelle, active FROM llx_c_forme_juridique ORDER BY active DESC, code ASC";
+$tabsql[2] = "SELECT rowid, code_departement as code , nom as libelle, active FROM llx_c_departements ORDER BY active DESC, code ASC";
+$tabsql[3] = "SELECT r.rowid as rowid, code_region as code , nom as libelle, p.libelle as pays, r.active FROM llx_c_regions as r, llx_c_pays as p WHERE r.fk_pays=p.rowid ORDER BY active DESC, code ASC";
+$tabsql[4] = "SELECT rowid, code, libelle, active FROM llx_c_pays ORDER BY active DESC, code ASC";
+
+// Champs à afficher
+$tabfield[1] = "code,libelle";
+$tabfield[2] = "code,libelle";
+$tabfield[3] = "code,libelle,pays";
+$tabfield[4] = "code,libelle";
+
+if (! $user->admin)
accessforbidden();
-if ($user->admin)
+
+if ($_GET["action"] == 'delete')
{
- if ($_GET["action"] == 'delete')
+ if ($_GET["rowid"] >0) {
+ $sql = "UPDATE ".$tabid[$_GET["id"]]." SET active = 0 WHERE rowid=".$_GET["rowid"];
+ }
+ elseif ($_GET["code"] >0) {
+ $sql = "UPDATE ".$tabid[$_GET["id"]]." SET active = 0 WHERE code=".$_GET["code"];
+ }
+
+ $result = $db->query($sql);
+ if (!$result)
+{
+ print $db->error();
+}
+}
+if ($_GET["action"] == 'add')
+{
+ $sql = "UPDATE ".$tabid[$_GET["id"]]." SET active = 1 WHERE rowid=".$_GET["rowid"];
+
+ $result = $db->query($sql);
+ if (!$result)
{
- $sql = "UPDATE ".$tabid[$_GET["id"]]." SET active = 0 WHERE rowid=".$_GET["rowid"];
-
- $result = $db->query($sql);
- if (!$result)
- {
- print $db->error();
- }
- }
- if ($_GET["action"] == 'add')
- {
- $sql = "UPDATE ".$tabid[$_GET["id"]]." SET active = 1 WHERE rowid=".$_GET["rowid"];
-
- $result = $db->query($sql);
- if (!$result)
- {
- print $db->error();
- }
+ print $db->error();
}
}
@@ -61,60 +84,80 @@ if ($user->admin)
llxHeader();
-print_titre("Configuration des dictionnaires de données");
-
-print '
';
-
-$active = 1;
-$sql = array();
if ($_GET["id"])
{
- ShowTable($db,1, $_GET["id"], $actl, $acts);
- ShowTable($db,0, $_GET["id"], $actl, $acts);
-}
-else
-{
- print 'Forme Juridique
';
- print 'Départements
';
- print 'Régions
';
-}
+ print_titre("Configuration des dictionnaires de données : ".$tabnom[$_GET["id"]]);
+ print '
';
-
-
-$db->close();
-
-llxFooter();
-
-Function ShowTable($db, $active, $id, $actl, $acts)
-{
- global $bc;
- $sql[1] = "SELECT code, libelle, active FROM llx_c_forme_juridique WHERE active = $active ORDER BY code ASC";
- $sql[2] = "SELECT rowid, code_departement as code , nom as libelle, active FROM llx_c_departements WHERE active = $active ORDER BY code ASC";
- $sql[3] = "SELECT rowid, code_region as code , nom as libelle, active FROM llx_c_regions WHERE active = $active ORDER BY code ASC";
-
-
- if ($db->query($sql[$id]))
+ // Affiche table des valeurs
+ $sql=$tabsql[$_GET["id"]];
+ if ($db->query($sql))
+ {
+ $num = $db->num_rows();
+ $i = 0;
+ $var=True;
+ if ($num)
{
- $num = $db->num_rows();
- $i = 0; $var=True;
- if ($num)
- {
print '
';
- print '| Code | Valeur | Type |
';
+ print '';
+
+ $fieldlist=split(',',$tabfield[$_GET["id"]]);
+ foreach ($fieldlist as $field => $value) {
+ print '| '.ucfirst($fieldlist[$field]).' | ';
+ }
+
+ print 'Actif | ';
+ print 'Inactif | ';
+ print '
';
while ($i < $num)
{
- $obj = $db->fetch_object( $i);
+ $obj = $db->fetch_object($i);
$var=!$var;
- print "| \n";
- print $obj->code.' | '.$obj->libelle.' | ';
- print ''.$actl[$active].'';
- print " |
\n";
+ print "";
+
+ foreach ($fieldlist as $field => $value) {
+ print '| '.$obj->$fieldlist[$field].' | ';
+ }
+
+ if ($obj->active) {
+ print '';
+ print 'active].'">'.$actl[$obj->active].'';
+ print " | ";
+ }
+ else print ' | ';
+ if (! $obj->active) {
+ print '';
+ print 'active].'">'.$actl[$obj->active].'';
+ print " | ";
+ }
+ else print ' | ';
+
+ print "
\n";
$i++;
}
print '
';
}
}
+ else {
+ print "Erreur : $sql : ".$db->error();
+ }
+}
+else
+{
+ print_titre("Configuration des dictionnaires de données");
+ print '
';
+
+ foreach ($tabid as $i => $value) {
+ print ''.$tabnom[$i].' (Table '.$tabid[$i].')
';
+ }
}
+print '
';
+
+$db->close();
+
+llxFooter();
+
+
?>
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 7a3ffb35cc8..62fe55c7214 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -384,16 +384,17 @@ if ($action == 'pdf')
facture_pdf_create($db, $facid);
}
+
llxHeader();
$html = new Form($db);
+
/*********************************************************************
*
* Mode creation
*
*
- *
************************************************************************/
if ($_GET["action"] == 'create')
{
@@ -894,7 +895,7 @@ else
{
$objp = $db->fetch_object( $i);
$var=!$var;
- print "";
+ print "
";
if ($objp->fk_product > 0)
{
print '| '.stripslashes(nl2br($objp->description)).'';
@@ -908,9 +909,9 @@ else
print " | \n";
}
- print ''.$objp->tva_taux.' % | ';
- print ''.price($objp->subprice)." | \n";
- print ''.$objp->qty.' | ';
+ print ''.$objp->tva_taux.' % | ';
+ print ''.price($objp->subprice)." | \n";
+ print ''.$objp->qty.' | ';
if ($objp->remise_percent > 0)
{
print ''.$objp->remise_percent." % | \n";
@@ -1321,7 +1322,6 @@ else
/***************************************************************************
* *
* Mode Liste *
- * *
* *
***************************************************************************/
if ($page == -1)
@@ -1340,7 +1340,7 @@ else
if ($sortfield == "")
$sortfield="f.datef";
- $sql = "SELECT s.nom,s.idp,f.facnumber,f.total,f.total_ttc,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid, f.fk_statut, sum(pf.amount) as am";
+ $sql = "SELECT s.nom,s.idp,f.facnumber,f.total,f.total_ttc,".$db->pdate("f.datef")." as df, f.paye as paye, f.rowid as facid, f.fk_statut, sum(pf.amount) as am";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture WHERE f.fk_soc = s.idp";
if ($socidp)
@@ -1369,7 +1369,12 @@ else
$sql .= " GROUP BY f.facnumber";
- $sql .= " ORDER BY $sortfield $sortorder, f.rowid DESC ";
+ $sql .= " ORDER BY ";
+ $listfield=split(',',$sortfield);
+ foreach ($listfield as $key => $value) {
+ $sql.="$listfield[$key] $sortorder,";
+ }
+ $sql .= " f.rowid DESC ";
$sql .= $db->plimit($limit,$offset);
@@ -1395,8 +1400,9 @@ else
print_liste_field_titre("Montant TTC",$PHP_SELF,"f.total_ttc","","&socidp=$socidp");
print '';
print_liste_field_titre("Reçu",$PHP_SELF,"am","","&socidp=$socidp");
+ print ' | ';
+ print_liste_field_titre("Statut",$PHP_SELF,"fk_statut,paye","","&socidp=$socidp");
print ' | ';
- print 'Status | ';
print "
\n";
if ($num > 0)
@@ -1444,14 +1450,14 @@ else
}
else
{
- print "!!! | \n";
+ print "!!! | \n";
}
- print ''.$objp->nom.' | ';
-
- print "".price($objp->total)." | ";
- print "".price($objp->total_ttc)." | ";
- print "".price($objp->am)." | ";
+ print ''.$objp->nom.' | ';
+ print "".price($objp->total)." | ";
+ print "".price($objp->total_ttc)." | ";
+ print "".price($objp->am)." | ";
+ // Affiche statut de la facture
if (! $objp->paye)
{
if ($objp->fk_statut == 0)
@@ -1472,7 +1478,7 @@ else
print 'payée | ';
}
- print "\n";
+ print "\n";
$total+=$objp->total;
$total_ttc+=$objp->total_ttc;
$totalrecu+=$objp->am;
@@ -1482,10 +1488,10 @@ else
if ($num <= $limit) {
// Print total
print "";
- print "| Total : | ";
- print "".price($total)." | ";
- print "".price($total_ttc)." | ";
- print "".price($totalrecu)." | ";
+ print "Total : | ";
+ print "".price($total)." | ";
+ print "".price($total_ttc)." | ";
+ print "".price($totalrecu)." | ";
print ' | ';
print "
\n";
}
diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php
index 4fa167adbbf..eec59ef362d 100755
--- a/htdocs/compta/paiement_charge.php
+++ b/htdocs/compta/paiement_charge.php
@@ -81,7 +81,7 @@ if ($_POST["action"] == 'add_paiement')
// Insertion dans llx_bank
$label = "Règlement charge";
$acc = new Account($db, $_POST["accountid"]);
- $bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementtype, $label, $total, $paiement->num_paiement, '', $user);
+ $bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementtype, $label, -abs($total), $paiement->num_paiement, '', $user);
// Mise a jour fk_bank dans llx_paiementcharge. On connait ainsi le paiement qui a généré l'écriture bancaire
if ($bank_line_id) {
diff --git a/htdocs/facturefourn.class.php b/htdocs/facturefourn.class.php
index 6763f147704..7e847670bad 100644
--- a/htdocs/facturefourn.class.php
+++ b/htdocs/facturefourn.class.php
@@ -41,11 +41,11 @@ class FactureFourn
var $db_table;
var $propalid;
var $lignes;
+
/*
* Initialisation
*
*/
-
Function FactureFourn($DB, $soc_idp="", $facid="")
{
$this->db = $DB ;
@@ -150,8 +150,9 @@ class FactureFourn
$this->updateprice($this->id);
return 1;
}
+
/*
- *
+ * Création d'une facture fournisseur
*
*/
Function create($user)
@@ -286,25 +287,6 @@ class FactureFourn
print $this->db->error();
}
}
- /*
- *
- *
- *
- */
- Function valid($userid, $dir)
- {
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_statut = 1, date_valid=now(), fk_user_valid=$userid";
- $sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;";
-
- if ($this->db->query($sql) )
- {
- return 1;
- }
- else
- {
- print $this->db->error() . ' in ' . $sql;
- }
- }
/*
* Suppression de la facture
@@ -338,48 +320,40 @@ class FactureFourn
return 0;
}
}
- /*
- *
- *
- *
- */
- Function set_payed($rowid)
- {
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture set paye = 1 WHERE rowid = $rowid ;";
- $return = $this->db->query( $sql);
- }
- /*
- *
- *
- *
- *
- */
- Function set_valid($rowid, $userid)
- {
- global $conf;
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_statut = 1, fk_user_valid = $userid WHERE rowid = $rowid ;";
+ /*
+ * Passe une facture fournisseur a l'état validé
+ *
+ */
+ Function set_valid($userid)
+ {
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn set fk_statut = 1, fk_user_valid = $userid WHERE rowid = ".$this->id;
$result = $this->db->query( $sql);
-
- $dir = $conf->facture->outputdir . "/" . $rowid;
-
- if (! is_dir ("$dir"))
- {
- if (! mkdir ("$dir"))
- {
- print $dir;
- }
- }
+ if (! $result) {
+ print "Erreur : $sql : ".$this->db->error();
+ }
}
+
/*
+ * Passe une facture fournisseur a l'état payé
*
- *
+ */
+ Function set_payed($userid)
+ {
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn set paye = 1 WHERE rowid = ".$this->id;
+ $result = $this->db->query( $sql);
+ if (! $result) {
+ print "Erreur : $sql : ".$this->db->error();
+ }
+ }
+
+ /*
*
*
*/
Function addline($facid, $desc, $pu, $qty)
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet (fk_facture,description,price,qty) VALUES ($facid, '$desc', $pu, $qty) ;";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_fourn_det (fk_facture,description,price,qty) VALUES ($facid, '$desc', $pu, $qty) ;";
$result = $this->db->query( $sql);
$this->updateprice($facid);
@@ -390,7 +364,7 @@ class FactureFourn
*/
Function updateline($rowid, $desc, $pu, $qty)
{
- $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set description='$desc',price=$pu,qty=$qty WHERE rowid = $rowid ;";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facture-fourn_det set description='$desc',price=$pu,qty=$qty WHERE rowid = $rowid ;";
$result = $this->db->query( $sql);
$this->updateprice($this->id);
@@ -401,7 +375,7 @@ class FactureFourn
*/
Function deleteline($rowid)
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = $rowid;";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det WHERE rowid = $rowid;";
$result = $this->db->query( $sql);
$this->updateprice($this->id);
@@ -448,14 +422,6 @@ class FactureFourn
Function pdf()
{
-
- print "
Génération du PDF";
-
- $command = "export DBI_DSN=\"".$GLOBALS["DBI"]."\" ";
- $command .= " ; ../../scripts/facture-tex.pl --facture=$facid --pdf --ps" ;
-
- $output = system($command);
- print "
command : $command
";
}
}
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 54197db981c..4bf8ebad38e 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -22,6 +22,7 @@
*/
require("./pre.inc.php");
require("./paiementfourn.class.php");
+require("../../facturefourn.class.php");
/*
* Sécurité accés client
@@ -36,14 +37,19 @@ $html = new Form($db);
if ($action == 'valid')
{
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn set fk_statut = 1 WHERE rowid = $facid ;";
- $result = $db->query( $sql);
+print "ddddddddddddddd";
+ $facturefourn=new FactureFourn($db);
+ $facturefourn->fetch($_GET["facid"]);
+
+ $facturefourn->set_valid($user->id);
}
if ($action == 'payed')
{
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn set paye = 1 WHERE rowid = $facid ;";
- $result = $db->query( $sql);
+ $facturefourn=new FactureFourn($db);
+ $facturefourn->fetch($_GET["facid"]);
+
+ $facturefourn->set_payed($user->id);
}
if($_GET["action"] == 'deletepaiement')
diff --git a/htdocs/fourn/facture/pre.inc.php b/htdocs/fourn/facture/pre.inc.php
index b704a4d8325..8e1960bbc97 100644
--- a/htdocs/fourn/facture/pre.inc.php
+++ b/htdocs/fourn/facture/pre.inc.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2004 Laurent Destailleur
*
* 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
@@ -20,14 +21,12 @@
*
*/
require("../../main.inc.php");
-require("../../facturefourn.class.php");
include_once DOL_DOCUMENT_ROOT."/compta/bank/account.class.php";
function llxHeader($head = "", $urlp = "") {
global $user, $conf;
-
/*
*
*