New: early development of multi-company module

This commit is contained in:
Regis Houssin 2009-04-30 12:14:50 +00:00
parent 88d0f1ede7
commit 929939d0bf
3 changed files with 54 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
*
* 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<EFBFBD>cup<EFBFBD>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 '</td></tr>';
// Mode de r<EFBFBD>glement
// Mode de reglement
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
$html->select_types_paiements($soc->mode_reglement,'mode_reglement_id');
print '</td></tr>';
@ -227,9 +231,15 @@ if ($_GET["action"] == 'create')
print '<td>';
$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)
{

View File

@ -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);

View File

@ -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);
}