diff --git a/dev/initdemo/initdemo.sql b/dev/initdemo/initdemo.sql index 98dc6cf1241..32515ac6c27 100644 --- a/dev/initdemo/initdemo.sql +++ b/dev/initdemo/initdemo.sql @@ -2988,7 +2988,6 @@ CREATE TABLE `llx_facture_rec` ( `last_gen` varchar(7) default NULL, PRIMARY KEY (`rowid`), 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_user_author` (`fk_user_author`), KEY `idx_facture_rec_fk_projet` (`fk_projet`), diff --git a/doc/dev/dbmodel/dolibarr_schema.xml b/doc/dev/dbmodel/dolibarr_schema.xml index ff69cedb90d..9d89676fa5e 100644 --- a/doc/dev/dbmodel/dolibarr_schema.xml +++ b/doc/dev/dbmodel/dolibarr_schema.xml @@ -4961,7 +4961,7 @@ - + diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 3aa38deeec2..653f05ad228 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -21,11 +21,11 @@ */ /** - \file htdocs/categories/categorie.php - \ingroup category - \brief Page de l'onglet categories - \version $Id$ -*/ + * \file htdocs/categories/categorie.php + * \ingroup category + * \brief Page de l'onglet categories + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); @@ -57,8 +57,8 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid); /* -* Actions -*/ + * Actions + */ //Suppression d'un objet d'une categorie if ($_REQUEST["removecat"]) @@ -113,8 +113,8 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) /* -* View -*/ + * View + */ $html = new Form($db); @@ -136,7 +136,7 @@ if ($_GET["socid"]) llxHeader("","",$langs->trans("Category")); - /* + /* * Affichage onglets */ $head = societe_prepare_head($soc); @@ -203,7 +203,7 @@ if ($_GET["socid"]) } else if ($_GET["id"] || $_GET["ref"]) { - /* + /* * Fiche categorie de produit */ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); @@ -262,9 +262,9 @@ else if ($_GET["id"] || $_GET["ref"]) } -/* -* Fonction Barre d'actions -*/ +/** + * Fonction Barre d'actions + */ function formCategory($db,$object,$type,$typeid) { global $user,$langs,$html,$bc; diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php index ce37bd9f77c..990efacd5bb 100644 --- a/htdocs/compta/facture/facture-rec.class.php +++ b/htdocs/compta/facture/facture-rec.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2009 Regis Houssin * * 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 @@ -31,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); /** * \class FactureRec - * \brief Classe de gestion des factures recurrentes/Mod�les + * \brief Classe de gestion des factures recurrentes/Modeles */ class FactureRec extends Facture { @@ -43,8 +44,10 @@ class FactureRec extends Facture var $id ; - var $socid; // Id client - var $client; // Objet societe client (� charger par fetch_client) + //! Id customer + var $socid; + //! Customer object (charging by fetch_client) + var $client; var $number; 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) { @@ -75,7 +78,7 @@ class FactureRec extends Facture */ function create($user) { - global $langs; + global $conf, $langs; $error=0; @@ -99,11 +102,32 @@ class FactureRec extends Facture // On positionne en mode brouillon la facture $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.= " VALUES ('$this->titre', '$facsrc->socid', ".$this->db->idate(mktime()).", '$facsrc->amount', '$facsrc->remise', '".addslashes($this->note)."','$user->id',"; - $sql.= " ".($facsrc->projetid?"'".$facsrc->projetid."'":"null").", "; - $sql.= " '".$facsrc->cond_reglement_id."',"; - $sql.= " '".$facsrc->mode_reglement_id."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec ("; + $sql.= "titre"; + $sql.= ", fk_soc"; + $sql.= ", entity"; + $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) ) { $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 * \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 */ - 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.= ','.$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.'co_fa as cf ON cf.fk_facture = f.rowid'; $sql.= ' WHERE f.rowid='.$rowid; - if ($societe_id > 0) - { - $sql.= ' AND f.fk_soc = '.$societe_id; - } + if ($socid > 0) $sql.= ' AND f.fk_soc = '.$socid; + $result = $this->db->query($sql); if ($result) @@ -426,19 +448,34 @@ class FactureRec extends Facture $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 .= " VALUES ('".$facid."', '".addslashes($desc)."'"; - $sql .= ",".price2num($price); - $sql .= ",".price2num($qty); - $sql .= ",".price2num($txtva); - $sql .= ",".($fk_product?"'".$fk_product."'":"null"); - $sql .= ",".$product_type; - $sql .= ",'".price2num($remise_percent)."'"; - $sql .= ",'".price2num($pu_ht)."'"; - $sql .= ",'".price2num($remise)."'"; - $sql .= ",'".price2num($total_ht)."'"; - $sql .= ",'".price2num($total_tva)."'"; - $sql .= ",'".price2num($total_ttc)."') ;"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec ("; + $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($qty); + $sql.= ", ".price2num($txtva); + $sql.= ", ".($fk_product?"'".$fk_product."'":"null"); + $sql.= ", ".$product_type; + $sql.= ", '".price2num($remise_percent)."'"; + $sql.= ", '".price2num($pu_ht)."'"; + $sql.= ", '".price2num($remise)."'"; + $sql.= ", '".price2num($total_ht)."'"; + $sql.= ", '".price2num($total_tva)."'"; + $sql.= ", '".price2num($total_ttc)."') ;"; dol_syslog("FactureRec::addline sql=".$sql, LOG_DEBUG); if ($this->db->query( $sql)) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 8eb179d4af7..9056b03d461 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -21,7 +21,7 @@ /** * \file htdocs/compta/facture/fiche-rec.php * \ingroup facture - * \brief Page d'affichage d'une facture r�current + * \brief Page d'affichage d'une facture recurrente * \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."/product.class.php"); -if (!$user->rights->facture->lire) -accessforbidden(); // Security check $facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"]; $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; 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) { @@ -95,11 +95,9 @@ llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture- $html = new Form($db); -/********************************************************************* - * - * Mode creation - * - ************************************************************************/ +/* + * Create mode + */ if ($_GET["action"] == 'create') { print_fiche_titre($langs->trans("CreateRepeatableInvoice")); @@ -167,7 +165,7 @@ if ($_GET["action"] == 'create') } /* - * Lines de factures + * Invoice lines */ print ''; print '\n"; /* - * Autres charges impayées + * Autres charges impay�es */ $num = 1; $i = 0; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 5da837164a1..fae93a98b2f 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1981,10 +1981,10 @@ class Facture extends CommonObject $sql.= ' AND type < 2'; if ($option == 'validated') $sql.= ' AND fk_statut = 1'; // PROTECTION BAD DATA - // Au cas ou base corrompue et qu'il y a une facture de remplacement valid�e - // et une autre non, on donne priorit� � la valid�e. - // Ne devrait pas arriver (sauf si acc�s concurrentiel et que 2 personnes - // ont cr�� en meme temps une facture de remplacement pour la meme facture) + // Au cas ou base corrompue et qu'il y a une facture de remplacement validee + // et une autre non, on donne priorite a la validee. + // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes + // ont cree en meme temps une facture de remplacement pour la meme facture) $sql.= ' ORDER BY fk_statut DESC'; $resql=$this->db->query($sql); @@ -2009,7 +2009,7 @@ class Facture extends CommonObject } /** - * \brief Retourne le libell� du type de facture + * \brief Retourne le libelle du type de facture * \return string Libelle */ function getLibType() @@ -2024,8 +2024,8 @@ class Facture extends CommonObject /** - * \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� lon + * \brief Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * \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 * \return string Libelle */ @@ -2035,13 +2035,13 @@ class Facture extends CommonObject } /** - * \brief Renvoi le libell� d'un statut donn� + * \brief Renvoi le libelle d'un statut donne * \param paye Etat paye * \param statut Id statut - * \param mode 0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long, 5=Libell� court + Pict - * \param alreadypaid Montant deja pay� + * \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 paye * \param type Type facture - * \return string Libell� du statut + * \return string Libelle du statut */ function LibStatut($paye,$statut,$mode=0,$alreadypaid=-1,$type=0) { diff --git a/htdocs/install/mysql/migration/2.6.0-2.7.0.sql b/htdocs/install/mysql/migration/2.6.0-2.7.0.sql index 30e2cb64bce..00df2853388 100644 --- a/htdocs/install/mysql/migration/2.6.0-2.7.0.sql +++ b/htdocs/install/mysql/migration/2.6.0-2.7.0.sql @@ -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_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_facture_rec ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER fk_soc; ALTER TABLE llx_rights_def 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_adherent DROP INDEX uk_adherent_login; 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_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_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_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre, entity); 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); 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_POPUP_CALENDAR' AND entity=1; diff --git a/htdocs/install/mysql/tables/llx_facture_rec.key.sql b/htdocs/install/mysql/tables/llx_facture_rec.key.sql index 2a36ef78291..4e9f0d1da0e 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.key.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.key.sql @@ -1,6 +1,7 @@ -- ============================================================================ -- Copyright (C) 2002-2004 Rodolphe Quiedeville -- Copyright (C) 2004-2006 Laurent Destailleur +-- Copyright (C) 2009 Regis Houssin -- -- 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,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_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 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_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); - -ALTER TABLE llx_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre); diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index fc1d884a02d..b1b65d14eb0 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -1,6 +1,7 @@ -- =========================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville -- Copyright (C) 2006 Laurent Destailleur +-- Copyright (C) 2009 Regis Houssin -- -- 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 @@ -23,6 +24,7 @@ create table llx_facture_rec ( rowid integer AUTO_INCREMENT PRIMARY KEY, titre varchar(50) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id fk_soc integer NOT NULL, datec datetime, -- date de creation @@ -35,9 +37,9 @@ create table llx_facture_rec total_ttc real DEFAULT 0, fk_user_author integer, -- createur - fk_projet integer, -- projet auquel est associ� la facture + fk_projet integer, -- projet auquel est associe la facture fk_cond_reglement integer DEFAULT 0, -- condition de reglement - fk_mode_reglement integer DEFAULT 0, -- mode de reglement (Virement, Pr�l�vement) + fk_mode_reglement integer DEFAULT 0, -- mode de reglement (Virement, Prelevement) date_lim_reglement date, -- date limite de reglement note text,
'; @@ -327,12 +325,10 @@ if ($_GET["action"] == 'create') } } else -/* *************************************************************************** */ -/* */ -/* */ -/* */ -/* *************************************************************************** */ { + /* + * View mode + */ if ($facid > 0) { @@ -485,13 +481,12 @@ else { print $langs->trans("ErrorRecordNotFound"); } - } else { - /*************************************************************************** - * * - * Mode Liste * - * * - * * - ***************************************************************************/ + } + else + { + /* + * List mode + */ if ($user->rights->facture->lire) { diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 3f4bb68d94b..64ffd5e2a55 100755 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -19,7 +19,7 @@ /** \file htdocs/compta/paiement_charge.php \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$ */ @@ -31,7 +31,7 @@ $langs->load("bills"); $chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; -// Sécurité accés client +// Securite acces client if ($user->societe_id > 0) { $action = ''; @@ -110,12 +110,12 @@ if ($_POST["action"] == 'add_paiement') $acc = new Account($db, $_POST["accountid"]); $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�n�r� l'�criture bancaire if ($bank_line_id > 0) { $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�e par le paiement) foreach ($paiement->amounts as $key => $value) { $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 { $db->rollback(); - $mesg = "Echec de la création entrée compte: ".$db->error(); + $mesg = "Echec de la cr�ation entr�e compte: ".$db->error(); } } else { $db->rollback(); - $mesg = "Echec de la création du paiement: paiement_id=$paiement_id ".$db->error(); + $mesg = "Echec de la cr�ation du paiement: paiement_id=$paiement_id ".$db->error(); } } @@ -229,7 +229,7 @@ if ($_GET["action"] == 'create') print "