2004-10-20 22:06:49 +02:00
|
|
|
|
<?php
|
2004-05-27 12:11:38 +02:00
|
|
|
|
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2003-09-04 13:19:23 +02:00
|
|
|
|
*
|
|
|
|
|
|
* 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
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
*
|
|
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-08-14 15:16:01 +02:00
|
|
|
|
/*! \file htdocs/projet/project.class.php
|
|
|
|
|
|
\ingroup projet
|
|
|
|
|
|
\brief Fichier de la classe de gestion des projets
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \class Project
|
|
|
|
|
|
\brief Classe de gestion des projets
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2003-09-04 13:19:23 +02:00
|
|
|
|
class Project {
|
|
|
|
|
|
var $id;
|
|
|
|
|
|
var $db;
|
|
|
|
|
|
var $ref;
|
|
|
|
|
|
var $title;
|
|
|
|
|
|
var $socidp;
|
|
|
|
|
|
var $societe;
|
|
|
|
|
|
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function Project($DB)
|
2003-09-04 13:19:23 +02:00
|
|
|
|
{
|
|
|
|
|
|
$this->db = $DB;
|
|
|
|
|
|
$this->societe = new Societe($DB);
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function create($creatorid)
|
2003-09-04 13:19:23 +02:00
|
|
|
|
{
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet (ref, title, fk_soc, fk_user_creat, dateo) ";
|
2003-09-04 13:19:23 +02:00
|
|
|
|
$sql .= " VALUES ('$this->ref', '$this->title', $this->socidp, $creatorid, now()) ;";
|
|
|
|
|
|
|
2004-07-21 16:40:55 +02:00
|
|
|
|
if ($this->db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
return $this->db->last_insert_id();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2003-09-04 13:19:23 +02:00
|
|
|
|
{
|
|
|
|
|
|
print '<b>'.$sql.'</b><br>'.$this->db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function update()
|
2003-09-04 13:19:23 +02:00
|
|
|
|
{
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."projet ";
|
2003-09-04 13:19:23 +02:00
|
|
|
|
$sql .= " SET ref = '$this->ref', title = '$this->title'";
|
|
|
|
|
|
$sql .= " WHERE rowid = $this->id";
|
|
|
|
|
|
|
|
|
|
|
|
if (!$this->db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<b>'.$sql.'</b><br>'.$this->db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function delete()
|
2003-09-04 13:19:23 +02:00
|
|
|
|
{
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet WHERE rowid = $this->id";
|
2003-09-04 13:19:23 +02:00
|
|
|
|
|
|
|
|
|
|
if ($this->db->query($sql) )
|
|
|
|
|
|
{
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_projet = 0 WHERE fk_projet = $this->id";
|
2003-09-04 13:19:23 +02:00
|
|
|
|
if ($this->db->query($sql) )
|
|
|
|
|
|
{
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_projet = 0 WHERE fk_projet = $this->id";
|
2003-09-04 13:19:23 +02:00
|
|
|
|
|
|
|
|
|
|
if ($this->db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function fetch($rowid)
|
2003-09-04 13:19:23 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "SELECT fk_soc, title, ref FROM ".MAIN_DB_PREFIX."projet WHERE rowid=$rowid;";
|
2003-09-04 13:19:23 +02:00
|
|
|
|
|
|
|
|
|
|
if ($this->db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->db->num_rows())
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $this->db->fetch_object(0);
|
|
|
|
|
|
|
|
|
|
|
|
$this->id = $rowid;
|
|
|
|
|
|
$this->ref = $obj->ref;
|
|
|
|
|
|
$this->title = $obj->title;
|
2003-10-22 16:20:03 +02:00
|
|
|
|
$this->titre = $obj->title;
|
2003-09-04 13:19:23 +02:00
|
|
|
|
$this->societe->id = $obj->fk_soc;
|
|
|
|
|
|
$this->db->free();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function get_propal_list()
|
2003-09-04 13:19:23 +02:00
|
|
|
|
{
|
|
|
|
|
|
$propales = array();
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=$this->id;";
|
2003-09-04 13:19:23 +02:00
|
|
|
|
|
|
|
|
|
|
if ($this->db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
$nump = $this->db->num_rows();
|
|
|
|
|
|
if ($nump)
|
|
|
|
|
|
{
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
while ($i < $nump)
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $this->db->fetch_object($i);
|
|
|
|
|
|
|
|
|
|
|
|
$propales[$i] = $obj->rowid;
|
|
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$this->db->free();
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Retourne un tableau contenant la liste des propales associees
|
|
|
|
|
|
*/
|
|
|
|
|
|
return $propales;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error() . '<br>' .$sql;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-10-22 16:20:03 +02:00
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function get_facture_list()
|
2003-10-22 16:20:03 +02:00
|
|
|
|
{
|
|
|
|
|
|
$factures = array();
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=$this->id;";
|
2003-10-22 16:20:03 +02:00
|
|
|
|
|
|
|
|
|
|
if ($this->db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
$nump = $this->db->num_rows();
|
|
|
|
|
|
if ($nump)
|
|
|
|
|
|
{
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
while ($i < $nump)
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $this->db->fetch_object($i);
|
|
|
|
|
|
|
|
|
|
|
|
$factures[$i] = $obj->rowid;
|
|
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$this->db->free();
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Retourne un tableau contenant la liste des factures associees
|
|
|
|
|
|
*/
|
|
|
|
|
|
return $factures;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error() . '<br>' .$sql;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-11-07 10:41:47 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Renvoie la liste des commande associ<EFBFBD>es au projet
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function get_commande_list()
|
2003-11-07 10:41:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
$commandes = array();
|
2004-02-01 02:33:59 +01:00
|
|
|
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=$this->id;";
|
2003-11-07 10:41:47 +01:00
|
|
|
|
|
|
|
|
|
|
if ($this->db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
$nump = $this->db->num_rows();
|
|
|
|
|
|
if ($nump)
|
|
|
|
|
|
{
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
while ($i < $nump)
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $this->db->fetch_object($i);
|
|
|
|
|
|
|
|
|
|
|
|
$commandes[$i] = $obj->rowid;
|
|
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$this->db->free();
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Retourne un tableau contenant la liste des commandes associees
|
|
|
|
|
|
*/
|
|
|
|
|
|
return $commandes;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error() . '<br>' .$sql;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-09-04 13:19:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
?>
|