From 929939d0bfba1a2d32fee20fe52feb7a49ed16f9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 30 Apr 2009 12:14:50 +0000 Subject: [PATCH] New: early development of multi-company module --- htdocs/comm/addpropal.php | 22 ++++++--- .../modules/propale/modules_propale.php | 3 +- htdocs/propal.class.php | 45 +++++++++++++++---- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index dabde8b5310..38a9650ad8e 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * * This program is free software; you can redistribute it and/or modify @@ -53,7 +53,7 @@ print_fiche_titre($langs->trans("NewProp")); $html=new Form($db); -// R�cup�ration de l'id de projet +// Recuperation de l'id de projet $projetid = 0; if ($_GET["projetid"]) { @@ -84,7 +84,11 @@ if ($_GET["action"] == 'create') // Fix pour modele numerotation qui deconne // Si numero deja pris (ne devrait pas arriver), on incremente par .num+1 - $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'"; + $sql = "SELECT count(*) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal"; + $sql.= " WHERE ref like '$numpr%'"; + $sql.= " AND entity = ".$conf->entity; + $resql=$db->query($sql); if ($resql) { @@ -146,7 +150,7 @@ if ($_GET["action"] == 'create') $html->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); print ''; - // Mode de r�glement + // Mode de reglement print ''.$langs->trans('PaymentMode').''; $html->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); print ''; @@ -227,9 +231,15 @@ if ($_GET["action"] == 'create') print ''; $liste_propal = array(); $liste_propal[0] = ''; + $sql ="SELECT p.rowid as id, p.ref, s.nom"; - $sql.=" FROM ".MAIN_DB_PREFIX."propal p, ".MAIN_DB_PREFIX."societe s"; - $sql.=" WHERE s.rowid = p.fk_soc AND fk_statut <> 0 ORDER BY Id"; + $sql.=" FROM ".MAIN_DB_PREFIX."propal p"; + $sql.= ", ".MAIN_DB_PREFIX."societe s"; + $sql.= " WHERE s.rowid = p.fk_soc"; + $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.fk_statut <> 0"; + $sql.= " ORDER BY Id"; + $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index bf0f5b26dd7..5760c8369dd 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -58,10 +58,11 @@ class ModelePDFPropales extends FPDF $type='propal'; $liste=array(); + $sql = "SELECT nom as id, nom as lib"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " WHERE type = '".$type."'"; - $sql.= " AND entity = ".$cont->entity; + $sql.= " AND entity = ".$conf->entity; dol_syslog("modules_propale::liste_modeles sql=".$sql, LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index a82e0564209..eba84ce17c4 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -527,21 +527,46 @@ class Propal extends CommonObject $this->fetch_client(); // Insertion dans la base - $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, price"; - $sql.= ", remise, remise_percent, remise_absolue"; - $sql.= ", tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite"; - $sql.= ", fk_cond_reglement, fk_mode_reglement, ref_client"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal ("; + $sql.= "fk_soc"; + $sql.= ", price"; + $sql.= ", remise"; + $sql.= ", remise_percent"; + $sql.= ", remise_absolue"; + $sql.= ", tva"; + $sql.= ", total"; + $sql.= ", datep"; + $sql.= ", datec"; + $sql.= ", ref"; + $sql.= ", fk_user_author"; + $sql.= ", note"; + $sql.= ", note_public"; + $sql.= ", model_pdf"; + $sql.= ", fin_validite"; + $sql.= ", fk_cond_reglement"; + $sql.= ", fk_mode_reglement"; + $sql.= ", ref_client"; $sql.= ", date_livraison"; $sql.= ", entity"; $sql.= ") "; - $sql.= " VALUES (".$this->socid.", 0"; - $sql.= ", ".$this->remise.", ".($this->remise_percent?$this->remise_percent:'null').", ".($this->remise_absolue?$this->remise_absolue:'null'); - $sql.= ", 0, 0,".$this->db->idate($this->datep).", ".$this->db->idate(mktime()).", '".$this->ref; + $sql.= " VALUES ("; + $sql.= $this->socid; + $sql.= ", 0"; + $sql.= ", ".$this->remise; + $sql.= ", ".($this->remise_percent?$this->remise_percent:'null'); + $sql.= ", ".($this->remise_absolue?$this->remise_absolue:'null'); + $sql.= ", 0"; + $sql.= ", 0"; + $sql.= ", ".$this->db->idate($this->datep); + $sql.= ", ".$this->db->idate(mktime()); + $sql.= ", '".$this->ref."'"; $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); $sql.= ", '".addslashes($this->note)."'"; $sql.= ", '".addslashes($this->note_public)."'"; - $sql.= ", '".$this->modelpdf."',".$this->db->idate($this->fin_validite)."'"; - $sql.= ", ".$this->cond_reglement_id.", ".$this->mode_reglement_id; + $sql.= ", '".$this->modelpdf."'"; + $sql.= ", ".$this->db->idate($this->fin_validite); + $sql.= ", ".$this->cond_reglement_id; + $sql.= ", ".$this->mode_reglement_id; $sql.= ", '".addslashes($this->ref_client)."'"; $sql.= ", ".($this->date_livraison!=''?$this->db->idate($this->date_livraison):'null'); $sql.= ", ".$conf->entity; @@ -586,6 +611,7 @@ class Propal extends CommonObject $sql.= " SET fk_projet=".$this->projetidp; $sql.= " WHERE ref='".$this->ref."'"; $sql.= " AND entity = ".$conf->entity; + $result=$this->db->query($sql); } @@ -596,6 +622,7 @@ class Propal extends CommonObject $sql.= " SET fk_adresse_livraison = ".$this->adresse_livraison_id; $sql.= " WHERE ref = '".$this->ref."'"; $sql.= " AND entity = ".$conf->entity; + $result=$this->db->query($sql); }