Fix: bad security access

Fix: add entity in facture_rec and constraint with fk_soc
Fix: uniformize code
This commit is contained in:
Regis Houssin 2009-11-19 11:25:08 +00:00
parent 02ece7082c
commit d6e0912f6c
10 changed files with 130 additions and 90 deletions

View File

@ -2988,7 +2988,6 @@ CREATE TABLE `llx_facture_rec` (
`last_gen` varchar(7) default NULL, `last_gen` varchar(7) default NULL,
PRIMARY KEY (`rowid`), PRIMARY KEY (`rowid`),
UNIQUE KEY `idx_facture_rec_uk_titre` (`titre`), UNIQUE KEY `idx_facture_rec_uk_titre` (`titre`),
KEY `idx_facture_rec_fksoc` (`fk_soc`),
KEY `idx_facture_rec_fk_soc` (`fk_soc`), KEY `idx_facture_rec_fk_soc` (`fk_soc`),
KEY `idx_facture_rec_fk_user_author` (`fk_user_author`), KEY `idx_facture_rec_fk_user_author` (`fk_user_author`),
KEY `idx_facture_rec_fk_projet` (`fk_projet`), KEY `idx_facture_rec_fk_projet` (`fk_projet`),

View File

@ -4961,7 +4961,7 @@
<INDEXCOLUMN idColumn="1916" LengthParam="0" /> <INDEXCOLUMN idColumn="1916" LengthParam="0" />
</INDEXCOLUMNS> </INDEXCOLUMNS>
</INDEX> </INDEX>
<INDEX ID="1933" IndexName="idx_facture_rec_fksoc" IndexKind="1" FKRefDef_Obj_id="-1"> <INDEX ID="1933" IndexName="idx_facture_rec_fk_soc" IndexKind="1" FKRefDef_Obj_id="-1">
<INDEXCOLUMNS> <INDEXCOLUMNS>
<INDEXCOLUMN idColumn="1918" LengthParam="0" /> <INDEXCOLUMN idColumn="1918" LengthParam="0" />
</INDEXCOLUMNS> </INDEXCOLUMNS>

View File

@ -21,10 +21,10 @@
*/ */
/** /**
\file htdocs/categories/categorie.php * \file htdocs/categories/categorie.php
\ingroup category * \ingroup category
\brief Page de l'onglet categories * \brief Page de l'onglet categories
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -262,7 +262,7 @@ else if ($_GET["id"] || $_GET["ref"])
} }
/* /**
* Fonction Barre d'actions * Fonction Barre d'actions
*/ */
function formCategory($db,$object,$type,$typeid) function formCategory($db,$object,$type,$typeid)

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
* *
* 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
@ -31,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
/** /**
* \class FactureRec * \class FactureRec
* \brief Classe de gestion des factures recurrentes/Mod<EFBFBD>les * \brief Classe de gestion des factures recurrentes/Modeles
*/ */
class FactureRec extends Facture class FactureRec extends Facture
{ {
@ -43,8 +44,10 @@ class FactureRec extends Facture
var $id ; var $id ;
var $socid; // Id client //! Id customer
var $client; // Objet societe client (<28> charger par fetch_client) var $socid;
//! Customer object (charging by fetch_client)
var $client;
var $number; var $number;
var $author; var $author;
@ -61,7 +64,7 @@ class FactureRec extends Facture
/** /**
* \brief Initialisation de la class * \brief Initialisation de la classe
*/ */
function FactureRec($DB, $facid=0) function FactureRec($DB, $facid=0)
{ {
@ -75,7 +78,7 @@ class FactureRec extends Facture
*/ */
function create($user) function create($user)
{ {
global $langs; global $conf, $langs;
$error=0; $error=0;
@ -99,11 +102,32 @@ class FactureRec extends Facture
// On positionne en mode brouillon la facture // On positionne en mode brouillon la facture
$this->brouillon = 1; $this->brouillon = 1;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (titre, fk_soc, datec, amount, remise, note, fk_user_author,fk_projet, fk_cond_reglement, fk_mode_reglement) "; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (";
$sql.= " VALUES ('$this->titre', '$facsrc->socid', ".$this->db->idate(mktime()).", '$facsrc->amount', '$facsrc->remise', '".addslashes($this->note)."','$user->id',"; $sql.= "titre";
$sql.= " ".($facsrc->projetid?"'".$facsrc->projetid."'":"null").", "; $sql.= ", fk_soc";
$sql.= " '".$facsrc->cond_reglement_id."',"; $sql.= ", entity";
$sql.= " '".$facsrc->mode_reglement_id."')"; $sql.= ", datec";
$sql.= ", amount";
$sql.= ", remise";
$sql.= ", note";
$sql.= ", fk_user_author";
$sql.= ", fk_projet";
$sql.= ", fk_cond_reglement";
$sql.= ", fk_mode_reglement";
$sql.= ") VALUES (";
$sql.= "'".$this->titre."'";
$sql.= ", '".$facsrc->socid."'";
$sql.= ", ".$conf->entity;
$sql.= ", ".$this->db->idate(mktime());
$sql.= ", '".$facsrc->amount."'";
$sql.= ", '".$facsrc->remise."'";
$sql.= ", '".addslashes($this->note)."'";
$sql.= ", '".$user->id."'";
$sql.= ", ".($facsrc->projetid?"'".$facsrc->projetid."'":"null");
$sql.= ", '".$facsrc->cond_reglement_id."'";
$sql.= ", '".$facsrc->mode_reglement_id."'";
$sql.= ")";
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec");
@ -158,12 +182,12 @@ class FactureRec extends Facture
/** /**
* \brief Recupere l'objet facture et ses lignes de factures * \brief Recupere l'objet facture et ses lignes de factures
* \param rowid id de la facture a recuperer * \param rowid id de la facture a recuperer
* \param societe_id id de societe * \param socid id de societe
* \return int >0 si ok, <0 si ko * \return int >0 si ok, <0 si ko
*/ */
function fetch($rowid, $societe_id=0) function fetch($rowid, $socid=0)
{ {
dol_syslog("Facture::Fetch rowid=".$rowid.", societe_id=".$societe_id, LOG_DEBUG); dol_syslog("Facture::Fetch rowid=".$rowid.", societe_id=".$socid, LOG_DEBUG);
$sql = 'SELECT f.titre,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise'; $sql = 'SELECT f.titre,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise';
$sql.= ','.$this->db->pdate('f.date_lim_reglement').' as dlr'; $sql.= ','.$this->db->pdate('f.date_lim_reglement').' as dlr';
@ -177,10 +201,8 @@ class FactureRec extends Facture
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_fa as cf ON cf.fk_facture = f.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_fa as cf ON cf.fk_facture = f.rowid';
$sql.= ' WHERE f.rowid='.$rowid; $sql.= ' WHERE f.rowid='.$rowid;
if ($societe_id > 0) if ($socid > 0) $sql.= ' AND f.fk_soc = '.$socid;
{
$sql.= ' AND f.fk_soc = '.$societe_id;
}
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@ -426,8 +448,23 @@ class FactureRec extends Facture
$product_type=$product->type; $product_type=$product->type;
} }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec (fk_facture,description,price,qty,tva_taux, fk_product, product_type, remise_percent, subprice, remise, total_ht, total_tva, total_ttc)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec (";
$sql .= " VALUES ('".$facid."', '".addslashes($desc)."'"; $sql.= "fk_facture";
$sql.= ", description";
$sql.= ", price";
$sql.= ", qty";
$sql.= ", tva_taux";
$sql.= ", fk_product";
$sql.= ", product_type";
$sql.= ", remise_percent";
$sql.= ", subprice";
$sql.= ", remise";
$sql.= ", total_ht";
$sql.= ", total_tva";
$sql.= ", total_ttc";
$sql.= ") VALUES (";
$sql.= "'".$facid."'";
$sql.= ", '".addslashes($desc)."'";
$sql.= ", ".price2num($price); $sql.= ", ".price2num($price);
$sql.= ", ".price2num($qty); $sql.= ", ".price2num($qty);
$sql.= ", ".price2num($txtva); $sql.= ", ".price2num($txtva);

View File

@ -21,7 +21,7 @@
/** /**
* \file htdocs/compta/facture/fiche-rec.php * \file htdocs/compta/facture/fiche-rec.php
* \ingroup facture * \ingroup facture
* \brief Page d'affichage d'une facture r<EFBFBD>current * \brief Page d'affichage d'une facture recurrente
* \version $Id$ * \version $Id$
*/ */
@ -30,14 +30,14 @@ require_once("./facture-rec.class.php");
require_once(DOL_DOCUMENT_ROOT."/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
if (!$user->rights->facture->lire)
accessforbidden();
// Security check // Security check
$facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"]; $facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"];
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'facture', $facid,'facture_rec'); $objecttype = 'facture_rec';
if ($action == "create" || $action == "add") $objecttype = '';
$result = restrictedArea($user, 'facture', $facid, $objecttype);
if ($page == -1) if ($page == -1)
{ {
@ -95,11 +95,9 @@ llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-
$html = new Form($db); $html = new Form($db);
/********************************************************************* /*
* * Create mode
* Mode creation */
*
************************************************************************/
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
print_fiche_titre($langs->trans("CreateRepeatableInvoice")); print_fiche_titre($langs->trans("CreateRepeatableInvoice"));
@ -167,7 +165,7 @@ if ($_GET["action"] == 'create')
} }
/* /*
* Lines de factures * Invoice lines
*/ */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr><td colspan="3">'; print '<tr><td colspan="3">';
@ -327,12 +325,10 @@ if ($_GET["action"] == 'create')
} }
} }
else else
/* *************************************************************************** */
/* */
/* */
/* */
/* *************************************************************************** */
{ {
/*
* View mode
*/
if ($facid > 0) if ($facid > 0)
{ {
@ -485,13 +481,12 @@ else
{ {
print $langs->trans("ErrorRecordNotFound"); print $langs->trans("ErrorRecordNotFound");
} }
} else { }
/*************************************************************************** else
* * {
* Mode Liste * /*
* * * List mode
* * */
***************************************************************************/
if ($user->rights->facture->lire) if ($user->rights->facture->lire)
{ {

View File

@ -19,7 +19,7 @@
/** /**
\file htdocs/compta/paiement_charge.php \file htdocs/compta/paiement_charge.php
\ingroup compta \ingroup compta
\brief Page de création d'un paiement d'une charge \brief Page de creation d'un paiement d'une charge
\version $Id$ \version $Id$
*/ */
@ -31,7 +31,7 @@ $langs->load("bills");
$chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; $chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
// Sécurité accés client // Securite acces client
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
@ -110,12 +110,12 @@ if ($_POST["action"] == 'add_paiement')
$acc = new Account($db, $_POST["accountid"]); $acc = new Account($db, $_POST["accountid"]);
$bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementtype, $label, -abs($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 // Mise a jour fk_bank dans llx_paiementcharge. On connait ainsi le paiement qui a g<EFBFBD>n<EFBFBD>r<EFBFBD> l'<27>criture bancaire
if ($bank_line_id > 0) if ($bank_line_id > 0)
{ {
$paiement->update_fk_bank($bank_line_id); $paiement->update_fk_bank($bank_line_id);
// Mise a jour liens (pour chaque charge concernée par le paiement) // Mise a jour liens (pour chaque charge concern<EFBFBD>e par le paiement)
foreach ($paiement->amounts as $key => $value) foreach ($paiement->amounts as $key => $value)
{ {
$acc->add_url_line($bank_line_id, $chid, DOL_URL_ROOT.'/compta/sociales/charges.php?id=', '(socialcontribution)','sc'); $acc->add_url_line($bank_line_id, $chid, DOL_URL_ROOT.'/compta/sociales/charges.php?id=', '(socialcontribution)','sc');
@ -129,13 +129,13 @@ if ($_POST["action"] == 'add_paiement')
} }
else { else {
$db->rollback(); $db->rollback();
$mesg = "Echec de la création entrée compte: ".$db->error(); $mesg = "Echec de la cr<EFBFBD>ation entr<74>e compte: ".$db->error();
} }
} }
else else
{ {
$db->rollback(); $db->rollback();
$mesg = "Echec de la création du paiement: paiement_id=$paiement_id ".$db->error(); $mesg = "Echec de la cr<EFBFBD>ation du paiement: paiement_id=$paiement_id ".$db->error();
} }
} }
@ -229,7 +229,7 @@ if ($_GET["action"] == 'create')
print "<td><input name=\"num_paiement\" type=\"text\"></td></tr>\n"; print "<td><input name=\"num_paiement\" type=\"text\"></td></tr>\n";
/* /*
* Autres charges impayées * Autres charges impay<EFBFBD>es
*/ */
$num = 1; $num = 1;
$i = 0; $i = 0;

View File

@ -1981,10 +1981,10 @@ class Facture extends CommonObject
$sql.= ' AND type < 2'; $sql.= ' AND type < 2';
if ($option == 'validated') $sql.= ' AND fk_statut = 1'; if ($option == 'validated') $sql.= ' AND fk_statut = 1';
// PROTECTION BAD DATA // PROTECTION BAD DATA
// Au cas ou base corrompue et qu'il y a une facture de remplacement valid<EFBFBD>e // Au cas ou base corrompue et qu'il y a une facture de remplacement validee
// et une autre non, on donne priorit<EFBFBD> <20> la valid<69>e. // et une autre non, on donne priorite a la validee.
// Ne devrait pas arriver (sauf si acc<EFBFBD>s concurrentiel et que 2 personnes // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes
// ont cr<EFBFBD><EFBFBD> en meme temps une facture de remplacement pour la meme facture) // ont cree en meme temps une facture de remplacement pour la meme facture)
$sql.= ' ORDER BY fk_statut DESC'; $sql.= ' ORDER BY fk_statut DESC';
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -2009,7 +2009,7 @@ class Facture extends CommonObject
} }
/** /**
* \brief Retourne le libell<EFBFBD> du type de facture * \brief Retourne le libelle du type de facture
* \return string Libelle * \return string Libelle
*/ */
function getLibType() function getLibType()
@ -2024,8 +2024,8 @@ class Facture extends CommonObject
/** /**
* \brief Retourne le libell<EFBFBD> du statut d'une facture (brouillon, valid<EFBFBD>e, abandonn<EFBFBD>e, pay<EFBFBD>e) * \brief Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> lon * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle lon
* \param alreadypaid 0=Not payment already done, 1=Some payments already done * \param alreadypaid 0=Not payment already done, 1=Some payments already done
* \return string Libelle * \return string Libelle
*/ */
@ -2035,13 +2035,13 @@ class Facture extends CommonObject
} }
/** /**
* \brief Renvoi le libell<EFBFBD> d'un statut donn<EFBFBD> * \brief Renvoi le libelle d'un statut donne
* \param paye Etat paye * \param paye Etat paye
* \param statut Id statut * \param statut Id statut
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> long, 5=Libell<EFBFBD> court + Pict * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Pict
* \param alreadypaid Montant deja pay<EFBFBD> * \param alreadypaid Montant deja paye
* \param type Type facture * \param type Type facture
* \return string Libell<EFBFBD> du statut * \return string Libelle du statut
*/ */
function LibStatut($paye,$statut,$mode=0,$alreadypaid=-1,$type=0) function LibStatut($paye,$statut,$mode=0,$alreadypaid=-1,$type=0)
{ {

View File

@ -136,6 +136,7 @@ ALTER TABLE llx_projet ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
ALTER TABLE llx_adherent ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_adherent ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_adherent_type ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_adherent_type ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_adherent_options_label ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER name; ALTER TABLE llx_adherent_options_label ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER name;
ALTER TABLE llx_facture_rec ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER fk_soc;
ALTER TABLE llx_rights_def DROP PRIMARY KEY; ALTER TABLE llx_rights_def DROP PRIMARY KEY;
ALTER TABLE llx_dolibarr_modules DROP PRIMARY KEY; ALTER TABLE llx_dolibarr_modules DROP PRIMARY KEY;
@ -169,6 +170,7 @@ ALTER TABLE llx_projet DROP INDEX ref;
ALTER TABLE llx_boxes_def DROP INDEX uk_boxes_def; ALTER TABLE llx_boxes_def DROP INDEX uk_boxes_def;
ALTER TABLE llx_adherent DROP INDEX uk_adherent_login; ALTER TABLE llx_adherent DROP INDEX uk_adherent_login;
ALTER TABLE llx_adherent_type DROP INDEX uk_adherent_type_libelle; ALTER TABLE llx_adherent_type DROP INDEX uk_adherent_type_libelle;
ALTER TABLE llx_facture_rec DROP INDEX idx_facture_rec_uk_titre;
ALTER TABLE llx_rights_def ADD PRIMARY KEY pk_rights_def (id, entity); ALTER TABLE llx_rights_def ADD PRIMARY KEY pk_rights_def (id, entity);
ALTER TABLE llx_dolibarr_modules ADD PRIMARY KEY pk_dolibarr_modules (numero, entity); ALTER TABLE llx_dolibarr_modules ADD PRIMARY KEY pk_dolibarr_modules (numero, entity);
@ -201,11 +203,14 @@ ALTER TABLE llx_boxes_def ADD UNIQUE INDEX uk_boxes_def (file, entity);
ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login, entity); ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login, entity);
ALTER TABLE llx_adherent_type ADD UNIQUE INDEX uk_adherent_type_libelle (libelle, entity); ALTER TABLE llx_adherent_type ADD UNIQUE INDEX uk_adherent_type_libelle (libelle, entity);
ALTER TABLE llx_adherent_options_label ADD UNIQUE INDEX uk_adherent_options_label_name (name, entity); ALTER TABLE llx_adherent_options_label ADD UNIQUE INDEX uk_adherent_options_label_name (name, entity);
ALTER TABLE llx_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre, entity);
ALTER TABLE llx_projet ADD INDEX idx_projet_fk_soc (fk_soc); ALTER TABLE llx_projet ADD INDEX idx_projet_fk_soc (fk_soc);
-- V4.1 update llx_projet set fk_soc=null where fk_soc is not null and fk_soc not in (select rowid from llx_societe); -- V4.1 update llx_projet set fk_soc=null where fk_soc is not null and fk_soc not in (select rowid from llx_societe);
ALTER TABLE llx_projet ADD CONSTRAINT fk_projet_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_projet ADD CONSTRAINT fk_projet_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
UPDATE llx_const SET entity=0 WHERE name='MAIN_MODULE_USER' AND entity=1; UPDATE llx_const SET entity=0 WHERE name='MAIN_MODULE_USER' AND entity=1;
UPDATE llx_const SET entity=0 WHERE name='MAIN_POPUP_CALENDAR' AND entity=1; UPDATE llx_const SET entity=0 WHERE name='MAIN_POPUP_CALENDAR' AND entity=1;

View File

@ -1,6 +1,7 @@
-- ============================================================================ -- ============================================================================
-- 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-2006 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
-- --
-- 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
@ -20,11 +21,12 @@
-- ============================================================================ -- ============================================================================
ALTER TABLE llx_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre, entity);
ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_soc (fk_soc); ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_soc (fk_soc);
ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_user_author (fk_user_author); ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_user_author (fk_user_author);
ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_projet (fk_projet); ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_projet (fk_projet);
ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid);
ALTER TABLE llx_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre);

View File

@ -1,6 +1,7 @@
-- =========================================================================== -- ===========================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
-- --
-- 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
@ -23,6 +24,7 @@ create table llx_facture_rec
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
titre varchar(50) NOT NULL, titre varchar(50) NOT NULL,
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_soc integer NOT NULL, fk_soc integer NOT NULL,
datec datetime, -- date de creation datec datetime, -- date de creation
@ -35,9 +37,9 @@ create table llx_facture_rec
total_ttc real DEFAULT 0, total_ttc real DEFAULT 0,
fk_user_author integer, -- createur fk_user_author integer, -- createur
fk_projet integer, -- projet auquel est associ<EFBFBD> la facture fk_projet integer, -- projet auquel est associe la facture
fk_cond_reglement integer DEFAULT 0, -- condition de reglement fk_cond_reglement integer DEFAULT 0, -- condition de reglement
fk_mode_reglement integer DEFAULT 0, -- mode de reglement (Virement, Pr<EFBFBD>l<EFBFBD>vement) fk_mode_reglement integer DEFAULT 0, -- mode de reglement (Virement, Prelevement)
date_lim_reglement date, -- date limite de reglement date_lim_reglement date, -- date limite de reglement
note text, note text,